Convert features.filesystemmodel to QT_[REQUIRE_]CONFIG

Change-Id: I862510387e79d04221ec075f3e79896908ee9d8f
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io>
This commit is contained in:
Stephan Binner 2017-05-31 23:08:35 +02:00
parent 341554e343
commit 2fb9705521
9 changed files with 34 additions and 41 deletions

View File

@ -50,7 +50,9 @@
#endif #endif
#include <QtCore/qdir.h> #include <QtCore/qdir.h>
#include <QtGui/qevent.h> #include <QtGui/qevent.h>
#if QT_CONFIG(filesystemmodel)
#include <QtWidgets/qfilesystemmodel.h> #include <QtWidgets/qfilesystemmodel.h>
#endif
#include <QtWidgets/qstyleditemdelegate.h> #include <QtWidgets/qstyleditemdelegate.h>
#include <QtPrintSupport/qprinter.h> #include <QtPrintSupport/qprinter.h>
@ -677,7 +679,7 @@ QUnixPrintWidgetPrivate::QUnixPrintWidgetPrivate(QUnixPrintWidget *p, QPrinter *
} }
widget.properties->setEnabled(true); 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); QFileSystemModel *fsm = new QFileSystemModel(widget.filename);
fsm->setRootPath(QDir::homePath()); fsm->setRootPath(QDir::homePath());
widget.filename->setCompleter(new QCompleter(fsm, widget.filename)); widget.filename->setCompleter(new QCompleter(fsm, widget.filename));

View File

@ -2,16 +2,11 @@
HEADERS += \ HEADERS += \
dialogs/qfontdialog.h \ dialogs/qfontdialog.h \
dialogs/qfontdialog_p.h \ dialogs/qfontdialog_p.h
dialogs/qfilesystemmodel.h \
dialogs/qfilesystemmodel_p.h \
dialogs/qfileinfogatherer_p.h
INCLUDEPATH += $$PWD INCLUDEPATH += $$PWD
SOURCES += \ SOURCES += \
dialogs/qfontdialog.cpp \ dialogs/qfontdialog.cpp
dialogs/qfilesystemmodel.cpp \
dialogs/qfileinfogatherer.cpp
qtConfig(colordialog) { qtConfig(colordialog) {
HEADERS += dialogs/qcolordialog.h HEADERS += dialogs/qcolordialog.h
@ -45,6 +40,17 @@ qtConfig(filedialog) {
FORMS += dialogs/qfiledialog.ui 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) { qtConfig(fscompleter) {
HEADERS += dialogs/qfscompleter_p.h HEADERS += dialogs/qfscompleter_p.h
} }

View File

@ -50,8 +50,6 @@
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
#ifndef QT_NO_FILESYSTEMMODEL
#ifdef QT_BUILD_INTERNAL #ifdef QT_BUILD_INTERNAL
static QBasicAtomicInt fetchedRoot = Q_BASIC_ATOMIC_INITIALIZER(false); static QBasicAtomicInt fetchedRoot = Q_BASIC_ATOMIC_INITIALIZER(false);
Q_AUTOTEST_EXPORT void qt_test_resetFetchedRoot() 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 QT_END_NAMESPACE
#include "moc_qfileinfogatherer_p.cpp" #include "moc_qfileinfogatherer_p.cpp"

View File

@ -66,6 +66,8 @@
#include <private/qfilesystemengine_p.h> #include <private/qfilesystemengine_p.h>
QT_REQUIRE_CONFIG(filesystemmodel);
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
class QExtendedInformation { class QExtendedInformation {
@ -150,8 +152,6 @@ private :
class QFileIconProvider; class QFileIconProvider;
#ifndef QT_NO_FILESYSTEMMODEL
class Q_AUTOTEST_EXPORT QFileInfoGatherer : public QThread class Q_AUTOTEST_EXPORT QFileInfoGatherer : public QThread
{ {
Q_OBJECT Q_OBJECT
@ -208,9 +208,6 @@ private:
QFileIconProvider *m_iconProvider; // not accessed by run() QFileIconProvider *m_iconProvider; // not accessed by run()
QFileIconProvider defaultProvider; QFileIconProvider defaultProvider;
}; };
#endif // QT_NO_FILESYSTEMMODEL
QT_END_NAMESPACE QT_END_NAMESPACE
#endif // QFILEINFOGATHERER_H #endif // QFILEINFOGATHERER_H

View File

@ -58,8 +58,6 @@
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
#ifndef QT_NO_FILESYSTEMMODEL
/*! /*!
\enum QFileSystemModel::Roles \enum QFileSystemModel::Roles
\value FileIconRole \value FileIconRole
@ -1995,5 +1993,3 @@ bool QFileSystemModelPrivate::passNameFilters(const QFileSystemNode *node) const
QT_END_NAMESPACE QT_END_NAMESPACE
#include "moc_qfilesystemmodel.cpp" #include "moc_qfilesystemmodel.cpp"
#endif // QT_NO_FILESYSTEMMODEL

View File

@ -47,11 +47,10 @@
#include <QtGui/qicon.h> #include <QtGui/qicon.h>
#include <QtCore/qdiriterator.h> #include <QtCore/qdiriterator.h>
QT_REQUIRE_CONFIG(filesystemmodel);
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
#ifndef QT_NO_FILESYSTEMMODEL
class ExtendedInformation; class ExtendedInformation;
class QFileSystemModelPrivate; class QFileSystemModelPrivate;
class QFileIconProvider; class QFileIconProvider;
@ -166,9 +165,6 @@ inline QString QFileSystemModel::fileName(const QModelIndex &aindex) const
inline QIcon QFileSystemModel::fileIcon(const QModelIndex &aindex) const inline QIcon QFileSystemModel::fileIcon(const QModelIndex &aindex) const
{ return qvariant_cast<QIcon>(aindex.data(Qt::DecorationRole)); } { return qvariant_cast<QIcon>(aindex.data(Qt::DecorationRole)); }
#endif // QT_NO_FILESYSTEMMODEL
QT_END_NAMESPACE QT_END_NAMESPACE
#endif // QFILESYSTEMMODEL_H #endif // QFILESYSTEMMODEL_H

View File

@ -54,8 +54,6 @@
#include <QtWidgets/private/qtwidgetsglobal_p.h> #include <QtWidgets/private/qtwidgetsglobal_p.h>
#include "qfilesystemmodel.h" #include "qfilesystemmodel.h"
#ifndef QT_NO_FILESYSTEMMODEL
#include <private/qabstractitemmodel_p.h> #include <private/qabstractitemmodel_p.h>
#include <qabstractitemmodel.h> #include <qabstractitemmodel.h>
#include "qfileinfogatherer_p.h" #include "qfileinfogatherer_p.h"
@ -66,6 +64,8 @@
#include <qtimer.h> #include <qtimer.h>
#include <qhash.h> #include <qhash.h>
QT_REQUIRE_CONFIG(filesystemmodel);
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
class ExtendedInformation; class ExtendedInformation;
@ -313,9 +313,7 @@ public:
}; };
Q_DECLARE_TYPEINFO(QFileSystemModelPrivate::Fetching, Q_MOVABLE_TYPE); Q_DECLARE_TYPEINFO(QFileSystemModelPrivate::Fetching, Q_MOVABLE_TYPE);
#endif // QT_NO_FILESYSTEMMODEL
QT_END_NAMESPACE QT_END_NAMESPACE
#endif #endif

View File

@ -148,7 +148,9 @@
#include "QtWidgets/qscrollbar.h" #include "QtWidgets/qscrollbar.h"
#include "QtCore/qstringlistmodel.h" #include "QtCore/qstringlistmodel.h"
#include "QtWidgets/qdirmodel.h" #include "QtWidgets/qdirmodel.h"
#if QT_CONFIG(filesystemmodel)
#include "QtWidgets/qfilesystemmodel.h" #include "QtWidgets/qfilesystemmodel.h"
#endif
#include "QtWidgets/qheaderview.h" #include "QtWidgets/qheaderview.h"
#include "QtWidgets/qlistview.h" #include "QtWidgets/qlistview.h"
#include "QtWidgets/qapplication.h" #include "QtWidgets/qapplication.h"
@ -467,7 +469,7 @@ QMatchData QCompletionEngine::filterHistory()
const bool isDirModel = false; const bool isDirModel = false;
#endif #endif
Q_UNUSED(isDirModel) Q_UNUSED(isDirModel)
#ifndef QT_NO_FILESYSTEMMODEL #if QT_CONFIG(filesystemmodel)
const bool isFsModel = (qobject_cast<QFileSystemModel *>(source) != 0); const bool isFsModel = (qobject_cast<QFileSystemModel *>(source) != 0);
#else #else
const bool isFsModel = false; const bool isFsModel = false;
@ -872,7 +874,7 @@ void QCompleterPrivate::_q_complete(QModelIndex index, bool highlighted)
completion += QDir::separator(); completion += QDir::separator();
} }
#endif #endif
#ifndef QT_NO_FILESYSTEMMODEL #if QT_CONFIG(filesystemmodel)
// add a trailing separator in inline // add a trailing separator in inline
if (mode == QCompleter::InlineCompletion) { if (mode == QCompleter::InlineCompletion) {
if (qobject_cast<QFileSystemModel *>(proxy->sourceModel()) && QFileInfo(completion).isDir()) if (qobject_cast<QFileSystemModel *>(proxy->sourceModel()) && QFileInfo(completion).isDir())
@ -1044,7 +1046,7 @@ void QCompleter::setModel(QAbstractItemModel *model)
{ {
Q_D(QCompleter); Q_D(QCompleter);
QAbstractItemModel *oldModel = d->proxy->sourceModel(); QAbstractItemModel *oldModel = d->proxy->sourceModel();
#ifndef QT_NO_FILESYSTEMMODEL #if QT_CONFIG(filesystemmodel)
if (qobject_cast<const QFileSystemModel *>(oldModel)) if (qobject_cast<const QFileSystemModel *>(oldModel))
setCompletionRole(Qt::EditRole); // QTBUG-54642, clear FileNameRole set by QFileSystemModel setCompletionRole(Qt::EditRole); // QTBUG-54642, clear FileNameRole set by QFileSystemModel
#endif #endif
@ -1062,7 +1064,7 @@ void QCompleter::setModel(QAbstractItemModel *model)
#endif #endif
} }
#endif // QT_NO_DIRMODEL #endif // QT_NO_DIRMODEL
#ifndef QT_NO_FILESYSTEMMODEL #if QT_CONFIG(filesystemmodel)
QFileSystemModel *fsModel = qobject_cast<QFileSystemModel *>(model); QFileSystemModel *fsModel = qobject_cast<QFileSystemModel *>(model);
if (fsModel) { if (fsModel) {
#if defined(Q_OS_WIN) #if defined(Q_OS_WIN)
@ -1073,7 +1075,7 @@ void QCompleter::setModel(QAbstractItemModel *model)
setCompletionRole(QFileSystemModel::FileNameRole); setCompletionRole(QFileSystemModel::FileNameRole);
connect(fsModel, SIGNAL(directoryLoaded(QString)), this, SLOT(_q_fileSystemModelDirectoryLoaded(QString))); 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 #ifndef QT_NO_DIRMODEL
isDirModel = qobject_cast<QDirModel *>(d->proxy->sourceModel()) != 0; isDirModel = qobject_cast<QDirModel *>(d->proxy->sourceModel()) != 0;
#endif #endif
#ifndef QT_NO_FILESYSTEMMODEL #if QT_CONFIG(filesystemmodel)
isFsModel = qobject_cast<QFileSystemModel *>(d->proxy->sourceModel()) != 0; isFsModel = qobject_cast<QFileSystemModel *>(d->proxy->sourceModel()) != 0;
#endif #endif
if (!isDirModel && !isFsModel) if (!isDirModel && !isFsModel)
@ -1782,7 +1784,7 @@ QString QCompleter::pathFromIndex(const QModelIndex& index) const
QString t; QString t;
if (isDirModel) if (isDirModel)
t = sourceModel->data(idx, Qt::EditRole).toString(); t = sourceModel->data(idx, Qt::EditRole).toString();
#ifndef QT_NO_FILESYSTEMMODEL #if QT_CONFIG(filesystemmodel)
else else
t = sourceModel->data(idx, QFileSystemModel::FileNameRole).toString(); t = sourceModel->data(idx, QFileSystemModel::FileNameRole).toString();
#endif #endif
@ -1820,7 +1822,7 @@ QStringList QCompleter::splitPath(const QString& path) const
Q_D(const QCompleter); Q_D(const QCompleter);
isDirModel = qobject_cast<QDirModel *>(d->proxy->sourceModel()) != 0; isDirModel = qobject_cast<QDirModel *>(d->proxy->sourceModel()) != 0;
#endif #endif
#ifndef QT_NO_FILESYSTEMMODEL #if QT_CONFIG(filesystemmodel)
#ifdef QT_NO_DIRMODEL #ifdef QT_NO_DIRMODEL
Q_D(const QCompleter); Q_D(const QCompleter);
#endif #endif

View File

@ -348,7 +348,7 @@ void tst_QCompleter::getSetCheck()
completer.setWrapAround(false); completer.setWrapAround(false);
QCOMPARE(completer.wrapAround(), false); QCOMPARE(completer.wrapAround(), false);
#ifndef QT_NO_FILESYSTEMMODEL #if QT_CONFIG(filesystemmodel)
// QTBUG-54642, changing from QFileSystemModel to another model should restore role. // QTBUG-54642, changing from QFileSystemModel to another model should restore role.
completer.setCompletionRole(Qt::EditRole); completer.setCompletionRole(Qt::EditRole);
QCOMPARE(completer.completionRole(), static_cast<int>(Qt::EditRole)); // default value QCOMPARE(completer.completionRole(), static_cast<int>(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 QStandardItemModel standardItemModel2(2, 2); // Do not clobber a custom role when changing models
completer.setModel(&standardItemModel2); completer.setModel(&standardItemModel2);
QCOMPARE(completer.completionRole(), static_cast<int>(Qt::ToolTipRole)); QCOMPARE(completer.completionRole(), static_cast<int>(Qt::ToolTipRole));
#endif // QT_NO_FILESYSTEMMODEL #endif // QT_CONFIG(filesystemmodel)
} }
void tst_QCompleter::csMatchingOnCsSortedModel_data() void tst_QCompleter::csMatchingOnCsSortedModel_data()