summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/itemmodels
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@qt.io>2020-04-02 14:21:50 +0200
committerLars Knoll <lars.knoll@qt.io>2020-04-15 14:38:40 +0200
commiteb349930eee1ca8f31415dd2269a70d3dfd76257 (patch)
tree6f26a330928139086f80d1e84dcba292d901ac5a /tests/auto/corelib/itemmodels
parent48794f5057f49373a7b8803db8bab7131e04575c (diff)
Remove QRegExp support from QSortFilterProxyModel
Map setFilterWildcard() and setFilterFixedString() to now use QRegularExpression. Change-Id: I2dff2015234decb2badfd306975dcff8553cdd7f Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
Diffstat (limited to 'tests/auto/corelib/itemmodels')
-rw-r--r--tests/auto/corelib/itemmodels/CMakeLists.txt1
-rw-r--r--tests/auto/corelib/itemmodels/itemmodels.pro1
-rw-r--r--tests/auto/corelib/itemmodels/qsortfilterproxymodel_common/tst_qsortfilterproxymodel.cpp44
-rw-r--r--tests/auto/corelib/itemmodels/qsortfilterproxymodel_regexp/.gitignore1
-rw-r--r--tests/auto/corelib/itemmodels/qsortfilterproxymodel_regexp/CMakeLists.txt18
-rw-r--r--tests/auto/corelib/itemmodels/qsortfilterproxymodel_regexp/qsortfilterproxymodel_regexp.pro16
-rw-r--r--tests/auto/corelib/itemmodels/qsortfilterproxymodel_regexp/tst_qsortfilterproxymodel_regexp.cpp69
-rw-r--r--tests/auto/corelib/itemmodels/qsortfilterproxymodel_regularexpression/tst_qsortfilterproxymodel_regularexpression.cpp3
8 files changed, 8 insertions, 145 deletions
diff --git a/tests/auto/corelib/itemmodels/CMakeLists.txt b/tests/auto/corelib/itemmodels/CMakeLists.txt
index 6f52ed2600..530a54c91e 100644
--- a/tests/auto/corelib/itemmodels/CMakeLists.txt
+++ b/tests/auto/corelib/itemmodels/CMakeLists.txt
@@ -11,7 +11,6 @@ if(TARGET Qt::Gui)
add_subdirectory(qtransposeproxymodel)
endif()
if(TARGET Qt::Widgets)
- add_subdirectory(qsortfilterproxymodel_regexp)
add_subdirectory(qsortfilterproxymodel_regularexpression)
endif()
if(TARGET Qt::Sql AND TARGET Qt::Widgets)
diff --git a/tests/auto/corelib/itemmodels/itemmodels.pro b/tests/auto/corelib/itemmodels/itemmodels.pro
index ffbda6ec40..d0b9bb1fc3 100644
--- a/tests/auto/corelib/itemmodels/itemmodels.pro
+++ b/tests/auto/corelib/itemmodels/itemmodels.pro
@@ -13,7 +13,6 @@ qtHaveModule(gui): SUBDIRS += \
qtHaveModule(widgets) {
SUBDIRS += \
- qsortfilterproxymodel_regexp \
qsortfilterproxymodel_regularexpression
qtHaveModule(sql): SUBDIRS += \
diff --git a/tests/auto/corelib/itemmodels/qsortfilterproxymodel_common/tst_qsortfilterproxymodel.cpp b/tests/auto/corelib/itemmodels/qsortfilterproxymodel_common/tst_qsortfilterproxymodel.cpp
index 6f032d2696..2d8813050b 100644
--- a/tests/auto/corelib/itemmodels/qsortfilterproxymodel_common/tst_qsortfilterproxymodel.cpp
+++ b/tests/auto/corelib/itemmodels/qsortfilterproxymodel_common/tst_qsortfilterproxymodel.cpp
@@ -78,15 +78,7 @@ void tst_QSortFilterProxyModel::cleanupTestCase()
void tst_QSortFilterProxyModel::cleanup()
{
- switch (m_filterType) {
- case FilterType::RegExp:
- m_proxy->setFilterRegExp(QRegExp());
- break;
- case FilterType::RegularExpression:
- m_proxy->setFilterRegularExpression(QRegularExpression());
- break;
- }
-
+ m_proxy->setFilterRegularExpression(QRegularExpression());
m_proxy->sort(-1, Qt::AscendingOrder);
m_model->clear();
m_model->insertColumns(0, 1);
@@ -553,7 +545,7 @@ void tst_QSortFilterProxyModel::appendRowFromCombobox()
QSortFilterProxyModel proxy;
proxy.setSourceModel(&model);
- proxy.setFilterRegExp(pattern);
+ proxy.setFilterRegularExpression(pattern);
QComboBox comboBox;
comboBox.setModel(&proxy);
@@ -873,29 +865,16 @@ class MyFilteredColumnProxyModel : public QSortFilterProxyModel
{
Q_OBJECT
public:
- MyFilteredColumnProxyModel(FilterType filterType, QObject *parent = nullptr) :
- QSortFilterProxyModel(parent),
- m_filterType(filterType)
+ MyFilteredColumnProxyModel(QObject *parent = nullptr) :
+ QSortFilterProxyModel(parent)
{ }
protected:
bool filterAcceptsColumn(int sourceColumn, const QModelIndex &) const override
{
QString key = sourceModel()->headerData(sourceColumn, Qt::Horizontal).toString();
- bool result = false;
- switch (m_filterType) {
- case FilterType::RegExp:
- result = key.contains(filterRegExp());
- break;
- case FilterType::RegularExpression:
- result = key.contains(filterRegularExpression());
- break;
- }
- return result;
+ return key.contains(filterRegularExpression());
}
-
-private:
- FilterType m_filterType;
};
void tst_QSortFilterProxyModel::removeColumns_data()
@@ -1104,7 +1083,7 @@ void tst_QSortFilterProxyModel::removeColumns()
QFETCH(QStringList, expectedSource);
QStandardItemModel model;
- MyFilteredColumnProxyModel proxy(m_filterType);
+ MyFilteredColumnProxyModel proxy;
proxy.setSourceModel(&model);
if (!filter.isEmpty())
setupFilter(&proxy, filter);
@@ -1358,14 +1337,7 @@ void tst_QSortFilterProxyModel::checkHierarchy(const QStringList &l, const QAbst
void tst_QSortFilterProxyModel::setupFilter(QSortFilterProxyModel *model, const QString& pattern)
{
- switch (m_filterType) {
- case FilterType::RegExp:
- model->setFilterRegExp(pattern);
- break;
- case FilterType::RegularExpression:
- model->setFilterRegularExpression(pattern);
- break;
- }
+ model->setFilterRegularExpression(pattern);
}
class TestModel: public QAbstractTableModel
@@ -4928,7 +4900,7 @@ void tst_QSortFilterProxyModel::filterAndInsertRow()
model.setStringList(initialModelList);
proxyModel.setSourceModel(&model);
proxyModel.setDynamicSortFilter(true);
- proxyModel.setFilterRegExp(filterRegExp);
+ proxyModel.setFilterRegularExpression(filterRegExp);
QVERIFY(proxyModel.insertRow(row));
QCOMPARE(model.stringList(), expectedModelList);
diff --git a/tests/auto/corelib/itemmodels/qsortfilterproxymodel_regexp/.gitignore b/tests/auto/corelib/itemmodels/qsortfilterproxymodel_regexp/.gitignore
deleted file mode 100644
index 4fdaebc09d..0000000000
--- a/tests/auto/corelib/itemmodels/qsortfilterproxymodel_regexp/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-tst_qsortfilterproxymodel_regexp
diff --git a/tests/auto/corelib/itemmodels/qsortfilterproxymodel_regexp/CMakeLists.txt b/tests/auto/corelib/itemmodels/qsortfilterproxymodel_regexp/CMakeLists.txt
deleted file mode 100644
index 8df14a96b1..0000000000
--- a/tests/auto/corelib/itemmodels/qsortfilterproxymodel_regexp/CMakeLists.txt
+++ /dev/null
@@ -1,18 +0,0 @@
-# Generated from qsortfilterproxymodel_regexp.pro.
-
-#####################################################################
-## tst_qsortfilterproxymodel_regexp Test:
-#####################################################################
-
-add_qt_test(tst_qsortfilterproxymodel_regexp
- SOURCES
- ../../../other/qabstractitemmodelutils/dynamictreemodel.cpp ../../../other/qabstractitemmodelutils/dynamictreemodel.h
- ../qsortfilterproxymodel_common/tst_qsortfilterproxymodel.cpp ../qsortfilterproxymodel_common/tst_qsortfilterproxymodel.h
- tst_qsortfilterproxymodel_regexp.cpp
- INCLUDE_DIRECTORIES
- ../../../other/qabstractitemmodelutils
- ../qsortfilterproxymodel_common
- PUBLIC_LIBRARIES
- Qt::Gui
- Qt::Widgets
-)
diff --git a/tests/auto/corelib/itemmodels/qsortfilterproxymodel_regexp/qsortfilterproxymodel_regexp.pro b/tests/auto/corelib/itemmodels/qsortfilterproxymodel_regexp/qsortfilterproxymodel_regexp.pro
deleted file mode 100644
index 7c510930f4..0000000000
--- a/tests/auto/corelib/itemmodels/qsortfilterproxymodel_regexp/qsortfilterproxymodel_regexp.pro
+++ /dev/null
@@ -1,16 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qsortfilterproxymodel_regexp
-
-QT += widgets testlib
-mtdir = ../../../other/qabstractitemmodelutils
-qsfpmdir = ../qsortfilterproxymodel_common
-
-INCLUDEPATH += $$PWD/$${mtdir} $$PWD/$${qsfpmdir}
-SOURCES += \
- tst_qsortfilterproxymodel_regexp.cpp \
- $${qsfpmdir}/tst_qsortfilterproxymodel.cpp \
- $${mtdir}/dynamictreemodel.cpp
-
-HEADERS += \
- $${qsfpmdir}/tst_qsortfilterproxymodel.h \
- $${mtdir}/dynamictreemodel.h
diff --git a/tests/auto/corelib/itemmodels/qsortfilterproxymodel_regexp/tst_qsortfilterproxymodel_regexp.cpp b/tests/auto/corelib/itemmodels/qsortfilterproxymodel_regexp/tst_qsortfilterproxymodel_regexp.cpp
deleted file mode 100644
index 38607f1378..0000000000
--- a/tests/auto/corelib/itemmodels/qsortfilterproxymodel_regexp/tst_qsortfilterproxymodel_regexp.cpp
+++ /dev/null
@@ -1,69 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QtTest/QtTest>
-
-#include "tst_qsortfilterproxymodel.h"
-
-class tst_QSortFilterProxyModelRegExp : public tst_QSortFilterProxyModel
-{
- Q_OBJECT
-public:
- tst_QSortFilterProxyModelRegExp();
-private slots:
- void tst_invalid();
- void tst_caseSensitivity();
-};
-
-tst_QSortFilterProxyModelRegExp::tst_QSortFilterProxyModelRegExp() :
- tst_QSortFilterProxyModel()
-{
- m_filterType = FilterType::RegExp;
-}
-
-void tst_QSortFilterProxyModelRegExp::tst_invalid()
-{
- const QLatin1String pattern("test");
- QSortFilterProxyModel model;
- model.setFilterRegExp(pattern);
- QCOMPARE(model.filterRegExp(), QRegExp(pattern));
- model.setFilterRegularExpression(pattern);
- QCOMPARE(model.filterRegExp(), QRegExp());
-}
-
-void tst_QSortFilterProxyModelRegExp::tst_caseSensitivity()
-{
- const QLatin1String pattern("test");
- QSortFilterProxyModel model;
- model.setFilterCaseSensitivity(Qt::CaseInsensitive);
- model.setFilterRegExp(pattern);
- QCOMPARE(model.filterCaseSensitivity(), Qt::CaseInsensitive);
-}
-
-QTEST_MAIN(tst_QSortFilterProxyModelRegExp)
-#include "tst_qsortfilterproxymodel_regexp.moc"
diff --git a/tests/auto/corelib/itemmodels/qsortfilterproxymodel_regularexpression/tst_qsortfilterproxymodel_regularexpression.cpp b/tests/auto/corelib/itemmodels/qsortfilterproxymodel_regularexpression/tst_qsortfilterproxymodel_regularexpression.cpp
index 821e199bcb..e6f5080cdb 100644
--- a/tests/auto/corelib/itemmodels/qsortfilterproxymodel_regularexpression/tst_qsortfilterproxymodel_regularexpression.cpp
+++ b/tests/auto/corelib/itemmodels/qsortfilterproxymodel_regularexpression/tst_qsortfilterproxymodel_regularexpression.cpp
@@ -42,7 +42,6 @@ private slots:
tst_QSortFilterProxyModelRegularExpression::tst_QSortFilterProxyModelRegularExpression() :
tst_QSortFilterProxyModel()
{
- m_filterType = FilterType::RegularExpression;
}
void tst_QSortFilterProxyModelRegularExpression::tst_invalid()
@@ -51,8 +50,6 @@ void tst_QSortFilterProxyModelRegularExpression::tst_invalid()
QSortFilterProxyModel model;
model.setFilterRegularExpression(pattern);
QCOMPARE(model.filterRegularExpression(), QRegularExpression(pattern));
- model.setFilterRegExp(pattern);
- QCOMPARE(model.filterRegularExpression(), QRegularExpression());
}
QTEST_MAIN(tst_QSortFilterProxyModelRegularExpression)