[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-06 18:16:41
Message-ID: 20110206181641.92BF0AC8E5 () svn ! kde ! org
[Download RAW message or body]

SVN commit 1219168 by smankowski:

feature: Possibility to merge units by using massive update on name of units

 M  +2 -0      CHANGELOG  
 M  +1 -10     skgbankgui/skgobjectmodel.cpp  
 M  +18 -0     skgbankmodeler/skgunitobject.cpp  
 M  +8 -0      skgbankmodeler/skgunitobject.h  
 M  +0 -1      skrooge_payee/skgpayeepluginwidget.cpp  
 M  +24 -1     skrooge_unit/skgunitpluginwidget.cpp  


--- trunk/extragear/office/skrooge/CHANGELOG #1219167:1219168
@@ -33,6 +33,8 @@
   *New feature: New "About" panel using KDE 4.6 features
   *New feature: Better mass update on "account", "payee", "tracker" and "unit" pages
   *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  
  -- maintainer Stephane MANKOWSKI <stephane@mankowski.fr>  xxx
 
--- trunk/extragear/office/skrooge/skgbankgui/skgobjectmodel.cpp #1219167:1219168
@@ -854,19 +854,10 @@
 
                 SKGUnitObject child(getDocument(), o_id);
                 err = child.load();
-                SKGObjectBase::SKGListSKGObjectBase ops;
-                if(err.isSucceeded()) err = child.getOperations(ops);
-                int nb = ops.count();
-                for(int i = 0; err.isSucceeded() && i < nb; ++i) {
-                    SKGOperationObject op = ops.at(i);
-                    err = op.setUnit(parentUnit);
-                    if(err.isSucceeded()) err = op.save(true, false);
+                if(err.isSucceeded()) err = parentUnit.merge(child);
                 }
-
-                if(err.isSucceeded()) err = child.remove();
             }
         }
-    }
     SKGMainPanel::displayErrorMessage(err);
     return err.isSucceeded();
 }
--- trunk/extragear/office/skrooge/skgbankmodeler/skgunitobject.cpp #1219167:1219168
@@ -22,6 +22,7 @@
 #include "skgunitobject.h"
 #include "skgunitvalueobject.h"
 #include "skgdocumentbank.h"
+#include "skgoperationobject.h"
 #include "skgtraces.h"
 
 #include <klocale.h>
@@ -830,4 +831,21 @@
     return err;
 }
 
+SKGError SKGUnitObject::merge(const SKGUnitObject& iUnit)
+{
+    SKGError err;
+
+    SKGObjectBase::SKGListSKGObjectBase ops;
+    if(err.isSucceeded()) err = iUnit.getOperations(ops);
+    int nb = ops.count();
+    for(int i = 0; err.isSucceeded() && i < nb; ++i) {
+        SKGOperationObject op = ops.at(i);
+        err = op.setUnit(*this);
+        if(err.isSucceeded()) err = op.save(true, false);
+    }
+
+    if(err.isSucceeded()) err = iUnit.remove();
+    return err;
+}
+
 #include "skgunitobject.moc"
--- trunk/extragear/office/skrooge/skgbankmodeler/skgunitobject.h #1219167:1219168
@@ -310,6 +310,14 @@
      */
     virtual SKGError getOperations(SKGListSKGObjectBase& oOperations) const;
 
+    /**
+     * Merge iUnit in current unit
+     * @param iUnit the unit. All operations will be transferred into this unit. The \
unit will be removed +     * @return an object managing the error
+     *   @see SKGError
+     */
+    virtual SKGError merge(const SKGUnitObject& iUnit);
+
 protected:
     /**
      * Get where clause needed to identify objects.
--- trunk/extragear/office/skrooge/skrooge_payee/skgpayeepluginwidget.cpp \
#1219167:1219168 @@ -203,7 +203,6 @@
     {
         SKGBEGINPROGRESSTRANSACTION(*getDocument(), i18nc("Noun, name of the user \
action", "Payee update")  , err, nb);  for(int i = 0; err.isSucceeded() && i < nb; \
                ++i) {
-
             //Modification of object
             SKGPayeeObject payee = selection[i];
             err = payee.setName(ui.kNameInput->text());
--- trunk/extragear/office/skrooge/skrooge_unit/skgunitpluginwidget.cpp \
#1219167:1219168 @@ -37,6 +37,7 @@
 #include <QDomDocument>
 #include <QFile>
 #include <QKeyEvent>
+#include <kmessagebox.h>
 
 SKGUnitPluginWidget::SKGUnitPluginWidget(SKGDocumentBank* iDocument)
     : SKGTabPage(iDocument)
@@ -392,7 +393,29 @@
     SKGObjectBase::SKGListSKGObjectBase selection = getSelectedObjects();
 
     int nb = selection.count();
-    if(nb) {
+
+    //Is it a massive modification of payees to merge them ?
+    if(nb > 1 && ui.kNameCreatorUnit->text() != NOUPDATE && \
!ui.kNameCreatorUnit->text().startsWith(QLatin1String("="))) { +        \
QApplication::setOverrideCursor(QCursor(Qt::ArrowCursor)); +        int code = \
KMessageBox::questionYesNo(this, i18nc("Question", "You are trying to modify all \
names of selected units.\nDo you want to merge them?")); +        \
QApplication::restoreOverrideCursor(); +        if(code == KMessageBox::Yes) {
+            //Do the merge
+            SKGBEGINTRANSACTION(*getDocument(), i18nc("Noun, name of the user \
action", "Merge payees"), err); +            SKGUnitObject unitObj1 = selection[0];
+            for(int i = 1; err.isSucceeded() && i < nb; ++i) {
+                SKGUnitObject unitObj = selection[i];
+                err = unitObj1.merge(unitObj);
+            }
+
+            //Change selection for the rest of the operation
+            selection.clear();
+            selection.push_back(unitObj1);
+            nb = 1;
+        }
+    }
+
+    {
         SKGBEGINPROGRESSTRANSACTION(*getDocument(), (nb == 1 ? i18nc("Noun, name of \
the user action", "Unit '%1' update", ui.kNameCreatorUnit->text()) : i18nc("Noun, \
name of the user action", "Updating %1 units.", nb))  , err, nb);  
         for(int i = 0; err.isSucceeded() && i < nb; i++) {


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic