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