From: Peter Penz Date: Fri, 18 Jan 2008 18:14:10 +0000 (+0000) Subject: show the correct meta information in the information sidebar also for non-local files X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/commitdiff_plain/c93959934611c95f72e9de350c1dc5b6661f493f show the correct meta information in the information sidebar also for non-local files BUG: 155534 svn path=/trunk/KDE/kdebase/apps/; revision=763141 --- diff --git a/src/infosidebarpage.cpp b/src/infosidebarpage.cpp index 7b0d2d40c..bcb28aa19 100644 --- a/src/infosidebarpage.cpp +++ b/src/infosidebarpage.cpp @@ -48,7 +48,9 @@ InfoSidebarPage::InfoSidebarPage(QWidget* parent) : SidebarPage(parent), m_pendingPreview(false), - m_timer(0), + m_shownUrl(), + m_urlCandidate(), + m_fileItem(), m_preview(0), m_nameLabel(0), m_infoLabel(0), @@ -136,10 +138,13 @@ void InfoSidebarPage::requestDelayedItemInfo(const KFileItem& item) { cancelRequest(); + m_fileItem = KFileItem(); + if (!item.isNull() && (selection().size() <= 1)) { const KUrl url = item.url(); if (!url.isEmpty()) { m_urlCandidate = url; + m_fileItem = item; m_timer->start(TimerDelay); } } @@ -283,16 +288,21 @@ void InfoSidebarPage::showMetaInfo() const KFileItemList& selectedItems = selection(); if (selectedItems.size() <= 1) { - KFileItem fileItem(S_IFDIR, KFileItem::Unknown, m_shownUrl); - fileItem.refresh(); + KFileItem fileItem; + if (m_fileItem.isNull()) { + // no pending request is ongoing + fileItem = KFileItem(KFileItem::Unknown, KFileItem::Unknown, m_shownUrl); + fileItem.refresh(); + } else { + fileItem = m_fileItem; + } if (fileItem.isDir()) { addInfoLine(text, i18nc("@label", "Type:"), i18nc("@label", "Folder")); } else { addInfoLine(text, i18nc("@label", "Type:"), fileItem.mimeComment()); - QString sizeText(KIO::convertSize(fileItem.size())); - addInfoLine(text, i18nc("@label", "Size:"), sizeText); + addInfoLine(text, i18nc("@label", "Size:"), KIO::convertSize(fileItem.size())); addInfoLine(text, i18nc("@label", "Modified:"), fileItem.timeString()); // TODO: See convertMetaInfo below, find a way to display only interesting information @@ -335,8 +345,9 @@ void InfoSidebarPage::showMetaInfo() foreach (const KFileItem& item, selectedItems) { // Only count the size of files, not dirs; to match what // DolphinViewContainer::selectionStatusBarText does. - if (!item.isDir() && !item.isLink()) + if (!item.isDir() && !item.isLink()) { totalSize += item.size(); + } } addInfoLine(text, i18nc("@label", "Total size:"), KIO::convertSize(totalSize)); } diff --git a/src/infosidebarpage.h b/src/infosidebarpage.h index ef014b316..6012e883c 100644 --- a/src/infosidebarpage.h +++ b/src/infosidebarpage.h @@ -139,8 +139,9 @@ private: private: bool m_pendingPreview; QTimer* m_timer; - KUrl m_shownUrl; - KUrl m_urlCandidate; + KUrl m_shownUrl; // URL that is shown as info + KUrl m_urlCandidate; // URL candidate that will replace m_shownURL after a delay + KFileItem m_fileItem; // file item for m_shownUrl if available (otherwise null) PixmapViewer* m_preview; QLabel* m_nameLabel;