diff --git a/kdecore/services/kmimetype.cpp b/kdecore/services/kmimetype.cpp index e5772fb7..38a7b559 100644 --- a/kdecore/services/kmimetype.cpp +++ b/kdecore/services/kmimetype.cpp @@ -322,7 +322,7 @@ bool KMimeType::isBinaryData(const QString &fileName) return isBufferBinaryData(file.read(32)); } -QString KMimeType::iconNameForUrl(const KUrl &url, mode_t mode) +QString KMimeType::iconNameForUrl(const KUrl &url, mode_t mode, const QString &_mimeType) { static const QLatin1String s_trashprotocol = QLatin1String("trash"); static const QString s_usertrash = QString::fromLatin1("user-trash"); @@ -340,7 +340,7 @@ QString KMimeType::iconNameForUrl(const KUrl &url, mode_t mode) return i; } - const KMimeType::Ptr mt = findByUrl(url, mode); + const KMimeType::Ptr mt = (_mimeType.isEmpty() ? findByUrl(url, mode) : KMimeType::mimeType(_mimeType)); if (!mt) { return QString(); } diff --git a/kdecore/services/kmimetype.h b/kdecore/services/kmimetype.h index d6c9b1df..a007792a 100644 --- a/kdecore/services/kmimetype.h +++ b/kdecore/services/kmimetype.h @@ -63,12 +63,12 @@ public: * KIconLoader::loadMimeTypeIcon to load the icon. * * @param url URL for the file - * @param mode the mode of the file. The mode may modify the icon with overlays that show - * special properties of the icon. Use 0 for default + * @param mode the mode of the file. Use 0 for default + * @param mimeType the mime type if known. Use empty string to determine it from @p url * @return the name of the icon. The name of a default icon if there is no icon for the mime * type */ - static QString iconNameForUrl(const KUrl &url, mode_t mode = 0); + static QString iconNameForUrl(const KUrl &url, mode_t mode = 0, const QString &mimeType = QString()); /** * Return the "favicon" for the given @p url if available. Does NOT attempt to download the diff --git a/kio/kio/kfileitem.cpp b/kio/kio/kfileitem.cpp index dd43b593..f34c888d 100644 --- a/kio/kio/kfileitem.cpp +++ b/kio/kio/kfileitem.cpp @@ -537,17 +537,16 @@ QString KFileItem::iconName() const return d->m_iconName; } + KMimeType::Ptr mime; // Use guessed mimetype for the icon if (!d->m_guessedMimeType.isEmpty()) { - KMimeType::Ptr mime = KMimeType::mimeType(d->m_guessedMimeType); - if (mime) { - d->m_iconName = mime->iconName(d->m_url); - return d->m_iconName; - } + mime = KMimeType::mimeType(d->m_guessedMimeType); + } else { + mime = mimeTypePtr(); } // kDebug() << "finding icon for" << d->m_url << ":" << d->m_iconName; - d->m_iconName = KMimeType::iconNameForUrl(d->m_url, d->m_fileMode); + d->m_iconName = KMimeType::iconNameForUrl(d->m_url, d->m_fileMode, mime ? mime->name() : QString()); return d->m_iconName; }