]> cloud.milkyroute.net Git - dolphin.git/commitdiff
performance optimization: don't retrieve the meta information immediately when changi...
authorPeter Penz <peter.penz19@gmail.com>
Sat, 19 May 2007 14:42:11 +0000 (14:42 +0000)
committerPeter Penz <peter.penz19@gmail.com>
Sat, 19 May 2007 14:42:11 +0000 (14:42 +0000)
svn path=/trunk/KDE/kdebase/apps/; revision=666342

src/infosidebarpage.cpp
src/infosidebarpage.h

index 7dfb07c6ab0bfd5366bd6639f8a14fc860b0fbea..1523894116459694be5641d774ee38b10c5a2fe6 100644 (file)
@@ -52,7 +52,6 @@
 
 InfoSidebarPage::InfoSidebarPage(QWidget* parent) :
     SidebarPage(parent),
-    m_multipleSelection(false), //TODO: check if I'm needed
     m_pendingPreview(false),
     m_timer(0),
     m_preview(0),
@@ -63,6 +62,7 @@ InfoSidebarPage::InfoSidebarPage(QWidget* parent) :
     const int spacing = KDialog::spacingHint();
 
     m_timer = new QTimer(this);
+    m_timer->setSingleShot(true);
     connect(m_timer, SIGNAL(timeout()),
             this, SLOT(slotTimeout()));
 
@@ -110,7 +110,7 @@ InfoSidebarPage::~InfoSidebarPage()
 
 void InfoSidebarPage::setUrl(const KUrl& url)
 {
-    if (!m_shownUrl.equals(url, KUrl::CompareWithoutTrailingSlash)) {
+    if (url.isValid() && !m_shownUrl.equals(url, KUrl::CompareWithoutTrailingSlash)) {
         cancelRequest();
         m_shownUrl = url;
         showItemInfo();
@@ -119,20 +119,17 @@ void InfoSidebarPage::setUrl(const KUrl& url)
 
 void InfoSidebarPage::setSelection(const KFileItemList& selection)
 {
-    cancelRequest();
     SidebarPage::setSelection(selection);
-    m_multipleSelection = (selection.size() > 1);
-    showItemInfo();
+    m_timer->start(TimerDelay);
 }
 
 void InfoSidebarPage::requestDelayedItemInfo(const KUrl& url)
 {
     cancelRequest();
 
-    if (!url.isEmpty() && !m_multipleSelection) {
+    if (!url.isEmpty() && (selection().size() <= 1)) {
         m_urlCandidate = url;
-        m_timer->setSingleShot(true);
-        m_timer->start(300);
+        m_timer->start(TimerDelay);
     }
 }
 
@@ -166,12 +163,13 @@ void InfoSidebarPage::showItemInfo()
     const KFileItemList& selectedItems = selection();
 
     KUrl file;
+    const int itemCount = selectedItems.count();
     if (selectedItems.count() == 0) {
         file = m_shownUrl;
     } else {
         file = selectedItems[0]->url();
     }
-    if (m_multipleSelection) {
+    if (itemCount > 1) {
         KIconLoader iconLoader;
         QPixmap icon = iconLoader.loadIcon("exec",
                                            K3Icon::NoGroup,
index 9fcf449be3149fac5677a772d1a2f12b508e8a20..c9b15bdac11c10728195fce71a87d7c24f74afa4 100644 (file)
@@ -107,6 +107,8 @@ private slots:
     void showPreview(const KFileItem& item, const QPixmap& pixmap);
 
 private:
+    enum { TimerDelay = 300 };
+
     /**
      * Checks whether the an URL is repesented by a bookmark. If yes,
      * then the bookmark icon and name are shown instead of a preview.
@@ -133,7 +135,6 @@ private:
     bool showMetaInfo(const QString& key) const;
 
 private:
-    bool m_multipleSelection;
     bool m_pendingPreview;
     QTimer* m_timer;
     KUrl m_shownUrl;