From: Peter Penz Date: Thu, 3 May 2007 05:52:54 +0000 (+0000) Subject: let the information sidebar react on selection changes X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/commitdiff_plain/7b286a5463e208990f7ee1d1e28b7bb062b7a409 let the information sidebar react on selection changes svn path=/trunk/KDE/kdebase/apps/; revision=660580 --- diff --git a/src/dolphinmainwindow.cpp b/src/dolphinmainwindow.cpp index 9223dc19f..489a99327 100644 --- a/src/dolphinmainwindow.cpp +++ b/src/dolphinmainwindow.cpp @@ -1280,6 +1280,8 @@ void DolphinMainWindow::setupDockWidgets() addDockWidget(Qt::RightDockWidgetArea, infoDock); connect(this, SIGNAL(urlChanged(KUrl)), infoWidget, SLOT(setUrl(KUrl))); + connect(this, SIGNAL(selectionChanged(KFileItemList)), + infoWidget, SLOT(setSelection(KFileItemList))); // setup "Tree View" QDockWidget* treeViewDock = new QDockWidget(i18n("Folders")); diff --git a/src/infosidebarpage.cpp b/src/infosidebarpage.cpp index a9ffc7257..7de4d882e 100644 --- a/src/infosidebarpage.cpp +++ b/src/infosidebarpage.cpp @@ -111,7 +111,8 @@ InfoSidebarPage::InfoSidebarPage(QWidget* parent) : } InfoSidebarPage::~InfoSidebarPage() -{} +{ +} void InfoSidebarPage::setUrl(const KUrl& url) { @@ -124,16 +125,10 @@ void InfoSidebarPage::setUrl(const KUrl& url) void InfoSidebarPage::setSelection(const KFileItemList& selection) { - // TODO: deactivated the following code, as it has side effects. To - // reproduce start Dolphin and open a folder -> the URL navigator gets - // reset. First guess: it seems that a setUrl signal is emitted - // by the following code - - Q_UNUSED(selection); - /*cancelRequest(); + cancelRequest(); m_currentSelection = selection; m_multipleSelection = (m_currentSelection.size() > 1); - showItemInfo();*/ + showItemInfo(); } void InfoSidebarPage::requestDelayedItemInfo(const KUrl& url) @@ -183,9 +178,9 @@ void InfoSidebarPage::showItemInfo() job->setIgnoreMaximumSize(true); connect(job, SIGNAL(gotPreview(const KFileItem&, const QPixmap&)), - this, SLOT(gotPreview(const KFileItem&, const QPixmap&))); + this, SLOT(showPreview(const KFileItem&, const QPixmap&))); connect(job, SIGNAL(failed(const KFileItem&)), - this, SLOT(slotPreviewFailed(const KFileItem&))); + this, SLOT(showIcon(const KFileItem&))); QString text(""); text.append(file.fileName()); @@ -202,7 +197,7 @@ void InfoSidebarPage::slotTimeout() showItemInfo(); } -void InfoSidebarPage::slotPreviewFailed(const KFileItem& item) +void InfoSidebarPage::showIcon(const KFileItem& item) { m_pendingPreview = false; if (!applyBookmark(item.url())) { @@ -210,8 +205,8 @@ void InfoSidebarPage::slotPreviewFailed(const KFileItem& item) } } -void InfoSidebarPage::gotPreview(const KFileItem& item, - const QPixmap& pixmap) +void InfoSidebarPage::showPreview(const KFileItem& item, + const QPixmap& pixmap) { Q_UNUSED(item); if (m_pendingPreview) { @@ -222,7 +217,7 @@ void InfoSidebarPage::gotPreview(const KFileItem& item, bool InfoSidebarPage::applyBookmark(const KUrl& url) { - KFilePlacesModel *placesModel = DolphinSettings::instance().placesModel(); + KFilePlacesModel* placesModel = DolphinSettings::instance().placesModel(); int count = placesModel->rowCount(); for (int i = 0; i < count; ++i) { @@ -258,8 +253,9 @@ void InfoSidebarPage::createMetaInfo() if (fileItem.isDir()) { addInfoLine(i18n("Type:"), i18n("Directory")); } - if (MetaDataWidget::metaDataAvailable()) + if (MetaDataWidget::metaDataAvailable()) { m_metadataWidget->setFile(fileItem.url()); + } } else if (m_currentSelection.count() == 1) { KFileItem* fileItem = m_currentSelection.at(0); addInfoLine(i18n("Type:"), fileItem->mimeComment()); @@ -278,11 +274,14 @@ void InfoSidebarPage::createMetaInfo() } } } - if (MetaDataWidget::metaDataAvailable()) + if (MetaDataWidget::metaDataAvailable()) { m_metadataWidget->setFile(fileItem->url()); + } } else { - if (MetaDataWidget::metaDataAvailable()) + if (MetaDataWidget::metaDataAvailable()) { m_metadataWidget->setFiles(m_currentSelection.urlList()); + } + unsigned long int totSize = 0; foreach(KFileItem* item, m_currentSelection) { totSize += item->size(); //FIXME what to do with directories ? (same with the one-item-selected-code), item->size() does not return the size of the content : not very instinctive for users @@ -340,8 +339,9 @@ bool InfoSidebarPage::showMetaInfo(const QString& key) const void InfoSidebarPage::addInfoLine(const QString& labelText, const QString& infoText) { - if (!m_infoLines.isEmpty()) + if (!m_infoLines.isEmpty()) { m_infoLines += "
"; + } m_infoLines += QString("%1 %2").arg(labelText).arg(infoText); } diff --git a/src/infosidebarpage.h b/src/infosidebarpage.h index 640feb6a3..8d84512e9 100644 --- a/src/infosidebarpage.h +++ b/src/infosidebarpage.h @@ -90,13 +90,13 @@ private slots: * Is invoked if no preview is available for the item. In this * case the icon will be shown. */ - void slotPreviewFailed(const KFileItem& item); + void showIcon(const KFileItem& item); /** * Is invoked if a preview is available for the item. The preview * \a pixmap is shown inside the info page. */ - void gotPreview(const KFileItem& item, const QPixmap& pixmap); + void showPreview(const KFileItem& item, const QPixmap& pixmap); private: /** @@ -124,6 +124,7 @@ private: */ bool showMetaInfo(const QString& key) const; +private: bool m_multipleSelection; bool m_pendingPreview; QTimer* m_timer;