Move QFileSystemModel into QtGui
This requires a QAbstractFileIconProvider in QtGui, as the standard QFileIconProvider depends on QStyle, and cannot be moved out of QtWidgets. QAbstractFileIconProvider returns strings for file types, but returns no icons yet. Support for a default icon set might be added in a follow-up commit. Change-Id: Ib9d095cd612fdcf04db62f2e40709fcffe3dc2b7 Fixes: QTBUG-66177 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>bb10
parent
e24bbc4871
commit
fb9ec8ad44
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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.",
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
@ -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
|
||||
|
|
@ -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
|
||||
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
@ -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
|
||||
|
|
@ -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);
|
||||
|
|
@ -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;
|
||||
|
|
@ -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)) {
|
||||
|
|
@ -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>
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
|
|
|
|||
|
|
@ -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.",
|
||||
|
|
|
|||
|
|
@ -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 \
|
||||
|
|
|
|||
|
|
@ -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())
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
{
|
||||
}
|
||||
QFileIconProvider::~QFileIconProvider() = default;
|
||||
|
||||
/*!
|
||||
\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;
|
||||
}
|
||||
|
||||
/*!
|
||||
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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
|
|
|||
|
|
@ -1,7 +1,10 @@
|
|||
TEMPLATE=subdirs
|
||||
SUBDIRS= \
|
||||
qstandarditem \
|
||||
qstandarditemmodel
|
||||
qstandarditemmodel \
|
||||
qfilesystemmodel
|
||||
|
||||
mingw: SUBDIRS -= qfilesystemmodel # QTBUG-29403
|
||||
|
||||
!qtHaveModule(widgets): SUBDIRS -= \
|
||||
qstandarditemmodel
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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>
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
Loading…
Reference in New Issue