summaryrefslogtreecommitdiff
path: root/tasklist.hxx
diff options
context:
space:
mode:
authorꦌ ꦫꦶ ꦏ꧀ꦦꦿ ꦧ ꦮ ꦑ ꦩ ꦭ꧀ <erik@darapsa.co.id>2019-09-05 22:48:01 +0800
committerꦌ ꦫꦶ ꦏ꧀ꦦꦿ ꦧ ꦮ ꦑ ꦩ ꦭ꧀ <erik@darapsa.co.id>2019-09-05 22:48:01 +0800
commit015650a6fadd2592100950c57146fcc5c61764a2 (patch)
tree94b58691f4f7a85560c6a706b9578746b7b6a98f /tasklist.hxx
parent89bff3fa5d58aeb0d507d633aa058d781f06a8c0 (diff)
Task List abstract list model
Diffstat (limited to 'tasklist.hxx')
-rw-r--r--tasklist.hxx37
1 files changed, 37 insertions, 0 deletions
diff --git a/tasklist.hxx b/tasklist.hxx
new file mode 100644
index 0000000..716c365
--- /dev/null
+++ b/tasklist.hxx
@@ -0,0 +1,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