Skip to content
Snippets Groups Projects
Commit f0c8b6fd authored by Thomas Baumgart's avatar Thomas Baumgart
Browse files

Display total value if equity accounts are hidden

Show the accounts value incl. the value of sub-accounts
 - if the account is not expanded or
 - the account is a top-level account or
 - the account is an investment account and equity accounts are hidden

That last condition was not present before and caused the value of
investments to be shown incorrect in case the display of equity accounts
had been suppressed by the respective setting.

BUG: 361898
parent 39585e4b
No related branches found
No related tags found
No related merge requests found
......@@ -212,13 +212,21 @@ QVariant AccountsViewFilterProxyModel::data(const QModelIndex &index, int role)
if (index.isValid() && role == Qt::DisplayRole) {
int sourceColumn = mapToSource(index).column();
if (sourceColumn == AccountsModel::TotalValue) {
QVariant accountId = mapToSource(AccountsViewFilterProxyModel::index(index.row(), 0, index.parent())).data(AccountsModel::AccountIdRole);
if (d->isAccountExpanded(accountId.toString()) && index.parent().isValid()) {
// if an account is not a top-level account and it is expanded display it's value
return data(index, AccountsModel::AccountValueDisplayRole);
} else {
// if an account is a top-level account or it is collapsed display it's total value
MyMoneyAccount account = mapToSource(AccountsViewFilterProxyModel::index(index.row(), 0, index.parent()))
.data(AccountsModel::AccountRole).value<MyMoneyAccount>();
// show the accounts value incl. the value of sub-accounts
// if the account is not expanded or,
bool showTotalValue = !d->isAccountExpanded(account.id());
// the account is a top-level account or
showTotalValue |= !index.parent().isValid();
// the account is an investment account and equity accounts are hidden
showTotalValue |= (account.accountType() == MyMoneyAccount::Investment && hideEquityAccounts());
if (showTotalValue) {
return data(index, AccountsModel::AccountTotalValueDisplayRole);
} else {
return data(index, AccountsModel::AccountValueDisplayRole);
}
}
if (sourceColumn == AccountsModel::TotalBalance) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment