45 #ifndef QT_NO_FILEICONPROVIDER 51 # define _WIN32_IE 0x0500 53 # include <commctrl.h> 55 #elif defined(Q_WS_MAC) 56 # include <private/qt_cocoa_helpers_mac_p.h> 59 #include <private/qfunctions_p.h> 60 #include <private/qguiplatformplugin_p.h> 62 #if defined(Q_WS_X11) && !defined(QT_NO_STYLE_GTK) 63 # include <private/qgtkstyle_p.h> 64 # include <private/qt_x11_p.h> 67 #ifndef SHGFI_ADDOVERLAYS 68 # define SHGFI_ADDOVERLAYS 0x000000020 69 # define SHGFI_OVERLAYINDEX 0x000000040 95 homePath(
QDir::home().absolutePath()), useCustomDirectoryIcons(true)
224 static int defaultFolderIIcon = -1;
241 const bool cacheableDirIcon = fileInfo.
isDir() && !fileInfo.
isRoot();
242 if (!useCustomDirectoryIcons && defaultFolderIIcon >= 0 && cacheableDirIcon) {
260 unsigned long val = 0;
270 if (cacheableDirIcon && !useCustomDirectoryIcons) {
271 flags |= SHGFI_USEFILEATTRIBUTES;
272 val = SHGetFileInfo(L
"dummy",
273 FILE_ATTRIBUTE_DIRECTORY, &info,
274 sizeof(SHFILEINFO), flags | SHGFI_SMALLICON);
277 0, &
info,
sizeof(SHFILEINFO), flags | SHGFI_SMALLICON);
281 if (val && info.hIcon) {
283 if (!useCustomDirectoryIcons && defaultFolderIIcon < 0)
284 defaultFolderIIcon = info.iIcon;
292 DestroyIcon(info.hIcon);
308 qWarning(
"QFileIconProviderPrivate::getWinIcon() no small icon found");
311 DestroyIcon(info.hIcon);
316 0, &
info,
sizeof(SHFILEINFO), flags | SHGFI_LARGEICON);
318 if (val && info.hIcon) {
334 qWarning(
"QFileIconProviderPrivate::getWinIcon() no large icon found");
336 DestroyIcon(info.hIcon);
341 #elif defined(Q_WS_MAC) 342 QIcon QFileIconProviderPrivate::getMacIcon(
const QFileInfo &fi)
const 376 HFSUniStr255 macName;
377 status = FSGetCatalogInfo(&macRef, kIconServicesCatalogInfoMask, &info, &macName, 0, 0);
382 status = GetIconRefFromFileInfo(&macRef, macName.length, macName.unicode,
383 kIconServicesCatalogInfoMask, &info, kIconServicesNormalUsageFlag,
384 &iconRef, &iconLabel);
388 ReleaseIconRef(iconRef);
391 pixmap = retIcon.
pixmap(16);
393 pixmap = retIcon.
pixmap(32);
395 pixmap = retIcon.
pixmap(64);
397 pixmap = retIcon.
pixmap(128);
415 if (!platformIcon.
isNull())
418 #if defined(Q_WS_X11) && !defined(QT_NO_STYLE_GTK) 427 QIcon retIcon =
d->getMacIcon(info);
430 #elif defined Q_WS_WIN 441 case DRIVE_REMOVABLE:
451 case DRIVE_NO_ROOT_DIR:
The QDir class provides access to directory structures and their contents.
static bool isCacheable(const QFileInfo &fi)
static mach_timebase_info_data_t info
void addPixmap(const QPixmap &pixmap, Mode mode=Normal, State state=Off)
Adds pixmap to the icon, as a specialization for mode and state.
#define SHGFI_OVERLAYINDEX
#define QT_END_NAMESPACE
This macro expands to.
static QPixmap fromWinHICON(HICON hicon)
virtual ~QFileIconProvider()
Destroys the file icon provider.
QByteArray toUtf8() const Q_REQUIRED_RESULT
Returns a UTF-8 representation of the string as a QByteArray.
#define Q_WS_WIN
Defined on Windows.
QString & prepend(QChar c)
QString toUpper() const Q_REQUIRED_RESULT
Returns an uppercase copy of the string.
virtual QIcon icon(IconType type) const
Returns an icon set for the given type.
static LibLoadStatus status
QString absoluteFilePath() const
Returns an absolute path including the file name.
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
static QStyle * style()
Returns the application's style object.
The QString class provides a Unicode character string.
virtual QString type(const QFileInfo &info) const
Returns the type of the file described by info.
StandardPixmap
This enum describes the available standard pixmaps.
static QPixmap * find(const QString &key)
static QString translate(const char *context, const char *key, const char *disambiguation=0, Encoding encoding=CodecForTr)
#define Q_OS_MAC
Defined on MAC OS (synonym for Darwin).
QIcon standardIcon(StandardPixmap standardIcon, const QStyleOption *option=0, const QWidget *widget=0) const
Returns an icon for the given standardIcon.
#define QT_BEGIN_NAMESPACE
This macro expands to.
bool useCustomDirectoryIcons
bool isDir() const
Returns true if this object points to a directory or to a symbolic link to a directory; otherwise ret...
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
bool isNull() const
Returns true if the icon is empty; otherwise returns false.
QString canonicalFilePath() const
Returns the canonical path including the file name, i.e.
Q_CORE_EXPORT void qWarning(const char *,...)
The QFileIconProvider class provides file icons for the QDirModel and the QFileSystemModel classes...
QFileIconProvider()
Constructs a file icon provider.
bool isExecutable() const
Returns true if the file is executable; otherwise returns false.
static QIcon getFilesystemIcon(const QFileInfo &)
#define SHGFI_ADDOVERLAYS
const char * constData() const
Returns a pointer to the data stored in the byte array.
QString arg(qlonglong a, int fieldwidth=0, int base=10, const QChar &fillChar=QLatin1Char(' ')) const Q_REQUIRED_RESULT
int compare(const QString &s) const
bool isRoot() const
Returns true if the object points to a directory or to a symbolic link to a directory, and that directory is the root directory; otherwise returns false.
QIcon getWinIcon(const QFileInfo &fi) const
static QString fromLatin1(const char *, int size=-1)
Returns a QString initialized with the first size characters of the Latin-1 string str...
QString suffix() const
Returns the suffix of the file.
static bool insert(const QString &key, const QPixmap &pixmap)
Inserts a copy of the pixmap pixmap associated with the key into the cache.
void qt_mac_constructQIconFromIconRef(const IconRef icon, const IconRef overlayIcon, QIcon *retIcon, QStyle::StandardPixmap standardIcon)
bool isFile() const
Returns true if this object points to a file or to a symbolic link to a file.
QIcon getIcon(QStyle::StandardPixmap name) const
The QPixmap class is an off-screen image representation that can be used as a paint device...
QFileIconProviderPrivate()
QPixmap pixmap(const QSize &size, Mode mode=Normal, State state=Off) const
Returns a pixmap with the requested size, mode, and state, generating one if necessary.
bool isNull() const
Returns true if this is a null pixmap; otherwise returns false.
bool isSymLink() const
Returns true if this object points to a symbolic link (or to a shortcut on Windows); otherwise return...
The QFileInfo class provides system-independent file information.
QString filePath() const
Returns the file name, including the path (which may be absolute or relative).
static QString toNativeSeparators(const QString &pathName)
Returns pathName with the '/' separators converted to separators that are appropriate for the underly...
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
struct OpaqueIconRef * IconRef
void setUseCustomDirectoryIcons(bool enable)
const ushort * utf16() const
Returns the QString as a '\0\'-terminated array of unsigned shorts.
The QIcon class provides scalable icons in different modes and states.