From: Peter Penz Date: Thu, 19 Nov 2009 19:38:34 +0000 (+0000) Subject: Provide clickable resources for the Information Panel. Thanks to Sebastian Trüg für... X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/commitdiff_plain/2b6cceb0f6a46c47ad55f36379e38cb143f28d36 Provide clickable resources for the Information Panel. Thanks to Sebastian Trüg für the patch! CCMAIL: trueg@kde.org svn path=/trunk/KDE/kdebase/apps/; revision=1051553 --- diff --git a/src/dolphinmainwindow.cpp b/src/dolphinmainwindow.cpp index a8847f494..bec451a09 100644 --- a/src/dolphinmainwindow.cpp +++ b/src/dolphinmainwindow.cpp @@ -1375,6 +1375,7 @@ void DolphinMainWindow::setupDockWidgets() infoDock->setObjectName("infoDock"); infoDock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea); Panel* infoPanel = new InformationPanel(infoDock); + connect(infoPanel, SIGNAL(urlActivated(KUrl)), activeViewContainer(), SLOT(setUrl(KUrl))); infoDock->setWidget(infoPanel); QAction* infoAction = infoDock->toggleViewAction(); diff --git a/src/dolphinviewcontainer.cpp b/src/dolphinviewcontainer.cpp index ece22f4c0..a821d5d29 100644 --- a/src/dolphinviewcontainer.cpp +++ b/src/dolphinviewcontainer.cpp @@ -191,20 +191,6 @@ DolphinViewContainer::~DolphinViewContainer() m_dirLister = 0; // deleted by m_dolphinModel } -void DolphinViewContainer::setUrl(const KUrl& newUrl) -{ - if (newUrl != m_urlNavigator->url()) { - m_urlNavigator->setUrl(newUrl); - // Temporary disable the 'File'->'Create New...' menu until - // the write permissions can be checked in a fast way at - // DolphinViewContainer::slotDirListerCompleted(). - m_isFolderWritable = false; - if (isActive()) { - m_mainWindow->newMenu()->menu()->setEnabled(false); - } - } -} - const KUrl& DolphinViewContainer::url() const { return m_urlNavigator->url(); @@ -236,6 +222,20 @@ bool DolphinViewContainer::isFilterBarVisible() const return m_filterBar->isVisible(); } +void DolphinViewContainer::setUrl(const KUrl& newUrl) +{ + if (newUrl != m_urlNavigator->url()) { + m_urlNavigator->setUrl(newUrl); + // Temporary disable the 'File'->'Create New...' menu until + // the write permissions can be checked in a fast way at + // DolphinViewContainer::slotDirListerCompleted(). + m_isFolderWritable = false; + if (isActive()) { + m_mainWindow->newMenu()->menu()->setEnabled(false); + } + } +} + void DolphinViewContainer::showFilterBar(bool show) { Q_ASSERT(m_filterBar != 0); diff --git a/src/dolphinviewcontainer.h b/src/dolphinviewcontainer.h index 8dc4b0443..0f2ab9aad 100644 --- a/src/dolphinviewcontainer.h +++ b/src/dolphinviewcontainer.h @@ -68,15 +68,6 @@ public: virtual ~DolphinViewContainer(); - /** - * Sets the current active URL, where all actions are applied. The - * URL navigator is synchronized with this URL. The signals - * KUrlNavigator::urlChanged() and KUrlNavigator::historyChanged() - * are emitted. - * @see DolphinViewContainer::urlNavigator() - */ - void setUrl(const KUrl& url); - /** * Returns the current active URL, where all actions are applied. * The URL navigator is synchronized with this URL. @@ -114,6 +105,15 @@ public: bool isFilterBarVisible() const; public slots: + /** + * Sets the current active URL, where all actions are applied. The + * URL navigator is synchronized with this URL. The signals + * KUrlNavigator::urlChanged() and KUrlNavigator::historyChanged() + * are emitted. + * @see DolphinViewContainer::urlNavigator() + */ + void setUrl(const KUrl& url); + /** * Popups the filter bar above the status bar if \a show is true. */ @@ -125,7 +125,7 @@ signals: */ void showFilterBarChanged(bool shown); -private slots: +private slots: /** * Updates the number of items (= number of files + number of * directories) in the statusbar. If files are selected, the number diff --git a/src/panels/information/informationpanel.cpp b/src/panels/information/informationpanel.cpp index 028f0ae0c..05b1f89de 100644 --- a/src/panels/information/informationpanel.cpp +++ b/src/panels/information/informationpanel.cpp @@ -255,7 +255,7 @@ void InformationPanel::slotLeftDirectory(const QString& directory) // The signal 'leftDirectory' is also emitted when a media // has been unmounted. In this case no directory change will be // done in Dolphin, but the Information Panel must be updated to - // indicate an invalid directory. + // indicate an invalid directory. markUrlAsInvalid(); } } @@ -313,6 +313,7 @@ void InformationPanel::init() connect(dirNotify, SIGNAL(leftDirectory(QString)), SLOT(slotLeftDirectory(QString))); m_content = new InformationPanelContent(this); + connect(m_content, SIGNAL(urlActivated(KUrl)), this, SIGNAL(urlActivated(KUrl))); m_initialized = true; } diff --git a/src/panels/information/informationpanel.h b/src/panels/information/informationpanel.h index b83db7f70..0622a79a2 100644 --- a/src/panels/information/informationpanel.h +++ b/src/panels/information/informationpanel.h @@ -38,6 +38,9 @@ public: /** @see QWidget::sizeHint() */ virtual QSize sizeHint() const; +signals: + void urlActivated(const KUrl& url); + public slots: /** @see Panel::setUrl() */ virtual void setUrl(const KUrl& url); diff --git a/src/panels/information/informationpanelcontent.cpp b/src/panels/information/informationpanelcontent.cpp index 16876e302..bd24e568d 100644 --- a/src/panels/information/informationpanelcontent.cpp +++ b/src/panels/information/informationpanelcontent.cpp @@ -103,6 +103,7 @@ InformationPanelContent::InformationPanelContent(QWidget* parent) : m_metaDataWidget = new KMetaDataWidget(parent); m_metaDataWidget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Minimum); + connect(m_metaDataWidget, SIGNAL(urlActivated(KUrl)), this, SIGNAL(urlActivated(KUrl))); // Encapsulate the MetaDataWidget inside a container that has a dummy widget // at the bottom. This prevents that the meta data widget gets vertically stretched diff --git a/src/panels/information/kloadmetadatathread.cpp b/src/panels/information/kloadmetadatathread.cpp index b1083be91..b942c2038 100644 --- a/src/panels/information/kloadmetadatathread.cpp +++ b/src/panels/information/kloadmetadatathread.cpp @@ -100,7 +100,11 @@ void KLoadMetaDataThread::run() Item item; item.name = prop.name(); item.label = tunedLabel(prop.label()); - item.value = formatValue(it.value()); + if (it.value().isResource() || it.value().isResourceList()) { + item.resources = it.value().toResourceList(); + } else { + item.value = formatValue(it.value()); + } m_items.append(item); } ++it; diff --git a/src/panels/information/kloadmetadatathread_p.h b/src/panels/information/kloadmetadatathread_p.h index 08e4b0855..885e975fc 100644 --- a/src/panels/information/kloadmetadatathread_p.h +++ b/src/panels/information/kloadmetadatathread_p.h @@ -42,6 +42,7 @@ public: QString name; QString label; QString value; + QList resources; }; KLoadMetaDataThread(); diff --git a/src/panels/information/kmetadatawidget.cpp b/src/panels/information/kmetadatawidget.cpp index 73ba3d078..7e99c45ff 100644 --- a/src/panels/information/kmetadatawidget.cpp +++ b/src/panels/information/kmetadatawidget.cpp @@ -94,6 +94,7 @@ public: void slotCommentChanged(const QString& comment); void slotMetaDataUpdateDone(); + void slotLinkActivated(const QString& link); #ifdef HAVE_NEPOMUK /** @@ -107,6 +108,12 @@ public: * Merges items like 'width' and 'height' as one item. */ QList mergedItems(const QList& items); + + /** + * Returns a (clickable) text for the given item, that can be used for + * the information value widget. + */ + QString labelText(const KLoadMetaDataThread::Item& item) const; #endif bool m_sizeVisible; @@ -365,7 +372,9 @@ void KMetaDataWidget::Private::slotLoadingFinished() } else { // create new row QLabel* infoLabel = new QLabel(item.label, q); - QLabel* infoValue = new QLabel(item.value, q); + QLabel* infoValue = new QLabel(labelText(item), q); + connect(infoValue, SIGNAL(linkActivated(QString)), + q, SLOT(slotLinkActivated(QString))); addRow(infoLabel, infoValue); } ++index; @@ -432,6 +441,11 @@ void KMetaDataWidget::Private::slotMetaDataUpdateDone() #endif } +void KMetaDataWidget::Private::slotLinkActivated(const QString& link) +{ + emit q->urlActivated(KUrl(link)); +} + #ifdef HAVE_NEPOMUK void KMetaDataWidget::Private::startChangeDataJob(KJob* job) { @@ -489,6 +503,21 @@ QList return mergedItems; } + +QString KMetaDataWidget::Private::labelText(const KLoadMetaDataThread::Item& item) const +{ + if (item.resources.isEmpty()) { + return item.value; + } + + QStringList links; + foreach(const Nepomuk::Resource& res, item.resources) { + links << QString::fromLatin1("%2") + .arg(KUrl(res.resourceUri()).url()) + .arg(res.genericLabel()); + } + return QLatin1String("

") + links.join(QLatin1String(";\n")); +} #endif KMetaDataWidget::KMetaDataWidget(QWidget* parent) : diff --git a/src/panels/information/kmetadatawidget.h b/src/panels/information/kmetadatawidget.h index 9d1232cf2..2618913b8 100644 --- a/src/panels/information/kmetadatawidget.h +++ b/src/panels/information/kmetadatawidget.h @@ -122,6 +122,9 @@ public: /** @see QWidget::sizeHint() */ virtual QSize sizeHint() const; +Q_SIGNALS: + void urlActivated(const KUrl& url); + private: class Private; Private* d; @@ -131,6 +134,7 @@ private: Q_PRIVATE_SLOT(d, void slotTagsChanged(const QList& tags)) Q_PRIVATE_SLOT(d, void slotCommentChanged(const QString& comment)) Q_PRIVATE_SLOT(d, void slotMetaDataUpdateDone()) + Q_PRIVATE_SLOT(d, void slotLinkActivated(const QString& link)) }; Q_DECLARE_OPERATORS_FOR_FLAGS(KMetaDataWidget::MetaDataTypes)