1 /*
2  * Copyright 2017-2018  Łukasz Wojniłowicz <lukasz.wojnilowicz@gmail.com>
3  *
4  * 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  * published by the Free Software Foundation; either version 2 of
7  * the License, or (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 #ifndef MODELENUMS_H
19 #define MODELENUMS_H
20 
21 #include <QHashFunctions>
22 #include <qnamespace.h>
23 #include <QMetaType>
24 
25 namespace eAccountsModel {
26     enum class Column {
27         FirstColumnMarker = 0,
28         Account = 0,  // CAUTION! Assumption is being made that Account column number is always 0 and you shouldn't change this
29         Type,
30         Tax,
31         VAT,
32         CostCenter,
33         TotalBalance,
34         PostedValue,
35         TotalValue,
36         AccountNumber,
37         AccountSortCode,
38         LastColumnMarker
39     };
40 
qHash(const Column key,uint seed)41     inline uint qHash(const Column key, uint seed) { return ::qHash(static_cast<uint>(key), seed); }
42 
43     enum class Role {
44         ID = Qt::UserRole,                     /**< The account id is stored in this role in column 0 as a string.*/
45         Favorite = Qt::UserRole + 1,           /**< The 'account is favorite' property is stored in this role in column 0 as a bool.*/
46         Account = Qt::UserRole + 2,            /**< The MyMoneyAccount is stored in this role in column 0.*/
47         Balance = Qt::UserRole + 3,            /**< The account balance is stored in this role in column 0 as a MyMoneyMoney object.*/
48         Value = Qt::UserRole + 4,              /**< The account value (the balance converted to base currency) is stored in this role in column 0 as a MyMoneyMoney object.*/
49         TotalValue = 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.*/
50         DisplayOrder = Qt::UserRole + 9,       /**< This role is used by the filtering proxies to order the accounts for displaying.*/
51         FullName = Qt::UserRole + 10,          /**< This role is used to provide the full pathname of the account */
52     };
53 
qHash(const Role key,uint seed)54     inline uint qHash(const Role key, uint seed) { return ::qHash(static_cast<uint>(key), seed); }
55 }
56 
57 namespace eLedgerModel {
58   enum class Column {
59     Number = 0,
60     Date,
61     Security,
62     CostCenter,
63     Detail,
64     Reconciliation,
65     Payment,
66     Deposit,
67     Quantity,
68     Price,
69     Amount,
70     Value,
71     Balance,
72 
73     // insert new columns above this line
74     LastColumn
75   };
76 
77   enum class Role {
78     // Roles returning values
79     PostDate = Qt::UserRole,
80     PayeeName,
81     Account,
82     CounterAccount,
83     SplitCount,
84     Reconciliation,
85     ReconciliationShort,
86     ReconciliationLong,
87     SplitShares,
88     ShareAmount,
89     ShareAmountSuffix,
90     SplitValue,
91     Memo,
92     SingleLineMemo,
93     Number,
94     Erroneous,
95     Import,
96     Split,
97     Transaction,
98 
99     // Roles returning ids
100     TransactionId,
101     SplitId,
102     TransactionSplitId,
103     PayeeId,
104     AccountId,
105     CounterAccountId,
106     CostCenterId,
107     ScheduleId,
108     TransactionCommodity,
109 
110     // A pseudo role to emit the dataChanged() signal when
111     // used with setData()
112     EmitDataChanged
113 
114   };
115 }
116 
117 /**
118   * Make it possible to hold eAccountsModel::Column objects inside @ref QVariant objects.
119   */
120 Q_DECLARE_METATYPE(eAccountsModel::Column)
121 
122 #endif
123