]> cloud.milkyroute.net Git - dolphin.git/commitdiff
* use existing KFileItem also for the selection instead of creating a new KFileItem...
authorPeter Penz <peter.penz19@gmail.com>
Mon, 30 Jun 2008 17:12:03 +0000 (17:12 +0000)
committerPeter Penz <peter.penz19@gmail.com>
Mon, 30 Jun 2008 17:12:03 +0000 (17:12 +0000)
* don't invoke fileItem() if a multiple selection is provided

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

src/infosidebarpage.cpp

index 0433bfa9cb07d707f3e1d9d04fb5378f730f76d7..8e6bda8e884a7dc68a5b9340de115c9df77c67ab 100644 (file)
@@ -183,12 +183,6 @@ void InfoSidebarPage::showItemInfo()
 
     cancelRequest();
 
 
     cancelRequest();
 
-    const KFileItem item = fileItem();
-    if (item.isNull()) {
-        return;
-    }
-    const KUrl itemUrl = item.url();
-
     if (showMultipleSelectionInfo()) {
         KIconLoader iconLoader;
         QPixmap icon = iconLoader.loadIcon("dialog-information",
     if (showMultipleSelectionInfo()) {
         KIconLoader iconLoader;
         QPixmap icon = iconLoader.loadIcon("dialog-information",
@@ -196,30 +190,34 @@ void InfoSidebarPage::showItemInfo()
                                            KIconLoader::SizeEnormous);
         m_preview->setPixmap(icon);
         m_nameLabel->setText(i18ncp("@info", "%1 item selected", "%1 items selected",  m_selection.count()));
                                            KIconLoader::SizeEnormous);
         m_preview->setPixmap(icon);
         m_nameLabel->setText(i18ncp("@info", "%1 item selected", "%1 items selected",  m_selection.count()));
-    } else if (!applyPlace(itemUrl)) {
-        // try to get a preview pixmap from the item...
-        m_pendingPreview = true;
-
-        // Mark the currently shown preview as outdated. This is done
-        // with a small delay to prevent a flickering when the next preview
-        // can be shown within a short timeframe.
-        m_outdatedPreviewTimer->start();
-
-        KIO::PreviewJob* job = KIO::filePreview(KUrl::List() << itemUrl,
-                                                m_preview->width(),
-                                                m_preview->height(),
-                                                0,
-                                                0,
-                                                true,
-                                                false);
-        job->setIgnoreMaximumSize(true);
-
-        connect(job, SIGNAL(gotPreview(const KFileItem&, const QPixmap&)),
-                this, SLOT(showPreview(const KFileItem&, const QPixmap&)));
-        connect(job, SIGNAL(failed(const KFileItem&)),
-                this, SLOT(showIcon(const KFileItem&)));
-
-        m_nameLabel->setText(itemUrl.fileName());
+    } else {
+        const KFileItem item = fileItem();
+        const KUrl itemUrl = item.url();
+        if (!applyPlace(itemUrl)) {
+            // try to get a preview pixmap from the item...
+            m_pendingPreview = true;
+
+            // Mark the currently shown preview as outdated. This is done
+            // with a small delay to prevent a flickering when the next preview
+            // can be shown within a short timeframe.
+            m_outdatedPreviewTimer->start();
+
+            KIO::PreviewJob* job = KIO::filePreview(KUrl::List() << itemUrl,
+                                                    m_preview->width(),
+                                                    m_preview->height(),
+                                                    0,
+                                                    0,
+                                                    true,
+                                                    false);
+            job->setIgnoreMaximumSize(true);
+
+            connect(job, SIGNAL(gotPreview(const KFileItem&, const QPixmap&)),
+                    this, SLOT(showPreview(const KFileItem&, const QPixmap&)));
+            connect(job, SIGNAL(failed(const KFileItem&)),
+                    this, SLOT(showIcon(const KFileItem&)));
+
+            m_nameLabel->setText(itemUrl.fileName());
+        }
     }
 
     showMetaInfo();
     }
 
     showMetaInfo();
@@ -455,8 +453,14 @@ KFileItem InfoSidebarPage::fileItem() const
         return m_fileItem;
     }
 
         return m_fileItem;
     }
 
-    const KUrl url = m_selection.isEmpty() ? m_shownUrl : m_selection[0].url();
-    KFileItem item(KFileItem::Unknown, KFileItem::Unknown, url);
+    if (!m_selection.isEmpty()) {
+        Q_ASSERT(m_selection.count() == 1);
+        return m_selection.first();
+    }
+
+    // no item is hovered and no selection has been done: provide
+    // an item for the directory represented by m_shownUrl
+    KFileItem item(KFileItem::Unknown, KFileItem::Unknown, m_shownUrl);
     item.refresh();
     return item;
 }
     item.refresh();
     return item;
 }