[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [plasma-framework] src/declarativeimports/calendar: [Calendar DaysModel] Don't call layoutChanged()
From: Kai Uwe Broulik <kde () privat ! broulik ! de>
Date: 2016-08-14 9:49:18
Message-ID: E1bYs2g-0001if-HM () code ! kde ! org
[Download RAW message or body]
Git commit 97a3611c165b154211344336d99973391023c057 by Kai Uwe Broulik.
Committed on 14/08/2016 at 09:48.
Pushed by broulik into branch 'master'.
[Calendar DaysModel] Don't call layoutChanged() and emit dataChanged() with roles
LayoutChanged causes QML to destroy all delegates and re-create them.
Since the number of days doesn't change but only the numbers, we can just call \
dataChanged on all roles.
Furthermore, when agenda-related data changes, only the containsEventItems role
might have changed, so only emit a change for it.
CHANGELOG: Performance when changing months in the calendar has been greatly improved
REVIEW: 128648
M +9 -6 src/declarativeimports/calendar/daysmodel.cpp
http://commits.kde.org/plasma-framework/97a3611c165b154211344336d99973391023c057
diff --git a/src/declarativeimports/calendar/daysmodel.cpp \
b/src/declarativeimports/calendar/daysmodel.cpp index 169711e..03dd3c2 100644
--- a/src/declarativeimports/calendar/daysmodel.cpp
+++ b/src/declarativeimports/calendar/daysmodel.cpp
@@ -98,9 +98,6 @@ void DaysModel::update()
m_eventsData.clear();
- // We always have 42 items (or weeks * num of days in week) so we only have to \
tell the view that the data changed.
- layoutChanged();
-
const QDate modelFirstDay(m_data->at(0).yearNumber, m_data->at(0).monthNumber, \
m_data->at(0).dayNumber);
if (m_pluginsManager) {
@@ -108,6 +105,9 @@ void DaysModel::update()
eventsPlugin->loadEventsForDateRange(modelFirstDay, \
modelFirstDay.addDays(42)); }
}
+
+ // We always have 42 items (or weeks * num of days in week) so we only have to \
tell the view that the data changed. + emit dataChanged(index(0, 0), \
index(m_data->count() - 1, 0)); }
void DaysModel::onDataReady(const QMultiHash<QDate, CalendarEvents::EventData> \
&data) @@ -118,7 +118,10 @@ void DaysModel::onDataReady(const QMultiHash<QDate, \
CalendarEvents::EventData> & if (data.contains(QDate::currentDate())) {
m_agendaNeedsUpdate = true;
}
- layoutChanged();
+
+ // only the containsEventItems role may have changed
+ emit dataChanged(index(0, 0), index(m_data->count() - 1, 0), \
{containsEventItems}); +
Q_EMIT agendaUpdated(QDate::currentDate());
}
@@ -142,7 +145,7 @@ void DaysModel::onEventModified(const CalendarEvents::EventData \
&data) Q_FOREACH (const QDate date, updatesList) {
const QModelIndex changedIndex = indexForDate(date);
if (changedIndex.isValid()) {
- Q_EMIT dataChanged(changedIndex, changedIndex);
+ Q_EMIT dataChanged(changedIndex, changedIndex, {containsEventItems});
}
Q_EMIT agendaUpdated(date);
}
@@ -168,7 +171,7 @@ void DaysModel::onEventRemoved(const QString &uid)
Q_FOREACH (const QDate date, updatesList) {
const QModelIndex changedIndex = indexForDate(date);
if (changedIndex.isValid()) {
- Q_EMIT dataChanged(changedIndex, changedIndex);
+ Q_EMIT dataChanged(changedIndex, changedIndex, {containsEventItems});
}
Q_EMIT agendaUpdated(date);
}
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic