Bug 100321 - Regression: KProtocolInfo::icon() not used anymore.
Summary: Regression: KProtocolInfo::icon() not used anymore.
Status: RESOLVED FIXED
Alias: None
Product: kio
Classification: Frameworks and Libraries
Component: general (show other bugs)
Version: unspecified
Platform: unspecified Linux
: NOR normal
Target Milestone: ---
Assignee: David Faure
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-02-26 18:53 UTC by M
Modified: 2005-04-07 14:37 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description M 2005-02-26 18:53:27 UTC
Version:           unknown (using KDE 3.4.0 Level "a" , SUSE 9.2 UNSUPPORTED)
Compiler:          gcc version 3.3.4 (pre 3.3.5 20040809)
OS:                Linux (i686) release 2.6.8-24.11-default

When going to trash:/ in Konqueror, the window icon should be the Trash icon which is used on the desktop.
Comment 1 Stephan Binner 2005-04-05 22:48:11 UTC
KMimeType::iconForURL() doesn't lookup KProtocolInfo::icon() anymore.
Comment 2 David Faure 2005-04-07 14:37:24 UTC
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