KSPM: Fix setting selection state after source reset.

This ammends the parent commit.
wilder
Stephen Kelly 11 years ago
parent 41b8a5fc84
commit 7298c92200
  1. 16
      autotests/kselectionproxymodeltest.cpp
  2. 1
      src/kselectionproxymodel.cpp

@ -20,12 +20,13 @@ private Q_SLOTS:
void KSelectionProxyModelTest::selectOnSourceReset()
{
QStringListModel strings({
QStringList days = {
"Monday",
"Tuesday",
"Wednesday",
"Thursday"
});
};
QStringListModel strings(days);
QItemSelectionModel selectionModel(&strings);
connect(&strings, &QAbstractItemModel::modelReset, [&] {
@ -39,7 +40,16 @@ void KSelectionProxyModelTest::selectOnSourceReset()
selectionModel.select(QItemSelection(strings.index(0, 0), strings.index(2, 0)),
QItemSelectionModel::Select);
strings.setStringList({ "One", "Two", "Three", "Four" });
QCOMPARE(proxy.rowCount(), 3);
for (int i = 0; i < 3; ++i)
QCOMPARE(proxy.index(i, 0).data().toString(), days.at(i));
QStringList numbers = { "One", "Two", "Three", "Four" };
strings.setStringList(numbers);
QCOMPARE(proxy.rowCount(), 3);
for (int i = 0; i < 3; ++i)
QCOMPARE(proxy.index(i, 0).data().toString(), numbers.at(i));
QVERIFY(selectionModel.selection().contains(strings.index(0, 0)));
QVERIFY(selectionModel.selection().contains(strings.index(1, 0)));

@ -905,6 +905,7 @@ void KSelectionProxyModelPrivate::sourceModelReset()
resetInternalData();
m_sourceModelResetting = false;
m_resetting = false;
selectionChanged(m_selectionModel->selection(), QItemSelection());
q->endResetModel();
}

Loading…
Cancel
Save