diff options
Diffstat (limited to 'framework/src/domain/eventtreemodel.h')
-rw-r--r-- | framework/src/domain/eventtreemodel.h | 25 |
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 | |||
63 | public: | 67 | public: |
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 | |||
88 | private: | 98 | private: |
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 | }; |