]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Added all code necessary for clickable tags in the KTaggingWidget. As soon as we...
authorSebastian Trueg <sebastian@trueg.de>
Mon, 7 Dec 2009 16:41:37 +0000 (16:41 +0000)
committerSebastian Trueg <sebastian@trueg.de>
Mon, 7 Dec 2009 16:41:37 +0000 (16:41 +0000)
only show links on hover we are good to go.
This is actually a fix as resources in the rest of the info view are already clickable.

CCMAIL: peter.penz@gmx.at

svn path=/trunk/KDE/kdebase/apps/; revision=1059908

src/panels/information/kmetadatawidget.cpp
src/panels/information/kmetadatawidget.h
src/panels/information/ktaggingwidget.cpp
src/panels/information/ktaggingwidget_p.h

index 819e9f26db3048c19ad867577d638ace588fcc1c..8b658a03f8d5e015928d631b813e25141a822b0d 100644 (file)
@@ -98,6 +98,8 @@ public:
     void slotLinkActivated(const QString& link);
 
 #ifdef HAVE_NEPOMUK
+    void slotTagActivated(const Nepomuk::Tag& tag);
+
     /**
      * Disables the metadata widget and starts the job that
      * changes the meta data asynchronously. After the job
@@ -189,6 +191,8 @@ KMetaDataWidget::Private::Private(KMetaDataWidget* parent) :
         m_taggingWidget = new KTaggingWidget(parent);
         connect(m_taggingWidget, SIGNAL(tagsChanged(const QList<Nepomuk::Tag>&)),
                 q, SLOT(slotTagsChanged(const QList<Nepomuk::Tag>&)));
+        connect(m_taggingWidget, SIGNAL(tagActivated(const Nepomuk::Tag&)),
+                q, SLOT(slotTagActivated(const Nepomuk::Tag&)));
 
         m_commentWidget = new KCommentWidget(parent);
         connect(m_commentWidget, SIGNAL(commentChanged(const QString&)),
@@ -425,6 +429,13 @@ void KMetaDataWidget::Private::slotCommentChanged(const QString& comment)
 #endif
 }
 
+#ifdef HAVE_NEPOMUK
+void KMetaDataWidget::Private::slotTagActivated(const Nepomuk::Tag& tag)
+{
+    emit q->urlActivated(tag.resourceUri());
+}
+#endif
+
 void KMetaDataWidget::Private::slotMetaDataUpdateDone()
 {
 #ifdef HAVE_NEPOMUK
index 060b82c73321ccfe2607522dea644c044a72ee24..a7d131e14b7084a57d292d111b5e97a8ce441ed7 100644 (file)
@@ -25,6 +25,8 @@
 #include <QList>
 #include <QWidget>
 
+#include <config-nepomuk.h>
+
 class KUrl;
 
 /**
@@ -138,6 +140,9 @@ private:
     Q_PRIVATE_SLOT(d, void slotCommentChanged(const QString& comment))
     Q_PRIVATE_SLOT(d, void slotMetaDataUpdateDone())
     Q_PRIVATE_SLOT(d, void slotLinkActivated(const QString& link))
+#ifdef HAVE_NEPOMUK
+    Q_PRIVATE_SLOT(d, void slotTagActivated(const Nepomuk::Tag& tag))
+#endif
 };
 
 Q_DECLARE_OPERATORS_FOR_FLAGS(KMetaDataWidget::MetaDataTypes)
index d33b9f6deaf24a8772b6d23042c36dc7e1299aea..4c0ab98bea1e8b660ab57b240d9eefcc83f8ca32 100644 (file)
@@ -22,6 +22,7 @@
 
 #include <kglobalsettings.h>
 #include <klocale.h>
+#include <kurl.h>
 
 #include <QEvent>
 #include <QLabel>
@@ -61,7 +62,15 @@ void KTaggingWidget::setTags(const QList<Nepomuk::Tag>& tags)
         if (!first) {
             m_tagsText += ", ";
         }
-        m_tagsText += tag.genericLabel();
+#ifdef DOLPHIN_ENABLE_CLICKABLE_TAGS
+        if (m_readOnly) {
+#endif
+            m_tagsText += tag.genericLabel();
+#ifdef DOLPHIN_ENABLE_CLICKABLE_TAGS
+        } else {
+            m_tagsText += QString::fromLatin1( "<a href=\"%1\">%2</a>" ).arg( KUrl(tag.resourceUri()).url(), tag.genericLabel() );
+        }
+#endif
         first = false;
     }
 
@@ -70,7 +79,7 @@ void KTaggingWidget::setTags(const QList<Nepomuk::Tag>& tags)
         if (m_readOnly) {
             text = "-";
         } else {
-            text = "<a href=\"addTags\">" + i18nc("@label", "Add Tags...") + "</a>";
+            text = "<a href=\"changeTags\">" + i18nc("@label", "Add Tags...") + "</a>";
         }
     } else {
         if (m_readOnly) {
@@ -108,33 +117,36 @@ bool KTaggingWidget::event(QEvent* event)
 
 void KTaggingWidget::slotLinkActivated(const QString& link)
 {
-    Q_UNUSED(link);
-
-    KEditTagsDialog dialog(m_tags, this, Qt::Dialog);
-    KConfigGroup dialogConfig(KGlobal::config(), "Nepomuk KEditTagsDialog");
-    dialog.restoreDialogSize(dialogConfig);
-
-    if (dialog.exec() == QDialog::Accepted) {
-        const QList<Nepomuk::Tag> oldTags = m_tags;
-        m_tags = dialog.tags();
-
-        if (oldTags.count() != m_tags.count()) {
-            emit tagsChanged(m_tags);
-        } else {
-            // The number of tags is equal. Check whether the
-            // content of the tags are also equal:
-            const int tagsCount = m_tags.count();
-            for (int i = 0; i < tagsCount; ++i) {
-                if (oldTags[i].genericLabel() != m_tags[i].genericLabel()) {
-                    // at least one tag has been changed
-                    emit tagsChanged(m_tags);
-                    break;
+    if ( link == QLatin1String( "changeTags" ) ) {
+        KEditTagsDialog dialog(m_tags, this, Qt::Dialog);
+        KConfigGroup dialogConfig(KGlobal::config(), "Nepomuk KEditTagsDialog");
+        dialog.restoreDialogSize(dialogConfig);
+
+        if (dialog.exec() == QDialog::Accepted) {
+            const QList<Nepomuk::Tag> oldTags = m_tags;
+            m_tags = dialog.tags();
+
+            if (oldTags.count() != m_tags.count()) {
+                emit tagsChanged(m_tags);
+            } else {
+                // The number of tags is equal. Check whether the
+                // content of the tags are also equal:
+                const int tagsCount = m_tags.count();
+                for (int i = 0; i < tagsCount; ++i) {
+                    if (oldTags[i].genericLabel() != m_tags[i].genericLabel()) {
+                        // at least one tag has been changed
+                        emit tagsChanged(m_tags);
+                        break;
+                    }
                 }
             }
         }
-    }
 
-    dialog.saveDialogSize(dialogConfig, KConfigBase::Persistent);
+        dialog.saveDialogSize(dialogConfig, KConfigBase::Persistent);
+    }
+    else {
+        emit tagActivated(Nepomuk::Tag(KUrl(link)));
+    }
 }
 
 #include "ktaggingwidget_p.moc"
index 1a4589a62245d64df46bb6fa36b653f8e15fcc1d..dfa23ea3b8ea902838f970b797e1832d7da55eb8 100644 (file)
@@ -49,6 +49,7 @@ public:
 
 signals:
     void tagsChanged(const QList<Nepomuk::Tag>& tags);
+    void tagActivated(const Nepomuk::Tag& tag);
 
 protected:
     virtual bool event(QEvent* event);