]> cloud.milkyroute.net Git - dolphin.git/commitdiff
* Starts to add Nepomuk supports to dolphin (currently, only annotations are supported)
authorOscar Blumberg <o.blumberg@robertlan.eu.org>
Thu, 22 Feb 2007 16:45:53 +0000 (16:45 +0000)
committerOscar Blumberg <o.blumberg@robertlan.eu.org>
Thu, 22 Feb 2007 16:45:53 +0000 (16:45 +0000)
* Little changes in InfoSidebarPage (no more multiple label for infos & Q3Layout>QLayout)
* Support infos for multiple files (only total size, what else ?)

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

src/CMakeLists.txt
src/dolphinapplication.cpp
src/dolphinapplication.h
src/dolphinmainwindow.cpp
src/infosidebarpage.cpp
src/infosidebarpage.h
src/metadataloader.cpp [new file with mode: 0644]
src/metadataloader.h [new file with mode: 0644]

index d07886a1b3841f2bbe391450304ce2dbcd8a3681..7c39fa1d97468f0d9fe208d1be85b682c395699c 100644 (file)
@@ -33,6 +33,7 @@ set(dolphin_SRCS
    iconsviewsettingspage.cpp
    infosidebarpage.cpp
    main.cpp
    iconsviewsettingspage.cpp
    infosidebarpage.cpp
    main.cpp
+   metadataloader.cpp
    protocolcombo.cpp
    pixmapviewer.cpp
    renamedialog.cpp
    protocolcombo.cpp
    pixmapviewer.cpp
    renamedialog.cpp
@@ -64,7 +65,7 @@ qt4_add_dbus_adaptor(dolphin_SRCS
    dolphinmainwindow.h DolphinMainWindow)
 kde4_add_executable(dolphin ${dolphin_SRCS})
 
    dolphinmainwindow.h DolphinMainWindow)
 kde4_add_executable(dolphin ${dolphin_SRCS})
 
-target_link_libraries(dolphin  ${KDE4_KDECORE_LIBS} ${KDE4_KDEPRINT_LIBS} konq )
+target_link_libraries(dolphin  ${KDE4_KDECORE_LIBS} ${KDE4_KDEPRINT_LIBS} konq kmetadata)
 
 install(TARGETS dolphin DESTINATION ${BIN_INSTALL_DIR})
 
 
 install(TARGETS dolphin DESTINATION ${BIN_INSTALL_DIR})
 
index cad0056304588a5bf9db5f4ae2906e6e990acc49..b426ec1b821b946e1a3011e58da8ddceaa888575 100644 (file)
@@ -20,6 +20,7 @@
 
 #include "dolphinapplication.h"
 #include "dolphinmainwindow.h"
 
 #include "dolphinapplication.h"
 #include "dolphinmainwindow.h"
+#include "metadataloader.h"
 
 #include <applicationadaptor.h>
 #include <kurl.h>
 
 #include <applicationadaptor.h>
 #include <kurl.h>
@@ -55,6 +56,12 @@ DolphinMainWindow* DolphinApplication::createMainWindow()
     return mainWindow;
 }
 
     return mainWindow;
 }
 
+MetadataLoader* DolphinApplication::metadataLoader()
+{
+    static MetadataLoader loader;
+    return &loader;
+}
+
 int DolphinApplication::openWindow(const QString& url)
 {
     DolphinMainWindow* win = createMainWindow();
 int DolphinApplication::openWindow(const QString& url)
 {
     DolphinMainWindow* win = createMainWindow();
@@ -62,6 +69,7 @@ int DolphinApplication::openWindow(const QString& url)
         win->activeView()->setUrl(KUrl(url));
     }
     win->show();
         win->activeView()->setUrl(KUrl(url));
     }
     win->show();
+    //TODO find how to raise a window (as if we've launched a new dolphin process)
     return win->getId();
 }
 
     return win->getId();
 }
 
index fa6a1ceeefb6f0b7399b49d6accfaaaf5f5941be..ad95f23920b1e2a3f7b1a0dfde8dd34ac76c829c 100644 (file)
@@ -25,6 +25,7 @@
 #include <kuniqueapplication.h>
 
 class DolphinMainWindow;
 #include <kuniqueapplication.h>
 
 class DolphinMainWindow;
+class MetadataLoader;
 
 /**
  * @brief Holds the application data which can be accessed.
 
 /**
  * @brief Holds the application data which can be accessed.
@@ -51,6 +52,11 @@ public:
     DolphinMainWindow* createMainWindow();
     void refreshMainWindows();
 
     DolphinMainWindow* createMainWindow();
     void refreshMainWindows();
 
+    /**
+     * Returns the metadata loader.
+     */
+    MetadataLoader* metadataLoader();
+
 public slots:
     int openWindow(const QString& url);
 
 public slots:
     int openWindow(const QString& url);
 
index 2cf524bbd7f124c9558474387c1361ac3b95006b..adc7d17ceebc7c4f09ce3ee94db8e49f072b4c9e 100644 (file)
@@ -36,6 +36,7 @@
 #include "dolphin_generalsettings.h"\r
 #include "viewpropertiesdialog.h"\r
 #include "viewproperties.h"\r
 #include "dolphin_generalsettings.h"\r
 #include "viewpropertiesdialog.h"\r
 #include "viewproperties.h"\r
+#include "metadataloader.h"\r
 #include "mainwindowadaptor.h"\r
 \r
 #include <kaction.h>\r
 #include "mainwindowadaptor.h"\r
 \r
 #include <kaction.h>\r
@@ -952,6 +953,9 @@ void DolphinMainWindow::init()
         // assure a proper default size if Dolphin runs the first time\r
         resize(640, 480);\r
     }\r
         // assure a proper default size if Dolphin runs the first time\r
         resize(640, 480);\r
     }\r
+    \r
+    if (!DolphinApplication::app()->metadataLoader()->storageUp())\r
+        activeView()->statusBar()->setMessage(i18n("Failed to contact Nepomuk service, annotation and tagging are disabled."), DolphinStatusBar::Error);\r
 }\r
 \r
 void DolphinMainWindow::loadSettings()\r
 }\r
 \r
 void DolphinMainWindow::loadSettings()\r
index 2336e1dd420ae5eb144b83faf09d968c431e652f..efc85cc71ed9bb847797cd7ebf1a2d5842d64532 100644 (file)
@@ -36,6 +36,7 @@
 #include <Q3ValueList>
 #include <QEvent>
 #include <Q3VBoxLayout>
 #include <Q3ValueList>
 #include <QEvent>
 #include <Q3VBoxLayout>
+#include <QInputDialog>
 
 #include <kbookmarkmanager.h>
 #include <klocale.h>
 
 #include <kbookmarkmanager.h>
 #include <klocale.h>
 #include <kvbox.h>
 
 #include "dolphinmainwindow.h"
 #include <kvbox.h>
 
 #include "dolphinmainwindow.h"
+#include "dolphinapplication.h"
 #include "pixmapviewer.h"
 #include "dolphinsettings.h"
 #include "pixmapviewer.h"
 #include "dolphinsettings.h"
+#include "metadataloader.h"
 
 InfoSidebarPage::InfoSidebarPage(DolphinMainWindow* mainWindow, QWidget* parent) :
     SidebarPage(mainWindow, parent),
 
 InfoSidebarPage::InfoSidebarPage(DolphinMainWindow* mainWindow, QWidget* parent) :
     SidebarPage(mainWindow, parent),
@@ -58,9 +61,8 @@ InfoSidebarPage::InfoSidebarPage(DolphinMainWindow* mainWindow, QWidget* parent)
     m_timer(0),
     m_preview(0),
     m_name(0),
     m_timer(0),
     m_preview(0),
     m_name(0),
-    m_currInfoLineIdx(0),
-    m_infoGrid(0),
-    m_actionBox(0)
+    m_infos(0),
+    m_metadata(DolphinApplication::app()->metadataLoader())
 {
     const int spacing = KDialog::spacingHint();
 
 {
     const int spacing = KDialog::spacingHint();
 
@@ -68,7 +70,7 @@ InfoSidebarPage::InfoSidebarPage(DolphinMainWindow* mainWindow, QWidget* parent)
     connect(m_timer, SIGNAL(timeout()),
             this, SLOT(slotTimeout()));
 
     connect(m_timer, SIGNAL(timeout()),
             this, SLOT(slotTimeout()));
 
-    Q3VBoxLayout* layout = new Q3VBoxLayout(this);
+    QVBoxLayout* layout = new QVBoxLayout;
     layout->setSpacing(spacing);
 
     // preview
     layout->setSpacing(spacing);
 
     // preview
@@ -88,12 +90,27 @@ InfoSidebarPage::InfoSidebarPage(DolphinMainWindow* mainWindow, QWidget* parent)
     sep1->setFixedHeight(1);
 
     // general information
     sep1->setFixedHeight(1);
 
     // general information
-    m_infoGrid = new Q3Grid(2, this);
-    m_infoGrid->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
+    m_infos = new QLabel(this);
+    m_infos->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
+    m_infos->setTextFormat(Qt::RichText);
+
+    // annotation
+    if (m_metadata->storageUp()) {
+        m_annotationLabel = new QLabel(this);
+        m_annotationLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
+        m_annotationLabel->setTextFormat(Qt::RichText);
+        m_annotationLabel->setWordWrap(true);
+        m_annotationButton = new QPushButton("", this);
+        m_annotationButton->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
+        connect(m_annotationButton, SIGNAL(released()), this, SLOT(changeAnnotation()));
+    }
 
     QWidget* sep2 = new Q3HGroupBox(this);  // TODO: check whether default widget exist for this?
     sep2->setFixedHeight(1);
 
 
     QWidget* sep2 = new Q3HGroupBox(this);  // TODO: check whether default widget exist for this?
     sep2->setFixedHeight(1);
 
+    QWidget* sep3 = new Q3HGroupBox(this);  // TODO: check whether default widget exist for this?
+    sep3->setFixedHeight(1);
+
     // actions
     m_actionBox = new KVBox(this);
     m_actionBox->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
     // actions
     m_actionBox = new KVBox(this);
     m_actionBox->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
@@ -106,11 +123,16 @@ InfoSidebarPage::InfoSidebarPage(DolphinMainWindow* mainWindow, QWidget* parent)
     layout->addWidget(m_preview);
     layout->addWidget(m_name);
     layout->addWidget(sep1);
     layout->addWidget(m_preview);
     layout->addWidget(m_name);
     layout->addWidget(sep1);
-    layout->addWidget(m_infoGrid);
+    layout->addWidget(m_infos);
     layout->addWidget(sep2);
     layout->addWidget(sep2);
+    if (m_metadata->storageUp()) {
+        layout->addWidget(m_annotationLabel);
+        layout->addWidget(m_annotationButton);
+        layout->addWidget(sep3);
+    }
     layout->addWidget(m_actionBox);
     layout->addWidget(dummy);
     layout->addWidget(m_actionBox);
     layout->addWidget(dummy);
-
+    setLayout(layout);
     connect(mainWindow, SIGNAL(selectionChanged()),
             this, SLOT(showItemInfo()));
 
     connect(mainWindow, SIGNAL(selectionChanged()),
             this, SLOT(showItemInfo()));
 
@@ -281,10 +303,6 @@ void InfoSidebarPage::cancelRequest()
 
 void InfoSidebarPage::createMetaInfo()
 {
 
 void InfoSidebarPage::createMetaInfo()
 {
-    // To prevent a flickering it's important to reuse available
-    // labels instead of deleting them and recreate them afterwards.
-    // The methods beginInfoLines(), addInfoLine() and endInfoLines()
-    // take care of this.
     beginInfoLines();
     DolphinView* view = mainWindow()->activeView();
     if (!view->hasSelection()) {
     beginInfoLines();
     DolphinView* view = mainWindow()->activeView();
     if (!view->hasSelection()) {
@@ -294,56 +312,47 @@ void InfoSidebarPage::createMetaInfo()
         if (fileItem.isDir()) {
             addInfoLine(i18n("Type:"), i18n("Directory"));
         }
         if (fileItem.isDir()) {
             addInfoLine(i18n("Type:"), i18n("Directory"));
         }
-        else {
-            addInfoLine(i18n("Type:"), fileItem.mimeComment());
-
-            QString sizeText(KIO::convertSize(fileItem.size()));
-            addInfoLine(i18n("Size:"), sizeText);
-            addInfoLine(i18n("Modified:"), fileItem.timeString());
-
-            const KFileMetaInfo& metaInfo = fileItem.metaInfo();
-            if (metaInfo.isValid()) {
-                QStringList keys = metaInfo.supportedKeys();
-                for (QStringList::Iterator it = keys.begin(); it != keys.end(); ++it) {
-                    if (showMetaInfo(*it)) {
-                        KFileMetaInfoItem metaInfoItem = metaInfo.item(*it);
-                        addInfoLine(*it, metaInfoItem.string());
-                    }
+        showAnnotation(m_shownUrl);
+    }
+    else if (view->selectedItems().count() == 1) {
+        KFileItem* fileItem = view->selectedItems()[0];
+        addInfoLine(i18n("Type:"), fileItem->mimeComment());
+
+        QString sizeText(KIO::convertSize(fileItem->size()));
+        addInfoLine(i18n("Size:"), sizeText);
+        addInfoLine(i18n("Modified:"), fileItem->timeString());
+
+        const KFileMetaInfo& metaInfo = fileItem->metaInfo();
+        if (metaInfo.isValid()) {
+            QStringList keys = metaInfo.supportedKeys();
+            for (QStringList::Iterator it = keys.begin(); it != keys.end(); ++it) {
+                if (showMetaInfo(*it)) {
+                    KFileMetaInfoItem metaInfoItem = metaInfo.item(*it);
+                    addInfoLine(*it, metaInfoItem.string());
                 }
             }
         }
                 }
             }
         }
+        showAnnotation(fileItem->url());
+    }
+    else {
+        showAnnotations(view->selectedItems().urlList());
+        unsigned long int totSize = 0;
+        foreach(KFileItem* item, view->selectedItems()) {
+            totSize += item->size(); //FIXME what to do with directories ? (same with the one-item-selected-code), item->size() does not return the size of the content : not very instinctive for users
+        }
+        addInfoLine(i18n("Total size:"), KIO::convertSize(totSize));
     }
     endInfoLines();
 }
 
 void InfoSidebarPage::beginInfoLines()
 {
     }
     endInfoLines();
 }
 
 void InfoSidebarPage::beginInfoLines()
 {
-    m_currInfoLineIdx = 0;
+    m_infoLines = QString("");
 }
 
 void InfoSidebarPage::endInfoLines()
 {
 }
 
 void InfoSidebarPage::endInfoLines()
 {
-    if (m_currInfoLineIdx <= 0) {
-        return;
-    }
-
-    // remove labels which have not been used
-    if (m_currInfoLineIdx < static_cast<int>(m_infoWidgets.count())) {
-        Q3PtrListIterator<QLabel> deleteIter(m_infoWidgets);
-        deleteIter += m_currInfoLineIdx;
-
-        QWidget* widget = 0;
-        int removeCount = 0;
-        while ((widget = deleteIter.current()) != 0) {
-            widget->close();
-            widget->deleteLater();
-            ++deleteIter;
-            ++removeCount;
-        }
-        for (int i = 0; i < removeCount; ++i) {
-            m_infoWidgets.removeLast();
-        }
-    }
+    m_infos->setText(m_infoLines);
 }
 
 bool InfoSidebarPage::showMetaInfo(const QString& key) const
 }
 
 bool InfoSidebarPage::showMetaInfo(const QString& key) const
@@ -386,34 +395,9 @@ bool InfoSidebarPage::showMetaInfo(const QString& key) const
 
 void InfoSidebarPage::addInfoLine(const QString& labelText, const QString& infoText)
 {
 
 void InfoSidebarPage::addInfoLine(const QString& labelText, const QString& infoText)
 {
-    QString labelStr("<b>");
-    labelStr.append(labelText);
-    labelStr.append("</b>&nbsp;");
-
-    const int count = m_infoWidgets.count();
-    if (m_currInfoLineIdx < count - 1) {
-        // reuse available labels
-        m_infoWidgets.at(m_currInfoLineIdx++)->setText(labelStr);
-        m_infoWidgets.at(m_currInfoLineIdx++)->setText(infoText);
-    }
-    else {
-        // no labels are available anymore, hence create 2 new ones
-        QLabel* label = new QLabel(labelStr, m_infoGrid);
-        label->setTextFormat(Qt::RichText);
-        label->setAlignment(Qt::AlignRight |
-                            Qt::AlignTop);
-        label->show();
-        m_infoWidgets.append(label);
-
-        QLabel* info = new QLabel(infoText, m_infoGrid);
-        info->setTextFormat(Qt::RichText);
-        info->setAlignment(Qt::AlignTop);
-        info->setWordWrap(true);
-        info->show();
-        m_infoWidgets.append(info);
-
-        m_currInfoLineIdx += 2;
-    }
+    if (!m_infoLines.isEmpty())
+        m_infoLines += "<br/>";
+    m_infoLines += QString("<b>%1</b> %2").arg(labelText).arg(infoText);
 }
 
 void InfoSidebarPage::insertActions()
 }
 
 void InfoSidebarPage::insertActions()
@@ -535,6 +519,72 @@ void InfoSidebarPage::insertActions()
     }
 }
 
     }
 }
 
+void InfoSidebarPage::showAnnotation(const KUrl& file)
+{
+    if(m_metadata->storageUp()) {
+        QString text = m_metadata->getAnnotation(file);
+        if (!text.isEmpty()) {
+            m_annotationLabel->show();
+            m_annotationLabel->setText(QString("<b>%1</b> :<br/>%2").arg(i18n("Annotation")).arg(text));
+            m_annotationButton->setText(i18n("Change annotation"));
+        } else {
+            m_annotationLabel->hide();
+            m_annotationButton->setText(i18n("Annotate file"));
+        }
+    }
+}
+
+void InfoSidebarPage::showAnnotations(const KUrl::List& files)
+{
+    static unsigned int maxShownAnnot = 3;
+    if (m_metadata->storageUp()) {
+        bool hasAnnotation = false;
+        unsigned int annotateNum = 0;
+        QString firsts("<b>%1 :</b><br/>");
+        firsts.arg(i18n("Annotations"));
+        foreach (KUrl file, files) {
+            QString annotation = m_metadata->getAnnotation(file);
+            if (!annotation.isEmpty()) {
+                hasAnnotation = true;
+                if(annotateNum < maxShownAnnot) {
+                    firsts += m_annotationLabel->fontMetrics().elidedText(QString("<b>%1</b> : %2<br/>").arg(file.fileName()).arg(annotation), Qt::ElideRight, width());
+                    annotateNum++;
+                }
+            }
+        }
+        if (hasAnnotation) {
+            m_annotationLabel->show();
+            m_annotationLabel->setText(firsts);
+        } else m_annotationLabel->hide();
+        m_annotationButton->setText(hasAnnotation ? i18n("Change annotations") : i18n("Annotate files"));
+    }
+}
+
+void InfoSidebarPage::changeAnnotation()
+{
+    bool ok = false;
+    KUrl::List files(mainWindow()->activeView()->selectedItems().urlList());
+    QString name, old;
+    if (files.isEmpty()) {
+        files << m_shownUrl;
+    }
+    else if (files.count() == 1) {
+        name = files[0].url();
+        old = m_metadata->getAnnotation(files[0]);
+    }
+    else {
+        name = QString("%1 files").arg(files.count());
+        old = QString();
+    }
+    QString text = QInputDialog::getText(this, "Annotate", QString("Set annotation for %1").arg(name), QLineEdit::Normal, old, &ok);//FIXME temporary, must move to a real dialog
+    if(ok) {
+        foreach(KUrl file, files) {
+            m_metadata->setAnnotation(file, text);
+        }
+        showAnnotation(files[0]);
+    }
+}
+
 ServiceButton::ServiceButton(const QIcon& icon,
                              const QString& text,
                              QWidget* parent,
 ServiceButton::ServiceButton(const QIcon& icon,
                              const QString& text,
                              QWidget* parent,
index ad1e71357e2dc4f8eddb66e44f14f0e5c589409c..cebb7f4aae6b8649afed25aabe78351c38ba37fa 100644 (file)
@@ -48,6 +48,7 @@ class QLabel;
 class KVBox;
 class Q3Grid;
 class PixmapViewer;
 class KVBox;
 class Q3Grid;
 class PixmapViewer;
+class MetadataLoader;
 
 /**
  * @brief Prototype for a information sidebar.
 
 /**
  * @brief Prototype for a information sidebar.
@@ -113,6 +114,12 @@ private slots:
      */
     void startService(int index);
 
      */
     void startService(int index);
 
+    /**
+     * Opens a dialog to change the annotation of the currently selected
+     * file(s).
+     */
+    void changeAnnotation();
+
 private:
     /**
      * Connects to signals from the currently active Dolphin view to get
 private:
     /**
      * Connects to signals from the currently active Dolphin view to get
@@ -149,6 +156,16 @@ private:
      */
     void insertActions();
 
      */
     void insertActions();
 
+    /**
+     * Show the annotation of a file in the sidebar.
+     */
+    void showAnnotation(const KUrl& file);
+    
+    /**
+     * Show the annotations of multiple files in the sidebar.
+     */
+    void showAnnotations(const KUrl::List& files);
+    
     bool m_multipleSelection;
     bool m_pendingPreview;
     QTimer* m_timer;
     bool m_multipleSelection;
     bool m_pendingPreview;
     QTimer* m_timer;
@@ -158,13 +175,16 @@ private:
     PixmapViewer* m_preview;
     QLabel* m_name;
 
     PixmapViewer* m_preview;
     QLabel* m_name;
 
-    int m_currInfoLineIdx;
-    Q3Grid* m_infoGrid;
-    Q3PtrList<QLabel> m_infoWidgets;       // TODO: use children() from QObject instead
+    QString m_infoLines;
+    QLabel* m_infos;
 
     KVBox* m_actionBox;
     Q3PtrList<QWidget> m_actionWidgets;    // TODO: use children() from QObject instead
     Q3ValueVector<KDEDesktopMimeType::Service> m_actionsVector;
 
     KVBox* m_actionBox;
     Q3PtrList<QWidget> m_actionWidgets;    // TODO: use children() from QObject instead
     Q3ValueVector<KDEDesktopMimeType::Service> m_actionsVector;
+
+    QLabel* m_annotationLabel;
+    QPushButton* m_annotationButton;//Move to sthing sexy visually
+    MetadataLoader* m_metadata;
 };
 
 // TODO #1: move to SidebarPage?
 };
 
 // TODO #1: move to SidebarPage?
diff --git a/src/metadataloader.cpp b/src/metadataloader.cpp
new file mode 100644 (file)
index 0000000..f43220a
--- /dev/null
@@ -0,0 +1,58 @@
+/***************************************************************************
+ *   Copyright (C) 2006 by Oscar Blumberg                                  *
+ *   o.blumberg@robertlan.eu.org                                           *
+ *                                                                         *
+ *   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 "metadataloader.h"
+
+#include <kmetadata/kmetadata.h>
+#include <kurl.h>
+#include <QString>
+
+MetadataLoader::MetadataLoader()
+{
+    if (Nepomuk::KMetaData::ResourceManager::instance()->init()) {
+        m_up = false;
+        Nepomuk::KMetaData::ResourceManager::instance()->setAutoSync(false);
+    } else {
+        m_up = true;
+    }
+}
+
+MetadataLoader::~MetadataLoader()
+{
+}
+
+bool MetadataLoader::storageUp() {
+    return m_up;
+}
+
+QString MetadataLoader::getAnnotation(const KUrl& file)
+{
+    if(m_up)
+        return Nepomuk::KMetaData::File(file.url()).getAnnotation();
+    else
+        return QString();
+}
+
+void MetadataLoader::setAnnotation(const KUrl& file, const QString& annotation)
+{
+    if(m_up)
+        Nepomuk::KMetaData::File(file.url()).setAnnotation(annotation);
+}
+
diff --git a/src/metadataloader.h b/src/metadataloader.h
new file mode 100644 (file)
index 0000000..98cf718
--- /dev/null
@@ -0,0 +1,54 @@
+/***************************************************************************
+ *   Copyright (C) 2006 by Oscar Blumberg                                  *
+ *   o.blumberg@robertlan.eu.org                                           *
+ *                                                                         *
+ *   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 METADATALOADER_H
+#define METADATALOADER_H
+
+namespace Nempomuk {
+namespace Backbone {
+    class Registry;
+}
+}
+class KUrl;
+class QString;
+
+/**
+ * @brief Load metadata for specific files.
+ * This class uses the KMetaData API to load metadata from the NEPOMUK storage.
+ *
+ * @author Oscar Blumberg <o.blumberg@robertlan.eu.org>
+ */
+class MetadataLoader
+{
+friend class DolphinApplication;
+public:
+        ~MetadataLoader();
+        bool storageUp();
+
+        QString getAnnotation(const KUrl& file);
+        void setAnnotation(const KUrl& file, const QString& annotation);
+
+private:
+        MetadataLoader();
+        bool m_up;
+};
+
+
+#endif