X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/ed68687614472e18904c4a3f613d01df2f5bb90e..39f89141b06c:/src/panels/information/informationpanel.cpp diff --git a/src/panels/information/informationpanel.cpp b/src/panels/information/informationpanel.cpp index 2d6810c88..86a7bb999 100644 --- a/src/panels/information/informationpanel.cpp +++ b/src/panels/information/informationpanel.cpp @@ -18,12 +18,13 @@ ***************************************************************************/ #include "informationpanel.h" + +#include "informationpanelcontent.h" +#include #include +#include #include #include -#include "informationpanelcontent.h" - -#include InformationPanel::InformationPanel(QWidget* parent) : Panel(parent), @@ -52,24 +53,6 @@ QSize InformationPanel::sizeHint() const return size; } -void InformationPanel::setUrl(const KUrl& url) -{ - Panel::setUrl(url); - if (url.isValid() && !isEqualToShownUrl(url)) { - if (isVisible()) { - cancelRequest(); - m_shownUrl = url; - // Update the content with a delay. This gives - // the directory lister the chance to show the content - // before expensive operations are done to show - // meta information. - m_urlChangedTimer->start(); - } else { - m_shownUrl = url; - } - } -} - void InformationPanel::setSelection(const KFileItemList& selection) { if (!isVisible()) { @@ -103,29 +86,61 @@ void InformationPanel::setSelection(const KFileItemList& selection) void InformationPanel::requestDelayedItemInfo(const KFileItem& item) { - if (!isVisible()) { + if (!isVisible() || (item.isNull() && m_fileItem.isNull())) { return; } - cancelRequest(); + if (QApplication::mouseButtons() & Qt::LeftButton) { + // Ignore the request of an item information when a rubberband + // selection is ongoing. + return; + } - m_fileItem = KFileItem(); if (item.isNull()) { // The cursor is above the viewport. If files are selected, // show information regarding the selection. if (m_selection.size() > 0) { + cancelRequest(); + m_fileItem = KFileItem(); m_infoTimer->start(); } - } else { - const KUrl url = item.url(); - if (url.isValid() && !isEqualToShownUrl(url)) { - m_urlCandidate = item.url(); - m_fileItem = item; - m_infoTimer->start(); - } + } else if (item.url().isValid() && !isEqualToShownUrl(item.url())) { + // The cursor is above an item that is not shown currently + cancelRequest(); + + m_urlCandidate = item.url(); + m_fileItem = item; + m_infoTimer->start(); } } +bool InformationPanel::urlChanged() +{ + if (!url().isValid()) { + return false; + } + + if (!isVisible()) { + return true; + } + + cancelRequest(); + m_selection.clear(); + + if (!isEqualToShownUrl(url())) { + m_shownUrl = url(); + m_fileItem = KFileItem(); + + // Update the content with a delay. This gives + // the directory lister the chance to show the content + // before expensive operations are done to show + // meta information. + m_urlChangedTimer->start(); + } + + return true; +} + void InformationPanel::showEvent(QShowEvent* event) { Panel::showEvent(event); @@ -136,6 +151,8 @@ void InformationPanel::showEvent(QShowEvent* event) // Information Panel init(); } + + m_shownUrl = url(); showItemInfo(); } } @@ -163,10 +180,11 @@ void InformationPanel::showItemInfo() cancelRequest(); - if (showMultipleSelectionInfo()) { + if (m_fileItem.isNull() && (m_selection.count() > 1)) { + // The information for a selection of items should be shown m_content->showItems(m_selection); - m_shownUrl = KUrl(); } else { + // The information for exactly one item should be shown KFileItem item; if (!m_fileItem.isNull()) { item = m_fileItem; @@ -175,14 +193,13 @@ void InformationPanel::showItemInfo() item = m_selection.first(); } - if ( item.isNull() ) { - // no item is hovered and no selection has been done: provide - // an item for the directory represented by m_shownUrl - m_folderStatJob = KIO::stat(m_shownUrl, KIO::HideProgressInfo); + if (item.isNull()) { + // No item is hovered and no selection has been done: provide + // an item for the currently shown directory. + m_folderStatJob = KIO::stat(url(), KIO::HideProgressInfo); connect(m_folderStatJob, SIGNAL(result(KJob*)), this, SLOT(slotFolderStatFinished(KJob*))); - } - else { + } else { m_content->showItem(item); } } @@ -198,6 +215,7 @@ void InformationPanel::slotFolderStatFinished(KJob* job) void InformationPanel::slotInfoTimeout() { m_shownUrl = m_urlCandidate; + m_urlCandidate.clear(); showItemInfo(); } @@ -288,12 +306,13 @@ void InformationPanel::cancelRequest() { delete m_folderStatJob; m_folderStatJob = 0; + m_infoTimer->stop(); -} + m_urlChangedTimer->stop(); + m_resetUrlTimer->stop(); -bool InformationPanel::showMultipleSelectionInfo() const -{ - return m_fileItem.isNull() && (m_selection.count() > 1); + m_invalidUrlCandidate.clear(); + m_urlCandidate.clear(); } bool InformationPanel::isEqualToShownUrl(const KUrl& url) const