diff options
Diffstat (limited to 'src/widgets/itemviews/qfileiconprovider.cpp')
-rw-r--r-- | src/widgets/itemviews/qfileiconprovider.cpp | 152 |
1 files changed, 9 insertions, 143 deletions
diff --git a/src/widgets/itemviews/qfileiconprovider.cpp b/src/widgets/itemviews/qfileiconprovider.cpp index d70d47be5e..003fef4224 100644 --- a/src/widgets/itemviews/qfileiconprovider.cpp +++ b/src/widgets/itemviews/qfileiconprovider.cpp @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWidgets 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "qfileiconprovider.h" #include "qfileiconprovider_p.h" @@ -67,29 +31,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 +98,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; -} +QFileIconProvider::~QFileIconProvider() = default; /*! - \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. + \reimp */ QIcon QFileIconProvider::icon(IconType type) const @@ -221,21 +136,13 @@ QIcon QFileIconProvider::icon(IconType type) const return QIcon(); } -static inline QPlatformTheme::IconOptions toThemeIconOptions(QFileIconProvider::Options options) -{ - QPlatformTheme::IconOptions result; - if (options & QFileIconProvider::DontUseCustomDirectoryIcons) - result |= QPlatformTheme::DontUseCustomDirectoryIcons; - return result; -} - QIcon QFileIconProviderPrivate::getIcon(const QFileInfo &fi) const { - return QGuiApplicationPrivate::platformTheme()->fileIcon(fi, toThemeIconOptions(options)); + return getPlatformThemeIcon(fi); } /*! - Returns an icon for the file described by \a info. + \reimp */ QIcon QFileIconProvider::icon(const QFileInfo &info) const @@ -292,45 +199,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 |