]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Provide clickable resources for the Information Panel. Thanks to Sebastian Trüg für...
authorPeter Penz <peter.penz19@gmail.com>
Thu, 19 Nov 2009 19:38:34 +0000 (19:38 +0000)
committerPeter Penz <peter.penz19@gmail.com>
Thu, 19 Nov 2009 19:38:34 +0000 (19:38 +0000)
CCMAIL: trueg@kde.org

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

src/dolphinmainwindow.cpp
src/dolphinviewcontainer.cpp
src/dolphinviewcontainer.h
src/panels/information/informationpanel.cpp
src/panels/information/informationpanel.h
src/panels/information/informationpanelcontent.cpp
src/panels/information/kloadmetadatathread.cpp
src/panels/information/kloadmetadatathread_p.h
src/panels/information/kmetadatawidget.cpp
src/panels/information/kmetadatawidget.h

index a8847f49454254f9a15cb64ef9d8f7ac0a1d28c8..bec451a0998e1ca3a858a79eebef0aa7a7248e40 100644 (file)
@@ -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();
index ece22f4c0cd146f81a43ffc5e7014f3e81cb5a95..a821d5d298b57e2af978ff748cd0bf0222376abd 100644 (file)
@@ -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);
index 8dc4b0443b643d596a356c2224fb2967f4b17589..0f2ab9aad387ab8b61d55cccb87d126ed772f514 100644 (file)
@@ -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
index 028f0ae0c82e04eb450eb7e994533799ee4fa551..05b1f89de9dce6914aeff692bb44758371dfca28 100644 (file)
@@ -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;
 }
index b83db7f709aa9fd33b2c224e66f6126a1b7bb5f4..0622a79a2b6f41608dcef10a49dcf6c2207cfe26 100644 (file)
@@ -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);
index 16876e302570571ad05aa70c3d489fdca471a14c..bd24e568d27ba47b8ec98669337a4e35ec7c56fe 100644 (file)
@@ -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
index b1083be9124e4223558f77ff1294544507a1047a..b942c20386f9c43c14a68ce47a82dd39df35d5d4 100644 (file)
@@ -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;
index 08e4b0855efdd8ac4da50fc9ab0efeae68edc8dd..885e975fc41273a6401f586b7f6b4ab4f4b68b9e 100644 (file)
@@ -42,6 +42,7 @@ public:
         QString name;
         QString label;
         QString value;
+        QList<Nepomuk::Resource> resources;
     };
 
     KLoadMetaDataThread();
index 73ba3d0782640a4f3e490469a194b4850fd0d6c0..7e99c45ff039cac7aba99d42ebcd827a72649686 100644 (file)
@@ -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) :
index 9d1232cf23f10171f9563cbb4721de39f18ae9fc..2618913b8c3ff365231d516287536c2be950953e 100644 (file)
@@ -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<Nepomuk::Tag>& 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)