Changeset View
Changeset View
Standalone View
Standalone View
kmymoney/models/accountsmodel.cpp
Show First 20 Lines • Show All 973 Lines • ▼ Show 20 Line(s) | 973 | /** | |||
---|---|---|---|---|---|
974 | * Notify the model that the account balance has been changed. | 974 | * Notify the model that the account balance has been changed. | ||
975 | */ | 975 | */ | ||
976 | void AccountsModel::slotBalanceOrValueChanged(const MyMoneyAccount &account) | 976 | void AccountsModel::slotBalanceOrValueChanged(const MyMoneyAccount &account) | ||
977 | { | 977 | { | ||
978 | auto itParent = d->itemFromAccountId(this, account.id()); // get node of account in model | 978 | auto itParent = d->itemFromAccountId(this, account.id()); // get node of account in model | ||
979 | auto isTopLevel = false; // it could be top-level but we don't know it yet | 979 | auto isTopLevel = false; // it could be top-level but we don't know it yet | ||
980 | while (itParent && !isTopLevel) { // loop in which we set total values and balances from the bottom to the top | 980 | while (itParent && !isTopLevel) { // loop in which we set total values and balances from the bottom to the top | ||
981 | auto itCurrent = itParent; | 981 | auto itCurrent = itParent; | ||
982 | auto accCurrent = &d->m_file->account(itCurrent->data((int)Role::Account).value<MyMoneyAccount>().id()); | 982 | const auto accCurrent = d->m_file->account(itCurrent->data((int)Role::Account).value<MyMoneyAccount>().id()); | ||
983 | if (accCurrent->id().isEmpty()) { // this is institution | 983 | if (accCurrent.id().isEmpty()) { // this is institution | ||
984 | d->setInstitutionTotalValue(invisibleRootItem(), itCurrent->row()); | 984 | d->setInstitutionTotalValue(invisibleRootItem(), itCurrent->row()); | ||
985 | break; // it's top-level node so nothing above that; | 985 | break; // it's top-level node so nothing above that; | ||
986 | } | 986 | } | ||
987 | itParent = itCurrent->parent(); | 987 | itParent = itCurrent->parent(); | ||
988 | if (!itParent) { | 988 | if (!itParent) { | ||
989 | itParent = this->invisibleRootItem(); | 989 | itParent = this->invisibleRootItem(); | ||
990 | isTopLevel = true; | 990 | isTopLevel = true; | ||
991 | } | 991 | } | ||
992 | d->setAccountBalanceAndValue(itParent, itCurrent->row(), *accCurrent, d->m_columns); | 992 | d->setAccountBalanceAndValue(itParent, itCurrent->row(), accCurrent, d->m_columns); | ||
993 | } | 993 | } | ||
994 | checkNetWorth(); | 994 | checkNetWorth(); | ||
995 | checkProfit(); | 995 | checkProfit(); | ||
996 | } | 996 | } | ||
997 | 997 | | |||
998 | /** | 998 | /** | ||
999 | * The pimpl of the @ref InstitutionsModel derived from the pimpl of the @ref AccountsModel. | 999 | * The pimpl of the @ref InstitutionsModel derived from the pimpl of the @ref AccountsModel. | ||
1000 | */ | 1000 | */ | ||
▲ Show 20 Lines • Show All 231 Lines • Show Last 20 Lines |