diff options
Diffstat (limited to 'framework/src')
-rw-r--r-- | framework/src/domain/daylongeventmodel.cpp | 12 | ||||
-rw-r--r-- | framework/src/domain/perioddayeventmodel.cpp | 14 |
2 files changed, 16 insertions, 10 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 |
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 | ||
34 | PeriodDayEventModel::PeriodDayEventModel(QObject *parent) | 34 | PeriodDayEventModel::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 | ||
70 | void PeriodDayEventModel::partitionData() | 70 | void 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 | ||
178 | QByteArray PeriodDayEventModel::getColor(const QByteArray &calendar) const | 176 | QByteArray 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 | ||
183 | QDateTime PeriodDayEventModel::getStartTimeOfDay(const QDateTime &dateTime, int day) const | 185 | QDateTime PeriodDayEventModel::getStartTimeOfDay(const QDateTime &dateTime, int day) const |