CVS commit by faure: Make iconForURL("trash:/") use the trash icon, i.e. prefer the protocol icon [or favicon] when there's one, over the mimetype icon, for the root of a protocol. Added regression tests for iconForURL(). [but this wasn't a regression :)] BUG: 100321 A tests/kmimetypetest.cpp 1.1 [LGPL] M +56 -48 kio/kmimetype.cpp 1.194 M +2 -1 tests/Makefile.am 1.60 --- kdelibs/kio/kio/kmimetype.cpp #1.193:1.194 @@ -504,15 +504,23 @@ QPixmap KMimeType::pixmapForURL( const K QString KMimeType::iconForURL( const KURL & _url, mode_t _mode ) { - KMimeType::Ptr mt = findByURL( _url, _mode, _url.isLocalFile(), + const KMimeType::Ptr mt = findByURL( _url, _mode, _url.isLocalFile(), false /*HACK*/); static const QString& unknown = KGlobal::staticQString("unknown"); - QString i( mt->icon( _url, _url.isLocalFile() )); + const QString mimeTypeIcon = mt->icon( _url, _url.isLocalFile() ); + QString i = mimeTypeIcon; // if we don't find an icon, maybe we can use the one for the protocol - if ( i == unknown || i.isEmpty() || mt == defaultMimeTypePtr()) { + if ( i == unknown || i.isEmpty() || mt == defaultMimeTypePtr() + // and for the root of the protocol (e.g. trash:/) the protocol icon has priority over the mimetype icon + || _url.path().length() <= 1 ) + { i = favIconForURL( _url ); // maybe there is a favicon? if ( i.isEmpty() ) i = KProtocolInfo::icon( _url.protocol() ); + + // root of protocol: if we found nothing, revert to mimeTypeIcon (which is usually "folder") + if ( _url.path().length() <= 1 && ( i == unknown || i.isEmpty() ) ) + i = mimeTypeIcon; } return i; --- kdelibs/kio/tests/Makefile.am #1.59:1.60 @@ -28,5 +28,5 @@ kmimefromext kpropsdlgtest kmfitest dataprotocoltest \ kprotocolinfotest ksycocaupdatetest netaccesstest jobtest \ - kurlcompletiontest + kurlcompletiontest kmimetypetest # Unfortunately some tests depend on the network settings, it seems @@ -71,4 +71,5 @@ jobtest_SOURCES = jobtest.cpp kurlcompletiontest_SOURCES = kurlcompletiontest.cpp +kmimetypetest_SOURCES = kmimetypetest.cpp # kfile meta stuff. Comment this in, if you want a small