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.
This commit is contained in:
Mark Liversedge
2013-12-10 18:08:59 +00:00
parent 3694b67358
commit 3c246ffa28
2 changed files with 11 additions and 10 deletions

View File

@@ -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:

View File

@@ -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++)