diff --git a/kmymoney/dialogs/hierarchyfilterproxymodel.cpp b/kmymoney/dialogs/hierarchyfilterproxymodel.cpp index ee8483e60..7be9fb237 100644 --- a/kmymoney/dialogs/hierarchyfilterproxymodel.cpp +++ b/kmymoney/dialogs/hierarchyfilterproxymodel.cpp @@ -1,102 +1,103 @@ /* * Copyright 2002-2003 Michael Edwardes * Copyright 2005-2018 Thomas Baumgart * Copyright 2017-2018 Łukasz Wojniłowicz + * Copyright 2020 Robert Szczesiak * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of * the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include "hierarchyfilterproxymodel.h" // ---------------------------------------------------------------------------- // QT Includes // ---------------------------------------------------------------------------- // KDE Headers // ---------------------------------------------------------------------------- // Project Includes #include "accountsmodel.h" #include "modelenums.h" HierarchyFilterProxyModel::HierarchyFilterProxyModel(QObject *parent) : AccountsProxyModel(parent) { } /** * The current account and all it's children are not selectable because the view is used to select a possible parent account. */ Qt::ItemFlags HierarchyFilterProxyModel::flags(const QModelIndex &index) const { Qt::ItemFlags flags = AccountsProxyModel::flags(index); QModelIndex currentIndex = index; while (currentIndex.isValid()) { QVariant accountId = data(currentIndex, (int)eAccountsModel::Role::ID); if (accountId.isValid() && accountId.toString() == m_currentAccountId) { flags = flags & ~Qt::ItemIsSelectable & ~Qt::ItemIsEnabled; } currentIndex = currentIndex.parent(); } return flags; } /** * Set the account for which to select a parent. * * @param currentAccountId The current account. */ void HierarchyFilterProxyModel::setCurrentAccountId(const QString ¤tAccountId) { m_currentAccountId = currentAccountId; } /** * Get the index of the selected parent account. * * @return The model index of the selected parent account. */ QModelIndex HierarchyFilterProxyModel::getSelectedParentAccountIndex() const { QModelIndexList list = match(index(0, 0), (int)eAccountsModel::Role::ID, m_currentAccountId, -1, Qt::MatchFlags(Qt::MatchExactly | Qt::MatchCaseSensitive | Qt::MatchRecursive)); if (!list.empty()) { return list.front().parent(); } return QModelIndex(); } /** * Filter the favorites accounts group. */ bool HierarchyFilterProxyModel::filterAcceptsRow(int source_row, const QModelIndex &source_parent) const { - if (!source_parent.isValid()) { - const auto data = sourceModel()->index(source_row, (int)eAccountsModel::Column::Account, source_parent).data((int)eAccountsModel::Role::ID); - if (data.isValid() && data.toString() == AccountsModel::favoritesAccountId) - return false; - } + const auto index = sourceModel()->index(source_row, (int)eAccountsModel::Column::Account, source_parent); + const auto data = source_parent.isValid() ? index.parent().data((int)eAccountsModel::Role::ID) + : index.data((int)eAccountsModel::Role::ID); + if (data.isValid() && data.toString() == AccountsModel::favoritesAccountId) + return false; return AccountsProxyModel::filterAcceptsRow(source_row, source_parent); } /** * Filter all but the first column. */ bool HierarchyFilterProxyModel::filterAcceptsColumn(int source_column, const QModelIndex &source_parent) const { Q_UNUSED(source_parent) if (source_column == 0) return true; return false; } diff --git a/kmymoney/dialogs/knewaccountdlg.ui b/kmymoney/dialogs/knewaccountdlg.ui index 285797f82..625001ccc 100644 --- a/kmymoney/dialogs/knewaccountdlg.ui +++ b/kmymoney/dialogs/knewaccountdlg.ui @@ -1,905 +1,905 @@ KNewAccountDlg 0 0 670 518 New Account Dialog true 0 General 60 0 60 32767 Name: false Opening information 6 6 6 6 6 Currency: false true 1 0 Type: false 0 0 Date: false Balance: false Options Qt::Horizontal QSizePolicy::Expanding 140 20 Last check number: false 0 0 32767 32767 Notes: Qt::AlignTop false No auto-VAT-assignment Price entry false false 1 0 Preferred Account Cost Center assignment required true <html><head/><body><p>Flag this account to be an opening balance account</p></body></html> Opening Balance Account Qt::Vertical QSizePolicy::Expanding 20 16 Institution Institution 6 0 0 0 0 0 0 New... 60 0 60 32767 Number: false BIC false IBAN false false Qt::Vertical QSizePolicy::Expanding 21 30 - + Hierarchy Subaccount false Limits This page allows to setup certain limits. KMyMoney will warn you when the account balance reaches a limit. true Type false false Absolute limit false Maximum credit limit false false false false Minimum balance false QFrame::HLine QFrame::Sunken Early warning false Qt::Vertical QSizePolicy::Expanding 20 30 Tax VAT details VAT category QFrame::NoFrame QFrame::Plain 0 0 0 0 VAT percentage false Qt::Horizontal QSizePolicy::Expanding 21 20 Qt::Vertical QSizePolicy::Expanding 20 40 QFrame::NoFrame QFrame::Plain 0 0 0 0 Enable auto VAT assignment 0 0 32767 32767 Amount entered QFrame::StyledPanel QFrame::Sunken Gross amount true m_amountGroup Net a&mount m_amountGroup Qt::Vertical QSizePolicy::Expanding 20 21 Include on Tax Reports QFrame::HLine QFrame::Sunken QDialogButtonBox::Cancel|QDialogButtonBox::Ok KLineEdit QLineEdit
klineedit.h
KComboBox QComboBox
kcombobox.h
KTextEdit QTextEdit
ktextedit.h
AmountEdit QLineEdit
amountedit.h
KMyMoneyGeneralCombo QWidget
kmymoneygeneralcombo.h
1
KMyMoneyDateInput QWidget
kmymoneydateinput.h
1
KMyMoneySecuritySelector KComboBox
kmymoneycurrencyselector.h
1
KMyMoneyAccountTreeView QTreeView
kmymoneyaccounttreeview.h
KMyMoneyAccountSelector QWidget
../widgets/kmymoneyaccountselector.h
m_tab accountNameEdit typeCombo m_currency m_openingDateEdit m_openingBalanceEdit m_lastCheckNumberUsed descriptionEdit m_qcheckboxPreferred m_qcheckboxNoVat m_qcomboboxInstitutions m_qbuttonNew ibanEdit accountNoEdit m_minBalanceEarlyEdit m_minBalanceAbsoluteEdit m_maxCreditEarlyEdit m_maxCreditAbsoluteEdit m_vatCategory m_vatRate m_vatAssignment m_grossAmount m_qcheckboxTax