From 3c246ffa2850ba2ee4fab5520ea01fbcf76bdc9f Mon Sep 17 00:00:00 2001 From: Mark Liversedge Date: Tue, 10 Dec 2013 18:08:59 +0000 Subject: [PATCH] Model reset fixup to use begin/endResetModel Which is how you are supposed to reset a model and works on QT 4 as well as QT 5. --- src/GcCalendarModel.h | 10 +++++----- src/RideNavigatorProxy.h | 11 ++++++----- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/GcCalendarModel.h b/src/GcCalendarModel.h index d63215315..2ac6a7f45 100644 --- a/src/GcCalendarModel.h +++ b/src/GcCalendarModel.h @@ -88,6 +88,9 @@ public slots: if (!sourceModel()) return; // no model yet! + // ok, let em know we're about to reset! + beginResetModel(); + QDate first = QDate(year, month, 1); // Date array int monthDays = first.daysTo(first.addMonths(1)); // how many days in this month? @@ -135,12 +138,9 @@ public slots: arr->append(j); dateToRows.insert(dateTime.date(), arr); } -#if QT_VERSION > 0x050000 - resetInternalData(); //XXX BROKEN! -#else - reset(); -#endif + // reset completed + endResetModel(); } public: diff --git a/src/RideNavigatorProxy.h b/src/RideNavigatorProxy.h index dd3651a15..5edd7e0e8 100644 --- a/src/RideNavigatorProxy.h +++ b/src/RideNavigatorProxy.h @@ -488,13 +488,14 @@ public: public slots: void sourceModelChanged() { + + // notify everyone we're changing + beginResetModel(); + clearGroups(); setGroupBy(groupBy+2); // accomodate virtual columns -#if QT_VERSION > 0x050000 - resetInternalData(); //XXX BROKEN! -#else - reset(); -#endif + + endResetModel();// we're clean // lets expand column 0 for the groupBy heading for (int i=0; i < groupCount(); i++)