┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src/panels/information/kmetadatawidget.cpp
diff options
context:
space:
mode:
authorPeter Penz <[email protected]>2009-11-19 19:38:34 +0000
committerPeter Penz <[email protected]>2009-11-19 19:38:34 +0000
commit2b6cceb0f6a46c47ad55f36379e38cb143f28d36 (patch)
treeb44bbd50bbaf676077dfd7a22a666bfeee77c8c8 /src/panels/information/kmetadatawidget.cpp
parentf2c315a147ff4ec9c76e28e0636a02f81fba9548 (diff)
Provide clickable resources for the Information Panel. Thanks to Sebastian Trüg für the patch!
CCMAIL: [email protected] svn path=/trunk/KDE/kdebase/apps/; revision=1051553
Diffstat (limited to 'src/panels/information/kmetadatawidget.cpp')
-rw-r--r--src/panels/information/kmetadatawidget.cpp31
1 files changed, 30 insertions, 1 deletions
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<KLoadMetaDataThread::Item> mergedItems(const QList<KLoadMetaDataThread::Item>& 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<KLoadMetaDataThread::Item>
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("<a href=\"%1\">%2</a>")
+ .arg(KUrl(res.resourceUri()).url())
+ .arg(res.genericLabel());
+ }
+ return QLatin1String("<p>") + links.join(QLatin1String(";\n"));
+}
#endif
KMetaDataWidget::KMetaDataWidget(QWidget* parent) :