summaryrefslogtreecommitdiffstats
path: root/framework/src/domain/eventtreemodel.h
diff options
context:
space:
mode:
authorMinijackson <minijackson@riseup.net>2018-04-13 10:25:42 +0200
committerMinijackson <minijackson@riseup.net>2018-04-16 10:18:33 +0200
commitcabc867b3e7cbf56ac2d8f646c52deb59a3197f4 (patch)
tree2d9a193601d40b34a99af4949b0ff08f435bb1ad /framework/src/domain/eventtreemodel.h
parent5f425961620431040f1fabe77f70427b49d230fc (diff)
downloadkube-cabc867b3e7cbf56ac2d8f646c52deb59a3197f4.tar.gz
kube-cabc867b3e7cbf56ac2d8f646c52deb59a3197f4.zip
Make the event model size-generic and filter dates
Diffstat (limited to 'framework/src/domain/eventtreemodel.h')
-rw-r--r--framework/src/domain/eventtreemodel.h25
1 files changed, 19 insertions, 6 deletions
diff --git a/framework/src/domain/eventtreemodel.h b/framework/src/domain/eventtreemodel.h
index 77189073..516410ee 100644
--- a/framework/src/domain/eventtreemodel.h
+++ b/framework/src/domain/eventtreemodel.h
@@ -25,10 +25,11 @@
25 25
26#include <QAbstractItemModel> 26#include <QAbstractItemModel>
27#include <QList> 27#include <QList>
28#include <QMutex>
29#include <QSharedPointer> 28#include <QSharedPointer>
30#include <QVector> 29#include <QVector>
31 30
31#include <limits>
32
32// Implementation notes 33// Implementation notes
33// ==================== 34// ====================
34// 35//
@@ -38,8 +39,8 @@
38// Columns are never used. 39// Columns are never used.
39// 40//
40// Top-level items just contains the ".events" attribute, and their rows 41// Top-level items just contains the ".events" attribute, and their rows
41// correspond to their day of week. In that case the internalId contains 42// correspond to their offset compared to the start of the view (in number of
42// DAY_ID. 43// days). In that case the internalId contains DAY_ID.
43// 44//
44// Direct children are events, and their rows corresponds to their index in 45// Direct children are events, and their rows corresponds to their index in
45// their partition. In that case no internalId / internalPointer is used. 46// their partition. In that case no internalId / internalPointer is used.
@@ -60,6 +61,9 @@ class EventTreeModel : public QAbstractItemModel
60{ 61{
61 Q_OBJECT 62 Q_OBJECT
62 63
64 Q_PROPERTY(QVariant viewStart READ viewStart WRITE setViewStart)
65 Q_PROPERTY(int viewLength READ viewLength WRITE setViewLength)
66
63public: 67public:
64 using Event = Sink::ApplicationDomain::Event; 68 using Event = Sink::ApplicationDomain::Event;
65 69
@@ -85,13 +89,22 @@ public:
85 89
86 QHash<int, QByteArray> roleNames() const override; 90 QHash<int, QByteArray> roleNames() const override;
87 91
92 QDate viewStart() const;
93 void setViewStart(QDate);
94 void setViewStart(QVariant);
95 int viewLength() const;
96 void setViewLength(int);
97
88private: 98private:
89 void partitionData(); 99 void partitionData();
90 100
101 int bucketOf(QDate const &candidate) const;
102
103 QDate mViewStart;
104 int mViewLength = 7;
105
91 QSharedPointer<QAbstractItemModel> eventModel; 106 QSharedPointer<QAbstractItemModel> eventModel;
92 QVector<QList<QSharedPointer<Event>>> partitionedEvents; 107 QVector<QList<QSharedPointer<Event>>> partitionedEvents;
93 108
94 QMutex partitioningMutex; 109 static const constexpr quintptr DAY_ID = std::numeric_limits<quintptr>::max();
95
96 static const constexpr quintptr DAY_ID = 7;
97}; 110};