diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2018-08-20 08:52:03 +0200 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2018-08-20 08:52:03 +0200 |
commit | e391871b400c768d70c2b57bcf0180e62c31acf0 (patch) | |
tree | 5e6db49f451563abdb4418deba1a5a13689e05ac /framework/src/domain/daylongeventmodel.cpp | |
parent | 383fd8e26df252e77c26a5de6616bf9574773161 (diff) | |
download | kube-e391871b400c768d70c2b57bcf0180e62c31acf0.tar.gz kube-e391871b400c768d70c2b57bcf0180e62c31acf0.zip |
Fetching the calendar colors once is enough.
Diffstat (limited to 'framework/src/domain/daylongeventmodel.cpp')
-rw-r--r-- | framework/src/domain/daylongeventmodel.cpp | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/framework/src/domain/daylongeventmodel.cpp b/framework/src/domain/daylongeventmodel.cpp index cd26b5c4..cb9769c6 100644 --- a/framework/src/domain/daylongeventmodel.cpp +++ b/framework/src/domain/daylongeventmodel.cpp | |||
@@ -27,7 +27,9 @@ | |||
27 | 27 | ||
28 | #include "entitycache.h" | 28 | #include "entitycache.h" |
29 | 29 | ||
30 | DayLongEventModel::DayLongEventModel(QObject *parent) : QSortFilterProxyModel(parent) | 30 | DayLongEventModel::DayLongEventModel(QObject *parent) |
31 | : QSortFilterProxyModel(parent), | ||
32 | mCalendarCache{EntityCache<Calendar, Calendar::Color>::Ptr::create()} | ||
31 | { | 33 | { |
32 | setDynamicSortFilter(true); | 34 | setDynamicSortFilter(true); |
33 | 35 | ||
@@ -43,8 +45,6 @@ DayLongEventModel::DayLongEventModel(QObject *parent) : QSortFilterProxyModel(pa | |||
43 | 45 | ||
44 | mModel = Sink::Store::loadModel<Event>(query); | 46 | mModel = Sink::Store::loadModel<Event>(query); |
45 | 47 | ||
46 | mCalendarCache = EntityCache<Calendar, Calendar::Color>::Ptr::create(); | ||
47 | |||
48 | setSourceModel(mModel.data()); | 48 | setSourceModel(mModel.data()); |
49 | } | 49 | } |
50 | 50 | ||
@@ -61,7 +61,11 @@ QHash<int, QByteArray> DayLongEventModel::roleNames() const | |||
61 | 61 | ||
62 | QByteArray DayLongEventModel::getColor(const QByteArray &calendar) const | 62 | QByteArray DayLongEventModel::getColor(const QByteArray &calendar) const |
63 | { | 63 | { |
64 | return mCalendarCache->getProperty(calendar, "color").toByteArray(); | 64 | const auto color = mCalendarCache->getProperty(calendar, "color").toByteArray(); |
65 | if (color.isEmpty()) { | ||
66 | qWarning() << "Failed to get color for calendar " << calendar; | ||
67 | } | ||
68 | return color; | ||
65 | } | 69 | } |
66 | 70 | ||
67 | QVariant DayLongEventModel::data(const QModelIndex &idx, int role) const | 71 | QVariant DayLongEventModel::data(const QModelIndex &idx, int role) const |