From 2fb9705521bc2879dc89b54c1488d6a20a310d85 Mon Sep 17 00:00:00 2001 From: Stephan Binner Date: Wed, 31 May 2017 23:08:35 +0200 Subject: Convert features.filesystemmodel to QT_[REQUIRE_]CONFIG Change-Id: I862510387e79d04221ec075f3e79896908ee9d8f Reviewed-by: Oswald Buddenhagen --- src/printsupport/dialogs/qprintdialog_unix.cpp | 4 +++- src/widgets/dialogs/dialogs.pri | 20 +++++++++++++------- src/widgets/dialogs/qfileinfogatherer.cpp | 4 ---- src/widgets/dialogs/qfileinfogatherer_p.h | 7 ++----- src/widgets/dialogs/qfilesystemmodel.cpp | 4 ---- src/widgets/dialogs/qfilesystemmodel.h | 8 ++------ src/widgets/dialogs/qfilesystemmodel_p.h | 6 ++---- src/widgets/util/qcompleter.cpp | 18 ++++++++++-------- .../auto/widgets/util/qcompleter/tst_qcompleter.cpp | 4 ++-- 9 files changed, 34 insertions(+), 41 deletions(-) diff --git a/src/printsupport/dialogs/qprintdialog_unix.cpp b/src/printsupport/dialogs/qprintdialog_unix.cpp index e215e6cb9c..51c8a593a1 100644 --- a/src/printsupport/dialogs/qprintdialog_unix.cpp +++ b/src/printsupport/dialogs/qprintdialog_unix.cpp @@ -50,7 +50,9 @@ #endif #include #include +#if QT_CONFIG(filesystemmodel) #include +#endif #include #include @@ -677,7 +679,7 @@ QUnixPrintWidgetPrivate::QUnixPrintWidgetPrivate(QUnixPrintWidget *p, QPrinter * } widget.properties->setEnabled(true); -#if !defined(QT_NO_FILESYSTEMMODEL) && !defined(QT_NO_COMPLETER) +#if QT_CONFIG(filesystemmodel) && !defined(QT_NO_COMPLETER) QFileSystemModel *fsm = new QFileSystemModel(widget.filename); fsm->setRootPath(QDir::homePath()); widget.filename->setCompleter(new QCompleter(fsm, widget.filename)); diff --git a/src/widgets/dialogs/dialogs.pri b/src/widgets/dialogs/dialogs.pri index f072576acc..c2625ec1f4 100644 --- a/src/widgets/dialogs/dialogs.pri +++ b/src/widgets/dialogs/dialogs.pri @@ -2,16 +2,11 @@ HEADERS += \ dialogs/qfontdialog.h \ - dialogs/qfontdialog_p.h \ - dialogs/qfilesystemmodel.h \ - dialogs/qfilesystemmodel_p.h \ - dialogs/qfileinfogatherer_p.h + dialogs/qfontdialog_p.h INCLUDEPATH += $$PWD SOURCES += \ - dialogs/qfontdialog.cpp \ - dialogs/qfilesystemmodel.cpp \ - dialogs/qfileinfogatherer.cpp + dialogs/qfontdialog.cpp qtConfig(colordialog) { HEADERS += dialogs/qcolordialog.h @@ -45,6 +40,17 @@ qtConfig(filedialog) { FORMS += dialogs/qfiledialog.ui } +qtConfig(filesystemmodel) { + HEADERS += \ + dialogs/qfilesystemmodel.h \ + dialogs/qfilesystemmodel_p.h \ + dialogs/qfileinfogatherer_p.h + + SOURCES += \ + dialogs/qfilesystemmodel.cpp \ + dialogs/qfileinfogatherer.cpp +} + qtConfig(fscompleter) { HEADERS += dialogs/qfscompleter_p.h } diff --git a/src/widgets/dialogs/qfileinfogatherer.cpp b/src/widgets/dialogs/qfileinfogatherer.cpp index 08c5a40c7c..9f2d15d31b 100644 --- a/src/widgets/dialogs/qfileinfogatherer.cpp +++ b/src/widgets/dialogs/qfileinfogatherer.cpp @@ -50,8 +50,6 @@ QT_BEGIN_NAMESPACE -#ifndef QT_NO_FILESYSTEMMODEL - #ifdef QT_BUILD_INTERNAL static QBasicAtomicInt fetchedRoot = Q_BASIC_ATOMIC_INITIALIZER(false); Q_AUTOTEST_EXPORT void qt_test_resetFetchedRoot() @@ -366,8 +364,6 @@ void QFileInfoGatherer::fetch(const QFileInfo &fileInfo, QElapsedTimer &base, bo } } -#endif // QT_NO_FILESYSTEMMODEL - QT_END_NAMESPACE #include "moc_qfileinfogatherer_p.cpp" diff --git a/src/widgets/dialogs/qfileinfogatherer_p.h b/src/widgets/dialogs/qfileinfogatherer_p.h index 0018b6c387..52578126de 100644 --- a/src/widgets/dialogs/qfileinfogatherer_p.h +++ b/src/widgets/dialogs/qfileinfogatherer_p.h @@ -66,6 +66,8 @@ #include +QT_REQUIRE_CONFIG(filesystemmodel); + QT_BEGIN_NAMESPACE class QExtendedInformation { @@ -150,8 +152,6 @@ private : class QFileIconProvider; -#ifndef QT_NO_FILESYSTEMMODEL - class Q_AUTOTEST_EXPORT QFileInfoGatherer : public QThread { Q_OBJECT @@ -208,9 +208,6 @@ private: QFileIconProvider *m_iconProvider; // not accessed by run() QFileIconProvider defaultProvider; }; -#endif // QT_NO_FILESYSTEMMODEL - QT_END_NAMESPACE #endif // QFILEINFOGATHERER_H - diff --git a/src/widgets/dialogs/qfilesystemmodel.cpp b/src/widgets/dialogs/qfilesystemmodel.cpp index 0ada9c6c58..63b5cf7aaf 100644 --- a/src/widgets/dialogs/qfilesystemmodel.cpp +++ b/src/widgets/dialogs/qfilesystemmodel.cpp @@ -58,8 +58,6 @@ QT_BEGIN_NAMESPACE -#ifndef QT_NO_FILESYSTEMMODEL - /*! \enum QFileSystemModel::Roles \value FileIconRole @@ -1995,5 +1993,3 @@ bool QFileSystemModelPrivate::passNameFilters(const QFileSystemNode *node) const QT_END_NAMESPACE #include "moc_qfilesystemmodel.cpp" - -#endif // QT_NO_FILESYSTEMMODEL diff --git a/src/widgets/dialogs/qfilesystemmodel.h b/src/widgets/dialogs/qfilesystemmodel.h index 7d790124c8..a5f23c9220 100644 --- a/src/widgets/dialogs/qfilesystemmodel.h +++ b/src/widgets/dialogs/qfilesystemmodel.h @@ -47,10 +47,9 @@ #include #include -QT_BEGIN_NAMESPACE - +QT_REQUIRE_CONFIG(filesystemmodel); -#ifndef QT_NO_FILESYSTEMMODEL +QT_BEGIN_NAMESPACE class ExtendedInformation; class QFileSystemModelPrivate; @@ -166,9 +165,6 @@ inline QString QFileSystemModel::fileName(const QModelIndex &aindex) const inline QIcon QFileSystemModel::fileIcon(const QModelIndex &aindex) const { return qvariant_cast(aindex.data(Qt::DecorationRole)); } -#endif // QT_NO_FILESYSTEMMODEL - QT_END_NAMESPACE #endif // QFILESYSTEMMODEL_H - diff --git a/src/widgets/dialogs/qfilesystemmodel_p.h b/src/widgets/dialogs/qfilesystemmodel_p.h index e7149a3097..640225529b 100644 --- a/src/widgets/dialogs/qfilesystemmodel_p.h +++ b/src/widgets/dialogs/qfilesystemmodel_p.h @@ -54,8 +54,6 @@ #include #include "qfilesystemmodel.h" -#ifndef QT_NO_FILESYSTEMMODEL - #include #include #include "qfileinfogatherer_p.h" @@ -66,6 +64,8 @@ #include #include +QT_REQUIRE_CONFIG(filesystemmodel); + QT_BEGIN_NAMESPACE class ExtendedInformation; @@ -313,9 +313,7 @@ public: }; Q_DECLARE_TYPEINFO(QFileSystemModelPrivate::Fetching, Q_MOVABLE_TYPE); -#endif // QT_NO_FILESYSTEMMODEL QT_END_NAMESPACE #endif - diff --git a/src/widgets/util/qcompleter.cpp b/src/widgets/util/qcompleter.cpp index 5a31eb4e52..c412c4cbd5 100644 --- a/src/widgets/util/qcompleter.cpp +++ b/src/widgets/util/qcompleter.cpp @@ -148,7 +148,9 @@ #include "QtWidgets/qscrollbar.h" #include "QtCore/qstringlistmodel.h" #include "QtWidgets/qdirmodel.h" +#if QT_CONFIG(filesystemmodel) #include "QtWidgets/qfilesystemmodel.h" +#endif #include "QtWidgets/qheaderview.h" #include "QtWidgets/qlistview.h" #include "QtWidgets/qapplication.h" @@ -467,7 +469,7 @@ QMatchData QCompletionEngine::filterHistory() const bool isDirModel = false; #endif Q_UNUSED(isDirModel) -#ifndef QT_NO_FILESYSTEMMODEL +#if QT_CONFIG(filesystemmodel) const bool isFsModel = (qobject_cast(source) != 0); #else const bool isFsModel = false; @@ -872,7 +874,7 @@ void QCompleterPrivate::_q_complete(QModelIndex index, bool highlighted) completion += QDir::separator(); } #endif -#ifndef QT_NO_FILESYSTEMMODEL +#if QT_CONFIG(filesystemmodel) // add a trailing separator in inline if (mode == QCompleter::InlineCompletion) { if (qobject_cast(proxy->sourceModel()) && QFileInfo(completion).isDir()) @@ -1044,7 +1046,7 @@ void QCompleter::setModel(QAbstractItemModel *model) { Q_D(QCompleter); QAbstractItemModel *oldModel = d->proxy->sourceModel(); -#ifndef QT_NO_FILESYSTEMMODEL +#if QT_CONFIG(filesystemmodel) if (qobject_cast(oldModel)) setCompletionRole(Qt::EditRole); // QTBUG-54642, clear FileNameRole set by QFileSystemModel #endif @@ -1062,7 +1064,7 @@ void QCompleter::setModel(QAbstractItemModel *model) #endif } #endif // QT_NO_DIRMODEL -#ifndef QT_NO_FILESYSTEMMODEL +#if QT_CONFIG(filesystemmodel) QFileSystemModel *fsModel = qobject_cast(model); if (fsModel) { #if defined(Q_OS_WIN) @@ -1073,7 +1075,7 @@ void QCompleter::setModel(QAbstractItemModel *model) setCompletionRole(QFileSystemModel::FileNameRole); connect(fsModel, SIGNAL(directoryLoaded(QString)), this, SLOT(_q_fileSystemModelDirectoryLoaded(QString))); } -#endif // QT_NO_FILESYSTEMMODEL +#endif // QT_CONFIG(filesystemmodel) } /*! @@ -1770,7 +1772,7 @@ QString QCompleter::pathFromIndex(const QModelIndex& index) const #ifndef QT_NO_DIRMODEL isDirModel = qobject_cast(d->proxy->sourceModel()) != 0; #endif -#ifndef QT_NO_FILESYSTEMMODEL +#if QT_CONFIG(filesystemmodel) isFsModel = qobject_cast(d->proxy->sourceModel()) != 0; #endif if (!isDirModel && !isFsModel) @@ -1782,7 +1784,7 @@ QString QCompleter::pathFromIndex(const QModelIndex& index) const QString t; if (isDirModel) t = sourceModel->data(idx, Qt::EditRole).toString(); -#ifndef QT_NO_FILESYSTEMMODEL +#if QT_CONFIG(filesystemmodel) else t = sourceModel->data(idx, QFileSystemModel::FileNameRole).toString(); #endif @@ -1820,7 +1822,7 @@ QStringList QCompleter::splitPath(const QString& path) const Q_D(const QCompleter); isDirModel = qobject_cast(d->proxy->sourceModel()) != 0; #endif -#ifndef QT_NO_FILESYSTEMMODEL +#if QT_CONFIG(filesystemmodel) #ifdef QT_NO_DIRMODEL Q_D(const QCompleter); #endif diff --git a/tests/auto/widgets/util/qcompleter/tst_qcompleter.cpp b/tests/auto/widgets/util/qcompleter/tst_qcompleter.cpp index 937be944a1..f8095badb8 100644 --- a/tests/auto/widgets/util/qcompleter/tst_qcompleter.cpp +++ b/tests/auto/widgets/util/qcompleter/tst_qcompleter.cpp @@ -348,7 +348,7 @@ void tst_QCompleter::getSetCheck() completer.setWrapAround(false); QCOMPARE(completer.wrapAround(), false); -#ifndef QT_NO_FILESYSTEMMODEL +#if QT_CONFIG(filesystemmodel) // QTBUG-54642, changing from QFileSystemModel to another model should restore role. completer.setCompletionRole(Qt::EditRole); QCOMPARE(completer.completionRole(), static_cast(Qt::EditRole)); // default value @@ -361,7 +361,7 @@ void tst_QCompleter::getSetCheck() QStandardItemModel standardItemModel2(2, 2); // Do not clobber a custom role when changing models completer.setModel(&standardItemModel2); QCOMPARE(completer.completionRole(), static_cast(Qt::ToolTipRole)); -#endif // QT_NO_FILESYSTEMMODEL +#endif // QT_CONFIG(filesystemmodel) } void tst_QCompleter::csMatchingOnCsSortedModel_data() -- cgit v1.2.3