-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTableModel.h
56 lines (38 loc) · 1.64 KB
/
TableModel.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
54
55
56
#ifndef TABLEMODEL_H
#define TABLEMODEL_H
#include <QAbstractTableModel>
#include <AccountingEntry.h>
class TableModel : public QAbstractTableModel
{
Q_OBJECT
public:
//! Konstruktor
TableModel(QObject* parent = nullptr);
enum Roles {
DataRoleSimple = Qt::UserRole + 1,
DataRole = Qt::UserRole + 2
};
public:
//! Anzahl der aktuellen Zeilen
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
//! Anzahl der aktuellen Spalten (immer = 4)
int columnCount(const QModelIndex &parent = QModelIndex()) const override;
//! Liefert die hinterlegten Daten in einer Zelle
QVariant data(const QModelIndex &index, int role) const override;
//! Liefert die Header-Daten (Zeilen- und Spalten-Bezeichnungen)
QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
//! Prueft was mit der selektierten Zelle gemacht werden darf
Qt::ItemFlags flags(const QModelIndex &index) const override;
//! Setzt neue Daten
bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) override;
//bool insertRows(int position, int rows, const QModelIndex &index = QModelIndex()) override;
//bool removeRows(int position, int rows, const QModelIndex &index = QModelIndex()) override;
//QList<AccountingEntry> getAccountingEntries() const;
//! Fuegt eine neue Buchung dem Model hinzu
QModelIndex addAccountingEntry(AccountingEntry entry);
//! Loescht Buchungen aus dem Model
bool deleteAccountingEntry(int position, int rows);
private:
QList<AccountingEntry> mEntries;
};
#endif // TABLEMODEL_H