]> cloud.milkyroute.net Git - dolphin.git/commitdiff
tried to simplify the logic to decide whether the information panel should show the...
authorPeter Penz <peter.penz19@gmail.com>
Fri, 27 Jun 2008 20:01:04 +0000 (20:01 +0000)
committerPeter Penz <peter.penz19@gmail.com>
Fri, 27 Jun 2008 20:01:04 +0000 (20:01 +0000)
CCMAIL: sebastian@trueg.de

svn path=/trunk/KDE/kdebase/apps/; revision=825317

src/infosidebarpage.cpp
src/infosidebarpage.h

index 2cfe56bf7977d500b51cdd7356279f9cd470bce7..7a11994af95b575c28d5f1dcc6f73791ff2d5c8c 100644 (file)
@@ -181,19 +181,18 @@ void InfoSidebarPage::showItemInfo()
 
     cancelRequest();
 
-    const KUrl file = (!m_fileItem.isNull() || m_selection.isEmpty()) ? m_shownUrl : m_selection[0].url();
+    const KUrl file = fileUrl();
     if (!file.isValid()) {
         return;
     }
 
-    const int selectionCount = m_selection.count();
-    if (m_fileItem.isNull() && (selectionCount > 1)) {
+    if (showMultipleSelectionInfo()) {
         KIconLoader iconLoader;
         QPixmap icon = iconLoader.loadIcon("dialog-information",
                                            KIconLoader::NoGroup,
                                            KIconLoader::SizeEnormous);
         m_preview->setPixmap(icon);
-        m_nameLabel->setText(i18ncp("@info", "%1 item selected", "%1 items selected", selectionCount));
+        m_nameLabel->setText(i18ncp("@info", "%1 item selected", "%1 items selected",  m_selection.count()));
     } else if (!applyPlace(file)) {
         // try to get a preview pixmap from the item...
         KUrl::List list;
@@ -339,10 +338,26 @@ void InfoSidebarPage::showMetaInfo()
 {
     m_metaTextLabel->clear();
 
-    const KUrl file = (!m_fileItem.isNull() || m_selection.isEmpty()) ? m_shownUrl : m_selection[0].url();
+    if (showMultipleSelectionInfo()) {
+        if (m_metaDataWidget != 0) {
+            KUrl::List urls;
+            foreach (const KFileItem& item, m_selection) {
+                urls.append(item.targetUrl());
+            }
+            m_metaDataWidget->setFiles(urls);
+        }
 
-    if ((m_selection.size() <= 1) || !m_fileItem.isNull()) {
-        KFileItem fileItem(KFileItem::Unknown, KFileItem::Unknown, file);
+        quint64 totalSize = 0;
+        foreach (const KFileItem& item, m_selection) {
+            // Only count the size of files, not dirs to match what
+            // DolphinViewContainer::selectionStatusBarText() does.
+            if (!item.isDir() && !item.isLink()) {
+                totalSize += item.size();
+            }
+        }
+        m_metaTextLabel->add(i18nc("@label", "Total size:"), KIO::convertSize(totalSize));
+    } else {
+        KFileItem fileItem(KFileItem::Unknown, KFileItem::Unknown, fileUrl());
         fileItem.refresh();
 
         if (fileItem.isDir()) {
@@ -382,24 +397,6 @@ void InfoSidebarPage::showMetaInfo()
         if (m_metaDataWidget != 0) {
             m_metaDataWidget->setFile(fileItem.targetUrl());
         }
-    } else {
-        if (m_metaDataWidget != 0) {
-            KUrl::List urls;
-            foreach (const KFileItem& item, m_selection) {
-                urls.append(item.targetUrl());
-            }
-            m_metaDataWidget->setFiles(urls);
-        }
-
-        quint64 totalSize = 0;
-        foreach (const KFileItem& item, m_selection) {
-            // Only count the size of files, not dirs to match what
-            // DolphinViewContainer::selectionStatusBarText() does.
-            if (!item.isDir() && !item.isLink()) {
-                totalSize += item.size();
-            }
-        }
-        m_metaTextLabel->add(i18nc("@label", "Total size:"), KIO::convertSize(totalSize));
     }
 }
 
@@ -441,6 +438,16 @@ bool InfoSidebarPage::convertMetaInfo(const QString& key, QString& text) const
     return false;
 }
 
+KUrl InfoSidebarPage::fileUrl() const
+{
+    return (!m_fileItem.isNull() || m_selection.isEmpty()) ? m_shownUrl : m_selection[0].url();
+}
+
+bool InfoSidebarPage::showMultipleSelectionInfo() const
+{
+    return m_fileItem.isNull() && (m_selection.count() > 1);
+}
+
 void InfoSidebarPage::init()
 {
     const int spacing = KDialog::spacingHint();
index b15a01814bcb8506ad1055ec1b4fa87f95218bbc..5663c119c277a6cdc52711e64d4590855d726dee 100644 (file)
@@ -139,6 +139,23 @@ private:
      */
     bool convertMetaInfo(const QString& key, QString& text) const;
 
+    /**
+     * Returns the URL of the file where the preview and meta information
+     * should be received, if InfoSidebarPage::showMultipleSelectionInfo()
+     * returns false.
+     */
+    KUrl fileUrl() const;
+
+    /**
+     * Returns true, if the meta information should be shown for
+     * the items multiple selected items that are stored in
+     * m_selection. If true is returned, it is assured that
+     * m_selection.count() > 1. If false is returned, the meta
+     * information should be shown for the file
+     * InfosidebarPage::fileUrl();
+     */
+    bool showMultipleSelectionInfo() const;
+
     void init();
 
 private: