]> cloud.milkyroute.net Git - dolphin.git/commitdiff
restore functionality that ratings, comments and tags get stored after the user chang...
authorPeter Penz <peter.penz19@gmail.com>
Tue, 13 Oct 2009 20:48:38 +0000 (20:48 +0000)
committerPeter Penz <peter.penz19@gmail.com>
Tue, 13 Oct 2009 20:48:38 +0000 (20:48 +0000)
svn path=/trunk/KDE/kdebase/apps/; revision=1034884

src/CMakeLists.txt
src/panels/information/commentwidget.cpp
src/panels/information/commentwidget_p.h
src/panels/information/edittagsdialog.cpp [new file with mode: 0644]
src/panels/information/edittagsdialog_p.h [new file with mode: 0644]
src/panels/information/metadatawidget.cpp
src/panels/information/metadatawidget.h
src/panels/information/nepomukmassupdatejob.cpp
src/panels/information/nepomukmassupdatejob_p.h
src/panels/information/taggingwidget.cpp
src/panels/information/taggingwidget_p.h

index 8cba1d90694eb05a513c2760c0a2f72492d1bd21..173a769e46ed290f2409de3ef4f253199e8c0bbd 100644 (file)
@@ -153,6 +153,7 @@ if(Nepomuk_FOUND)
 set(dolphin_SRCS
   ${dolphin_SRCS}
   panels/information/commentwidget.cpp
+  panels/information/edittagsdialog.cpp
   panels/information/nepomukmassupdatejob.cpp
   panels/information/taggingwidget.cpp
 )
index 6ad80bf2c7a853a824f6dd3aa3de313905c55a9e..673a8c30af1925e477d2460fa45c170e0fcb9e9f 100644 (file)
@@ -67,7 +67,7 @@ QString CommentWidget::text() const
 
 void CommentWidget::slotLinkActivated(const QString& link)
 {
-    KDialog dialog(0, Qt::Dialog);
+    KDialog dialog(this, Qt::Dialog);
 
     QTextEdit* editor = new QTextEdit(&dialog);
     editor->setText(m_comment);
@@ -82,11 +82,15 @@ void CommentWidget::slotLinkActivated(const QString& link)
     dialog.setDefaultButton(KDialog::Ok);
 
     KConfigGroup dialogConfig(KSharedConfig::openConfig("dolphinrc"),
-                              "EditCommitDialog");
+                              "EditCommentDialog");
     dialog.restoreDialogSize(dialogConfig);
 
     if (dialog.exec() == QDialog::Accepted) {
+        const QString oldText = m_comment;
         setText(editor->toPlainText());
+        if (oldText != m_comment) {
+            emit commentChanged(m_comment);
+        }
     }
 
     dialog.saveDialogSize(dialogConfig, KConfigBase::Persistent);
index 67bced0445d9730aaefe3881143fad431aa47d41..3985487d56b6e84dcc43848b6e5e1723c8b8ec9c 100644 (file)
@@ -37,6 +37,9 @@ public:
     void setText(const QString& comment);
     QString text() const;
 
+signals:
+    void commentChanged(const QString& comment);
+
 private slots:
     void slotLinkActivated(const QString& link);
 
diff --git a/src/panels/information/edittagsdialog.cpp b/src/panels/information/edittagsdialog.cpp
new file mode 100644 (file)
index 0000000..baa8a66
--- /dev/null
@@ -0,0 +1,48 @@
+/***************************************************************************
+ *   Copyright (C) 2009 by Peter Penz <peter.penz@gmx.at>                  *
+ *                                                                         *
+ *   This program is free software; you can redistribute it and/or modify  *
+ *   it under the terms of the GNU General Public License as published by  *
+ *   the Free Software Foundation; either version 2 of the License, or     *
+ *   (at your option) any later version.                                   *
+ *                                                                         *
+ *   This program is distributed in the hope that it will be useful,       *
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
+ *   GNU General Public License for more details.                          *
+ *                                                                         *
+ *   You should have received a copy of the GNU General Public License     *
+ *   along with this program; if not, write to the                         *
+ *   Free Software Foundation, Inc.,                                       *
+ *   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA            *
+ ***************************************************************************/
+
+#include "edittagsdialog_p.h"
+
+#include <klocale.h>
+
+EditTagsDialog::EditTagsDialog(const QList<Nepomuk::Tag>& tags,
+                               QWidget* parent,
+                               Qt::WFlags flags) :
+    KDialog(parent, flags),
+    m_tags(tags)
+{
+
+    const QString caption = (tags.count() > 0) ?
+                            i18nc("@title:window", "Change Tags") :
+                            i18nc("@title:window", "Add Tags");
+    setCaption(caption);
+    setButtons(KDialog::Ok | KDialog::Cancel);
+    setDefaultButton(KDialog::Ok);
+}
+
+EditTagsDialog::~EditTagsDialog()
+{
+}
+
+QList<Nepomuk::Tag> EditTagsDialog::tags() const
+{
+    return m_tags;
+}
+
+#include "edittagsdialog_p.moc"
diff --git a/src/panels/information/edittagsdialog_p.h b/src/panels/information/edittagsdialog_p.h
new file mode 100644 (file)
index 0000000..4dd0935
--- /dev/null
@@ -0,0 +1,50 @@
+/***************************************************************************
+ *   Copyright (C) 2009 by Peter Penz <peter.penz@gmx.at>                  *
+ *                                                                         *
+ *   This program is free software; you can redistribute it and/or modify  *
+ *   it under the terms of the GNU General Public License as published by  *
+ *   the Free Software Foundation; either version 2 of the License, or     *
+ *   (at your option) any later version.                                   *
+ *                                                                         *
+ *   This program is distributed in the hope that it will be useful,       *
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
+ *   GNU General Public License for more details.                          *
+ *                                                                         *
+ *   You should have received a copy of the GNU General Public License     *
+ *   along with this program; if not, write to the                         *
+ *   Free Software Foundation, Inc.,                                       *
+ *   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA            *
+ ***************************************************************************/
+
+#ifndef EDIT_TAGS_DIALOG_H
+#define EDIT_TAGS_DIALOG_H
+
+#include <kdialog.h>
+
+#include <Nepomuk/Tag>
+
+/**
+ * @brief Dialog to edit a list of Nepomuk tags.
+ *
+ * It is possible for the user to add existing tags,
+ * create new tags or to remove tags.
+ */
+class EditTagsDialog : public KDialog
+{
+    Q_OBJECT
+
+public:
+    EditTagsDialog(const QList<Nepomuk::Tag>& tags,
+                   QWidget* parent = 0,
+                   Qt::WFlags flags = 0);
+
+    virtual ~EditTagsDialog();
+
+    QList<Nepomuk::Tag> tags() const;
+
+private:
+    QList<Nepomuk::Tag> m_tags;
+};
+
+#endif
index 0168a7b6f0fb5d5ab60bc64637c8ae4d62dff89b..368d57e921086c6154fc41da963421f5f1d1628e 100644 (file)
@@ -43,7 +43,6 @@
 
     #include <Nepomuk/KRatingWidget>
     #include <Nepomuk/Resource>
-    #include <Nepomuk/Tag>
     #include <Nepomuk/Types/Property>
     #include <Nepomuk/Variant>
 
@@ -70,6 +69,17 @@ public:
     void setRowVisible(QWidget* infoWidget, bool visible);
 
     void slotLoadingFinished();
+    void slotRatingChanged(unsigned int rating);
+    void slotTagsChanged(const QList<Nepomuk::Tag>& tags);
+    void slotCommentChanged(const QString& comment);
+    void slotMetaDataUpdateDone();
+
+    /**
+     * Disables the metadata widget and starts the job that
+     * changes the meta data asynchronously. After the job
+     * has been finished, the metadata widget gets enabled again.
+     */
+    void startChangeDataJob(KJob* job);
 
     QList<Row> m_rows;
 
@@ -97,6 +107,7 @@ public:
         QList<Nepomuk::Tag> tags;
         QList<QString> metaInfoLabels;
         QList<QString> metaInfoValues;
+        QMap<KUrl, Nepomuk::Resource> files;
     } m_sharedData;
 
     /**
@@ -127,8 +138,8 @@ public:
         QString tunedLabel(const QString& label) const;
 
     private:
-        SharedData* m_m_sharedData;
-        QMutex* m_m_mutex;
+        SharedData* m_sharedData;
+        QMutex* m_mutex;
         KUrl::List m_urls;
         bool m_canceled;
     };
@@ -170,10 +181,16 @@ MetaDataWidget::Private::Private(MetaDataWidget* parent) :
     const QFontMetrics fontMetrics(KGlobalSettings::smallestReadableFont());
     m_ratingWidget = new KRatingWidget(parent);
     m_ratingWidget->setFixedHeight(fontMetrics.height());
+    connect(m_ratingWidget, SIGNAL(ratingChanged(unsigned int)),
+            q, SLOT(slotRatingChanged(unsigned int)));
 
     m_taggingWidget = new TaggingWidget(parent);
+    connect(m_taggingWidget, SIGNAL(tagsChanged(const QList<Nepomuk::Tag>&)),
+            q, SLOT(slotTagsChanged(const QList<Nepomuk::Tag>&)));
 
     m_commentWidget = new CommentWidget(parent);
+    connect(m_commentWidget, SIGNAL(commentChanged(const QString&)),
+            q, SLOT(slotCommentChanged(const QString&)));
 #endif
 
     addRow(new QLabel(i18nc("@label", "Type:"), parent), m_typeInfo);
@@ -288,12 +305,64 @@ void MetaDataWidget::Private::slotLoadingFinished()
 #endif
 }
 
+void MetaDataWidget::Private::slotRatingChanged(unsigned int rating)
+{
+#ifdef HAVE_NEPOMUK
+    QMutexLocker locker(&m_mutex);
+    Nepomuk::MassUpdateJob* job =
+            Nepomuk::MassUpdateJob::rateResources(m_sharedData.files.values(), rating);
+    locker.unlock();
+    startChangeDataJob(job);
+#else
+    Q_UNUSED(rating);
+#endif
+}
+
+void MetaDataWidget::Private::slotTagsChanged(const QList<Nepomuk::Tag>& tags)
+{
+#ifdef HAVE_NEPOMUK
+    QMutexLocker locker(&m_mutex);
+    Nepomuk::MassUpdateJob* job =
+            Nepomuk::MassUpdateJob::tagResources(m_sharedData.files.values(), tags);
+    locker.unlock();
+    startChangeDataJob(job);
+#else
+    Q_UNUSED(tags);
+#endif
+}
+
+void MetaDataWidget::Private::slotCommentChanged(const QString& comment)
+{
+#ifdef HAVE_NEPOMUK
+    QMutexLocker locker(&m_mutex);
+    Nepomuk::MassUpdateJob* job =
+            Nepomuk::MassUpdateJob::commentResources(m_sharedData.files.values(), comment);
+    locker.unlock();
+    startChangeDataJob(job);
+#else
+    Q_UNUSED(comment);
+#endif
+}
+
+void MetaDataWidget::Private::slotMetaDataUpdateDone()
+{
+    q->setEnabled(true);
+}
+
+void MetaDataWidget::Private::startChangeDataJob(KJob* job)
+{
+    connect(job, SIGNAL(result(KJob*)),
+            q, SLOT(slotMetaDataUpdateDone()));
+    q->setEnabled(false); // no updates during execution
+    job->start();
+}
+
 #ifdef HAVE_NEPOMUK
 MetaDataWidget::Private::LoadFilesThread::LoadFilesThread(
                             MetaDataWidget::Private::SharedData* m_sharedData,
                             QMutex* m_mutex) :
-    m_m_sharedData(m_sharedData),
-    m_m_mutex(m_mutex),
+    m_sharedData(m_sharedData),
+    m_mutex(m_mutex),
     m_urls(),
     m_canceled(false)
 {
@@ -309,7 +378,7 @@ MetaDataWidget::Private::LoadFilesThread::~LoadFilesThread()
 
 void MetaDataWidget::Private::LoadFilesThread::loadFiles(const KUrl::List& urls)
 {
-    QMutexLocker locker(m_m_mutex);
+    QMutexLocker locker(m_mutex);
     m_urls = urls;
     m_canceled = false;
     start();
@@ -317,7 +386,7 @@ void MetaDataWidget::Private::LoadFilesThread::loadFiles(const KUrl::List& urls)
 
 void MetaDataWidget::Private::LoadFilesThread::run()
 {
-    QMutexLocker locker(m_m_mutex);
+    QMutexLocker locker(m_mutex);
     const KUrl::List urls = m_urls;
     locker.unlock();
 
@@ -331,12 +400,14 @@ void MetaDataWidget::Private::LoadFilesThread::run()
     QList<Nepomuk::Tag> tags;
     QList<QString> metaInfoLabels;
     QList<QString> metaInfoValues;
+    QMap<KUrl, Nepomuk::Resource> files;
     foreach (const KUrl& url, urls) {
         if (m_canceled) {
             return;
         }
 
         Nepomuk::Resource file(url, Soprano::Vocabulary::Xesam::File());
+        files.insert(url, file);
 
         if (!first && (rating != file.rating())) {
             rating = 0; // reset rating
@@ -379,11 +450,12 @@ void MetaDataWidget::Private::LoadFilesThread::run()
     }
 
     locker.relock();
-    m_m_sharedData->rating = rating;
-    m_m_sharedData->comment = comment;
-    m_m_sharedData->tags = tags;
-    m_m_sharedData->metaInfoLabels = metaInfoLabels;
-    m_m_sharedData->metaInfoValues = metaInfoValues;
+    m_sharedData->rating = rating;
+    m_sharedData->comment = comment;
+    m_sharedData->tags = tags;
+    m_sharedData->metaInfoLabels = metaInfoLabels;
+    m_sharedData->metaInfoValues = metaInfoValues;
+    m_sharedData->files = files;
 }
 
 void MetaDataWidget::Private::LoadFilesThread::initMetaInfoSettings(KConfigGroup& group)
@@ -430,7 +502,7 @@ QString MetaDataWidget::Private::LoadFilesThread::tunedLabel(const QString& labe
     return tunedLabel + ':';
 }
 
-#endif
+#endif // HAVE_NEPOMUK
 
 MetaDataWidget::MetaDataWidget(QWidget* parent) :
     QWidget(parent),
index 1b390b27556a43c5f3e53d9a14b65a168b1e4c52..f12ce65d96efa147cd91fe7eeacd5905f7dd1e79 100644 (file)
 #ifndef METADATAWIDGET_H
 #define METADATAWIDGET_H
 
+#include <config-nepomuk.h>
+#ifdef HAVE_NEPOMUK
+    #include <Nepomuk/Tag>
+#else
+    // The HAVE_NEPOMUK macro cannot be used in combination with
+    // Q_PRIVATE_SLOT, hence a workaround is used for environments
+    // where Nepomuk is not available:
+    namespace Nepomuk {
+        typedef int Tag;
+    }
+#endif
+
+#include <QList>
 #include <QWidget>
 
 class KFileItem;
@@ -45,6 +58,10 @@ private:
     Private* d;
 
     Q_PRIVATE_SLOT(d, void slotLoadingFinished())
+    Q_PRIVATE_SLOT(d, void slotRatingChanged(unsigned int rating))
+    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())
 };
 
 #endif
index bd3aada6adf99a3587a41b35a92fec402389f3e5..8e3813023aaacd290b2fd0c4d845df684e53ae38 100644 (file)
 #include "nepomukmassupdatejob_p.h"
 
 #include <klocale.h>
-#include <kdebug.h>
 
 #include <nepomuk/tag.h>
 #include <nepomuk/tools.h>
 
 
-Nepomuk::MassUpdateJob::MassUpdateJob( QObject* parent )
-    : KJob( parent ),
-      m_index( -1 )
+Nepomuk::MassUpdateJob::MassUpdateJob(QObject* parent)
+    : KJob(parent),
+      m_index(-1)
 {
-    kDebug();
-    setCapabilities( Killable|Suspendable );
-    connect( &m_processTimer, SIGNAL( timeout() ),
-             this, SLOT( slotNext() ) );
+    setCapabilities(Killable|Suspendable);
+    connect(&m_processTimer, SIGNAL(timeout()),
+             this, SLOT(slotNext()));
 }
 
-
 Nepomuk::MassUpdateJob::~MassUpdateJob()
 {
-    kDebug();
 }
 
-
-void Nepomuk::MassUpdateJob::setFiles( const KUrl::List& urls )
+void Nepomuk::MassUpdateJob::setFiles(const KUrl::List& urls)
 {
     m_resources.clear();
-    foreach( const KUrl &url, urls ) {
-        m_resources.append( Resource( url ) );
+    foreach(const KUrl &url, urls){
+        m_resources.append(Resource(url));
     }
-    setTotalAmount( KJob::Files, m_resources.count() );
+    setTotalAmount(KJob::Files, m_resources.count());
 }
 
-
-void Nepomuk::MassUpdateJob::setResources( const QList<Nepomuk::Resource>& rl )
+void Nepomuk::MassUpdateJob::setResources(const QList<Nepomuk::Resource>& rl)
 {
     m_resources = rl;
-    setTotalAmount( KJob::Files, m_resources.count() );
+    setTotalAmount(KJob::Files, m_resources.count());
 }
 
-
-void Nepomuk::MassUpdateJob::setProperties( const QList<QPair<QUrl,Nepomuk::Variant> >& props )
+void Nepomuk::MassUpdateJob::setProperties(const QList<QPair<QUrl,Nepomuk::Variant> >& props)
 {
     m_properties = props;
 }
 
-
 void Nepomuk::MassUpdateJob::start()
 {
-    if ( m_index < 0 ) {
-        kDebug();
-        emit description( this,
-                          i18nc("@info:progress", "Changing annotations") );
+    if (m_index < 0){
+        emit description(this, i18nc("@info:progress", "Changing annotations"));
         m_index = 0;
         m_processTimer.start();
     }
-    else {
-        kDebug() << "Job has already been started";
-    }
 }
 
 
 bool Nepomuk::MassUpdateJob::doKill()
 {
-    if ( m_index > 0 ) {
+    if (m_index > 0){
         m_processTimer.stop();
         m_index = -1;
         return true;
-    }
-    else {
+    } else {
         return false;
     }
 }
 
-
 bool Nepomuk::MassUpdateJob::doSuspend()
 {
     m_processTimer.stop();
     return true;
 }
 
-
 bool Nepomuk::MassUpdateJob::doResume()
 {
-    if ( m_index > 0 ) {
+    if (m_index > 0){
         m_processTimer.start();
         return true;
-    }
-    else {
+    } else {
         return false;
     }
 }
 
-
 void Nepomuk::MassUpdateJob::slotNext()
 {
-    if ( !isSuspended() ) {
-        if ( m_index < m_resources.count() ) {
+    if (!isSuspended()) {
+        if (m_index < m_resources.count()){
             Nepomuk::Resource& res = m_resources[m_index];
-            for ( int i = 0; i < m_properties.count(); ++i ) {
-                res.setProperty( m_properties[i].first, m_properties[i].second );
+            for (int i = 0; i < m_properties.count(); ++i){
+                res.setProperty(m_properties[i].first, m_properties[i].second);
             }
             ++m_index;
-            setProcessedAmount( KJob::Files, m_index );
-        }
-        else if ( m_index >= m_resources.count() ) {
-            kDebug() << "done";
+            setProcessedAmount(KJob::Files, m_index);
+        } else if (m_index >= m_resources.count()) {
             m_index = -1;
             m_processTimer.stop();
             emitResult();
@@ -133,30 +113,36 @@ void Nepomuk::MassUpdateJob::slotNext()
     }
 }
 
-
-Nepomuk::MassUpdateJob* Nepomuk::MassUpdateJob::tagResources( const QList<Nepomuk::Resource>& rl, const QList<Nepomuk::Tag>& tags )
+Nepomuk::MassUpdateJob* Nepomuk::MassUpdateJob::tagResources(const QList<Nepomuk::Resource>& rl,
+                                                             const QList<Nepomuk::Tag>& tags)
 {
     Nepomuk::MassUpdateJob* job = new Nepomuk::MassUpdateJob();
-    job->setResources( rl );
-    job->setProperties( QList<QPair<QUrl,Nepomuk::Variant> >() << qMakePair( QUrl( Nepomuk::Resource::tagUri() ), Nepomuk::Variant( convertResourceList<Tag>( tags ) ) ) );
+    job->setResources(rl);
+    job->setProperties(QList<QPair<QUrl,Nepomuk::Variant> >() <<
+                       qMakePair(QUrl(Nepomuk::Resource::tagUri()),
+                       Nepomuk::Variant(convertResourceList<Tag>(tags))));
     return job;
 }
 
-
-Nepomuk::MassUpdateJob* Nepomuk::MassUpdateJob::rateResources( const QList<Nepomuk::Resource>& rl, int rating )
+Nepomuk::MassUpdateJob* Nepomuk::MassUpdateJob::rateResources(const QList<Nepomuk::Resource>& rl,
+                                                              unsigned int rating)
 {
     Nepomuk::MassUpdateJob* job = new Nepomuk::MassUpdateJob();
-    job->setResources( rl );
-    job->setProperties( QList<QPair<QUrl,Nepomuk::Variant> >() << qMakePair( QUrl( Nepomuk::Resource::ratingUri() ), Nepomuk::Variant( rating ) ) );
+    job->setResources(rl);
+    job->setProperties(QList<QPair<QUrl,Nepomuk::Variant> >() <<
+                       qMakePair(QUrl(Nepomuk::Resource::ratingUri()),
+                       Nepomuk::Variant(rating)));
     return job;
 }
 
-
-Nepomuk::MassUpdateJob* Nepomuk::MassUpdateJob::commentResources( const QList<Nepomuk::Resource>& rl, const QString& comment )
+Nepomuk::MassUpdateJob* Nepomuk::MassUpdateJob::commentResources(const QList<Nepomuk::Resource>& rl,
+                                                                 const QString& comment)
 {
     Nepomuk::MassUpdateJob* job = new Nepomuk::MassUpdateJob();
-    job->setResources( rl );
-    job->setProperties( QList<QPair<QUrl,Nepomuk::Variant> >() << qMakePair( QUrl( Nepomuk::Resource::descriptionUri() ), Nepomuk::Variant( comment ) ) );
+    job->setResources(rl);
+    job->setProperties(QList<QPair<QUrl,Nepomuk::Variant> >() <<
+                       qMakePair(QUrl(Nepomuk::Resource::descriptionUri()),
+                       Nepomuk::Variant(comment)));
     return job;
 }
 
index a19fa5ff95f4ddcf54c226e18dfd15d4bf668383..659fbd4e82586bd15f23c02711f68c8fda761f93 100644 (file)
@@ -17,8 +17,8 @@
  *   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA            *
  ***************************************************************************/
 
-#ifndef _NEPOMUK_MASS_UPDATE_JOB_H_
-#define _NEPOMUK_MASS_UPDATE_JOB_H_
+#ifndef NEPOMUK_MASS_UPDATE_JOB_H
+#define NEPOMUK_MASS_UPDATE_JOB_H
 
 #include <kjob.h>
 #include <kurl.h>
@@ -37,34 +37,34 @@ namespace Nepomuk {
         Q_OBJECT
 
     public:
-        MassUpdateJob( QObject* parent = 0 );
-        ~MassUpdateJob();
+        MassUpdateJob(QObject* parent = 0);
+        virtual ~MassUpdateJob();
 
         /**
          * Set a list of files to change
          * This has the same effect as using setResources
          * with a list of manually created resources.
          */
-        void setFiles( const KUrl::List& urls );
+        void setFiles(const KUrl::List& urls);
 
         /**
          * Set a list of resources to change.
          */
-        void setResources( const QList<Nepomuk::Resource>& );
+        void setResources(const QList<Nepomuk::Resource>&);
 
         /**
          * Set the properties to change in the mass update.
          */
-        void setProperties( const QList<QPair<QUrl,Nepomuk::Variant> >& props );
+        void setProperties(const QList<QPair<QUrl,Nepomuk::Variant> >& props);
 
         /**
          * Actually start the job.
          */
         void start();
 
-        static MassUpdateJob* tagResources( const QList<Nepomuk::Resource>&, const QList<Nepomuk::Tag>& tags );
-        static MassUpdateJob* commentResources( const QList<Nepomuk::Resource>&, const QString& comment );
-        static MassUpdateJob* rateResources( const QList<Nepomuk::Resource>&, int rating );
+        static MassUpdateJob* tagResources(const QList<Nepomuk::Resource>&, const QList<Nepomuk::Tag>& tags);
+        static MassUpdateJob* commentResources(const QList<Nepomuk::Resource>&, const QString& comment);
+        static MassUpdateJob* rateResources(const QList<Nepomuk::Resource>&, unsigned int rating);
 
     protected:
         bool doKill();
index a0029234a32a6d36fbfa4cc32d5a19a8b5064619..caba8fd41e17f4203a9123ede466871e48f5de9b 100644 (file)
@@ -19,6 +19,8 @@
 
 #include "taggingwidget_p.h"
 
+#include "edittagsdialog_p.h"
+
 #include <kglobalsettings.h>
 #include <klocale.h>
 
@@ -78,7 +80,33 @@ QList<Nepomuk::Tag> TaggingWidget::tags() const
 void TaggingWidget::slotLinkActivated(const QString& link)
 {
     Q_UNUSED(link);
-    // TODO
+
+    EditTagsDialog dialog(m_tags, this, Qt::Dialog);
+    KConfigGroup dialogConfig(KSharedConfig::openConfig("dolphinrc"),
+                              "EditTagsDialog");
+    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);
 }
 
 #include "taggingwidget_p.moc"
index 50f15ffe5d0ccb57afd5d1f9570fd1bb180fb839..64f8bffd56621f3614b396c2bdd51b6f503717e5 100644 (file)
@@ -17,8 +17,8 @@
  *   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA            *
  ***************************************************************************/
 
-#ifndef TAGGING_WIDGET
-#define TAGGING_WIDGET
+#ifndef TAGGING_WIDGET_H
+#define TAGGING_WIDGET_H
 
 #include <nepomuk/tag.h>
 #include <QString>
@@ -37,6 +37,9 @@ public:
     void setTags(const QList<Nepomuk::Tag>& tags);
     QList<Nepomuk::Tag> tags() const;
 
+signals:
+    void tagsChanged(const QList<Nepomuk::Tag>& tags);
+
 private slots:
     void slotLinkActivated(const QString& link);