Changeset View
Changeset View
Standalone View
Standalone View
kmymoney/wizards/newaccountwizard/hierarchyfilterproxymodel.cpp
- This file was added.
1 | /*************************************************************************** | ||||
---|---|---|---|---|---|
2 | hierarchyfilterproxymodel.cpp | ||||
3 | ------------------- | ||||
4 | begin : Tue Sep 25 2006 | ||||
5 | copyright : (C) 2007 Thomas Baumgart | ||||
6 | email : Thomas Baumgart <ipwizard@users.sourceforge.net> | ||||
7 | (C) 2017 by Łukasz Wojniłowicz <lukasz.wojnilowicz@gmail.com> | ||||
8 | ***************************************************************************/ | ||||
9 | | ||||
10 | /*************************************************************************** | ||||
11 | * * | ||||
12 | * This program is free software; you can redistribute it and/or modify * | ||||
13 | * it under the terms of the GNU General Public License as published by * | ||||
14 | * the Free Software Foundation; either version 2 of the License, or * | ||||
15 | * (at your option) any later version. * | ||||
16 | * * | ||||
17 | ***************************************************************************/ | ||||
18 | | ||||
19 | #include "hierarchyfilterproxymodel.h" | ||||
20 | | ||||
21 | // ---------------------------------------------------------------------------- | ||||
22 | // QT Includes | ||||
23 | | ||||
24 | // ---------------------------------------------------------------------------- | ||||
25 | // KDE Includes | ||||
26 | | ||||
27 | // ---------------------------------------------------------------------------- | ||||
28 | // Project Includes | ||||
29 | | ||||
30 | #include "accountsmodel.h" | ||||
31 | #include "accountsproxymodel.h" | ||||
32 | #include "modelenums.h" | ||||
33 | | ||||
34 | namespace NewAccountWizard | ||||
35 | { | ||||
36 | HierarchyFilterProxyModel::HierarchyFilterProxyModel(QObject *parent) | ||||
37 | : AccountsProxyModel(parent) | ||||
38 | { | ||||
39 | } | ||||
40 | | ||||
41 | /** | ||||
42 | * Filter the favorites accounts group. | ||||
43 | */ | ||||
44 | bool HierarchyFilterProxyModel::filterAcceptsRow(int source_row, const QModelIndex &source_parent) const | ||||
45 | { | ||||
46 | if (!source_parent.isValid()) { | ||||
47 | auto accCol = m_mdlColumns->indexOf(eAccountsModel::Column::Account); | ||||
48 | QVariant data = sourceModel()->index(source_row, accCol, source_parent).data((int)eAccountsModel::Role::ID); | ||||
49 | if (data.isValid() && data.toString() == AccountsModel::favoritesAccountId) | ||||
50 | return false; | ||||
51 | } | ||||
52 | return AccountsProxyModel::filterAcceptsRow(source_row, source_parent); | ||||
53 | } | ||||
54 | | ||||
55 | /** | ||||
56 | * Filter all but the first column. | ||||
57 | */ | ||||
58 | bool HierarchyFilterProxyModel::filterAcceptsColumn(int source_column, const QModelIndex &source_parent) const | ||||
59 | { | ||||
60 | Q_UNUSED(source_parent) | ||||
61 | if (source_column == 0) | ||||
62 | return true; | ||||
63 | return false; | ||||
64 | } | ||||
65 | } |