Changeset View
Changeset View
Standalone View
Standalone View
kmymoney/models/accountsmodel.h
1 | /*************************************************************************** | 1 | /*************************************************************************** | ||
---|---|---|---|---|---|
2 | * Copyright 2010 Cristian Onet onet.cristian@gmail.com * | 2 | * Copyright 2010 Cristian Onet onet.cristian@gmail.com * | ||
3 | * Copyright 2017 Łukasz Wojniłowicz lukasz.wojnilowicz@gmail.com * | ||||
3 | * * | 4 | * * | ||
4 | * This program is free software; you can redistribute it and/or * | 5 | * This program is free software; you can redistribute it and/or * | ||
5 | * modify it under the terms of the GNU General Public License as * | 6 | * modify it under the terms of the GNU General Public License as * | ||
6 | * published by the Free Software Foundation; either version 2 of * | 7 | * published by the Free Software Foundation; either version 2 of * | ||
7 | * the License or (at your option) version 3 or any later version * | 8 | * the License or (at your option) version 3 or any later version * | ||
8 | * accepted by the membership of KDE e.V. (or its successor approved * | 9 | * accepted by the membership of KDE e.V. (or its successor approved * | ||
9 | * by the membership of KDE e.V.), which shall act as a proxy * | 10 | * by the membership of KDE e.V.), which shall act as a proxy * | ||
10 | * defined in Section 14 of version 3 of the license. * | 11 | * defined in Section 14 of version 3 of the license. * | ||
▲ Show 20 Lines • Show All 52 Lines • ▼ Show 20 Line(s) | 62 | /** | |||
63 | */ | 64 | */ | ||
64 | enum AccountsItemDataRole { | 65 | enum AccountsItemDataRole { | ||
65 | AccountIdRole = Qt::UserRole, /**< The account id is stored in this role in column 0 as a string.*/ | 66 | AccountIdRole = Qt::UserRole, /**< The account id is stored in this role in column 0 as a string.*/ | ||
66 | AccountFavoriteRole = Qt::UserRole + 1, /**< The 'account is favorite' property is stored in this role in column 0 as a bool.*/ | 67 | AccountFavoriteRole = Qt::UserRole + 1, /**< The 'account is favorite' property is stored in this role in column 0 as a bool.*/ | ||
67 | AccountRole = Qt::UserRole + 2, /**< The MyMoneyAccount is stored in this role in column 0.*/ | 68 | AccountRole = Qt::UserRole + 2, /**< The MyMoneyAccount is stored in this role in column 0.*/ | ||
68 | AccountBalanceRole = Qt::UserRole + 3, /**< The account balance is stored in this role in column 0 as a MyMoneyMoney object.*/ | 69 | AccountBalanceRole = Qt::UserRole + 3, /**< The account balance is stored in this role in column 0 as a MyMoneyMoney object.*/ | ||
69 | AccountValueRole = Qt::UserRole + 4, /**< The account value (the balance converted to base currency) is stored in this role in column 0 as a MyMoneyMoney object.*/ | 70 | AccountValueRole = Qt::UserRole + 4, /**< The account value (the balance converted to base currency) is stored in this role in column 0 as a MyMoneyMoney object.*/ | ||
70 | AccountTotalValueRole = Qt::UserRole + 5, /**< The account total value (the value of the account and of child accounts) is stored in this role in column 0 as a MyMoneyMoney object.*/ | 71 | AccountTotalValueRole = Qt::UserRole + 5, /**< The account total value (the value of the account and of child accounts) is stored in this role in column 0 as a MyMoneyMoney object.*/ | ||
71 | AccountBalanceDisplayRole = Qt::UserRole + 6, /**< The account balance is stored in this role in column TotalBalance as a formatted string for the user.*/ | | |||
72 | AccountValueDisplayRole = Qt::UserRole + 7, /**< The account value (the balance converted to base currency) is stored in this role in column TotalValue as a formated string for the user.*/ | | |||
73 | AccountTotalValueDisplayRole = Qt::UserRole + 8, /**< The account total value is stored in this role in column TotalValue as a formatted string for the user.*/ | | |||
74 | DisplayOrderRole = Qt::UserRole + 9, /**< This role is used by the filtering proxies to order the accounts for displaying.*/ | 72 | DisplayOrderRole = Qt::UserRole + 9, /**< This role is used by the filtering proxies to order the accounts for displaying.*/ | ||
75 | FullNameRole = Qt::UserRole + 10, /**< This role is used to provide the full pathname of the account */ | 73 | FullNameRole = Qt::UserRole + 10, /**< This role is used to provide the full pathname of the account */ | ||
76 | }; | 74 | }; | ||
77 | 75 | | |||
78 | /** | 76 | /** | ||
79 | * The columns of this model. | 77 | * The columns of this model. | ||
80 | */ | 78 | */ | ||
81 | enum Columns { | 79 | enum Columns { | ||
82 | FirstColumnMarker = 0, | 80 | FirstColumnMarker = 0, | ||
83 | Account = 0, | 81 | Account = 0, // CAUTION! Assumption is being made that Account column number is always 0 and you shouldn't change this | ||
84 | Type, | 82 | Type, | ||
85 | Tax, | 83 | Tax, | ||
86 | VAT, | 84 | VAT, | ||
87 | CostCenter, | 85 | CostCenter, | ||
88 | TotalBalance, | 86 | TotalBalance, | ||
89 | PostedValue, | 87 | PostedValue, | ||
90 | TotalValue, | 88 | TotalValue, | ||
89 | AccountNumber, | ||||
90 | AccountSortCode, | ||||
91 | LastColumnMarker | 91 | LastColumnMarker | ||
92 | }; | 92 | }; | ||
93 | 93 | | |||
94 | /** | 94 | /** | ||
95 | * The account id used by this model for the 'Favorites' top level item. This can be used to identify that item on the @ref AccountIdRole. | 95 | * The account id used by this model for the 'Favorites' top level item. This can be used to identify that item on the @ref AccountIdRole. | ||
96 | */ | 96 | */ | ||
97 | static const QString favoritesAccountId; | 97 | static const QString favoritesAccountId; | ||
98 | 98 | | |||
Show All 16 Lines | |||||
115 | MyMoneyMoney accountValue(const MyMoneyAccount &account, const MyMoneyMoney &balance); | 115 | MyMoneyMoney accountValue(const MyMoneyAccount &account, const MyMoneyMoney &balance); | ||
116 | 116 | | |||
117 | /** | 117 | /** | ||
118 | * This method returns the QModelIndex of the account specified by its @a id. If the | 118 | * This method returns the QModelIndex of the account specified by its @a id. If the | ||
119 | * account was not found, an invalid QModelIndex is returned. | 119 | * account was not found, an invalid QModelIndex is returned. | ||
120 | */ | 120 | */ | ||
121 | QModelIndex accountById(const QString& id) const; | 121 | QModelIndex accountById(const QString& id) const; | ||
122 | 122 | | |||
123 | QList<AccountsModel::Columns> *getColumns(); | ||||
124 | | ||||
125 | void setColumnVisibility(const Columns column, const bool show); | ||||
126 | static QString getHeaderName(const Columns column); | ||||
127 | | ||||
123 | public slots: | 128 | public slots: | ||
124 | 129 | | |||
125 | void slotReconcileAccount(const MyMoneyAccount &account, const QDate &reconciliationDate, const MyMoneyMoney &endingBalance); | 130 | void slotReconcileAccount(const MyMoneyAccount &account, const QDate &reconciliationDate, const MyMoneyMoney &endingBalance); | ||
126 | void slotObjectAdded(MyMoneyFile::notificationObjectT objType, const MyMoneyObject * const obj); | 131 | void slotObjectAdded(MyMoneyFile::notificationObjectT objType, const MyMoneyObject * const obj); | ||
127 | void slotObjectModified(MyMoneyFile::notificationObjectT objType, const MyMoneyObject * const obj); | 132 | void slotObjectModified(MyMoneyFile::notificationObjectT objType, const MyMoneyObject * const obj); | ||
128 | void slotObjectRemoved(MyMoneyFile::notificationObjectT objType, const QString& id); | 133 | void slotObjectRemoved(MyMoneyFile::notificationObjectT objType, const QString& id); | ||
129 | void slotBalanceOrValueChanged(const MyMoneyAccount &account); | 134 | void slotBalanceOrValueChanged(const MyMoneyAccount &account); | ||
130 | 135 | | |||
▲ Show 20 Lines • Show All 103 Lines • ▼ Show 20 Line(s) | |||||
234 | { | 239 | { | ||
235 | Q_OBJECT | 240 | Q_OBJECT | ||
236 | 241 | | |||
237 | public: | 242 | public: | ||
238 | AccountsFilterProxyModel(QObject *parent = 0); | 243 | AccountsFilterProxyModel(QObject *parent = 0); | ||
239 | ~AccountsFilterProxyModel(); | 244 | ~AccountsFilterProxyModel(); | ||
240 | 245 | | |||
241 | void addAccountType(MyMoneyAccount::accountTypeE type); | 246 | void addAccountType(MyMoneyAccount::accountTypeE type); | ||
242 | void addAccountGroup(MyMoneyAccount::accountTypeE type); | 247 | void addAccountGroup(const QVector<MyMoneyAccount::_accountTypeE> &groups); | ||
243 | void removeAccountType(MyMoneyAccount::accountTypeE type); | 248 | void removeAccountType(MyMoneyAccount::accountTypeE type); | ||
244 | 249 | | |||
245 | void clear(); | 250 | void clear(); | ||
246 | 251 | | |||
247 | void setHideClosedAccounts(bool hideClosedAccounts); | 252 | void setHideClosedAccounts(bool hideClosedAccounts); | ||
248 | bool hideClosedAccounts() const; | 253 | bool hideClosedAccounts() const; | ||
249 | 254 | | |||
250 | void setHideEquityAccounts(bool hideEquityAccounts); | 255 | void setHideEquityAccounts(bool hideEquityAccounts); | ||
251 | bool hideEquityAccounts() const; | 256 | bool hideEquityAccounts() const; | ||
252 | 257 | | |||
253 | void setHideUnusedIncomeExpenseAccounts(bool hideUnusedIncomeExpenseAccounts); | 258 | void setHideUnusedIncomeExpenseAccounts(bool hideUnusedIncomeExpenseAccounts); | ||
254 | bool hideUnusedIncomeExpenseAccounts() const; | 259 | bool hideUnusedIncomeExpenseAccounts() const; | ||
255 | 260 | | |||
256 | int visibleItems(bool includeBaseAccounts = false) const; | 261 | int visibleItems(bool includeBaseAccounts = false) const; | ||
257 | 262 | | |||
263 | void init(AccountsModel *model, QList<AccountsModel::Columns> *visColumns); | ||||
264 | void init(AccountsModel *model); | ||||
265 | | ||||
258 | protected: | 266 | protected: | ||
259 | virtual bool lessThan(const QModelIndex &left, const QModelIndex &right) const; | 267 | virtual bool lessThan(const QModelIndex &left, const QModelIndex &right) const; | ||
268 | virtual bool filterAcceptsColumn(int source_column, const QModelIndex &source_parent) const; | ||||
260 | virtual bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const; | 269 | virtual bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const; | ||
261 | virtual bool acceptSourceItem(const QModelIndex &source) const; | 270 | virtual bool acceptSourceItem(const QModelIndex &source) const; | ||
262 | 271 | | |||
263 | bool filterAcceptsRowOrChildRows(int source_row, const QModelIndex &source_parent) const; | 272 | bool filterAcceptsRowOrChildRows(int source_row, const QModelIndex &source_parent) const; | ||
264 | 273 | | |||
265 | int visibleItems(const QModelIndex& index) const; | 274 | int visibleItems(const QModelIndex& index) const; | ||
266 | 275 | | |||
276 | QList<AccountsModel::Columns> *m_mdlColumns; | ||||
277 | QList<AccountsModel::Columns> *m_visColumns; | ||||
267 | signals: | 278 | signals: | ||
268 | void unusedIncomeExpenseAccountHidden() const; | 279 | void unusedIncomeExpenseAccountHidden() const; | ||
269 | 280 | | |||
270 | private: | 281 | private: | ||
271 | class Private; | 282 | class Private; | ||
272 | Private* const d; | 283 | Private* const d; | ||
273 | }; | 284 | }; | ||
274 | 285 | | |||
275 | #endif // ACCOUNTSMODEL_H | 286 | #endif // ACCOUNTSMODEL_H |