Ignore:
Timestamp:
Feb 11, 2010, 11:19:06 PM (15 years ago)
Author:
Dmitry A. Kuminov
Message:

trunk: Merged in qt 4.6.1 sources.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/src/gui/itemviews/qfileiconprovider.cpp

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    56**
    67** This file is part of the QtGui module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     24** In addition, as a special exception, Nokia gives you certain additional
     25** rights.  These rights are described in the Nokia Qt LGPL Exception
     26** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
     
    4646#include <qapplication.h>
    4747#include <qdir.h>
     48#include <qpixmapcache.h>
    4849#if defined(Q_WS_WIN)
    49 #define _WIN32_IE 0x0500
    50 #include <objbase.h>
    51 #include <private/qpixmapdata_p.h>
    52 #include <qpixmapcache.h>
     50#  define _WIN32_IE 0x0500
     51#  include <qt_windows.h>
     52#  include <commctrl.h>
     53#  include <objbase.h>
    5354#elif defined(Q_WS_MAC)
    54 #include <private/qt_mac_p.h>
    55 #endif
     55#  include <private/qt_cocoa_helpers_mac_p.h>
     56#endif
     57
    5658#include <private/qfunctions_p.h>
    57 #ifdef Q_OS_WINCE
    58 #include <Commctrl.h>
     59#include <private/qguiplatformplugin_p.h>
     60
     61#if defined(Q_WS_X11) && !defined(Q_NO_STYLE_GTK)
     62#  include <private/qgtkstyle_p.h>
     63#  include <private/qt_x11_p.h>
    5964#endif
    6065
    6166#ifndef SHGFI_ADDOVERLAYS
    62 #define SHGFI_ADDOVERLAYS 0x000000020
     67#  define SHGFI_ADDOVERLAYS 0x000000020
    6368#endif
    6469
     
    181186QFileIconProvider::~QFileIconProvider()
    182187{
    183     delete d_ptr;
    184188}
    185189
     
    216220{
    217221    QIcon retIcon;
    218     QString fileExtension = fileInfo.suffix().toUpper();
    219     fileExtension.prepend( QLatin1String(".") );
     222    const QString fileExtension = QLatin1Char('.') + fileInfo.suffix().toUpper();
    220223
    221224    QString key;
     
    245248    //Get the small icon
    246249#ifndef Q_OS_WINCE
    247     val = SHGetFileInfo((const WCHAR *)QDir::toNativeSeparators(fileInfo.filePath()).utf16(), 0, &info,
     250    val = SHGetFileInfo((const wchar_t *)QDir::toNativeSeparators(fileInfo.filePath()).utf16(), 0, &info,
    248251                        sizeof(SHFILEINFO), SHGFI_ICON|SHGFI_SMALLICON|SHGFI_SYSICONINDEX|SHGFI_ADDOVERLAYS);
    249252#else
    250     val = SHGetFileInfo((const WCHAR *)QDir::toNativeSeparators(fileInfo.filePath()).utf16(), 0, &info,
     253    val = SHGetFileInfo((const wchar_t *)QDir::toNativeSeparators(fileInfo.filePath()).utf16(), 0, &info,
    251254                        sizeof(SHFILEINFO), SHGFI_SMALLICON|SHGFI_SYSICONINDEX);
    252255#endif
     
    266269        if (pixmap.isNull()) {
    267270#ifndef Q_OS_WINCE
    268             pixmap = convertHIconToPixmap(info.hIcon);
    269 #else
    270             pixmap = convertHIconToPixmap(ImageList_GetIcon((HIMAGELIST) val, info.iIcon, ILD_NORMAL));
     271            pixmap = QPixmap::fromWinHICON(info.hIcon);
     272#else
     273            pixmap = QPixmap::fromWinHICON(ImageList_GetIcon((HIMAGELIST) val, info.iIcon, ILD_NORMAL));
    271274#endif
    272275            if (!pixmap.isNull()) {
     
    284287    //Get the big icon
    285288#ifndef Q_OS_WINCE
    286     val = SHGetFileInfo((const WCHAR *)QDir::toNativeSeparators(fileInfo.filePath()).utf16(), 0, &info,
     289    val = SHGetFileInfo((const wchar_t *)QDir::toNativeSeparators(fileInfo.filePath()).utf16(), 0, &info,
    287290                        sizeof(SHFILEINFO), SHGFI_ICON|SHGFI_LARGEICON|SHGFI_SYSICONINDEX|SHGFI_ADDOVERLAYS);
    288291#else
    289     val = SHGetFileInfo((const WCHAR *)QDir::toNativeSeparators(fileInfo.filePath()).utf16(), 0, &info,
     292    val = SHGetFileInfo((const wchar_t *)QDir::toNativeSeparators(fileInfo.filePath()).utf16(), 0, &info,
    290293                        sizeof(SHFILEINFO), SHGFI_LARGEICON|SHGFI_SYSICONINDEX);
    291294#endif
     
    296299        }
    297300#ifndef Q_OS_WINCE
    298         pixmap = convertHIconToPixmap(info.hIcon);
    299 #else
    300         pixmap = convertHIconToPixmap(ImageList_GetIcon((HIMAGELIST) val, info.iIcon, ILD_NORMAL), true);
     301        pixmap = QPixmap::fromWinHICON(info.hIcon);
     302#else
     303        pixmap = QPixmap::fromWinHICON(ImageList_GetIcon((HIMAGELIST) val, info.iIcon, ILD_NORMAL));
    301304#endif
    302305        if (!pixmap.isNull()) {
     
    317320{
    318321    QIcon retIcon;
     322    QString fileExtension = fi.suffix().toUpper();
     323    fileExtension.prepend(QLatin1String("."));
     324
     325    const QString keyBase = QLatin1String("qt_") + fileExtension;
     326
     327    QPixmap pixmap;
     328    if (fi.isFile() && !fi.isExecutable() && !fi.isSymLink()) {
     329        QPixmapCache::find(keyBase + QLatin1String("16"), pixmap);
     330    }
     331
     332    if (!pixmap.isNull()) {
     333        retIcon.addPixmap(pixmap);
     334        if (QPixmapCache::find(keyBase + QLatin1String("32"), pixmap)) {
     335            retIcon.addPixmap(pixmap);
     336            if (QPixmapCache::find(keyBase + QLatin1String("64"), pixmap)) {
     337                retIcon.addPixmap(pixmap);
     338                if (QPixmapCache::find(keyBase + QLatin1String("128"), pixmap)) {
     339                    retIcon.addPixmap(pixmap);
     340                    return retIcon;
     341                }
     342            }
     343        }
     344    }
     345
     346
    319347    FSRef macRef;
    320348    OSStatus status = FSPathMakeRef(reinterpret_cast<const UInt8*>(fi.canonicalFilePath().toUtf8().constData()),
     
    329357    IconRef iconRef;
    330358    SInt16 iconLabel;
    331     status = GetIconRefFromFileInfo(&macRef, macName.length, macName.unicode, kIconServicesCatalogInfoMask, &info, kIconServicesNormalUsageFlag, &iconRef, &iconLabel);
     359    status = GetIconRefFromFileInfo(&macRef, macName.length, macName.unicode,
     360                                    kIconServicesCatalogInfoMask, &info, kIconServicesNormalUsageFlag,
     361                                    &iconRef, &iconLabel);
    332362    if (status != noErr)
    333363        return retIcon;
    334     extern void qt_mac_constructQIconFromIconRef(const IconRef, const IconRef, QIcon*, QStyle::StandardPixmap = QStyle::SP_CustomBase); // qmacstyle_mac.cpp
    335364    qt_mac_constructQIconFromIconRef(iconRef, 0, &retIcon);
    336365    ReleaseIconRef(iconRef);
     366
     367    pixmap = retIcon.pixmap(16);
     368    QPixmapCache::insert(keyBase + QLatin1String("16"), pixmap);
     369    pixmap = retIcon.pixmap(32);
     370    QPixmapCache::insert(keyBase + QLatin1String("32"), pixmap);
     371    pixmap = retIcon.pixmap(64);
     372    QPixmapCache::insert(keyBase + QLatin1String("64"), pixmap);
     373    pixmap = retIcon.pixmap(128);
     374    QPixmapCache::insert(keyBase + QLatin1String("128"), pixmap);
     375
    337376    return retIcon;
    338377}
     
    347386{
    348387    Q_D(const QFileIconProvider);
     388
     389    QIcon platformIcon = qt_guiPlatformPlugin()->fileSystemIcon(info);
     390    if (!platformIcon.isNull())
     391        return platformIcon;
     392
     393#if defined(Q_WS_X11) && !defined(QT_NO_STYLE_GTK)
     394    if (X11->desktopEnvironment == DE_GNOME) {
     395        QIcon gtkIcon = QGtkStylePrivate::getFilesystemIcon(info);
     396        if (!gtkIcon.isNull())
     397            return gtkIcon;
     398    }
     399#endif
     400
    349401#ifdef Q_WS_MAC
    350402    QIcon retIcon = d->getMacIcon(info);
     
    357409#endif
    358410    if (info.isRoot())
    359 #if defined (Q_WS_WIN) && !defined(Q_OS_WINCE)
     411#if defined (Q_WS_WIN) && !defined(Q_WS_WINCE)
    360412    {
    361         uint type = DRIVE_UNKNOWN;
    362         QT_WA({ type = GetDriveTypeW((wchar_t *)info.absoluteFilePath().utf16()); },
    363         { type = GetDriveTypeA(info.absoluteFilePath().toLocal8Bit()); });
     413        UINT type = GetDriveType((wchar_t *)info.absoluteFilePath().utf16());
    364414
    365415        switch (type) {
     
    417467
    418468    if (info.isDir())
    419         return QApplication::translate("QFileDialog",
    420469#ifdef Q_WS_WIN
    421                                        "File Folder", "Match Windows Explorer"
    422 #else
    423                                        "Folder", "All other platforms"
    424 #endif
    425             );
     470        return QApplication::translate("QFileDialog", "File Folder", "Match Windows Explorer");
     471#else
     472        return QApplication::translate("QFileDialog", "Folder", "All other platforms");
     473#endif
    426474    // Windows   - "File Folder"
    427475    // OS X      - "Folder"
     
    430478
    431479    if (info.isSymLink())
    432         return QApplication::translate("QFileDialog",
    433480#ifdef Q_OS_MAC
    434                                        "Alias", "Mac OS X Finder"
    435 #else
    436                                        "Shortcut", "All other platforms"
    437 #endif
    438             );
     481        return QApplication::translate("QFileDialog", "Alias", "Mac OS X Finder");
     482#else
     483        return QApplication::translate("QFileDialog", "Shortcut", "All other platforms");
     484#endif
    439485    // OS X      - "Alias"
    440486    // Windows   - "Shortcut"
Note: See TracChangeset for help on using the changeset viewer.