-
Notifications
You must be signed in to change notification settings - Fork 3
/
taskmodel.h
52 lines (34 loc) · 975 Bytes
/
taskmodel.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
#ifndef TASKMODEL_H
#define TASKMODEL_H
#include <QAbstractListModel>
#include <QDateTime>
#include "taskitem.h"
namespace model {
class TaskModel : public QAbstractListModel
{
Q_OBJECT
Q_PROPERTY(int size READ size NOTIFY sizeChanged)
public:
explicit TaskModel(QObject *parent = 0);
~TaskModel();
enum Roles {
TaskTextRole = Qt::UserRole + 1,
TaskIsDoneRole,
TaskIndexRole,
ObjectRole
};
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
int size() const { return m_taskList.size(); }
QHash<int, QByteArray> roleNames() const override;
void addTask(TaskItem* task);
bool takeTask(TaskItem* task);
signals:
void sizeChanged(int arg);
private:
void loadTasks();
void saveTasks();
QList<TaskItem*> m_taskList;
};
} // namespace model
#endif // TASKMODEL_H