From e82a1d6b2998b30fc100c4ebf9b98ee18dd3c374 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Fri, 16 Aug 2019 11:30:58 +0200 Subject: Deprecate QDirModel Deprecate the constructors, add guards. Use a QStandardItemModel in tst_QCompleter::setters() instead. Task-number: QTBUG-69410 Change-Id: If77298982bb3d0b5321ae1271fab3f33b196101d Reviewed-by: Qt CI Bot Reviewed-by: Richard Moe Gustavsen --- .../corelib/itemmodels/qitemmodel/modelstotest.cpp | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'tests/auto/corelib') diff --git a/tests/auto/corelib/itemmodels/qitemmodel/modelstotest.cpp b/tests/auto/corelib/itemmodels/qitemmodel/modelstotest.cpp index 354190e754..d61d45bc52 100644 --- a/tests/auto/corelib/itemmodels/qitemmodel/modelstotest.cpp +++ b/tests/auto/corelib/itemmodels/qitemmodel/modelstotest.cpp @@ -90,7 +90,9 @@ ModelsToTest::ModelsToTest() { setupDatabase(); +#if QT_CONFIG(dirmodel) && QT_DEPRECATED_SINCE(5, 15) tests.append(test("QDirModel", ReadOnly, HasData)); +#endif tests.append(test("QStringListModel", ReadWrite, HasData)); tests.append(test("QStringListModelEmpty", ReadWrite, Empty)); @@ -165,11 +167,16 @@ QAbstractItemModel *ModelsToTest::createModel(const QString &modelType) return model; } +#if QT_CONFIG(dirmodel) && QT_DEPRECATED_SINCE(5, 15) +QT_WARNING_PUSH +QT_WARNING_DISABLE_DEPRECATED if (modelType == "QDirModel") { QDirModel *model = new QDirModel(); model->setReadOnly(false); return model; } +QT_WARNING_POP +#endif if (modelType == "QSqlQueryModel") { QSqlQueryModel *model = new QSqlQueryModel(); @@ -287,6 +294,7 @@ QModelIndex ModelsToTest::populateTestArea(QAbstractItemModel *model) return returnIndex; } +#if QT_CONFIG(dirmodel) && QT_DEPRECATED_SINCE(5, 15) if (QDirModel *dirModel = qobject_cast(model)) { m_dirModelTempDir.reset(new QTemporaryDir); if (!m_dirModelTempDir->isValid()) @@ -303,6 +311,7 @@ QModelIndex ModelsToTest::populateTestArea(QAbstractItemModel *model) } return dirModel->index(tempDir.path()); } +#endif // QT_CONFIG(dirmodel) && QT_DEPRECATED_SINCE(5, 15) if (QSqlQueryModel *queryModel = qobject_cast(model)) { QSqlQuery q; @@ -359,11 +368,12 @@ QModelIndex ModelsToTest::populateTestArea(QAbstractItemModel *model) */ void ModelsToTest::cleanupTestArea(QAbstractItemModel *model) { - if (qobject_cast(model)) { - m_dirModelTempDir.reset(); - } else if (qobject_cast(model)) { + if (qobject_cast(model)) QSqlQuery q("DROP TABLE test"); - } +#if QT_CONFIG(dirmodel) && QT_DEPRECATED_SINCE(5, 15) + if (qobject_cast(model)) + m_dirModelTempDir.reset(); +#endif } void ModelsToTest::setupDatabase() -- cgit v1.2.3