[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: extragear/office/skrooge
From: Stephane Mankowski <stephane () mankowski ! fr>
Date: 2011-02-09 18:54:00
Message-ID: 20110209185400.103CAAC8C0 () svn ! kde ! org
[Download RAW message or body]
SVN commit 1219629 by smankowski:
feature: Possibility to merge categories by using massive update on name of \
categories
M +1 -0 CHANGELOG
M +26 -0 skgbankmodeler/skgcategoryobject.cpp
M +16 -0 skgbankmodeler/skgcategoryobject.h
M +3 -0 skgbankmodelertest/skgtestcategory.cpp
M +16 -0 skrooge_categories/skgcategoriespluginwidget.cpp
--- trunk/extragear/office/skrooge/CHANGELOG #1219628:1219629
@@ -35,6 +35,7 @@
*New feature: Possibility to merge accounts by using massive update on name of \
accounts
*New feature: Possibility to merge payees by using massive update on name of \
payees
*New feature: Possibility to merge units by using massive update on name of units
+ *New feature: Possibility to merge categories by using massive update on name of \
categories
-- maintainer Stephane MANKOWSKI <stephane@mankowski.fr> xxx
--- trunk/extragear/office/skrooge/skgbankmodeler/skgcategoryobject.cpp \
#1219628:1219629 @@ -20,6 +20,7 @@
* @author Stephane MANKOWSKI / Guillaume DE BURE
*/
#include "skgcategoryobject.h"
+#include "skgsuboperationobject.h"
#include "skgdocumentbank.h"
#include "skgtraces.h"
@@ -223,4 +224,29 @@
return SKGServices::stringToDouble(cat.getAttribute("f_SUMCURRENTAMOUNT"));
}
+SKGError SKGCategoryObject::getSubOperations(SKGListSKGObjectBase& oSubOperations) \
const +{
+ SKGError err = getObjects(getDocument(), "v_suboperation",
+ "r_category_id=" + SKGServices::intToString(getID()) ,
+ oSubOperations);
+ return err;
+}
+
+SKGError SKGCategoryObject::merge(const SKGCategoryObject& iCategory)
+{
+ SKGError err;
+
+ SKGObjectBase::SKGListSKGObjectBase ops;
+ if(err.isSucceeded()) err = iCategory.getSubOperations(ops);
+ int nb = ops.count();
+ for(int i = 0; err.isSucceeded() && i < nb; ++i) {
+ SKGSubOperationObject op = ops.at(i);
+ err = op.setCategory(*this);
+ if(err.isSucceeded()) err = op.save(true, false);
+ }
+
+ if(err.isSucceeded()) err = iCategory.remove();
+ return err;
+}
+
#include "skgcategoryobject.moc"
--- trunk/extragear/office/skrooge/skgbankmodeler/skgcategoryobject.h \
#1219628:1219629 @@ -146,6 +146,22 @@
*/
virtual double getCurrentAmount() const;
+ /**
+ * Get all sub operations of this category
+ * @param oSubOperations all sub operations of this category
+ * @return an object managing the error
+ * @see SKGError
+ */
+ virtual SKGError getSubOperations(SKGListSKGObjectBase& oSubOperations) const;
+
+ /**
+ * Merge iCategory in current category
+ * @param iCategory the category. All sub operations will be transferred into \
this category. The category will be removed + * @return an object managing the \
error + * @see SKGError
+ */
+ virtual SKGError merge(const SKGCategoryObject& iCategory);
+
protected:
/**
* Get where clause needed to identify objects.
--- trunk/extragear/office/skrooge/skgbankmodelertest/skgtestcategory.cpp \
#1219628:1219629 @@ -227,6 +227,9 @@
QStringList oResult;
SKGTESTERROR("CAT:getDistinctValues", \
SKGServices::getDistinctValues(&document1, "category", "id", oResult), true); \
SKGTEST("CAT:oResult.size", oResult.size(), 4); +
+ //Merge
+ SKGTESTERROR("CAT:merge", categoryB.merge(categoryA), true);
}
}
//End test
--- trunk/extragear/office/skrooge/skrooge_categories/skgcategoriespluginwidget.cpp \
#1219628:1219629 @@ -223,6 +223,22 @@
int nb = selection.count();
{
SKGBEGINPROGRESSTRANSACTION(*getDocument(), i18nc("Noun, name of the user \
action", "Category update") , err, nb); + if(nb > 1 && ui.kNameInput->text() \
!= NOUPDATE && !ui.kNameInput->text().startsWith(QLatin1String("="))) { + \
getDocument()->sendMessage(i18nc("Information message", "You tried to modify all \
names of selected categories. Categories have been merged.")); +
+ //Do the merge
+ SKGCategoryObject catObj1 = selection[0];
+ for(int i = 1; err.isSucceeded() && i < nb; ++i) {
+ SKGCategoryObject catObj = selection[i];
+ err = catObj1.merge(catObj);
+ }
+
+ //Change selection for the rest of the operation
+ selection.clear();
+ selection.push_back(catObj1);
+ nb = 1;
+ }
+
for(int i = 0; err.isSucceeded() && i < nb; ++i) {
//Modification of object
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic