diff options
41 files changed, 485 insertions, 204 deletions
diff --git a/src/gui/.prev_CMakeLists.txt b/src/gui/.prev_CMakeLists.txt index 8a93a8752a..3dbae0069d 100644 --- a/src/gui/.prev_CMakeLists.txt +++ b/src/gui/.prev_CMakeLists.txt @@ -9,6 +9,7 @@ qt_add_module(Gui PLUGIN_TYPES accessiblebridge platforms platforms/darwin xcbglintegrations platformthemes platforminputcontexts generic iconengines imageformats egldeviceintegrations SOURCES image/qabstractfileiconengine.cpp image/qabstractfileiconengine_p.h + image/qabstractfileiconprovider.cpp image/qabstractfileiconprovider.h image/qabstractfileiconprovider_p.h image/qbitmap.cpp image/qbitmap.h image/qbmphandler.cpp image/qbmphandler_p.h image/qicon.cpp image/qicon.h image/qicon_p.h @@ -323,6 +324,7 @@ qt_extend_target(Gui CONDITION WIN32 gdi32 ole32 user32 + shell32 PUBLIC_LIBRARIES d3d11 dxgi @@ -439,6 +441,12 @@ qt_extend_target(Gui CONDITION QT_FEATURE_draganddrop kernel/qsimpledrag.cpp kernel/qsimpledrag_p.h ) +qt_extend_target(Gui CONDITION QT_FEATURE_filesystemmodel + SOURCES + itemmodels/qfileinfogatherer.cpp itemmodels/qfileinfogatherer_p.h + itemmodels/qfilesystemmodel.cpp itemmodels/qfilesystemmodel.h itemmodels/qfilesystemmodel_p.h +) + qt_extend_target(Gui CONDITION QT_FEATURE_shortcut SOURCES kernel/qkeysequence.cpp kernel/qkeysequence.h kernel/qkeysequence_p.h diff --git a/src/gui/CMakeLists.txt b/src/gui/CMakeLists.txt index 79f3bafcd5..3396adf23c 100644 --- a/src/gui/CMakeLists.txt +++ b/src/gui/CMakeLists.txt @@ -60,6 +60,7 @@ qt_add_module(Gui QMAKE_MODULE_CONFIG "${qmake_module_config}" # special case SOURCES image/qabstractfileiconengine.cpp image/qabstractfileiconengine_p.h + image/qabstractfileiconprovider.cpp image/qabstractfileiconprovider.h image/qabstractfileiconprovider_p.h image/qbitmap.cpp image/qbitmap.h image/qbmphandler.cpp image/qbmphandler_p.h image/qicon.cpp image/qicon.h image/qicon_p.h @@ -403,6 +404,7 @@ qt_extend_target(Gui CONDITION WIN32 gdi32 ole32 user32 + shell32 PUBLIC_LIBRARIES d3d11 dxgi @@ -537,6 +539,12 @@ qt_extend_target(Gui CONDITION QT_FEATURE_draganddrop kernel/qsimpledrag.cpp kernel/qsimpledrag_p.h ) +qt_extend_target(Gui CONDITION QT_FEATURE_filesystemmodel + SOURCES + itemmodels/qfileinfogatherer.cpp itemmodels/qfileinfogatherer_p.h + itemmodels/qfilesystemmodel.cpp itemmodels/qfilesystemmodel.h itemmodels/qfilesystemmodel_p.h +) + qt_extend_target(Gui CONDITION QT_FEATURE_shortcut SOURCES kernel/qkeysequence.cpp kernel/qkeysequence.h kernel/qkeysequence_p.h diff --git a/src/gui/configure.cmake b/src/gui/configure.cmake index f0b5d9b1fe..a6d265183f 100644 --- a/src/gui/configure.cmake +++ b/src/gui/configure.cmake @@ -830,6 +830,13 @@ qt_feature("eglfs_x11" PRIVATE LABEL "EGLFS X11" CONDITION QT_FEATURE_eglfs AND QT_FEATURE_xcb_xlib AND QT_FEATURE_egl_x11 ) +qt_feature("filesystemmodel" PUBLIC + SECTION "File I/O" + LABEL "QFileSystemModel" + PURPOSE "Provides a data model for the local filesystem." + CONDITION QT_FEATURE_itemmodel +) +qt_feature_definition("filesystemmodel" "QT_NO_FILESYSTEMMODEL" NEGATE VALUE "1") qt_feature("gif" PRIVATE LABEL "GIF" CONDITION QT_FEATURE_imageformatplugin diff --git a/src/gui/configure.json b/src/gui/configure.json index a88ce54360..a29f870f05 100644 --- a/src/gui/configure.json +++ b/src/gui/configure.json @@ -1548,6 +1548,13 @@ "condition": "features.itemmodel", "output": [ "publicFeature", "feature" ] }, + "filesystemmodel": { + "label": "QFileSystemModel", + "purpose": "Provides a data model for the local filesystem.", + "section": "File I/O", + "condition": "features.itemmodel", + "output": [ "publicFeature", "feature" ] + }, "imageformatplugin": { "label": "QImageIOPlugin", "purpose": "Provides a base for writing a image format plugins.", diff --git a/src/gui/gui.pro b/src/gui/gui.pro index 4e79e31e6e..13631aba67 100644 --- a/src/gui/gui.pro +++ b/src/gui/gui.pro @@ -51,7 +51,10 @@ QMAKE_LIBS += $$QMAKE_LIBS_GUI load(qt_module) load(cmake_functions) -win32: CMAKE_WINDOWS_BUILD = True +win32: { + CMAKE_WINDOWS_BUILD = True + QMAKE_USE_PRIVATE += shell32 +} qtConfig(egl) { CMAKE_EGL_LIBS = $$cmakeProcessLibs($$QMAKE_LIBS_EGL) diff --git a/src/gui/image/image.pri b/src/gui/image/image.pri index bf0aa519a8..f503c97b82 100644 --- a/src/gui/image/image.pri +++ b/src/gui/image/image.pri @@ -26,7 +26,9 @@ HEADERS += \ image/qiconloader_p.h \ image/qiconengine.h \ image/qiconengineplugin.h \ - image/qabstractfileiconengine_p.h + image/qabstractfileiconengine_p.h \ + image/qabstractfileiconprovider.h \ + image/qabstractfileiconprovider_p.h SOURCES += \ image/qbitmap.cpp \ @@ -48,7 +50,8 @@ SOURCES += \ image/qiconloader.cpp \ image/qiconengine.cpp \ image/qiconengineplugin.cpp \ - image/qabstractfileiconengine.cpp + image/qabstractfileiconengine.cpp \ + image/qabstractfileiconprovider.cpp qtConfig(movie) { HEADERS += image/qmovie.h diff --git a/src/gui/image/qabstractfileiconprovider.cpp b/src/gui/image/qabstractfileiconprovider.cpp new file mode 100644 index 0000000000..2c2a694b60 --- /dev/null +++ b/src/gui/image/qabstractfileiconprovider.cpp @@ -0,0 +1,197 @@ +/**************************************************************************** +** +** Copyright (C) 2020 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtGui module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** 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 Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** 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-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qabstractfileiconprovider.h" + +#include <qguiapplication.h> +#include <private/qabstractfileiconprovider_p.h> +#include <private/qfilesystementry_p.h> + +QT_BEGIN_NAMESPACE + +QAbstractFileIconProviderPrivate::QAbstractFileIconProviderPrivate(QAbstractFileIconProvider *q) + : q_ptr(q) +{} + +QAbstractFileIconProviderPrivate::~QAbstractFileIconProviderPrivate() = default; + +/*! + \class QAbstractFileIconProvider + + \inmodule QtGui + \since 6.0 + + \brief The QAbstractFileIconProvider class provides file icons for the QFileSystemModel class. +*/ + +/*! + \enum QAbstractFileIconProvider::IconType + + \value Computer + \value Desktop + \value Trashcan + \value Network + \value Drive + \value Folder + \value File +*/ + +/*! + \enum QAbstractFileIconProvider::Option + + \value DontUseCustomDirectoryIcons Always use the default directory icon. + Some platforms allow the user to set a different icon. Custom icon lookup + cause a big performance impact over network or removable drives. +*/ + +/*! + Constructs a file icon provider. +*/ +QAbstractFileIconProvider::QAbstractFileIconProvider() + : d_ptr(new QAbstractFileIconProviderPrivate(this)) +{ +} + +/*! + \internal +*/ +QAbstractFileIconProvider::QAbstractFileIconProvider(QAbstractFileIconProviderPrivate &dd) + : d_ptr(&dd) +{} + +/*! + Destroys the file icon provider. +*/ + +QAbstractFileIconProvider::~QAbstractFileIconProvider() = default; + + +/*! + Sets \a options that affect the icon provider. + \sa options() +*/ + +void QAbstractFileIconProvider::setOptions(QAbstractFileIconProvider::Options options) +{ + Q_D(QAbstractFileIconProvider); + d->options = options; +} + +/*! + Returns all the options that affect the icon provider. + By default, all options are disabled. + \sa setOptions() +*/ + +QAbstractFileIconProvider::Options QAbstractFileIconProvider::options() const +{ + Q_D(const QAbstractFileIconProvider); + return d->options; +} + +/*! + Returns an icon set for the given \a type. +*/ + +QIcon QAbstractFileIconProvider::icon(IconType type) const +{ + Q_UNUSED(type); + return {}; +} + +/*! + Returns an icon for the file described by \a info. +*/ + +QIcon QAbstractFileIconProvider::icon(const QFileInfo &info) const +{ + Q_UNUSED(info); + return {}; +} + +/*! + Returns the type of the file described by \a info. +*/ + +QString QAbstractFileIconProvider::type(const QFileInfo &info) const +{ + /* ### Qt 6 These string translations being in the QFileDialog context is not ideal, + but translating them in QFileDialog context only in the QFileIconProvider subclass + isn't either (it basically requires a duplication of the entire function). + Either we change it to QAbstractFileIconProvider context (invalidates existing + translations, but that's probably ok), or make a runtime lookup and use QFileDIalog + context only if QGuiApplication is a QApplication. + */ + if (QFileSystemEntry::isRootPath(info.absoluteFilePath())) + return QGuiApplication::translate("QFileDialog", "Drive"); + if (info.isFile()) { + // ### could use QMimeDatabase::mimeTypeForFile(const QFileInfo&) here + if (!info.suffix().isEmpty()) { + //: %1 is a file name suffix, for example txt + return QGuiApplication::translate("QFileDialog", "%1 File").arg(info.suffix()); + } + return QGuiApplication::translate("QFileDialog", "File"); + } + + if (info.isDir()) +#ifdef Q_OS_WIN + return QGuiApplication::translate("QFileDialog", "File Folder", "Match Windows Explorer"); +#else + return QGuiApplication::translate("QFileDialog", "Folder", "All other platforms"); +#endif + // Windows - "File Folder" + // macOS - "Folder" + // Konqueror - "Folder" + // Nautilus - "folder" + + if (info.isSymLink()) +#ifdef Q_OS_MACOS + return QGuiApplication::translate("QFileDialog", "Alias", "macOS Finder"); +#else + return QGuiApplication::translate("QFileDialog", "Shortcut", "All other platforms"); +#endif + // macOS - "Alias" + // Windows - "Shortcut" + // Konqueror - "Folder" or "TXT File" i.e. what it is pointing to + // Nautilus - "link to folder" or "link to object file", same as Konqueror + + return QGuiApplication::translate("QFileDialog", "Unknown"); +} + +QT_END_NAMESPACE diff --git a/src/gui/image/qabstractfileiconprovider.h b/src/gui/image/qabstractfileiconprovider.h new file mode 100644 index 0000000000..fc107e0ca3 --- /dev/null +++ b/src/gui/image/qabstractfileiconprovider.h @@ -0,0 +1,84 @@ +/**************************************************************************** +** +** Copyright (C) 2020 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtGui module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** 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 Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** 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-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QABSTRACTFILEICONPROVIDER_H +#define QABSTRACTFILEICONPROVIDER_H + +#include <QtGui/qtguiglobal.h> +#include <QtCore/qfileinfo.h> +#include <QtCore/qscopedpointer.h> +#include <QtGui/qicon.h> + +QT_BEGIN_NAMESPACE + +class QAbstractFileIconProviderPrivate; + +class Q_GUI_EXPORT QAbstractFileIconProvider +{ +public: + enum IconType { Computer, Desktop, Trashcan, Network, Drive, Folder, File }; + enum Option { + DontUseCustomDirectoryIcons = 0x00000001 + }; + Q_DECLARE_FLAGS(Options, Option) + + QAbstractFileIconProvider(); + virtual ~QAbstractFileIconProvider(); + + virtual QIcon icon(IconType) const; + virtual QIcon icon(const QFileInfo &) const; + virtual QString type(const QFileInfo &) const; + + virtual void setOptions(Options); + virtual Options options() const; + +protected: + QAbstractFileIconProvider(QAbstractFileIconProviderPrivate &dd); + QScopedPointer<QAbstractFileIconProviderPrivate> d_ptr; + +private: + Q_DECLARE_PRIVATE(QAbstractFileIconProvider) + Q_DISABLE_COPY(QAbstractFileIconProvider) +}; + +Q_DECLARE_OPERATORS_FOR_FLAGS(QAbstractFileIconProvider::Options) + +QT_END_NAMESPACE + +#endif // QABSTRACTFILEICONPROVIDER_H diff --git a/src/gui/image/qabstractfileiconprovider_p.h b/src/gui/image/qabstractfileiconprovider_p.h new file mode 100644 index 0000000000..db7ac6db1b --- /dev/null +++ b/src/gui/image/qabstractfileiconprovider_p.h @@ -0,0 +1,73 @@ +/**************************************************************************** +** +** Copyright (C) 2020 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtGui module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** 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 Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** 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-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QABSTRACTFILEICONPROVIDER_P_H +#define QABSTRACTFILEICONPROVIDER_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtGui/private/qtguiglobal_p.h> +#include "qabstractfileiconprovider.h" + +QT_BEGIN_NAMESPACE + +class Q_GUI_EXPORT QAbstractFileIconProviderPrivate +{ + Q_DECLARE_PUBLIC(QAbstractFileIconProvider) + +public: + QAbstractFileIconProviderPrivate(QAbstractFileIconProvider *q); + virtual ~QAbstractFileIconProviderPrivate(); + + QAbstractFileIconProvider *q_ptr = nullptr; + QAbstractFileIconProvider::Options options = {}; +}; + +QT_END_NAMESPACE + +#endif // QABSTRACTFILEICONPROVIDER_P_H diff --git a/src/gui/itemmodels/itemmodels.pri b/src/gui/itemmodels/itemmodels.pri index cab0594174..4de6cc29e2 100644 --- a/src/gui/itemmodels/itemmodels.pri +++ b/src/gui/itemmodels/itemmodels.pri @@ -1,8 +1,19 @@ -!qtConfig(standarditemmodel): return() +qtConfig(standarditemmodel) { + HEADERS += \ + itemmodels/qstandarditemmodel.h \ + itemmodels/qstandarditemmodel_p.h \ -HEADERS += \ - itemmodels/qstandarditemmodel.h \ - itemmodels/qstandarditemmodel_p.h \ + SOURCES += \ + itemmodels/qstandarditemmodel.cpp \ +} -SOURCES += \ - itemmodels/qstandarditemmodel.cpp \ +qtConfig(filesystemmodel) { + HEADERS += \ + itemmodels/qfilesystemmodel.h \ + itemmodels/qfilesystemmodel_p.h \ + itemmodels/qfileinfogatherer_p.h + + SOURCES += \ + itemmodels/qfilesystemmodel.cpp \ + itemmodels/qfileinfogatherer.cpp +} diff --git a/src/widgets/dialogs/qfileinfogatherer.cpp b/src/gui/itemmodels/qfileinfogatherer.cpp index 11d963226f..417c3d7e42 100644 --- a/src/widgets/dialogs/qfileinfogatherer.cpp +++ b/src/gui/itemmodels/qfileinfogatherer.cpp @@ -129,12 +129,12 @@ bool QFileInfoGatherer::resolveSymlinks() const #endif } -void QFileInfoGatherer::setIconProvider(QFileIconProvider *provider) +void QFileInfoGatherer::setIconProvider(QAbstractFileIconProvider *provider) { m_iconProvider = provider; } -QFileIconProvider *QFileInfoGatherer::iconProvider() const +QAbstractFileIconProvider *QFileInfoGatherer::iconProvider() const { return m_iconProvider; } diff --git a/src/widgets/dialogs/qfileinfogatherer_p.h b/src/gui/itemmodels/qfileinfogatherer_p.h index 664ea74c02..374331a588 100644 --- a/src/widgets/dialogs/qfileinfogatherer_p.h +++ b/src/gui/itemmodels/qfileinfogatherer_p.h @@ -51,7 +51,7 @@ // We mean it. // -#include <QtWidgets/private/qtwidgetsglobal_p.h> +#include <QtGui/private/qtguiglobal_p.h> #include <qthread.h> #include <qmutex.h> @@ -59,7 +59,7 @@ #if QT_CONFIG(filesystemwatcher) #include <qfilesystemwatcher.h> #endif -#include <qfileiconprovider.h> +#include <qabstractfileiconprovider.h> #include <qpair.h> #include <qstack.h> #include <qdatetime.h> @@ -155,7 +155,7 @@ private : class QFileIconProvider; -class Q_AUTOTEST_EXPORT QFileInfoGatherer : public QThread +class Q_GUI_EXPORT QFileInfoGatherer : public QThread { Q_OBJECT @@ -181,7 +181,7 @@ public: void clear(); void removePath(const QString &path); QExtendedInformation getInfo(const QFileInfo &info) const; - QFileIconProvider *iconProvider() const; + QAbstractFileIconProvider *iconProvider() const; bool resolveSymlinks() const; public Q_SLOTS: @@ -189,7 +189,7 @@ public Q_SLOTS: void fetchExtendedInformation(const QString &path, const QStringList &files); void updateFile(const QString &path); void setResolveSymlinks(bool enable); - void setIconProvider(QFileIconProvider *provider); + void setIconProvider(QAbstractFileIconProvider *provider); private Q_SLOTS: void driveAdded(); @@ -216,8 +216,8 @@ private: #if QT_CONFIG(filesystemwatcher) QFileSystemWatcher *m_watcher = nullptr; #endif - QFileIconProvider *m_iconProvider; // not accessed by run() - QFileIconProvider defaultProvider; + QAbstractFileIconProvider *m_iconProvider; // not accessed by run() + QAbstractFileIconProvider defaultProvider; #ifdef Q_OS_WIN bool m_resolveSymlinks = true; // not accessed by run() #endif diff --git a/src/widgets/dialogs/qfilesystemmodel.cpp b/src/gui/itemmodels/qfilesystemmodel.cpp index 4b933cdb8d..481f11162a 100644 --- a/src/widgets/dialogs/qfilesystemmodel.cpp +++ b/src/gui/itemmodels/qfilesystemmodel.cpp @@ -39,6 +39,7 @@ #include "qfilesystemmodel_p.h" #include "qfilesystemmodel.h" +#include <qabstractfileiconprovider.h> #include <qlocale.h> #include <qmimedata.h> #include <qurl.h> @@ -697,7 +698,7 @@ QVariant QFileSystemModel::myComputer(int role) const return QFileSystemModelPrivate::myComputer(); #if QT_CONFIG(filesystemwatcher) case Qt::DecorationRole: - return d->fileInfoGatherer.iconProvider()->icon(QFileIconProvider::Computer); + return d->fileInfoGatherer.iconProvider()->icon(QAbstractFileIconProvider::Computer); #endif } return QVariant(); @@ -735,9 +736,9 @@ QVariant QFileSystemModel::data(const QModelIndex &index, int role) const #if QT_CONFIG(filesystemwatcher) if (icon.isNull()) { if (d->node(index)->isDir()) - icon = d->fileInfoGatherer.iconProvider()->icon(QFileIconProvider::Folder); + icon = d->fileInfoGatherer.iconProvider()->icon(QAbstractFileIconProvider::Folder); else - icon = d->fileInfoGatherer.iconProvider()->icon(QFileIconProvider::File); + icon = d->fileInfoGatherer.iconProvider()->icon(QAbstractFileIconProvider::File); } #endif // filesystemwatcher return icon; @@ -1330,8 +1331,8 @@ void QFileSystemModel::setOptions(Options options) if (changed.testFlag(DontUseCustomDirectoryIcons)) { if (auto provider = iconProvider()) { - QFileIconProvider::Options providerOptions = provider->options(); - providerOptions.setFlag(QFileIconProvider::DontUseCustomDirectoryIcons, + QAbstractFileIconProvider::Options providerOptions = provider->options(); + providerOptions.setFlag(QAbstractFileIconProvider::DontUseCustomDirectoryIcons, options.testFlag(QFileSystemModel::DontUseCustomDirectoryIcons)); provider->setOptions(providerOptions); } else { @@ -1352,7 +1353,7 @@ QFileSystemModel::Options QFileSystemModel::options() const #endif if (auto provider = iconProvider()) { result.setFlag(DontUseCustomDirectoryIcons, - provider->options().testFlag(QFileIconProvider::DontUseCustomDirectoryIcons)); + provider->options().testFlag(QAbstractFileIconProvider::DontUseCustomDirectoryIcons)); } return result; } @@ -1550,7 +1551,7 @@ QDir QFileSystemModel::rootDirectory() const /*! Sets the \a provider of file icons for the directory model. */ -void QFileSystemModel::setIconProvider(QFileIconProvider *provider) +void QFileSystemModel::setIconProvider(QAbstractFileIconProvider *provider) { Q_D(QFileSystemModel); #if QT_CONFIG(filesystemwatcher) @@ -1562,7 +1563,7 @@ void QFileSystemModel::setIconProvider(QFileIconProvider *provider) /*! Returns the file icon provider for this directory model. */ -QFileIconProvider *QFileSystemModel::iconProvider() const +QAbstractFileIconProvider *QFileSystemModel::iconProvider() const { #if QT_CONFIG(filesystemwatcher) Q_D(const QFileSystemModel); diff --git a/src/widgets/dialogs/qfilesystemmodel.h b/src/gui/itemmodels/qfilesystemmodel.h index 518a45a477..a79c4c14df 100644 --- a/src/widgets/dialogs/qfilesystemmodel.h +++ b/src/gui/itemmodels/qfilesystemmodel.h @@ -40,7 +40,7 @@ #ifndef QFILESYSTEMMODEL_H #define QFILESYSTEMMODEL_H -#include <QtWidgets/qtwidgetsglobal.h> +#include <QtGui/qtguiglobal.h> #include <QtCore/qabstractitemmodel.h> #include <QtCore/qpair.h> #include <QtCore/qdir.h> @@ -53,9 +53,9 @@ QT_BEGIN_NAMESPACE class ExtendedInformation; class QFileSystemModelPrivate; -class QFileIconProvider; +class QAbstractFileIconProvider; -class Q_WIDGETS_EXPORT QFileSystemModel : public QAbstractItemModel +class Q_GUI_EXPORT QFileSystemModel : public QAbstractItemModel { Q_OBJECT Q_PROPERTY(bool resolveSymlinks READ resolveSymlinks WRITE setResolveSymlinks) @@ -122,8 +122,8 @@ public: QString rootPath() const; QDir rootDirectory() const; - void setIconProvider(QFileIconProvider *provider); - QFileIconProvider *iconProvider() const; + void setIconProvider(QAbstractFileIconProvider *provider); + QAbstractFileIconProvider *iconProvider() const; void setFilter(QDir::Filters filters); QDir::Filters filter() const; diff --git a/src/widgets/dialogs/qfilesystemmodel_p.h b/src/gui/itemmodels/qfilesystemmodel_p.h index 1870b08df1..092eae3b2e 100644 --- a/src/widgets/dialogs/qfilesystemmodel_p.h +++ b/src/gui/itemmodels/qfilesystemmodel_p.h @@ -51,7 +51,7 @@ // We mean it. // -#include <QtWidgets/private/qtwidgetsglobal_p.h> +#include <QtGui/private/qtguiglobal_p.h> #include "qfilesystemmodel.h" #include <private/qabstractitemmodel_p.h> @@ -89,7 +89,7 @@ inline size_t qHash(const QFileSystemModelNodePathKey &key) { return qHash(key.t typedef QString QFileSystemModelNodePathKey; #endif -class Q_AUTOTEST_EXPORT QFileSystemModelPrivate : public QAbstractItemModelPrivate +class Q_GUI_EXPORT QFileSystemModelPrivate : public QAbstractItemModelPrivate { Q_DECLARE_PUBLIC(QFileSystemModel) @@ -174,7 +174,7 @@ public: inline int visibleLocation(const QString &childName) { return visibleChildren.indexOf(childName); } - void updateIcon(QFileIconProvider *iconProvider, const QString &path) { + void updateIcon(QAbstractFileIconProvider *iconProvider, const QString &path) { if (info) info->icon = iconProvider->icon(QFileInfo(path)); for (QFileSystemNode *child : qAsConst(children)) { @@ -189,7 +189,7 @@ public: } } - void retranslateStrings(QFileIconProvider *iconProvider, const QString &path) { + void retranslateStrings(QAbstractFileIconProvider *iconProvider, const QString &path) { if (info) info->displayType = iconProvider->type(QFileInfo(path)); for (QFileSystemNode *child : qAsConst(children)) { diff --git a/src/printsupport/dialogs/qprintdialog_unix.cpp b/src/printsupport/dialogs/qprintdialog_unix.cpp index 6dcb613ff5..60e177f3e8 100644 --- a/src/printsupport/dialogs/qprintdialog_unix.cpp +++ b/src/printsupport/dialogs/qprintdialog_unix.cpp @@ -54,7 +54,7 @@ #include <QtCore/qstringconverter.h> #include <QtGui/qevent.h> #if QT_CONFIG(filesystemmodel) -#include <QtWidgets/qfilesystemmodel.h> +#include <QtGui/qfilesystemmodel.h> #endif #include <QtWidgets/qstyleditemdelegate.h> #include <QtWidgets/qformlayout.h> diff --git a/src/tools/uic/qclass_lib_map.h b/src/tools/uic/qclass_lib_map.h index 797bcf6e76..8558b74361 100644 --- a/src/tools/uic/qclass_lib_map.h +++ b/src/tools/uic/qclass_lib_map.h @@ -536,7 +536,7 @@ QT_CLASS_LIB(QColorDialog, QtWidgets, qcolordialog.h) QT_CLASS_LIB(QDialog, QtWidgets, qdialog.h) QT_CLASS_LIB(QErrorMessage, QtWidgets, qerrormessage.h) QT_CLASS_LIB(QFileDialog, QtWidgets, qfiledialog.h) -QT_CLASS_LIB(QFileSystemModel, QtWidgets, qfilesystemmodel.h) +QT_CLASS_LIB(QFileSystemModel, QtGui, qfilesystemmodel.h) QT_CLASS_LIB(QFontDialog, QtWidgets, qfontdialog.h) QT_CLASS_LIB(QInputDialog, QtWidgets, qinputdialog.h) QT_CLASS_LIB(QMessageBox, QtWidgets, qmessagebox.h) diff --git a/src/widgets/CMakeLists.txt b/src/widgets/CMakeLists.txt index 915fd7a99f..b20f4a514d 100644 --- a/src/widgets/CMakeLists.txt +++ b/src/widgets/CMakeLists.txt @@ -624,12 +624,6 @@ qt_extend_target(Widgets CONDITION QT_FEATURE_filedialog uic ) -qt_extend_target(Widgets CONDITION QT_FEATURE_filesystemmodel - SOURCES - dialogs/qfileinfogatherer.cpp dialogs/qfileinfogatherer_p.h - dialogs/qfilesystemmodel.cpp dialogs/qfilesystemmodel.h dialogs/qfilesystemmodel_p.h -) - qt_extend_target(Widgets CONDITION QT_FEATURE_fontdialog SOURCES dialogs/qfontdialog.cpp dialogs/qfontdialog.h dialogs/qfontdialog_p.h diff --git a/src/widgets/configure.cmake b/src/widgets/configure.cmake index 090fb7b64c..fa55073f62 100644 --- a/src/widgets/configure.cmake +++ b/src/widgets/configure.cmake @@ -50,13 +50,6 @@ qt_feature("effects" PRIVATE LABEL "Effects" PURPOSE "Provides special widget effects (e.g. fading and scrolling)." ) -qt_feature("filesystemmodel" PUBLIC - SECTION "File I/O" - LABEL "QFileSystemModel" - PURPOSE "Provides a data model for the local filesystem." - CONDITION QT_FEATURE_itemmodel -) -qt_feature_definition("filesystemmodel" "QT_NO_FILESYSTEMMODEL" NEGATE VALUE "1") qt_feature("itemviews" PUBLIC SECTION "ItemViews" LABEL "The Model/View Framework" diff --git a/src/widgets/configure.json b/src/widgets/configure.json index 5b984c3bf2..f2e88608de 100644 --- a/src/widgets/configure.json +++ b/src/widgets/configure.json @@ -69,13 +69,6 @@ "section": "Kernel", "output": [ "privateFeature" ] }, - "filesystemmodel": { - "label": "QFileSystemModel", - "purpose": "Provides a data model for the local filesystem.", - "section": "File I/O", - "condition": "features.itemmodel", - "output": [ "publicFeature", "feature" ] - }, "itemviews": { "label": "The Model/View Framework", "purpose": "Provides the model/view architecture managing the relationship between data and the way it is presented to the user.", diff --git a/src/widgets/dialogs/dialogs.pri b/src/widgets/dialogs/dialogs.pri index a6a6b2d352..75e0f5fcf8 100644 --- a/src/widgets/dialogs/dialogs.pri +++ b/src/widgets/dialogs/dialogs.pri @@ -34,17 +34,6 @@ 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(fontdialog) { HEADERS += \ dialogs/qfontdialog.h \ diff --git a/src/widgets/dialogs/qfiledialog.cpp b/src/widgets/dialogs/qfiledialog.cpp index bd58062375..81e182c352 100644 --- a/src/widgets/dialogs/qfiledialog.cpp +++ b/src/widgets/dialogs/qfiledialog.cpp @@ -1952,7 +1952,7 @@ QAbstractItemDelegate *QFileDialog::itemDelegate() const /*! Sets the icon provider used by the filedialog to the specified \a provider. */ -void QFileDialog::setIconProvider(QFileIconProvider *provider) +void QFileDialog::setIconProvider(QAbstractFileIconProvider *provider) { Q_D(QFileDialog); if (!d->usingWidgets()) @@ -1965,7 +1965,7 @@ void QFileDialog::setIconProvider(QFileIconProvider *provider) /*! Returns the icon provider used by the filedialog. */ -QFileIconProvider *QFileDialog::iconProvider() const +QAbstractFileIconProvider *QFileDialog::iconProvider() const { Q_D(const QFileDialog); if (!d->model) @@ -2977,6 +2977,7 @@ void QFileDialogPrivate::createWidgets() Qt::WindowStates preState = q->windowState(); model = new QFileSystemModel(q); + model->setIconProvider(&defaultIconProvider); model->setFilter(options->filter()); model->setObjectName(QLatin1String("qt_filesystem_model")); if (QPlatformFileDialogHelper *helper = platformFileDialogHelper()) diff --git a/src/widgets/dialogs/qfiledialog.h b/src/widgets/dialogs/qfiledialog.h index 0949302ef5..0a6b9e62ef 100644 --- a/src/widgets/dialogs/qfiledialog.h +++ b/src/widgets/dialogs/qfiledialog.h @@ -55,8 +55,8 @@ QT_BEGIN_NAMESPACE class QModelIndex; class QItemSelection; struct QFileDialogArgs; -class QFileIconProvider; class QFileDialogPrivate; +class QAbstractFileIconProvider; class QAbstractItemDelegate; class QAbstractProxyModel; @@ -153,8 +153,8 @@ public: void setItemDelegate(QAbstractItemDelegate *delegate); QAbstractItemDelegate *itemDelegate() const; - void setIconProvider(QFileIconProvider *provider); - QFileIconProvider *iconProvider() const; + void setIconProvider(QAbstractFileIconProvider *provider); + QAbstractFileIconProvider *iconProvider() const; void setLabelText(DialogLabel label, const QString &text); QString labelText(DialogLabel label) const; diff --git a/src/widgets/dialogs/qfiledialog_p.h b/src/widgets/dialogs/qfiledialog_p.h index 1d9929e36a..16b8b2f45b 100644 --- a/src/widgets/dialogs/qfiledialog_p.h +++ b/src/widgets/dialogs/qfiledialog_p.h @@ -57,7 +57,7 @@ #include "private/qdialog_p.h" #include "qplatformdefs.h" -#include "qfilesystemmodel_p.h" +#include <QtGui/private/qfilesystemmodel_p.h> #include <qlistview.h> #include <qtreeview.h> #include <qcombobox.h> @@ -69,6 +69,7 @@ #include <qstackedwidget.h> #include <qdialogbuttonbox.h> #include <qabstractproxymodel.h> +#include <qfileiconprovider.h> #if QT_CONFIG(completer) #include <qcompleter.h> #endif @@ -285,6 +286,7 @@ public: QByteArray splitterState; QByteArray headerData; QList<QUrl> sidebarUrls; + QFileIconProvider defaultIconProvider; ~QFileDialogPrivate(); diff --git a/src/widgets/dialogs/qfscompleter_p.h b/src/widgets/dialogs/qfscompleter_p.h index f5110a7622..be46f5be43 100644 --- a/src/widgets/dialogs/qfscompleter_p.h +++ b/src/widgets/dialogs/qfscompleter_p.h @@ -53,7 +53,7 @@ #include <QtWidgets/private/qtwidgetsglobal_p.h> #include "qcompleter.h" -#include <QtWidgets/qfilesystemmodel.h> +#include <QtGui/qfilesystemmodel.h> QT_REQUIRE_CONFIG(fscompleter); diff --git a/src/widgets/dialogs/qsidebar.cpp b/src/widgets/dialogs/qsidebar.cpp index 4272b612ec..296542a187 100644 --- a/src/widgets/dialogs/qsidebar.cpp +++ b/src/widgets/dialogs/qsidebar.cpp @@ -38,7 +38,6 @@ ****************************************************************************/ #include "qsidebar_p.h" -#include "qfilesystemmodel.h" #include <qaction.h> #include <qurl.h> @@ -48,7 +47,8 @@ #include <qmimedata.h> #include <qevent.h> #include <qdebug.h> -#include <qfileiconprovider.h> +#include <qfilesystemmodel.h> +#include <qabstractfileiconprovider.h> #include <qfiledialog.h> QT_BEGIN_NAMESPACE @@ -198,9 +198,9 @@ void QUrlModel::setUrl(const QModelIndex &index, const QUrl &url, const QModelIn QIcon newIcon = qvariant_cast<QIcon>(dirIndex.data(Qt::DecorationRole)); if (!dirIndex.isValid()) { - const QFileIconProvider *provider = fileSystemModel->iconProvider(); + const QAbstractFileIconProvider *provider = fileSystemModel->iconProvider(); if (provider) - newIcon = provider->icon(QFileIconProvider::Folder); + newIcon = provider->icon(QAbstractFileIconProvider::Folder); newName = QFileInfo(url.toLocalFile()).fileName(); if (!invalidUrls.contains(url)) invalidUrls.append(url); diff --git a/src/widgets/itemviews/qfileiconprovider.cpp b/src/widgets/itemviews/qfileiconprovider.cpp index d70d47be5e..59f132e17c 100644 --- a/src/widgets/itemviews/qfileiconprovider.cpp +++ b/src/widgets/itemviews/qfileiconprovider.cpp @@ -67,29 +67,8 @@ QT_BEGIN_NAMESPACE \brief The QFileIconProvider class provides file icons for the QFileSystemModel class. */ -/*! - \enum QFileIconProvider::IconType - \value Computer - \value Desktop - \value Trashcan - \value Network - \value Drive - \value Folder - \value File -*/ - - -/*! - \enum QFileIconProvider::Option - \since 5.2 - - \value DontUseCustomDirectoryIcons Always use the default directory icon. - Some platforms allow the user to set a different icon. Custom icon lookup - cause a big performance impact over network or removable drives. -*/ - -QFileIconProviderPrivate::QFileIconProviderPrivate(QFileIconProvider *q) : - q_ptr(q), homePath(QDir::home().absolutePath()) +QFileIconProviderPrivate::QFileIconProviderPrivate(QFileIconProvider *q) + : QAbstractFileIconProviderPrivate(q), homePath(QDir::home().absolutePath()) { } @@ -155,46 +134,18 @@ QIcon QFileIconProviderPrivate::getIcon(QStyle::StandardPixmap name) const */ QFileIconProvider::QFileIconProvider() - : d_ptr(new QFileIconProviderPrivate(this)) + : QAbstractFileIconProvider(*new QFileIconProviderPrivate(this)) { } /*! Destroys the file icon provider. - -*/ - -QFileIconProvider::~QFileIconProvider() -{ -} - -/*! - \since 5.2 - Sets \a options that affect the icon provider. - \sa options() -*/ - -void QFileIconProvider::setOptions(QFileIconProvider::Options options) -{ - Q_D(QFileIconProvider); - d->options = options; -} - -/*! - \since 5.2 - Returns all the options that affect the icon provider. - By default, all options are disabled. - \sa setOptions() */ -QFileIconProvider::Options QFileIconProvider::options() const -{ - Q_D(const QFileIconProvider); - return d->options; -} +QFileIconProvider::~QFileIconProvider() = default; /*! - Returns an icon set for the given \a type. + \reimpl */ QIcon QFileIconProvider::icon(IconType type) const @@ -235,7 +186,7 @@ QIcon QFileIconProviderPrivate::getIcon(const QFileInfo &fi) const } /*! - Returns an icon for the file described by \a info. + \reimpl */ QIcon QFileIconProvider::icon(const QFileInfo &info) const @@ -292,45 +243,4 @@ QIcon QFileIconProvider::icon(const QFileInfo &info) const return QIcon(); } -/*! - Returns the type of the file described by \a info. -*/ - -QString QFileIconProvider::type(const QFileInfo &info) const -{ - if (QFileSystemEntry::isRootPath(info.absoluteFilePath())) - return QApplication::translate("QFileDialog", "Drive"); - if (info.isFile()) { - if (!info.suffix().isEmpty()) { - //: %1 is a file name suffix, for example txt - return QApplication::translate("QFileDialog", "%1 File").arg(info.suffix()); - } - return QApplication::translate("QFileDialog", "File"); - } - - if (info.isDir()) -#ifdef Q_OS_WIN - return QApplication::translate("QFileDialog", "File Folder", "Match Windows Explorer"); -#else - return QApplication::translate("QFileDialog", "Folder", "All other platforms"); -#endif - // Windows - "File Folder" - // OS X - "Folder" - // Konqueror - "Folder" - // Nautilus - "folder" - - if (info.isSymLink()) -#ifdef Q_OS_MAC - return QApplication::translate("QFileDialog", "Alias", "OS X Finder"); -#else - return QApplication::translate("QFileDialog", "Shortcut", "All other platforms"); -#endif - // OS X - "Alias" - // Windows - "Shortcut" - // Konqueror - "Folder" or "TXT File" i.e. what it is pointing to - // Nautilus - "link to folder" or "link to object file", same as Konqueror - - return QApplication::translate("QFileDialog", "Unknown"); -} - QT_END_NAMESPACE diff --git a/src/widgets/itemviews/qfileiconprovider.h b/src/widgets/itemviews/qfileiconprovider.h index 732ca1ac8e..35db39bfd8 100644 --- a/src/widgets/itemviews/qfileiconprovider.h +++ b/src/widgets/itemviews/qfileiconprovider.h @@ -44,39 +44,27 @@ #include <QtCore/qfileinfo.h> #include <QtCore/qscopedpointer.h> #include <QtGui/qicon.h> +#include <QtGui/qabstractfileiconprovider.h> QT_BEGIN_NAMESPACE class QFileIconProviderPrivate; -class Q_WIDGETS_EXPORT QFileIconProvider +class Q_WIDGETS_EXPORT QFileIconProvider : public QAbstractFileIconProvider { public: QFileIconProvider(); - virtual ~QFileIconProvider(); - enum IconType { Computer, Desktop, Trashcan, Network, Drive, Folder, File }; + ~QFileIconProvider(); - enum Option { - DontUseCustomDirectoryIcons = 0x00000001 - }; - Q_DECLARE_FLAGS(Options, Option) - - virtual QIcon icon(IconType type) const; - virtual QIcon icon(const QFileInfo &info) const; - virtual QString type(const QFileInfo &info) const; - - void setOptions(Options options); - Options options() const; + QIcon icon(IconType type) const override; + QIcon icon(const QFileInfo &info) const override; private: Q_DECLARE_PRIVATE(QFileIconProvider) - QScopedPointer<QFileIconProviderPrivate> d_ptr; Q_DISABLE_COPY(QFileIconProvider) }; -Q_DECLARE_OPERATORS_FOR_FLAGS(QFileIconProvider::Options) - QT_END_NAMESPACE #endif // QFILEICONPROVIDER_H diff --git a/src/widgets/itemviews/qfileiconprovider_p.h b/src/widgets/itemviews/qfileiconprovider_p.h index 4726b15816..6a9a1f2e0e 100644 --- a/src/widgets/itemviews/qfileiconprovider_p.h +++ b/src/widgets/itemviews/qfileiconprovider_p.h @@ -54,6 +54,7 @@ #include <QtWidgets/private/qtwidgetsglobal_p.h> #include "qfileiconprovider.h" +#include <private/qabstractfileiconprovider_p.h> #include <QtCore/qstring.h> #include <QtGui/qicon.h> #include <QtWidgets/qstyle.h> @@ -62,7 +63,7 @@ QT_BEGIN_NAMESPACE class QFileInfo; -class QFileIconProviderPrivate +class QFileIconProviderPrivate : public QAbstractFileIconProviderPrivate { Q_DECLARE_PUBLIC(QFileIconProvider) @@ -71,9 +72,7 @@ public: QIcon getIcon(QStyle::StandardPixmap name) const; QIcon getIcon(const QFileInfo &fi) const; - QFileIconProvider *q_ptr; const QString homePath; - QFileIconProvider::Options options; private: mutable QIcon file; diff --git a/src/widgets/util/qcompleter.cpp b/src/widgets/util/qcompleter.cpp index b3833c5f50..7bfd112f5c 100644 --- a/src/widgets/util/qcompleter.cpp +++ b/src/widgets/util/qcompleter.cpp @@ -149,7 +149,7 @@ #include "QtCore/qstringlistmodel.h" #endif #if QT_CONFIG(filesystemmodel) -#include "QtWidgets/qfilesystemmodel.h" +#include "QtGui/qfilesystemmodel.h" #endif #include "QtWidgets/qheaderview.h" #if QT_CONFIG(listview) diff --git a/tests/auto/gui/itemmodels/CMakeLists.txt b/tests/auto/gui/itemmodels/CMakeLists.txt index b8c55489c4..e1d3ad3f6b 100644 --- a/tests/auto/gui/itemmodels/CMakeLists.txt +++ b/tests/auto/gui/itemmodels/CMakeLists.txt @@ -1,6 +1,9 @@ # Generated from itemmodels.pro. add_subdirectory(qstandarditem) +if(NOT MINGW) + add_subdirectory(qfilesystemmodel) +endif() if(TARGET Qt::Widgets) add_subdirectory(qstandarditemmodel) endif() diff --git a/tests/auto/gui/itemmodels/itemmodels.pro b/tests/auto/gui/itemmodels/itemmodels.pro index 8a300d0210..cde70aa2b2 100644 --- a/tests/auto/gui/itemmodels/itemmodels.pro +++ b/tests/auto/gui/itemmodels/itemmodels.pro @@ -1,7 +1,10 @@ TEMPLATE=subdirs SUBDIRS= \ qstandarditem \ - qstandarditemmodel + qstandarditemmodel \ + qfilesystemmodel + +mingw: SUBDIRS -= qfilesystemmodel # QTBUG-29403 !qtHaveModule(widgets): SUBDIRS -= \ qstandarditemmodel diff --git a/tests/auto/widgets/dialogs/qfilesystemmodel/.gitignore b/tests/auto/gui/itemmodels/qfilesystemmodel/.gitignore index 9804e5a3d7..9804e5a3d7 100644 --- a/tests/auto/widgets/dialogs/qfilesystemmodel/.gitignore +++ b/tests/auto/gui/itemmodels/qfilesystemmodel/.gitignore diff --git a/tests/auto/widgets/dialogs/qfilesystemmodel/BLACKLIST b/tests/auto/gui/itemmodels/qfilesystemmodel/BLACKLIST index 4119afce84..4119afce84 100644 --- a/tests/auto/widgets/dialogs/qfilesystemmodel/BLACKLIST +++ b/tests/auto/gui/itemmodels/qfilesystemmodel/BLACKLIST diff --git a/tests/auto/widgets/dialogs/qfilesystemmodel/CMakeLists.txt b/tests/auto/gui/itemmodels/qfilesystemmodel/CMakeLists.txt index 595b30bd56..595b30bd56 100644 --- a/tests/auto/widgets/dialogs/qfilesystemmodel/CMakeLists.txt +++ b/tests/auto/gui/itemmodels/qfilesystemmodel/CMakeLists.txt diff --git a/tests/auto/widgets/dialogs/qfilesystemmodel/qfilesystemmodel.pro b/tests/auto/gui/itemmodels/qfilesystemmodel/qfilesystemmodel.pro index db8cf7de3f..db8cf7de3f 100644 --- a/tests/auto/widgets/dialogs/qfilesystemmodel/qfilesystemmodel.pro +++ b/tests/auto/gui/itemmodels/qfilesystemmodel/qfilesystemmodel.pro diff --git a/tests/auto/widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp b/tests/auto/gui/itemmodels/qfilesystemmodel/tst_qfilesystemmodel.cpp index e814e79dbe..e814e79dbe 100644 --- a/tests/auto/widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp +++ b/tests/auto/gui/itemmodels/qfilesystemmodel/tst_qfilesystemmodel.cpp diff --git a/tests/auto/widgets/dialogs/CMakeLists.txt b/tests/auto/widgets/dialogs/CMakeLists.txt index 0c52076efe..13c4e6cad8 100644 --- a/tests/auto/widgets/dialogs/CMakeLists.txt +++ b/tests/auto/widgets/dialogs/CMakeLists.txt @@ -10,9 +10,6 @@ add_subdirectory(qinputdialog) add_subdirectory(qmessagebox) add_subdirectory(qprogressdialog) add_subdirectory(qwizard) -if(NOT MINGW) - add_subdirectory(qfilesystemmodel) -endif() if(QT_FEATURE_private_tests) add_subdirectory(qsidebar) endif() diff --git a/tests/auto/widgets/dialogs/dialogs.pro b/tests/auto/widgets/dialogs/dialogs.pro index cf548f2dea..b4217a219d 100644 --- a/tests/auto/widgets/dialogs/dialogs.pro +++ b/tests/auto/widgets/dialogs/dialogs.pro @@ -5,7 +5,6 @@ SUBDIRS=\ qerrormessage \ qfiledialog \ qfiledialog2 \ - qfilesystemmodel \ qfontdialog \ qinputdialog \ qmessagebox \ @@ -17,4 +16,4 @@ SUBDIRS=\ qsidebar \ mac:qinputdialog.CONFIG += no_check_target # QTBUG-25496 -mingw: SUBDIRS -= qfilesystemmodel # QTBUG-29403 + diff --git a/tests/auto/widgets/dialogs/qfiledialog2/tst_qfiledialog2.cpp b/tests/auto/widgets/dialogs/qfiledialog2/tst_qfiledialog2.cpp index e6130c56b1..cbb1c72b11 100644 --- a/tests/auto/widgets/dialogs/qfiledialog2/tst_qfiledialog2.cpp +++ b/tests/auto/widgets/dialogs/qfiledialog2/tst_qfiledialog2.cpp @@ -49,7 +49,7 @@ #include <qmenu.h> #include <qrandom.h> #include "../../../../../src/widgets/dialogs/qsidebar_p.h" -#include "../../../../../src/widgets/dialogs/qfilesystemmodel_p.h" +#include "../../../../../src/gui/itemmodels/qfilesystemmodel_p.h" #include "../../../../../src/widgets/dialogs/qfiledialog_p.h" #include <private/qguiapplication_p.h> diff --git a/tests/auto/widgets/dialogs/qsidebar/tst_qsidebar.cpp b/tests/auto/widgets/dialogs/qsidebar/tst_qsidebar.cpp index 146a9e262d..20866a0fa7 100644 --- a/tests/auto/widgets/dialogs/qsidebar/tst_qsidebar.cpp +++ b/tests/auto/widgets/dialogs/qsidebar/tst_qsidebar.cpp @@ -29,7 +29,8 @@ #include <QtTest/QtTest> #include <QtWidgets/private/qsidebar_p.h> -#include <QtWidgets/private/qfilesystemmodel_p.h> +#include <QtGui/private/qfilesystemmodel_p.h> +#include <QtWidgets/qfileiconprovider.h> class tst_QSidebar : public QObject { Q_OBJECT @@ -40,12 +41,16 @@ private slots: void addUrls(); void goToUrl(); + +private: + QFileIconProvider defaultIconProvider; }; void tst_QSidebar::setUrls() { QList<QUrl> urls; QFileSystemModel fsmodel; + fsmodel.setIconProvider(&defaultIconProvider); QSidebar qsidebar; qsidebar.setModelAndUrls(&fsmodel, urls); QAbstractItemModel *model = qsidebar.model(); @@ -67,6 +72,7 @@ void tst_QSidebar::selectUrls() urls << QUrl::fromLocalFile(QDir::rootPath()) << QUrl::fromLocalFile(QDir::temp().absolutePath()); QFileSystemModel fsmodel; + fsmodel.setIconProvider(&defaultIconProvider); QSidebar qsidebar; qsidebar.setModelAndUrls(&fsmodel, urls); @@ -79,6 +85,7 @@ void tst_QSidebar::addUrls() { QList<QUrl> emptyUrls; QFileSystemModel fsmodel; + fsmodel.setIconProvider(&defaultIconProvider); QSidebar qsidebar; qsidebar.setModelAndUrls(&fsmodel, emptyUrls); QAbstractItemModel *model = qsidebar.model(); @@ -179,6 +186,7 @@ void tst_QSidebar::goToUrl() urls << QUrl::fromLocalFile(QDir::rootPath()) << QUrl::fromLocalFile(QDir::temp().absolutePath()); QFileSystemModel fsmodel; + fsmodel.setIconProvider(&defaultIconProvider); QSidebar qsidebar; qsidebar.setModelAndUrls(&fsmodel, urls); qsidebar.show(); |