diff options
Diffstat (limited to 'framework/src/domain')
-rw-r--r-- | framework/src/domain/daylongeventmodel.cpp | 15 | ||||
-rw-r--r-- | framework/src/domain/daylongeventmodel.h | 5 | ||||
-rw-r--r-- | framework/src/domain/perioddayeventmodel.cpp | 14 | ||||
-rw-r--r-- | framework/src/domain/perioddayeventmodel.h | 5 |
4 files changed, 39 insertions, 0 deletions
diff --git a/framework/src/domain/daylongeventmodel.cpp b/framework/src/domain/daylongeventmodel.cpp index 7775310b..53b50652 100644 --- a/framework/src/domain/daylongeventmodel.cpp +++ b/framework/src/domain/daylongeventmodel.cpp | |||
@@ -99,6 +99,10 @@ bool DayLongEventModel::filterAcceptsRow(int sourceRow, const QModelIndex &sourc | |||
99 | auto idx = sourceModel()->index(sourceRow, 0, sourceParent); | 99 | auto idx = sourceModel()->index(sourceRow, 0, sourceParent); |
100 | auto event = idx.data(Sink::Store::DomainObjectRole).value<Event::Ptr>(); | 100 | auto event = idx.data(Sink::Store::DomainObjectRole).value<Event::Ptr>(); |
101 | 101 | ||
102 | if (!mCalendarFilter.contains(event->getCalendar())) { | ||
103 | return false; | ||
104 | } | ||
105 | |||
102 | auto eventStart = event->getStartTime().date(); | 106 | auto eventStart = event->getStartTime().date(); |
103 | auto eventEnd = event->getEndTime().date(); | 107 | auto eventEnd = event->getEndTime().date(); |
104 | 108 | ||
@@ -141,3 +145,14 @@ void DayLongEventModel::setPeriodLength(int length) | |||
141 | mPeriodLength = length; | 145 | mPeriodLength = length; |
142 | invalidateFilter(); | 146 | invalidateFilter(); |
143 | } | 147 | } |
148 | |||
149 | QSet<QByteArray> DayLongEventModel::calendarFilter() const | ||
150 | { | ||
151 | return mCalendarFilter; | ||
152 | } | ||
153 | |||
154 | void DayLongEventModel::setCalendarFilter(const QSet<QByteArray> &filter) | ||
155 | { | ||
156 | mCalendarFilter = filter; | ||
157 | invalidateFilter(); | ||
158 | } | ||
diff --git a/framework/src/domain/daylongeventmodel.h b/framework/src/domain/daylongeventmodel.h index 12827bef..cd7f4e4b 100644 --- a/framework/src/domain/daylongeventmodel.h +++ b/framework/src/domain/daylongeventmodel.h | |||
@@ -35,6 +35,7 @@ class KUBE_EXPORT DayLongEventModel : public QSortFilterProxyModel | |||
35 | 35 | ||
36 | Q_PROPERTY(QVariant start READ periodStart WRITE setPeriodStart) | 36 | Q_PROPERTY(QVariant start READ periodStart WRITE setPeriodStart) |
37 | Q_PROPERTY(int length READ periodLength WRITE setPeriodLength) | 37 | Q_PROPERTY(int length READ periodLength WRITE setPeriodLength) |
38 | Q_PROPERTY(QSet<QByteArray> calendarFilter READ calendarFilter WRITE setCalendarFilter) | ||
38 | 39 | ||
39 | public: | 40 | public: |
40 | using Event = Sink::ApplicationDomain::Event; | 41 | using Event = Sink::ApplicationDomain::Event; |
@@ -64,11 +65,15 @@ public: | |||
64 | int periodLength() const; | 65 | int periodLength() const; |
65 | void setPeriodLength(int); | 66 | void setPeriodLength(int); |
66 | 67 | ||
68 | QSet<QByteArray> calendarFilter() const; | ||
69 | void setCalendarFilter(const QSet<QByteArray> &); | ||
70 | |||
67 | private: | 71 | private: |
68 | QByteArray getColor(const QByteArray &calendar) const; | 72 | QByteArray getColor(const QByteArray &calendar) const; |
69 | 73 | ||
70 | QSharedPointer<QAbstractItemModel> mModel; | 74 | QSharedPointer<QAbstractItemModel> mModel; |
71 | QSharedPointer<EntityCacheInterface> mCalendarCache; | 75 | QSharedPointer<EntityCacheInterface> mCalendarCache; |
76 | QSet<QByteArray> mCalendarFilter; | ||
72 | 77 | ||
73 | QDate mPeriodStart; | 78 | QDate mPeriodStart; |
74 | int mPeriodLength = 7; | 79 | int mPeriodLength = 7; |
diff --git a/framework/src/domain/perioddayeventmodel.cpp b/framework/src/domain/perioddayeventmodel.cpp index ed853129..149c0fcb 100644 --- a/framework/src/domain/perioddayeventmodel.cpp +++ b/framework/src/domain/perioddayeventmodel.cpp | |||
@@ -83,6 +83,9 @@ void PeriodDayEventModel::partitionData() | |||
83 | SinkWarning() << "Invalid date in the eventModel, ignoring..."; | 83 | SinkWarning() << "Invalid date in the eventModel, ignoring..."; |
84 | continue; | 84 | continue; |
85 | } | 85 | } |
86 | if (!mCalendarFilter.contains(event->getCalendar())) { | ||
87 | continue; | ||
88 | } | ||
86 | 89 | ||
87 | int bucket = bucketOf(eventDate); | 90 | int bucket = bucketOf(eventDate); |
88 | SinkTrace() << "Adding event:" << event->getSummary() << "in bucket #" << bucket; | 91 | SinkTrace() << "Adding event:" << event->getSummary() << "in bucket #" << bucket; |
@@ -322,3 +325,14 @@ void PeriodDayEventModel::setPeriodLength(int length) | |||
322 | mPeriodLength = length; | 325 | mPeriodLength = length; |
323 | updateQuery(); | 326 | updateQuery(); |
324 | } | 327 | } |
328 | |||
329 | QSet<QByteArray> PeriodDayEventModel::calendarFilter() const | ||
330 | { | ||
331 | return mCalendarFilter; | ||
332 | } | ||
333 | |||
334 | void PeriodDayEventModel::setCalendarFilter(const QSet<QByteArray> &filter) | ||
335 | { | ||
336 | mCalendarFilter = filter; | ||
337 | updateQuery(); | ||
338 | } | ||
diff --git a/framework/src/domain/perioddayeventmodel.h b/framework/src/domain/perioddayeventmodel.h index 2d1d0177..2f53486c 100644 --- a/framework/src/domain/perioddayeventmodel.h +++ b/framework/src/domain/perioddayeventmodel.h | |||
@@ -86,6 +86,7 @@ class KUBE_EXPORT PeriodDayEventModel : public QAbstractItemModel | |||
86 | 86 | ||
87 | Q_PROPERTY(QVariant start READ periodStart WRITE setPeriodStart) | 87 | Q_PROPERTY(QVariant start READ periodStart WRITE setPeriodStart) |
88 | Q_PROPERTY(int length READ periodLength WRITE setPeriodLength) | 88 | Q_PROPERTY(int length READ periodLength WRITE setPeriodLength) |
89 | Q_PROPERTY(QSet<QByteArray> calendarFilter READ calendarFilter WRITE setCalendarFilter) | ||
89 | 90 | ||
90 | public: | 91 | public: |
91 | using Event = Sink::ApplicationDomain::Event; | 92 | using Event = Sink::ApplicationDomain::Event; |
@@ -122,6 +123,9 @@ public: | |||
122 | int periodLength() const; | 123 | int periodLength() const; |
123 | void setPeriodLength(int); | 124 | void setPeriodLength(int); |
124 | 125 | ||
126 | QSet<QByteArray> calendarFilter() const; | ||
127 | void setCalendarFilter(const QSet<QByteArray> &); | ||
128 | |||
125 | private: | 129 | private: |
126 | void updateQuery(); | 130 | void updateQuery(); |
127 | void partitionData(); | 131 | void partitionData(); |
@@ -137,6 +141,7 @@ private: | |||
137 | QSharedPointer<QAbstractItemModel> eventModel; | 141 | QSharedPointer<QAbstractItemModel> eventModel; |
138 | QVector<QList<QSharedPointer<Event>>> partitionedEvents; | 142 | QVector<QList<QSharedPointer<Event>>> partitionedEvents; |
139 | QSharedPointer<EntityCacheInterface> mCalendarCache; | 143 | QSharedPointer<EntityCacheInterface> mCalendarCache; |
144 | QSet<QByteArray> mCalendarFilter; | ||
140 | 145 | ||
141 | static const constexpr quintptr DAY_ID = std::numeric_limits<quintptr>::max(); | 146 | static const constexpr quintptr DAY_ID = std::numeric_limits<quintptr>::max(); |
142 | }; | 147 | }; |