diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2018-08-03 14:51:37 +0200 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2018-08-03 14:51:37 +0200 |
commit | 8bf3d43866ed23edc667b8c64295687e6e4bbc3d (patch) | |
tree | 8943f2fc879d60290c6223ef7cb3ab22c404d6ea | |
parent | 2085b83960cbb8e4693cf48a5bd265aa946256de (diff) | |
download | kube-8bf3d43866ed23edc667b8c64295687e6e4bbc3d.tar.gz kube-8bf3d43866ed23edc667b8c64295687e6e4bbc3d.zip |
Calculate indentation
-rw-r--r-- | framework/src/domain/perioddayeventmodel.cpp | 26 | ||||
-rw-r--r-- | framework/src/domain/perioddayeventmodel.h | 1 | ||||
-rw-r--r-- | views/calendar/qml/WeekView.qml | 4 |
3 files changed, 26 insertions, 5 deletions
diff --git a/framework/src/domain/perioddayeventmodel.cpp b/framework/src/domain/perioddayeventmodel.cpp index 4463e252..39cc1bc3 100644 --- a/framework/src/domain/perioddayeventmodel.cpp +++ b/framework/src/domain/perioddayeventmodel.cpp | |||
@@ -183,11 +183,29 @@ QVariant PeriodDayEventModel::data(const QModelIndex &id, int role) const | |||
183 | case Events: { | 183 | case Events: { |
184 | auto result = QVariantList{}; | 184 | auto result = QVariantList{}; |
185 | 185 | ||
186 | QMap<QTime, int> sorted; | ||
186 | for (int i = 0; i < partitionedEvents[day].size(); ++i) { | 187 | for (int i = 0; i < partitionedEvents[day].size(); ++i) { |
187 | auto eventId = index(i, 0, id); | 188 | const auto eventId = index(i, 0, id); |
189 | sorted.insert(data(eventId, StartTime).toDateTime().time(), i); | ||
190 | } | ||
191 | |||
192 | QMap<QTime, int> indentationStack; | ||
193 | for (auto it = sorted.begin(); it != sorted.end(); it++) { | ||
194 | auto eventId = index(it.value(), 0, id); | ||
188 | SinkTrace() << "Appending event:" << data(eventId, Summary); | 195 | SinkTrace() << "Appending event:" << data(eventId, Summary); |
189 | 196 | ||
190 | auto startTime = data(eventId, StartTime).toDateTime().time(); | 197 | const auto startTime = data(eventId, StartTime).toDateTime().time(); |
198 | |||
199 | //Remove all dates before startTime | ||
200 | for (auto it = indentationStack.begin(); it != indentationStack.end();) { | ||
201 | if (it.key() < startTime) { | ||
202 | it = indentationStack.erase(it); | ||
203 | } else { | ||
204 | ++it; | ||
205 | } | ||
206 | } | ||
207 | const int indentation = indentationStack.size(); | ||
208 | indentationStack.insert(data(eventId, EndTime).toDateTime().time(), 0); | ||
191 | 209 | ||
192 | result.append(QVariantMap{ | 210 | result.append(QVariantMap{ |
193 | {"text", data(eventId, Summary)}, | 211 | {"text", data(eventId, Summary)}, |
@@ -195,7 +213,7 @@ QVariant PeriodDayEventModel::data(const QModelIndex &id, int role) const | |||
195 | {"starts", startTime.hour() + startTime.minute() / 60.}, | 213 | {"starts", startTime.hour() + startTime.minute() / 60.}, |
196 | {"duration", data(eventId, Duration)}, | 214 | {"duration", data(eventId, Duration)}, |
197 | {"color", data(eventId, Color)}, | 215 | {"color", data(eventId, Color)}, |
198 | {"indention", 0}, | 216 | {"indentation", indentation}, |
199 | }); | 217 | }); |
200 | } | 218 | } |
201 | 219 | ||
@@ -218,6 +236,8 @@ QVariant PeriodDayEventModel::data(const QModelIndex &id, int role) const | |||
218 | return event->getDescription(); | 236 | return event->getDescription(); |
219 | case StartTime: | 237 | case StartTime: |
220 | return event->getStartTime(); | 238 | return event->getStartTime(); |
239 | case EndTime: | ||
240 | return event->getEndTime(); | ||
221 | case Duration: { | 241 | case Duration: { |
222 | auto start = event->getStartTime(); | 242 | auto start = event->getStartTime(); |
223 | auto end = event->getEndTime(); | 243 | auto end = event->getEndTime(); |
diff --git a/framework/src/domain/perioddayeventmodel.h b/framework/src/domain/perioddayeventmodel.h index a0410e2e..2eaa7f1c 100644 --- a/framework/src/domain/perioddayeventmodel.h +++ b/framework/src/domain/perioddayeventmodel.h | |||
@@ -98,6 +98,7 @@ public: | |||
98 | Summary, | 98 | Summary, |
99 | Description, | 99 | Description, |
100 | StartTime, | 100 | StartTime, |
101 | EndTime, | ||
101 | Duration, | 102 | Duration, |
102 | Color | 103 | Color |
103 | }; | 104 | }; |
diff --git a/views/calendar/qml/WeekView.qml b/views/calendar/qml/WeekView.qml index 08c56e5a..9366becc 100644 --- a/views/calendar/qml/WeekView.qml +++ b/views/calendar/qml/WeekView.qml | |||
@@ -260,10 +260,10 @@ FocusScope { | |||
260 | rightMargin: Kube.Units.smallSpacing | 260 | rightMargin: Kube.Units.smallSpacing |
261 | } | 261 | } |
262 | radius: 2 | 262 | radius: 2 |
263 | width: root.dayWidth - Kube.Units.smallSpacing * 2 - Kube.Units.gridUnit * model.modelData.indention | 263 | width: root.dayWidth - Kube.Units.smallSpacing * 2 - Kube.Units.gridUnit * model.modelData.indentation |
264 | height: Math.max(root.hourHeight * 0.5, root.hourHeight * model.modelData.duration) | 264 | height: Math.max(root.hourHeight * 0.5, root.hourHeight * model.modelData.duration) |
265 | y: root.hourHeight * model.modelData.starts | 265 | y: root.hourHeight * model.modelData.starts |
266 | x: Kube.Units.gridUnit * model.modelData.indention | 266 | x: Kube.Units.gridUnit * model.modelData.indentation |
267 | 267 | ||
268 | color: model.modelData.color | 268 | color: model.modelData.color |
269 | opacity: 0.8 | 269 | opacity: 0.8 |