Changeset View
Changeset View
Standalone View
Standalone View
kmymoney/models/accountsproxymodel.h
Show All 18 Lines | |||||
19 | #ifndef ACCOUNTSPROXYMODEL_H | 19 | #ifndef ACCOUNTSPROXYMODEL_H | ||
20 | #define ACCOUNTSPROXYMODEL_H | 20 | #define ACCOUNTSPROXYMODEL_H | ||
21 | 21 | | |||
22 | #include "kmm_models_export.h" | 22 | #include "kmm_models_export.h" | ||
23 | 23 | | |||
24 | // ---------------------------------------------------------------------------- | 24 | // ---------------------------------------------------------------------------- | ||
25 | // QT Includes | 25 | // QT Includes | ||
26 | 26 | | |||
27 | // ---------------------------------------------------------------------------- | 27 | #include <QtGlobal> // for QT_VERSION macro | ||
28 | // KDE Includes | 28 | #include <QSortFilterProxyModel> | ||
29 | 29 | | |||
30 | #if QT_VERSION < QT_VERSION_CHECK(5,10,0) | ||||
30 | #include <KItemModels/KRecursiveFilterProxyModel> | 31 | #include <KItemModels/KRecursiveFilterProxyModel> | ||
tbaumgart: I would add the following here
```
#define QSortFilterProxyModel KRecursiveFilterProxyModel
```… | |||||
32 | #define QSortFilterProxyModel KRecursiveFilterProxyModel | ||||
33 | #endif | ||||
34 | | ||||
35 | // ---------------------------------------------------------------------------- | ||||
36 | // KDE Includes | ||||
31 | 37 | | |||
32 | // ---------------------------------------------------------------------------- | 38 | // ---------------------------------------------------------------------------- | ||
33 | // Project Includes | 39 | // Project Includes | ||
34 | 40 | | |||
35 | /** | 41 | /** | ||
36 | * A proxy model to provide various sorting and filtering operations for @ref AccountsModel. | 42 | * A proxy model to provide various sorting and filtering operations for @ref AccountsModel. | ||
37 | * | 43 | * | ||
38 | * Here is an example of how to use this class in combination with the @ref AccountsModel. | 44 | * Here is an example of how to use this class in combination with the @ref AccountsModel. | ||
Show All 14 Lines | |||||
53 | * @author Cristian Onet 2010 | 59 | * @author Cristian Onet 2010 | ||
54 | * | 60 | * | ||
55 | */ | 61 | */ | ||
56 | 62 | | |||
57 | namespace eMyMoney { namespace Account {enum class Type;} } | 63 | namespace eMyMoney { namespace Account {enum class Type;} } | ||
58 | namespace eAccountsModel { enum class Column; } | 64 | namespace eAccountsModel { enum class Column; } | ||
59 | 65 | | |||
60 | class AccountsProxyModelPrivate; | 66 | class AccountsProxyModelPrivate; | ||
61 | class KMM_MODELS_EXPORT AccountsProxyModel : public KRecursiveFilterProxyModel | 67 | class KMM_MODELS_EXPORT AccountsProxyModel : public QSortFilterProxyModel | ||
62 | { | 68 | { | ||
63 | Q_OBJECT | 69 | Q_OBJECT | ||
64 | Q_DISABLE_COPY(AccountsProxyModel) | 70 | Q_DISABLE_COPY(AccountsProxyModel) | ||
65 | 71 | | |||
66 | public: | 72 | public: | ||
tbaumgart: This whole change is not necessary with the above mentioned `#define` | |||||
67 | explicit AccountsProxyModel(QObject *parent = nullptr); | 73 | explicit AccountsProxyModel(QObject *parent = nullptr); | ||
68 | virtual ~AccountsProxyModel(); | 74 | virtual ~AccountsProxyModel(); | ||
69 | 75 | | |||
70 | void addAccountType(eMyMoney::Account::Type type); | 76 | void addAccountType(eMyMoney::Account::Type type); | ||
71 | void addAccountGroup(const QVector<eMyMoney::Account::Type> &groups); | 77 | void addAccountGroup(const QVector<eMyMoney::Account::Type> &groups); | ||
72 | void removeAccountType(eMyMoney::Account::Type type); | 78 | void removeAccountType(eMyMoney::Account::Type type); | ||
73 | 79 | | |||
74 | void clear(); | 80 | void clear(); | ||
Show All 23 Lines | 95 | protected: | |||
98 | 104 | | |||
99 | int visibleItems(const QModelIndex& index) const; | 105 | int visibleItems(const QModelIndex& index) const; | ||
100 | 106 | | |||
101 | Q_SIGNALS: | 107 | Q_SIGNALS: | ||
102 | void unusedIncomeExpenseAccountHidden(); | 108 | void unusedIncomeExpenseAccountHidden(); | ||
103 | 109 | | |||
104 | private: | 110 | private: | ||
105 | Q_DECLARE_PRIVATE(AccountsProxyModel) | 111 | Q_DECLARE_PRIVATE(AccountsProxyModel) | ||
112 | | ||||
113 | #if QT_VERSION < QT_VERSION_CHECK(5,10,0) | ||||
114 | // provide the interface for backward compatbility | ||||
115 | void setRecursiveFilteringEnabled(bool enable) { | ||||
116 | setRecursiveFilteringEnabled(enable); | ||||
This needs to be removed, because it causes an infinite recursive call. We only need an empty method here in the KRecursiveFilterProxyModel case, because the method does not exist there. tbaumgart: This needs to be removed, because it causes an infinite recursive call. We only need an empty… | |||||
ahmadsamir: Right, I should have figured it out... :) | |||||
117 | } | ||||
118 | #endif | ||||
119 | | ||||
106 | }; | 120 | }; | ||
107 | 121 | | |||
108 | #endif | 122 | #endif |
I would add the following here
and use QSortFilterProxyModel throughout this file. This would make the code easier to read and adjustable in the future.