-
Notifications
You must be signed in to change notification settings - Fork 0
/
UserExpensesModel.h
53 lines (38 loc) · 1.42 KB
/
UserExpensesModel.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#ifndef USEREXPENSESMODEL_H
#define USEREXPENSESMODEL_H
#include <QAbstractTableModel>
#include <QColor>
struct Expense
{
QString name;
float amount;
Expense(const QString& n, const float& a): name(n), amount(a)
{
}
};
class UserExpensesModel : public QAbstractTableModel
{
Q_OBJECT
public:
enum ColEnum: int
{
ExpenseName,
Amount,
numCols
};
explicit UserExpensesModel(QObject *parent = nullptr);
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
bool setHeaderData(int section, Qt::Orientation orientation, const QVariant &value, int role = Qt::EditRole) override;
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
int columnCount(const QModelIndex &parent = QModelIndex()) const override;
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
bool setData(const QModelIndex &index, const QVariant &value,
int role = Qt::EditRole) override;
Qt::ItemFlags flags(const QModelIndex& index) const override;
bool insertRows(int row, int count, const QModelIndex &parent = QModelIndex()) override;
bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex()) override;
private:
QList<Expense*> m_Expenses;
QColor m_tableBackgroundColor = QColor(25, 25, 25);
};
#endif // USEREXPENSESMODEL_H