summaryrefslogtreecommitdiffstats
path: root/framework/src/domain/perioddayeventmodel.cpp
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2018-08-20 08:52:03 +0200
committerChristian Mollekopf <chrigi_1@fastmail.fm>2018-08-20 08:52:03 +0200
commite391871b400c768d70c2b57bcf0180e62c31acf0 (patch)
tree5e6db49f451563abdb4418deba1a5a13689e05ac /framework/src/domain/perioddayeventmodel.cpp
parent383fd8e26df252e77c26a5de6616bf9574773161 (diff)
downloadkube-e391871b400c768d70c2b57bcf0180e62c31acf0.tar.gz
kube-e391871b400c768d70c2b57bcf0180e62c31acf0.zip
Fetching the calendar colors once is enough.
Diffstat (limited to 'framework/src/domain/perioddayeventmodel.cpp')
-rw-r--r--framework/src/domain/perioddayeventmodel.cpp14
1 files changed, 8 insertions, 6 deletions
diff --git a/framework/src/domain/perioddayeventmodel.cpp b/framework/src/domain/perioddayeventmodel.cpp
index 1f08fbd3..af9ca110 100644
--- a/framework/src/domain/perioddayeventmodel.cpp
+++ b/framework/src/domain/perioddayeventmodel.cpp
@@ -32,7 +32,9 @@
32#include <entitycache.h> 32#include <entitycache.h>
33 33
34PeriodDayEventModel::PeriodDayEventModel(QObject *parent) 34PeriodDayEventModel::PeriodDayEventModel(QObject *parent)
35 : QAbstractItemModel(parent), partitionedEvents(7) 35 : QAbstractItemModel(parent),
36 partitionedEvents(7),
37 mCalendarCache{EntityCache<Calendar, Calendar::Color>::Ptr::create()}
36{ 38{
37 updateQuery(); 39 updateQuery();
38} 40}
@@ -62,15 +64,11 @@ void PeriodDayEventModel::updateQuery()
62 QObject::connect(eventModel.data(), &QAbstractItemModel::rowsMoved, this, &PeriodDayEventModel::partitionData); 64 QObject::connect(eventModel.data(), &QAbstractItemModel::rowsMoved, this, &PeriodDayEventModel::partitionData);
63 QObject::connect(eventModel.data(), &QAbstractItemModel::rowsRemoved, this, &PeriodDayEventModel::partitionData); 65 QObject::connect(eventModel.data(), &QAbstractItemModel::rowsRemoved, this, &PeriodDayEventModel::partitionData);
64 66
65 mCalendarCache = EntityCache<Calendar, Calendar::Color>::Ptr::create();
66
67 partitionData(); 67 partitionData();
68} 68}
69 69
70void PeriodDayEventModel::partitionData() 70void PeriodDayEventModel::partitionData()
71{ 71{
72 SinkLog() << "Partitioning event data";
73
74 beginResetModel(); 72 beginResetModel();
75 73
76 partitionedEvents = QVector<QList<QSharedPointer<Event>>>(mPeriodLength); 74 partitionedEvents = QVector<QList<QSharedPointer<Event>>>(mPeriodLength);
@@ -177,7 +175,11 @@ int PeriodDayEventModel::columnCount(const QModelIndex &parent) const
177 175
178QByteArray PeriodDayEventModel::getColor(const QByteArray &calendar) const 176QByteArray PeriodDayEventModel::getColor(const QByteArray &calendar) const
179{ 177{
180 return mCalendarCache->getProperty(calendar, "color").toByteArray(); 178 const auto color = mCalendarCache->getProperty(calendar, "color").toByteArray();
179 if (color.isEmpty()) {
180 qWarning() << "Failed to get color for calendar " << calendar;
181 }
182 return color;
181} 183}
182 184
183QDateTime PeriodDayEventModel::getStartTimeOfDay(const QDateTime &dateTime, int day) const 185QDateTime PeriodDayEventModel::getStartTimeOfDay(const QDateTime &dateTime, int day) const