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

List:       kde-commits
Subject:    [kmymoney] kmymoney/models: Fix the investment accounts handling in the institutions view.
From:       Cristian_OneČ› <onet.cristian () gmail ! com>
Date:       2012-11-15 20:00:17
Message-ID: 20121115200017.A8075A6091 () git ! kde ! org
[Download RAW message or body]

Git commit a5371f1e0ad7b42c7cfd1a2790108abbac96a732 by Cristian OneČ›.
Committed on 15/11/2012 at 20:51.
Pushed by conet into branch 'master'.

Fix the investment accounts handling in the institutions view.
Make the investment accounts the only accounts that are added
to their parent in the institutions view. The rest of the
accounts are added at the first level because they don't inherit
the institution from their parent. Thanks to Allen for working on
this.

BUG: 309105

M  +15   -1    kmymoney/models/accountsmodel.cpp

http://commits.kde.org/kmymoney/a5371f1e0ad7b42c7cfd1a2790108abbac96a732

diff --git a/kmymoney/models/accountsmodel.cpp b/kmymoney/models/accountsmodel.cpp
index c21c39d..37816f5 100644
--- a/kmymoney/models/accountsmodel.cpp
+++ b/kmymoney/models/accountsmodel.cpp
@@ -759,7 +759,10 @@ public:
     }
     QStandardItem *institutionItem = institutionItemFromId(model, institutionId);
     QStandardItem *item = itemFromAccountId(institutionItem, account.id());
-    QStandardItem *parentAccounItem = itemFromAccountId(institutionItem, \
account.parentAccountId()); +    // only investment accounts are added to their \
parent in the institutions view +    // this makes hierarchy maintenance a lot easier \
since the investment accounts +    // are the only ones that always have the same \
institution as their parent +    QStandardItem *parentAccounItem = account.isInvest() \
? itemFromAccountId(institutionItem, account.parentAccountId()) : 0;  if (!item) {
       item = new QStandardItem(account.name());
       if (parentAccounItem) {
@@ -876,7 +879,18 @@ void \
InstitutionsModel::slotObjectAdded(MyMoneyFile::notificationObjectT objType  if \
(!account || account->parentAccountId().isEmpty() || account->isIncomeExpense())  \
return;  
+  // load the account into the institution
   static_cast<InstitutionsPrivate *>(d)->loadInstitution(this, *account);
+
+  // load the investment sub-accounts if there are any - there could be sub-accounts \
if this is an add operation +  // that was triggered in slotObjectModified on an \
already existing account which went trough a hierarchy change +  \
QList<MyMoneyAccount> subAccounts; +  d->m_file->accountList(subAccounts, \
account->accountList(), true); +  for (QList<MyMoneyAccount>::ConstIterator it_a = \
subAccounts.constBegin(); it_a != subAccounts.constEnd(); ++it_a) { +    if \
((*it_a).isInvest()) { +      static_cast<InstitutionsPrivate \
*>(d)->loadInstitution(this, *it_a); +    }
+  }
 }
 
 /**


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

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