diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2018-08-03 13:49:56 +0200 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2018-08-03 13:56:58 +0200 |
commit | 2085b83960cbb8e4693cf48a5bd265aa946256de (patch) | |
tree | 58f5d6f7ff18cd63ac0aa8827dadfbb66e269083 /framework/src/domain/daylongeventmodel.cpp | |
parent | 064367aec304708591f5cd4d010ed462119a0323 (diff) | |
download | kube-2085b83960cbb8e4693cf48a5bd265aa946256de.tar.gz kube-2085b83960cbb8e4693cf48a5bd265aa946256de.zip |
Weekview with calendar colors
Diffstat (limited to 'framework/src/domain/daylongeventmodel.cpp')
-rw-r--r-- | framework/src/domain/daylongeventmodel.cpp | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/framework/src/domain/daylongeventmodel.cpp b/framework/src/domain/daylongeventmodel.cpp index 0ea73709..1b47edda 100644 --- a/framework/src/domain/daylongeventmodel.cpp +++ b/framework/src/domain/daylongeventmodel.cpp | |||
@@ -25,6 +25,8 @@ | |||
25 | #include <sink/query.h> | 25 | #include <sink/query.h> |
26 | #include <sink/store.h> | 26 | #include <sink/store.h> |
27 | 27 | ||
28 | #include "entitycache.h" | ||
29 | |||
28 | DayLongEventModel::DayLongEventModel(QObject *parent) : QSortFilterProxyModel(parent) | 30 | DayLongEventModel::DayLongEventModel(QObject *parent) : QSortFilterProxyModel(parent) |
29 | { | 31 | { |
30 | Sink::Query query; | 32 | Sink::Query query; |
@@ -33,11 +35,14 @@ DayLongEventModel::DayLongEventModel(QObject *parent) : QSortFilterProxyModel(pa | |||
33 | query.request<Event::Description>(); | 35 | query.request<Event::Description>(); |
34 | query.request<Event::StartTime>(); | 36 | query.request<Event::StartTime>(); |
35 | query.request<Event::EndTime>(); | 37 | query.request<Event::EndTime>(); |
38 | query.request<Event::Calendar>(); | ||
36 | 39 | ||
37 | query.filter<Event::AllDay>(true); | 40 | query.filter<Event::AllDay>(true); |
38 | 41 | ||
39 | mModel = Sink::Store::loadModel<Event>(query); | 42 | mModel = Sink::Store::loadModel<Event>(query); |
40 | 43 | ||
44 | mCalendarCache = EntityCache<Calendar, Calendar::Color>::Ptr::create(); | ||
45 | |||
41 | setSourceModel(mModel.data()); | 46 | setSourceModel(mModel.data()); |
42 | } | 47 | } |
43 | 48 | ||
@@ -48,9 +53,15 @@ QHash<int, QByteArray> DayLongEventModel::roleNames() const | |||
48 | {Description, "description"}, | 53 | {Description, "description"}, |
49 | {StartDate, "starts"}, | 54 | {StartDate, "starts"}, |
50 | {Duration, "duration"}, | 55 | {Duration, "duration"}, |
56 | {Color, "color"}, | ||
51 | }; | 57 | }; |
52 | } | 58 | } |
53 | 59 | ||
60 | QByteArray DayLongEventModel::getColor(const QByteArray &calendar) const | ||
61 | { | ||
62 | return mCalendarCache->getProperty(calendar, "color").toByteArray(); | ||
63 | } | ||
64 | |||
54 | QVariant DayLongEventModel::data(const QModelIndex &idx, int role) const | 65 | QVariant DayLongEventModel::data(const QModelIndex &idx, int role) const |
55 | { | 66 | { |
56 | auto srcIdx = mapToSource(idx); | 67 | auto srcIdx = mapToSource(idx); |
@@ -71,6 +82,8 @@ QVariant DayLongEventModel::data(const QModelIndex &idx, int role) const | |||
71 | } | 82 | } |
72 | case Duration: | 83 | case Duration: |
73 | return event->getStartTime().date().daysTo(event->getEndTime().date()); | 84 | return event->getStartTime().date().daysTo(event->getEndTime().date()); |
85 | case Color: | ||
86 | return getColor(event->getCalendar()); | ||
74 | } | 87 | } |
75 | 88 | ||
76 | return QSortFilterProxyModel::data(idx, role); | 89 | return QSortFilterProxyModel::data(idx, role); |