Fix KDescendantsProxyModel::setSourceModel() not clearing internal caches

This fixes Sune's unittest.
wilder
David Faure 10 years ago
parent 3244f2ff34
commit 73c005a031
  1. 1
      autotests/kdescendantsproxymodeltest.cpp
  2. 7
      src/kdescendantsproxymodel.cpp

@ -77,7 +77,6 @@ void tst_KDescendantProxyModel::testResetModelContent()
<< "SecondModel1-1"; << "SecondModel1-1";
QCOMPARE(proxy.rowCount(), results.count()); QCOMPARE(proxy.rowCount(), results.count());
for (int i = 0 ; i < proxy.rowCount() ; i++) { for (int i = 0 ; i < proxy.rowCount() ; i++) {
QEXPECT_FAIL("", "KDescendantProxyModel broken in setSourceModel", Continue);
QCOMPARE(proxy.index(i, 0).data(Qt::DisplayRole).toString(), results[i]); QCOMPARE(proxy.index(i, 0).data(Qt::DisplayRole).toString(), results[i]);
} }
} }

@ -246,6 +246,8 @@ QString KDescendantsProxyModel::ancestorSeparator() const
void KDescendantsProxyModel::setSourceModel(QAbstractItemModel *_sourceModel) void KDescendantsProxyModel::setSourceModel(QAbstractItemModel *_sourceModel)
{ {
Q_D(KDescendantsProxyModel);
beginResetModel(); beginResetModel();
static const char *const modelSignals[] = { static const char *const modelSignals[] = {
@ -291,6 +293,11 @@ void KDescendantsProxyModel::setSourceModel(QAbstractItemModel *_sourceModel)
} }
} }
resetInternalData();
if (_sourceModel && _sourceModel->hasChildren()) {
d->synchronousMappingRefresh();
}
endResetModel(); endResetModel();
} }

Loading…
Cancel
Save