From 2b6cceb0f6a46c47ad55f36379e38cb143f28d36 Mon Sep 17 00:00:00 2001 From: Peter Penz Date: Thu, 19 Nov 2009 19:38:34 +0000 Subject: Provide clickable resources for the Information Panel. Thanks to Sebastian Trüg für the patch! MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit CCMAIL: trueg@kde.org svn path=/trunk/KDE/kdebase/apps/; revision=1051553 --- src/panels/information/kmetadatawidget.cpp | 31 +++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) (limited to 'src/panels/information/kmetadatawidget.cpp') 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) : -- cgit v1.3