diff --git a/kdeui/widgets/khistorycombobox.cpp b/kdeui/widgets/khistorycombobox.cpp index 69e41e26..e0f983ea 100644 --- a/kdeui/widgets/khistorycombobox.cpp +++ b/kdeui/widgets/khistorycombobox.cpp @@ -38,8 +38,7 @@ static QPixmap kPixmapForUrl(const QString &item, const int height) { -#warning implement icon for KUrl/QUrl into KIconLoader? - // the logic is the same as in KIO::pixmapForUrl() but kdeui cannot depend on kio + // kdeui cannot depend on kio const QString iconName = KMimeType::iconNameForUrl(KUrl(item)); return KIconLoader::global()->loadMimeTypeIcon(iconName, KIconLoader::Desktop, height); } @@ -380,7 +379,8 @@ void KHistoryComboBox::insertItems( const QStringList& items ) while ( it != itEnd ) { const QString item = *it; - if ( !item.isEmpty() ) { // only insert non-empty items); + if ( !item.isEmpty() ) { + // only insert non-empty items); addItem( kPixmapForUrl(item, iconSize().height()), item ); } ++it; diff --git a/kio/kfile/kfileplaceeditdialog.h b/kio/kfile/kfileplaceeditdialog.h index 816ee1d7..c2f659bf 100644 --- a/kio/kfile/kfileplaceeditdialog.h +++ b/kio/kfile/kfileplaceeditdialog.h @@ -60,7 +60,7 @@ public: * @p parent the parent-widget for the dialog * * If you leave the icon empty, the default icon for the given url will be - * used (KMimeType::pixmapForUrl()). + * used (KMimeType::iconNameForUrl()). */ static bool getInformation( bool allowGlobal, KUrl& url, QString& label, QString& icon, @@ -83,7 +83,7 @@ public: * @p parent the parent-widget for the dialog * * If you leave the icon empty, the default icon for the given url will be - * used (KMimeType::pixmapForUrl()). + * used (KMimeType::iconNameForUrl()). */ KFilePlaceEditDialog(bool allowGlobal, const KUrl& url, const QString& label, const QString &icon, diff --git a/kio/kfile/kfilewidget.cpp b/kio/kfile/kfilewidget.cpp index b01c2329..b82cfd6d 100644 --- a/kio/kfile/kfilewidget.cpp +++ b/kio/kfile/kfilewidget.cpp @@ -326,11 +326,11 @@ KFileWidget::KFileWidget( const KUrl& _startDir, QWidget *parent ) KUrlComboBox *pathCombo = d->urlNavigator->editor(); u.setPath(QDir::rootPath()); pathCombo->addDefaultUrl(u, - KIO::pixmapForUrl(u, 0, KIconLoader::Small), + KIO::pixmapForUrl(u, KIconLoader::Small), u.toLocalFile()); u.setPath(QDir::homePath()); - pathCombo->addDefaultUrl(u, KIO::pixmapForUrl(u, 0, KIconLoader::Small), + pathCombo->addDefaultUrl(u, KIO::pixmapForUrl(u, KIconLoader::Small), u.path(KUrl::AddTrailingSlash)); KUrl docPath; @@ -339,13 +339,13 @@ KFileWidget::KFileWidget( const KUrl& _startDir, QWidget *parent ) QDir(docPath.path(KUrl::AddTrailingSlash)).exists() ) { pathCombo->addDefaultUrl( docPath, - KIO::pixmapForUrl( docPath, 0, KIconLoader::Small ), + KIO::pixmapForUrl( docPath, KIconLoader::Small ), docPath.path(KUrl::AddTrailingSlash)); } u.setPath( KGlobalSettings::desktopPath() ); pathCombo->addDefaultUrl(u, - KIO::pixmapForUrl(u, 0, KIconLoader::Small), + KIO::pixmapForUrl(u, KIconLoader::Small), u.path(KUrl::AddTrailingSlash)); d->ops = new KDirOperator(KUrl(), d->opsWidget); @@ -1165,19 +1165,17 @@ void KFileWidgetPrivate::removeDummyHistoryEntry() void KFileWidgetPrivate::setLocationText(const KUrl& url) { if (!url.isEmpty()) { - QPixmap mimeTypeIcon = KIconLoader::global()->loadMimeTypeIcon( KMimeType::iconNameForUrl( url ), KIconLoader::Small ); + QPixmap urlIcon = KIO::pixmapForUrl( url, KIconLoader::Small ); if (url.hasPath()) { - if (!url.directory().isEmpty()) - { + if (!url.directory().isEmpty()) { KUrl u(url); u.setPath(u.directory()); q->setUrl(u, false); - } - else { + } else { q->setUrl(url.path(), false); } } - setDummyHistoryEntry(url.fileName() , mimeTypeIcon); + setDummyHistoryEntry(url.fileName(), urlIcon); } else { removeDummyHistoryEntry(); } @@ -1219,8 +1217,7 @@ void KFileWidgetPrivate::setLocationText( const KUrl::List& urlList ) setDummyHistoryEntry( urls, QPixmap(), false ); } else if ( urlList.count() == 1 ) { - const QPixmap mimeTypeIcon = KIconLoader::global()->loadMimeTypeIcon( KMimeType::iconNameForUrl( urlList[0] ), KIconLoader::Small ); - setDummyHistoryEntry( relativePathOrUrl(currUrl, urlList[0]), mimeTypeIcon ); + setDummyHistoryEntry( relativePathOrUrl(currUrl, urlList[0]), KIO::pixmapForUrl(urlList[0], KIconLoader::Small)); } else { removeDummyHistoryEntry(); } diff --git a/kio/kio/global.cpp b/kio/kio/global.cpp index 12806e43..63de17f7 100644 --- a/kio/kio/global.cpp +++ b/kio/kio/global.cpp @@ -23,13 +23,14 @@ #include #include -#include #include #include #include #include #include #include +#include +#include #include #include @@ -976,16 +977,13 @@ KIO_EXPORT QByteArray KIO::rawErrorDetail(int errorCode, const QString &errorTex } /*************************************************************** - * * Utility functions - * ***************************************************************/ - -QPixmap KIO::pixmapForUrl( const KUrl & _url, mode_t _mode, KIconLoader::Group _group, - int _force_size, int _state, QString * _path ) +QPixmap KIO::pixmapForUrl(const KUrl &url, KIconLoader::Group group, + int force_size, int state, QString *path) { - const QString iconName = KMimeType::iconNameForUrl( _url, _mode ); - return KIconLoader::global()->loadMimeTypeIcon( iconName, _group, _force_size, _state, QStringList(), _path ); + const KFileItem fileitem(url); + return KIconLoader::global()->loadIcon(fileitem.iconName(), group, force_size, state, fileitem.overlays(), path); } KJobTrackerInterface *KIO::getJobTracker() diff --git a/kio/kio/global.h b/kio/kio/global.h index a48799a3..2dbec028 100644 --- a/kio/kio/global.h +++ b/kio/kio/global.h @@ -239,23 +239,16 @@ namespace KIO /** * Convenience method to find the pixmap for a URL. * - * Call this one when you don't know the mimetype. - * - * @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 _group The icon group where the icon is going to be used. - * @param _force_size Override globally configured icon size. - * Use 0 for the default size - * @param _state The icon state, one of: KIconLoader::DefaultState, + * @param url URL for the file. + * @param group The icon group where the icon is going to be used. + * @param force_size Override globally configured icon size. Use 0 for the default size + * @param state The icon state, one of: KIconLoader::DefaultState, * KIconLoader::ActiveState or KIconLoader::DisabledState. - * @param _path Output parameter to get the full path. Seldom needed. - * Ignored if 0 + * @param path Output parameter to get the full path, seldom needed. * @return the pixmap of the URL, can be a default icon if not found */ - KIO_EXPORT QPixmap pixmapForUrl( const KUrl & _url, mode_t _mode = 0, KIconLoader::Group _group = KIconLoader::Desktop, - int _force_size = 0, int _state = 0, QString * _path = 0 ); + KIO_EXPORT QPixmap pixmapForUrl(const KUrl &url, KIconLoader::Group group = KIconLoader::Desktop, + int force_size = 0, int state = 0, QString *path = nullptr); KIO_EXPORT KJobTrackerInterface *getJobTracker(); diff --git a/kio/kio/kfileitem.cpp b/kio/kio/kfileitem.cpp index 3850e586..cc422072 100644 --- a/kio/kio/kfileitem.cpp +++ b/kio/kio/kfileitem.cpp @@ -723,7 +723,6 @@ bool KFileItem::isFile() const return !isDir(); } - QString KFileItem::getStatusBarInfo() const { if (!d) { @@ -800,8 +799,7 @@ bool KFileItem::cmp(const KFileItem &item) const && d->m_entry.stringValue(KIO::UDSEntry::UDS_ICON_NAME) == item.d->m_entry.stringValue(KIO::UDSEntry::UDS_ICON_NAME) ); - // Don't compare the mimetypes here. They might not be known, and we don't want to - // do the slow operation of determining them here. + // Don't compare the mimetypes here } bool KFileItem::operator==(const KFileItem &other) const @@ -1036,11 +1034,10 @@ KMimeType::Ptr KFileItem::mimeTypePtr() const return KMimeType::Ptr(); } if (!d->m_pMimeType) { - // On-demand fast (but not always accurate) mimetype determination Q_ASSERT(!d->m_url.isEmpty()); d->m_pMimeType = KMimeType::findByUrl( d->m_url, d->m_fileMode, - // use fast mode if delayed mimetype determination can refine it later + // use fast mode if not local (content cannot be read) !d->m_bIsLocalUrl ); }