summaryrefslogtreecommitdiffstats
path: root/src/widgets/itemviews
diff options
context:
space:
mode:
authorVolker Hilsheimer <volker.hilsheimer@qt.io>2020-08-19 13:40:34 +0200
committerVolker Hilsheimer <volker.hilsheimer@qt.io>2020-08-25 06:33:44 +0200
commitfb9ec8ad44decba7b2878370f3711b61614f035a (patch)
tree6904b3936a8ee7c61a770ef92a4e033bb18b0fc3 /src/widgets/itemviews
parente24bbc4871e6a3711ffaa0e01397a40954465a3a (diff)
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>
Diffstat (limited to 'src/widgets/itemviews')
-rw-r--r--src/widgets/itemviews/qfileiconprovider.cpp102
-rw-r--r--src/widgets/itemviews/qfileiconprovider.h22
-rw-r--r--src/widgets/itemviews/qfileiconprovider_p.h5
3 files changed, 13 insertions, 116 deletions
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;