summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/itemmodels
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/corelib/itemmodels')
-rw-r--r--tests/auto/corelib/itemmodels/qabstractitemmodel/qabstractitemmodel.pro8
-rw-r--r--tests/auto/corelib/itemmodels/qabstractitemmodel/tst_qabstractitemmodel.cpp72
-rw-r--r--tests/auto/corelib/itemmodels/qabstractproxymodel/tst_qabstractproxymodel.cpp4
-rw-r--r--tests/auto/corelib/itemmodels/qidentityproxymodel/qidentityproxymodel.pro6
-rw-r--r--tests/auto/corelib/itemmodels/qidentityproxymodel/tst_qidentityproxymodel.cpp2
-rw-r--r--tests/auto/corelib/itemmodels/qitemmodel/tst_qitemmodel.cpp12
-rw-r--r--tests/auto/corelib/itemmodels/qsortfilterproxymodel/qsortfilterproxymodel.pro6
-rw-r--r--tests/auto/corelib/itemmodels/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp35
-rw-r--r--tests/auto/corelib/itemmodels/qsortfilterproxymodel_recursive/tst_qsortfilterproxymodel_recursive.cpp40
-rw-r--r--tests/auto/corelib/itemmodels/qstringlistmodel/tst_qstringlistmodel.cpp6
10 files changed, 141 insertions, 50 deletions
diff --git a/tests/auto/corelib/itemmodels/qabstractitemmodel/qabstractitemmodel.pro b/tests/auto/corelib/itemmodels/qabstractitemmodel/qabstractitemmodel.pro
index 7480bd45f6..da1f87e76a 100644
--- a/tests/auto/corelib/itemmodels/qabstractitemmodel/qabstractitemmodel.pro
+++ b/tests/auto/corelib/itemmodels/qabstractitemmodel/qabstractitemmodel.pro
@@ -1,9 +1,9 @@
CONFIG += testcase
TARGET = tst_qabstractitemmodel
-QT = core testlib
+QT = core testlib gui
-mtdir = ../../../other/modeltest
+mtdir = ../../../other/qabstractitemmodelutils
INCLUDEPATH += $$PWD/$${mtdir}
-SOURCES = tst_qabstractitemmodel.cpp $${mtdir}/dynamictreemodel.cpp $${mtdir}/modeltest.cpp
-HEADERS = $${mtdir}/dynamictreemodel.h $${mtdir}/modeltest.h
+SOURCES = tst_qabstractitemmodel.cpp $${mtdir}/dynamictreemodel.cpp
+HEADERS = $${mtdir}/dynamictreemodel.h
DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0
diff --git a/tests/auto/corelib/itemmodels/qabstractitemmodel/tst_qabstractitemmodel.cpp b/tests/auto/corelib/itemmodels/qabstractitemmodel/tst_qabstractitemmodel.cpp
index 9f67ccd9c9..b960ca9220 100644
--- a/tests/auto/corelib/itemmodels/qabstractitemmodel/tst_qabstractitemmodel.cpp
+++ b/tests/auto/corelib/itemmodels/qabstractitemmodel/tst_qabstractitemmodel.cpp
@@ -31,6 +31,7 @@
#include <QtCore/QSortFilterProxyModel>
#include <QtCore/QStringListModel>
+#include <QtGui/QStandardItemModel>
#include "dynamictreemodel.h"
@@ -105,6 +106,8 @@ private slots:
void testFunctionPointerSignalConnection();
+ void checkIndex();
+
private:
DynamicTreeModel *m_model;
};
@@ -2283,6 +2286,75 @@ void tst_QAbstractItemModel::testFunctionPointerSignalConnection()
// model.rowsInserted(QModelIndex(), 0, 0);
}
+void tst_QAbstractItemModel::checkIndex()
+{
+ const QRegularExpression ignorePattern("^Index QModelIndex");
+
+ // checkIndex is QAbstractItemModel API; using QStandardItem as an easy
+ // way to build a tree model
+ QStandardItemModel model;
+ QStandardItem *topLevel = new QStandardItem("topLevel");
+ model.appendRow(topLevel);
+
+ topLevel->appendRow(new QStandardItem("child1"));
+ topLevel->appendRow(new QStandardItem("child2"));
+
+ QVERIFY(model.checkIndex(QModelIndex()));
+ QVERIFY(model.checkIndex(QModelIndex(), QAbstractItemModel::CheckIndexOption::DoNotUseParent));
+ QVERIFY(model.checkIndex(QModelIndex(), QAbstractItemModel::CheckIndexOption::ParentIsInvalid));
+ QTest::ignoreMessage(QtWarningMsg, ignorePattern);
+ QVERIFY(!model.checkIndex(QModelIndex(), QAbstractItemModel::CheckIndexOption::IndexIsValid));
+
+ QModelIndex topLevelIndex = model.index(0, 0);
+ QVERIFY(topLevelIndex.isValid());
+ QVERIFY(model.checkIndex(topLevelIndex));
+ QVERIFY(model.checkIndex(topLevelIndex, QAbstractItemModel::CheckIndexOption::DoNotUseParent));
+ QVERIFY(model.checkIndex(topLevelIndex, QAbstractItemModel::CheckIndexOption::ParentIsInvalid));
+ QVERIFY(model.checkIndex(topLevelIndex, QAbstractItemModel::CheckIndexOption::IndexIsValid));
+
+ QModelIndex childIndex = model.index(0, 0, topLevelIndex);
+ QVERIFY(childIndex.isValid());
+ QVERIFY(model.checkIndex(childIndex));
+ QVERIFY(model.checkIndex(childIndex, QAbstractItemModel::CheckIndexOption::DoNotUseParent));
+ QTest::ignoreMessage(QtWarningMsg, ignorePattern);
+ QVERIFY(!model.checkIndex(childIndex, QAbstractItemModel::CheckIndexOption::ParentIsInvalid));
+ QVERIFY(model.checkIndex(childIndex, QAbstractItemModel::CheckIndexOption::IndexIsValid));
+
+ childIndex = model.index(1, 0, topLevelIndex);
+ QVERIFY(childIndex.isValid());
+ QVERIFY(model.checkIndex(childIndex));
+ QVERIFY(model.checkIndex(childIndex, QAbstractItemModel::CheckIndexOption::DoNotUseParent));
+ QTest::ignoreMessage(QtWarningMsg, ignorePattern);
+ QVERIFY(!model.checkIndex(childIndex, QAbstractItemModel::CheckIndexOption::ParentIsInvalid));
+ QVERIFY(model.checkIndex(childIndex, QAbstractItemModel::CheckIndexOption::IndexIsValid));
+
+ topLevel->removeRow(1);
+ QTest::ignoreMessage(QtWarningMsg, ignorePattern);
+ QVERIFY(!model.checkIndex(childIndex));
+ QVERIFY(model.checkIndex(childIndex, QAbstractItemModel::CheckIndexOption::DoNotUseParent));
+ QTest::ignoreMessage(QtWarningMsg, ignorePattern);
+ QVERIFY(!model.checkIndex(childIndex, QAbstractItemModel::CheckIndexOption::ParentIsInvalid));
+ QTest::ignoreMessage(QtWarningMsg, ignorePattern);
+ QVERIFY(!model.checkIndex(childIndex, QAbstractItemModel::CheckIndexOption::IndexIsValid));
+
+ QStandardItemModel model2;
+ model2.appendRow(new QStandardItem("otherTopLevel"));
+ topLevelIndex = model2.index(0, 0);
+ QVERIFY(topLevelIndex.isValid());
+ QVERIFY(model2.checkIndex(topLevelIndex));
+ QVERIFY(model2.checkIndex(topLevelIndex, QAbstractItemModel::CheckIndexOption::DoNotUseParent));
+ QVERIFY(model2.checkIndex(topLevelIndex, QAbstractItemModel::CheckIndexOption::ParentIsInvalid));
+ QVERIFY(model2.checkIndex(topLevelIndex, QAbstractItemModel::CheckIndexOption::IndexIsValid));
+
+ QTest::ignoreMessage(QtWarningMsg, ignorePattern);
+ QVERIFY(!model.checkIndex(topLevelIndex));
+ QTest::ignoreMessage(QtWarningMsg, ignorePattern);
+ QVERIFY(!model.checkIndex(topLevelIndex, QAbstractItemModel::CheckIndexOption::DoNotUseParent));
+ QTest::ignoreMessage(QtWarningMsg, ignorePattern);
+ QVERIFY(!model.checkIndex(topLevelIndex, QAbstractItemModel::CheckIndexOption::ParentIsInvalid));
+ QTest::ignoreMessage(QtWarningMsg, ignorePattern);
+ QVERIFY(!model.checkIndex(topLevelIndex, QAbstractItemModel::CheckIndexOption::IndexIsValid));
+}
QTEST_MAIN(tst_QAbstractItemModel)
#include "tst_qabstractitemmodel.moc"
diff --git a/tests/auto/corelib/itemmodels/qabstractproxymodel/tst_qabstractproxymodel.cpp b/tests/auto/corelib/itemmodels/qabstractproxymodel/tst_qabstractproxymodel.cpp
index 6c870737da..886941bff6 100644
--- a/tests/auto/corelib/itemmodels/qabstractproxymodel/tst_qabstractproxymodel.cpp
+++ b/tests/auto/corelib/itemmodels/qabstractproxymodel/tst_qabstractproxymodel.cpp
@@ -477,8 +477,8 @@ void tst_QAbstractProxyModel::testSwappingRowsProxy()
for (int row = 0; row < defaultModel.rowCount(); ++row) {
QModelIndex left = proxy.index(row, 0, QModelIndex());
QModelIndex right = proxy.index(row, 1, QModelIndex());
- QCOMPARE(left.sibling(left.row(), 1), right);
- QCOMPARE(right.sibling(right.row(), 0), left);
+ QCOMPARE(left.siblingAtColumn(1), right);
+ QCOMPARE(right.siblingAtColumn(0), left);
}
}
diff --git a/tests/auto/corelib/itemmodels/qidentityproxymodel/qidentityproxymodel.pro b/tests/auto/corelib/itemmodels/qidentityproxymodel/qidentityproxymodel.pro
index ba32f02962..ddec0d2354 100644
--- a/tests/auto/corelib/itemmodels/qidentityproxymodel/qidentityproxymodel.pro
+++ b/tests/auto/corelib/itemmodels/qidentityproxymodel/qidentityproxymodel.pro
@@ -1,8 +1,8 @@
CONFIG += testcase
TARGET = tst_qidentityproxymodel
-mtdir = ../../../other/modeltest
+mtdir = ../../../other/qabstractitemmodelutils
INCLUDEPATH += $$PWD/$${mtdir}
QT += testlib
-SOURCES += tst_qidentityproxymodel.cpp $${mtdir}/dynamictreemodel.cpp $${mtdir}/modeltest.cpp
-HEADERS += $${mtdir}/dynamictreemodel.h $${mtdir}/modeltest.h
+SOURCES += tst_qidentityproxymodel.cpp $${mtdir}/dynamictreemodel.cpp
+HEADERS += $${mtdir}/dynamictreemodel.h
diff --git a/tests/auto/corelib/itemmodels/qidentityproxymodel/tst_qidentityproxymodel.cpp b/tests/auto/corelib/itemmodels/qidentityproxymodel/tst_qidentityproxymodel.cpp
index 564b8547b1..f8c5c92677 100644
--- a/tests/auto/corelib/itemmodels/qidentityproxymodel/tst_qidentityproxymodel.cpp
+++ b/tests/auto/corelib/itemmodels/qidentityproxymodel/tst_qidentityproxymodel.cpp
@@ -360,7 +360,7 @@ class AppendStringProxy : public QIdentityProxyModel
public:
QVariant data(const QModelIndex &index, int role) const
{
- const QVariant result = sourceModel()->data(index, role);
+ const QVariant result = QIdentityProxyModel::data(index, role);
if (role != Qt::DisplayRole)
return result;
return result.toString() + "_appended";
diff --git a/tests/auto/corelib/itemmodels/qitemmodel/tst_qitemmodel.cpp b/tests/auto/corelib/itemmodels/qitemmodel/tst_qitemmodel.cpp
index 8ebb860edd..7cd220e684 100644
--- a/tests/auto/corelib/itemmodels/qitemmodel/tst_qitemmodel.cpp
+++ b/tests/auto/corelib/itemmodels/qitemmodel/tst_qitemmodel.cpp
@@ -428,6 +428,14 @@ void checkChildren(QAbstractItemModel *currentModel, const QModelIndex &parent,
const QModelIndex sibling = topLeftChild.sibling( r, c );
QVERIFY( index == sibling );
}
+ if (r == topLeftChild.row()) {
+ const QModelIndex sibling = topLeftChild.siblingAtColumn( c );
+ QVERIFY( index == sibling );
+ }
+ if (c == topLeftChild.column()) {
+ const QModelIndex sibling = topLeftChild.siblingAtRow( r );
+ QVERIFY( index == sibling );
+ }
// Some basic checking on the index that is returned
QCOMPARE(index.model(), currentModel);
@@ -533,9 +541,6 @@ void tst_QItemModel::data()
// A valid index should have a valid qvariant data
QVERIFY(currentModel->index(0,0).isValid());
- // shouldn't be able to set data on an invalid index
- QCOMPARE(currentModel->setData(QModelIndex(), "foo", Qt::DisplayRole), false);
-
// General Purpose roles
QVariant variant = currentModel->data(currentModel->index(0,0), Qt::ToolTipRole);
if (variant.isValid()) {
@@ -605,7 +610,6 @@ void tst_QItemModel::setData()
QVERIFY(currentModel);
QSignalSpy spy(currentModel, &QAbstractItemModel::dataChanged);
QVERIFY(spy.isValid());
- QCOMPARE(currentModel->setData(QModelIndex(), QVariant()), false);
QCOMPARE(spy.count(), 0);
QFETCH(bool, isEmpty);
diff --git a/tests/auto/corelib/itemmodels/qsortfilterproxymodel/qsortfilterproxymodel.pro b/tests/auto/corelib/itemmodels/qsortfilterproxymodel/qsortfilterproxymodel.pro
index 099f666def..dfa8b9fa1b 100644
--- a/tests/auto/corelib/itemmodels/qsortfilterproxymodel/qsortfilterproxymodel.pro
+++ b/tests/auto/corelib/itemmodels/qsortfilterproxymodel/qsortfilterproxymodel.pro
@@ -2,8 +2,8 @@ CONFIG += testcase
TARGET = tst_qsortfilterproxymodel
QT += widgets testlib
-mtdir = ../../../other/modeltest
+mtdir = ../../../other/qabstractitemmodelutils
INCLUDEPATH += $$PWD/$${mtdir}
-SOURCES += tst_qsortfilterproxymodel.cpp $${mtdir}/dynamictreemodel.cpp $${mtdir}/modeltest.cpp
-HEADERS += $${mtdir}/dynamictreemodel.h $${mtdir}/modeltest.h
+SOURCES += tst_qsortfilterproxymodel.cpp $${mtdir}/dynamictreemodel.cpp
+HEADERS += $${mtdir}/dynamictreemodel.h
diff --git a/tests/auto/corelib/itemmodels/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp b/tests/auto/corelib/itemmodels/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp
index 1fb51490db..1acedf4271 100644
--- a/tests/auto/corelib/itemmodels/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp
+++ b/tests/auto/corelib/itemmodels/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp
@@ -28,7 +28,6 @@
#include <QtTest/QtTest>
#include "dynamictreemodel.h"
-#include "modeltest.h"
#include <QtCore/QCoreApplication>
#include <QtGui/QStandardItem>
@@ -152,6 +151,7 @@ private slots:
void emitLayoutChangedOnlyIfSortingChanged_data();
void emitLayoutChangedOnlyIfSortingChanged();
+ void checkSetNewModel();
protected:
void buildHierarchy(const QStringList &data, QAbstractItemModel *model);
void checkHierarchy(const QStringList &data, const QAbstractItemModel *model);
@@ -1873,9 +1873,6 @@ void tst_QSortFilterProxyModel::changeFilter()
QCOMPARE(args.at(2).toInt(), finalRemoveIntervals.at(i).second);
}
-#ifdef Q_OS_IRIX
- QEXPECT_FAIL("filter (2)", "Not reliable on IRIX", Abort);
-#endif
QCOMPARE(finalInsertSpy.count(), insertIntervals.count());
for (int i = 0; i < finalInsertSpy.count(); ++i) {
QList<QVariant> args = finalInsertSpy.at(i);
@@ -3314,7 +3311,7 @@ void tst_QSortFilterProxyModel::filteredColumns()
FilteredColumnProxyModel *proxy = new FilteredColumnProxyModel(this);
proxy->setSourceModel(model);
- new ModelTest(proxy, this);
+ new QAbstractItemModelTester(proxy, this);
ModelInsertCommand *insertCommand = new ModelInsertCommand(model, this);
insertCommand->setNumCols(2);
@@ -3353,7 +3350,7 @@ void tst_QSortFilterProxyModel::headerDataChanged()
QSortFilterProxyModel *proxy = new QSortFilterProxyModel(this);
proxy->setSourceModel(model);
- new ModelTest(proxy, this);
+ new QAbstractItemModelTester(proxy, this);
model->emitHeaderDataChanged();
}
@@ -4072,11 +4069,11 @@ public:
}
bool canDropMimeData(const QMimeData *, Qt::DropAction,
- int row, int /* column */, const QModelIndex & /* parent */) const Q_DECL_OVERRIDE
+ int row, int /* column */, const QModelIndex & /* parent */) const override
{ return row == 1; }
bool dropMimeData(const QMimeData *, Qt::DropAction,
- int row, int /* column */, const QModelIndex & /* parent */) Q_DECL_OVERRIDE
+ int row, int /* column */, const QModelIndex & /* parent */) override
{ return row == 1; }
};
@@ -4131,7 +4128,7 @@ void tst_QSortFilterProxyModel::resortingDoesNotBreakTreeModels()
proxy.sort(0);
proxy.setSourceModel(treeModel);
- ModelTest modelTest(&proxy);
+ QAbstractItemModelTester modelTester(&proxy);
QCOMPARE(proxy.rowCount(), 2);
e1->setText("entry1");
@@ -4230,6 +4227,10 @@ public:
QModelIndex index(int, int, const QModelIndex& parent = QModelIndex()) const override
{
+ // QTBUG-44962: Would we always expect the parent to belong to the model
+ qDebug() << parent.model() << this;
+ Q_ASSERT(!parent.isValid() || parent.model() == this);
+
quintptr parentId = (parent.isValid()) ? parent.internalId() : 0;
if (parentId >= m_depth)
return QModelIndex();
@@ -4510,5 +4511,21 @@ void tst_QSortFilterProxyModel::dynamicFilterWithoutSort()
QCOMPARE(resetSpy.count(), 1);
}
+void tst_QSortFilterProxyModel::checkSetNewModel()
+{
+ QTreeView tv;
+ StepTreeModel model1;
+ model1.setDepth(4);
+ StepTreeModel model2;
+ model2.setDepth(4);
+
+ QSortFilterProxyModel proxy;
+ proxy.setSourceModel(&model1);
+ tv.setModel(&proxy);
+ tv.show();
+ tv.expandAll(); // create persistent indexes
+ proxy.setSourceModel(&model2);
+}
+
QTEST_MAIN(tst_QSortFilterProxyModel)
#include "tst_qsortfilterproxymodel.moc"
diff --git a/tests/auto/corelib/itemmodels/qsortfilterproxymodel_recursive/tst_qsortfilterproxymodel_recursive.cpp b/tests/auto/corelib/itemmodels/qsortfilterproxymodel_recursive/tst_qsortfilterproxymodel_recursive.cpp
index 852d9adb46..7cae554963 100644
--- a/tests/auto/corelib/itemmodels/qsortfilterproxymodel_recursive/tst_qsortfilterproxymodel_recursive.cpp
+++ b/tests/auto/corelib/itemmodels/qsortfilterproxymodel_recursive/tst_qsortfilterproxymodel_recursive.cpp
@@ -34,6 +34,8 @@
Q_DECLARE_METATYPE(QModelIndex)
+static const int s_filterRole = Qt::UserRole + 1;
+
class ModelSignalSpy : public QObject {
Q_OBJECT
public:
@@ -67,7 +69,7 @@ private Q_SLOTS:
mSignals << QStringLiteral("rowsMoved");
}
void onDataChanged(const QModelIndex &from, const QModelIndex& ) {
- mSignals << QStringLiteral("dataChanged(%1)").arg(from.data().toString());
+ mSignals << QStringLiteral("dataChanged(%1)").arg(from.data(Qt::DisplayRole).toString());
}
void onLayoutChanged() {
mSignals << QStringLiteral("layoutChanged");
@@ -78,7 +80,7 @@ private Q_SLOTS:
private:
QString textForRowSpy(const QModelIndex &parent, int start, int end)
{
- QString txt = parent.data().toString();
+ QString txt = parent.data(Qt::DisplayRole).toString();
if (!txt.isEmpty())
txt += QLatin1Char('.');
txt += QString::number(start+1);
@@ -95,13 +97,14 @@ public:
TestModel(QAbstractItemModel *sourceModel)
: QSortFilterProxyModel()
{
+ setFilterRole(s_filterRole);
setRecursiveFilteringEnabled(true);
setSourceModel(sourceModel);
}
virtual bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const override
{
- return sourceModel()->index(sourceRow, 0, sourceParent).data(Qt::UserRole +1).toBool()
+ return sourceModel()->index(sourceRow, 0, sourceParent).data(s_filterRole).toBool()
&& QSortFilterProxyModel::filterAcceptsRow(sourceRow, sourceParent);
}
};
@@ -114,7 +117,7 @@ public:
// - - E
// as a single string, englobing children in brackets, like this:
// [A[B[C D] E]]
-// In addition, items that match the filtering (data(UserRole+1) == true) have a * after their value.
+// In addition, items that match the filtering (data(s_filterRole) == true) have a * after their value.
static QString treeAsString(const QAbstractItemModel &model, const QModelIndex &parent = QModelIndex())
{
QString ret;
@@ -126,8 +129,8 @@ static QString treeAsString(const QAbstractItemModel &model, const QModelIndex &
ret += ' ';
}
const QModelIndex child = model.index(row, 0, parent);
- ret += child.data().toString();
- if (child.data(Qt::UserRole+1).toBool())
+ ret += child.data(Qt::DisplayRole).toString();
+ if (child.data(s_filterRole).toBool())
ret += QLatin1Char('*');
ret += treeAsString(model, child);
}
@@ -146,7 +149,7 @@ static void fillModel(QStandardItemModel &model, const QString &str)
const QChar ch = str.at(i);
if ((ch == '[' || ch == ']' || ch == ' ') && !data.isEmpty()) {
if (data.endsWith('*')) {
- item->setData(true, Qt::UserRole + 1);
+ item->setData(true, s_filterRole);
data.chop(1);
}
item->setText(data);
@@ -231,10 +234,10 @@ private Q_SLOTS:
QCOMPARE(treeAsString(proxy), QStringLiteral("[1[1.1[ME*]]]"));
+ // filterRole is Qt::UserRole + 1, so parents are not checked and
+ // therefore no dataChanged for parents
QCOMPARE(spy.mSignals, QStringList()
- << QStringLiteral("dataChanged(ME)")
- << QStringLiteral("dataChanged(1.1)")
- << QStringLiteral("dataChanged(1)"));
+ << QStringLiteral("dataChanged(ME)"));
}
// Test changing a role that is unrelated to the filtering, in a hidden item.
@@ -319,8 +322,8 @@ private Q_SLOTS:
ModelSignalSpy spy(proxy);
// When changing the data on the designated item to show this row
QStandardItem *itemToChange = itemByText(model, add);
- QVERIFY(!itemToChange->data().toBool());
- itemToChange->setData(true);
+ QVERIFY(!itemToChange->data(s_filterRole).toBool());
+ itemToChange->setData(true, s_filterRole);
// The proxy should update as expected
QCOMPARE(treeAsString(proxy), expectedProxyStr);
@@ -408,8 +411,8 @@ private Q_SLOTS:
// When changing the data on the designated item to exclude this row again
QStandardItem *itemToChange = itemByText(model, remove);
- QVERIFY(itemToChange->data().toBool());
- itemToChange->setData(false);
+ QVERIFY(itemToChange->data(s_filterRole).toBool());
+ itemToChange->setData(false, s_filterRole);
// The proxy should update as expected
QCOMPARE(treeAsString(proxy), expectedProxyStr);
@@ -431,7 +434,7 @@ private Q_SLOTS:
ModelSignalSpy spy(proxy);
QStandardItem *item_1_1_1 = model.item(0)->child(0)->child(0);
QStandardItem *item_1_1_1_1 = new QStandardItem(QStringLiteral("1.1.1.1"));
- item_1_1_1_1->setData(true);
+ item_1_1_1_1->setData(true, s_filterRole);
item_1_1_1->appendRow(item_1_1_1_1);
QCOMPARE(treeAsString(proxy), QStringLiteral("[1[1.1[1.1.1[1.1.1.1*]]]]"));
@@ -456,7 +459,7 @@ private Q_SLOTS:
ModelSignalSpy spy(proxy);
{
QStandardItem *item_1_1_1_1 = new QStandardItem(QStringLiteral("1.1.1.1"));
- item_1_1_1_1->setData(true);
+ item_1_1_1_1->setData(true, s_filterRole);
QStandardItem *item_1_1_1 = model.item(0)->child(0)->child(0);
item_1_1_1->appendRow(item_1_1_1_1);
}
@@ -484,7 +487,7 @@ private Q_SLOTS:
{
QStandardItem *item_1_1_1 = new QStandardItem(QStringLiteral("1.1.1"));
QStandardItem *item_1_1_1_1 = new QStandardItem(QStringLiteral("1.1.1.1"));
- item_1_1_1_1->setData(true);
+ item_1_1_1_1->setData(true, s_filterRole);
item_1_1_1->appendRow(item_1_1_1_1);
QStandardItem *item_1_1 = model.item(0)->child(0);
@@ -511,7 +514,7 @@ private Q_SLOTS:
{
QStandardItem *item_1_1_2 = new QStandardItem(QStringLiteral("1.1.2"));
QStandardItem *item_1_1_2_1 = new QStandardItem(QStringLiteral("1.1.2.1"));
- item_1_1_2_1->setData(true);
+ item_1_1_2_1->setData(true, s_filterRole);
item_1_1_2->appendRow(item_1_1_2_1);
QStandardItem *item_1_1 = model.item(0)->child(0);
@@ -706,6 +709,7 @@ private Q_SLOTS:
ModelSignalSpy spy(proxy);
//qDebug() << "setFilterFixedString";
+ proxy.setFilterRole(Qt::DisplayRole);
proxy.setFilterFixedString(filter);
QCOMPARE(treeAsString(proxy), expectedProxyStr);
diff --git a/tests/auto/corelib/itemmodels/qstringlistmodel/tst_qstringlistmodel.cpp b/tests/auto/corelib/itemmodels/qstringlistmodel/tst_qstringlistmodel.cpp
index adc8c59bf7..9a54c0a70d 100644
--- a/tests/auto/corelib/itemmodels/qstringlistmodel/tst_qstringlistmodel.cpp
+++ b/tests/auto/corelib/itemmodels/qstringlistmodel/tst_qstringlistmodel.cpp
@@ -112,12 +112,6 @@ void tst_QStringListModel::rowsAboutToBeRemoved_rowsRemoved_data()
QStringList res3;
QTest::newRow( "data3" ) << strings3 << 0 << 5 << aboutto3 << res3;
- /* Not sure if this is a valid test */
- QStringList strings4; strings4 << "One" << "Two" << "Three" << "Four" << "Five";
- QStringList aboutto4; aboutto4 << "Five" << "";
- QStringList res4; res4 << "One" << "Two" << "Three" << "Four";
- QTest::newRow( "data4" ) << strings4 << 4 << 2 << aboutto4 << res4;
-
/*
* Keep this, template to add more data
QStringList strings2; strings2 << "One" << "Two" << "Three" << "Four" << "Five";