Changeset 561 for trunk/src/gui/itemviews/qfileiconprovider.cpp
- Timestamp:
- Feb 11, 2010, 11:19:06 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
-
Property svn:mergeinfo
set to (toggle deleted branches)
/branches/vendor/nokia/qt/4.6.1 merged eligible /branches/vendor/nokia/qt/current merged eligible /branches/vendor/trolltech/qt/current 3-149
-
Property svn:mergeinfo
set to (toggle deleted branches)
-
trunk/src/gui/itemviews/qfileiconprovider.cpp
r2 r561 2 2 ** 3 3 ** 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) 5 6 ** 6 7 ** This file is part of the QtGui module of the Qt Toolkit. … … 21 22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 22 23 ** 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. 27 27 ** 28 28 ** GNU General Public License Usage … … 34 34 ** met: http://www.gnu.org/copyleft/gpl.html. 35 35 ** 36 ** If you are unsure which license is appropriate for your use, please37 ** 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. 38 38 ** $QT_END_LICENSE$ 39 39 ** … … 46 46 #include <qapplication.h> 47 47 #include <qdir.h> 48 #include <qpixmapcache.h> 48 49 #if defined(Q_WS_WIN) 49 # define _WIN32_IE 0x050050 # 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> 53 54 #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 56 58 #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> 59 64 #endif 60 65 61 66 #ifndef SHGFI_ADDOVERLAYS 62 # define SHGFI_ADDOVERLAYS 0x00000002067 # define SHGFI_ADDOVERLAYS 0x000000020 63 68 #endif 64 69 … … 181 186 QFileIconProvider::~QFileIconProvider() 182 187 { 183 delete d_ptr;184 188 } 185 189 … … 216 220 { 217 221 QIcon retIcon; 218 QString fileExtension = fileInfo.suffix().toUpper(); 219 fileExtension.prepend( QLatin1String(".") ); 222 const QString fileExtension = QLatin1Char('.') + fileInfo.suffix().toUpper(); 220 223 221 224 QString key; … … 245 248 //Get the small icon 246 249 #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, 248 251 sizeof(SHFILEINFO), SHGFI_ICON|SHGFI_SMALLICON|SHGFI_SYSICONINDEX|SHGFI_ADDOVERLAYS); 249 252 #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, 251 254 sizeof(SHFILEINFO), SHGFI_SMALLICON|SHGFI_SYSICONINDEX); 252 255 #endif … … 266 269 if (pixmap.isNull()) { 267 270 #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)); 271 274 #endif 272 275 if (!pixmap.isNull()) { … … 284 287 //Get the big icon 285 288 #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, 287 290 sizeof(SHFILEINFO), SHGFI_ICON|SHGFI_LARGEICON|SHGFI_SYSICONINDEX|SHGFI_ADDOVERLAYS); 288 291 #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, 290 293 sizeof(SHFILEINFO), SHGFI_LARGEICON|SHGFI_SYSICONINDEX); 291 294 #endif … … 296 299 } 297 300 #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)); 301 304 #endif 302 305 if (!pixmap.isNull()) { … … 317 320 { 318 321 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 319 347 FSRef macRef; 320 348 OSStatus status = FSPathMakeRef(reinterpret_cast<const UInt8*>(fi.canonicalFilePath().toUtf8().constData()), … … 329 357 IconRef iconRef; 330 358 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); 332 362 if (status != noErr) 333 363 return retIcon; 334 extern void qt_mac_constructQIconFromIconRef(const IconRef, const IconRef, QIcon*, QStyle::StandardPixmap = QStyle::SP_CustomBase); // qmacstyle_mac.cpp335 364 qt_mac_constructQIconFromIconRef(iconRef, 0, &retIcon); 336 365 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 337 376 return retIcon; 338 377 } … … 347 386 { 348 387 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 349 401 #ifdef Q_WS_MAC 350 402 QIcon retIcon = d->getMacIcon(info); … … 357 409 #endif 358 410 if (info.isRoot()) 359 #if defined (Q_WS_WIN) && !defined(Q_ OS_WINCE)411 #if defined (Q_WS_WIN) && !defined(Q_WS_WINCE) 360 412 { 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()); 364 414 365 415 switch (type) { … … 417 467 418 468 if (info.isDir()) 419 return QApplication::translate("QFileDialog",420 469 #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 426 474 // Windows - "File Folder" 427 475 // OS X - "Folder" … … 430 478 431 479 if (info.isSymLink()) 432 return QApplication::translate("QFileDialog",433 480 #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 439 485 // OS X - "Alias" 440 486 // Windows - "Shortcut"
Note:
See TracChangeset
for help on using the changeset viewer.