blob: 716c365521c3fa6c9b7e011252fffe1aa44b7dff (
plain)
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
|
#ifndef TASKLIST_HXX
#define TASKLIST_HXX
#include <QAbstractListModel>
struct Task
{
enum TaskRoles {
IdRole = Qt::UserRole + 1,
SubjectRole
};
QString id;
QString subject;
};
class TaskList : public QAbstractListModel
{
Q_OBJECT
Q_PROPERTY(int rowCount READ rowCount NOTIFY rowCountChanged)
public:
explicit TaskList(QObject* parent = nullptr) : QAbstractListModel{parent} {}
int rowCount(QModelIndex const& parent = QModelIndex()) const Q_DECL_OVERRIDE;
QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const Q_DECL_OVERRIDE;
protected:
QHash<int, QByteArray> roleNames() const Q_DECL_OVERRIDE;
signals:
void rowCountChanged();
private:
QList<Task> tasks;
void addTask(Task const& task);
};
#endif // TASKLIST_HXX
|