From: Peter Penz Date: Wed, 8 Oct 2008 19:10:00 +0000 (+0000) Subject: Don't request any meta data, if the requested URL is equal to the currently shown... X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/commitdiff_plain/7de3ccbf54ee3a2f7c751a2ba5352d3122d5126e?ds=inline Don't request any meta data, if the requested URL is equal to the currently shown URL. This is especially important when opening a directory, where the meta info has been requested twice (the first time on hovering a directory, the second time when opening - now when opening the directory no meta data is requested at all). Further performance improvements will follow... svn path=/trunk/KDE/kdebase/apps/; revision=869328 --- diff --git a/src/infosidebarpage.cpp b/src/infosidebarpage.cpp index 8e6bda8e8..9fc2286f1 100644 --- a/src/infosidebarpage.cpp +++ b/src/infosidebarpage.cpp @@ -79,7 +79,7 @@ QSize InfoSidebarPage::sizeHint() const void InfoSidebarPage::setUrl(const KUrl& url) { SidebarPage::setUrl(url); - if (url.isValid() && !m_shownUrl.equals(url, KUrl::CompareWithoutTrailingSlash)) { + if (url.isValid() && !isEqualToShownUrl(url)) { if (m_initialized) { cancelRequest(); m_shownUrl = url; @@ -108,8 +108,10 @@ void InfoSidebarPage::setSelection(const KFileItemList& selection) const int count = selection.count(); if (count == 0) { - m_shownUrl = url(); - showItemInfo(); + if (!isEqualToShownUrl(url())) { + m_shownUrl = url(); + showItemInfo(); + } } else { if ((count == 1) && !selection.first().url().isEmpty()) { m_urlCandidate = selection.first().url(); @@ -134,10 +136,13 @@ void InfoSidebarPage::requestDelayedItemInfo(const KFileItem& item) m_pendingPreview = false; m_infoTimer->start(); } - } else if (!item.url().isEmpty()) { - m_urlCandidate = item.url(); - m_fileItem = item; - m_infoTimer->start(); + } else { + const KUrl url = item.url(); + if (url.isValid() && !isEqualToShownUrl(url)) { + m_urlCandidate = item.url(); + m_fileItem = item; + m_infoTimer->start(); + } } } @@ -470,6 +475,11 @@ bool InfoSidebarPage::showMultipleSelectionInfo() const return m_fileItem.isNull() && (m_selection.count() > 1); } +bool InfoSidebarPage::isEqualToShownUrl(const KUrl& url) const +{ + return m_shownUrl.equals(url, KUrl::CompareWithoutTrailingSlash); +} + void InfoSidebarPage::init() { const int spacing = KDialog::spacingHint(); diff --git a/src/infosidebarpage.h b/src/infosidebarpage.h index 97d63afa9..ff7e1d0d7 100644 --- a/src/infosidebarpage.h +++ b/src/infosidebarpage.h @@ -159,6 +159,11 @@ private: * InfosidebarPage::fileUrl(); */ bool showMultipleSelectionInfo() const; + + /** + * Returns true, if \a url is equal to the shown URL m_shownUrl. + */ + bool isEqualToShownUrl(const KUrl& url) const; void init();