]> git.sesse.net Git - kdenlive/blobdiff - src/projectlist.cpp
Show Nepomuk rating in appropriate column
[kdenlive] / src / projectlist.cpp
index 82f6aa31ed7f021ca2f80708e864bb0ecb3406f9..7ff691f0c2f99ed319b5dadcbf91595b219d606b 100644 (file)
@@ -33,8 +33,8 @@
 #include <KMessageBox>
 
 #include <nepomuk/global.h>
-#include <nepomuk/resource.h>
-#include <nepomuk/tag.h>
+#include <nepomuk/resourcemanager.h>
+//#include <nepomuk/tag.h>
 
 #include "projectlist.h"
 #include "projectitem.h"
@@ -60,7 +60,7 @@ ProjectList::ProjectList(QWidget *parent)
     listView = new ProjectListView(this);;
     QVBoxLayout *layout = new QVBoxLayout;
     layout->setContentsMargins(0, 0, 0, 0);
-    m_clipIdCounter = 0;
+    // mbd: I think this has died at some point: m_clipIdCounter = 0;
     // setup toolbar
     searchView = new KTreeWidgetSearchLine(this);
     m_toolbar = new QToolBar("projectToolBar", this);
@@ -94,6 +94,14 @@ ProjectList::ProjectList(QWidget *parent)
 
     ItemDelegate *listViewDelegate = new ItemDelegate(listView);
     listView->setItemDelegate(listViewDelegate);
+
+    if (KdenliveSettings::activate_nepomuk()) {
+        Nepomuk::ResourceManager::instance()->init();
+        if (!Nepomuk::ResourceManager::instance()->initialized()) {
+            kDebug() << "Cannot communicate with Nepomuk, DISABLING it";
+            KdenliveSettings::setActivate_nepomuk(false);
+        }
+    }
 }
 
 ProjectList::~ProjectList() {
@@ -142,6 +150,7 @@ void ProjectList::slotEditClip() {
 
 void ProjectList::setRenderer(Render *projectRender) {
     m_render = projectRender;
+    listView->setIconSize(QSize(40 * m_render->dar(), 40));
 }
 
 void ProjectList::slotClipSelected() {
@@ -190,12 +199,7 @@ void ProjectList::slotUpdateClipProperties(ProjectItem *clip, QMap <QString, QSt
         if (KdenliveSettings::activate_nepomuk() && (type == AUDIO || type == VIDEO || type == AV || type == IMAGE || type == PLAYLIST)) {
             // Use Nepomuk system to store clip description
             Nepomuk::Resource f(clip->clipUrl().path());
-            if (f.isValid()) {
-                f.setDescription(properties.value("description"));
-            } else {
-                KMessageBox::sorry(this, i18n("Cannot access Desktop Search info for %1.\nDisabling Desktop Search integration.", clip->clipUrl().path()));
-                KdenliveSettings::setActivate_nepomuk(false);
-            }
+            f.setDescription(properties.value("description"));
         }
         emit projectModified();
     }
@@ -357,7 +361,7 @@ void ProjectList::slotAddClip(DocClipBase *clip, bool getProperties) {
     if (getProperties) listView->setEnabled(false);
     listView->blockSignals(true);
     const QString parent = clip->getProperty("groupid");
-    //kDebug() << "Adding clip with groupid: " << parent;
+    kDebug() << "Adding clip with groupid: " << parent;
     ProjectItem *item = NULL;
     if (!parent.isEmpty()) {
         ProjectItem *parentitem = getFolderItemById(parent);
@@ -379,21 +383,20 @@ void ProjectList::slotAddClip(DocClipBase *clip, bool getProperties) {
     if (!url.isEmpty() && KdenliveSettings::activate_nepomuk()) {
         // if file has Nepomuk comment, use it
         Nepomuk::Resource f(url.path());
-        QString annotation;
-        if (f.isValid()) {
-            annotation = f.description();
-            /*
-            Nepomuk::Tag tag("test");
-            f.addTag(tag);*/
-        } else {
-            KMessageBox::sorry(this, i18n("Cannot access Desktop Search info for %1.\nDisabling Desktop Search integration.", url.path()));
-            KdenliveSettings::setActivate_nepomuk(false);
-        }
+        QString annotation = f.description();
         if (!annotation.isEmpty()) item->setText(2, annotation);
     }
     listView->blockSignals(false);
 }
 
+void ProjectList::slotResetProjectList() {
+    listView->clear();
+    emit clipSelected(NULL);
+    m_thumbnailQueue.clear();
+    m_infoQueue.clear();
+    m_refreshed = false;
+}
+
 void ProjectList::requestClipInfo(const QDomElement xml, const QString id) {
     kDebug() << " PRG LIST REQUEST CLP INFO: " << id;
     m_infoQueue.insert(id, xml);
@@ -498,6 +501,7 @@ void ProjectList::slotRemoveInvalidClip(const QString &id) {
         m_doc->deleteProjectClip(ids);
     }
     if (!m_infoQueue.isEmpty()) QTimer::singleShot(300, this, SLOT(slotProcessNextClipInQueue()));
+    else listView->setEnabled(true);
 }
 
 void ProjectList::slotAddColorClip() {
@@ -578,6 +582,7 @@ void ProjectList::slotAddTitleClip() {
 void ProjectList::setDocument(KdenliveDoc *doc) {
     listView->blockSignals(true);
     listView->clear();
+    emit clipSelected(NULL);
     m_thumbnailQueue.clear();
     m_infoQueue.clear();
     m_refreshed = false;
@@ -666,6 +671,7 @@ void ProjectList::slotReplyGetFileProperties(const QString &clipId, Mlt::Produce
     if (item && producer) {
         listView->blockSignals(true);
         item->setProperties(properties, metadata);
+        Q_ASSERT_X(item->referencedClip(), "void ProjectList::slotReplyGetFileProperties", QString("Item with groupName %1 does not have a clip associated").arg(item->groupName()).toLatin1());
         item->referencedClip()->setProducer(producer);
         emit receivedClipDuration(clipId, item->clipMaxDuration());
         listView->blockSignals(false);
@@ -674,7 +680,7 @@ void ProjectList::slotReplyGetFileProperties(const QString &clipId, Mlt::Produce
     else listView->setEnabled(true);
 }
 
-void ProjectList::slotReplyGetImage(const QString &clipId, int pos, const QPixmap &pix, int w, int h) {
+void ProjectList::slotReplyGetImage(const QString &clipId, const QPixmap &pix) {
     ProjectItem *item = getItemById(clipId);
     if (item) {
         listView->blockSignals(true);