]> git.sesse.net Git - kdenlive/commitdiff
Show Nepomuk rating in appropriate column
authorJean-Baptiste Mardelle <jb@kdenlive.org>
Sat, 31 Jan 2009 22:44:09 +0000 (22:44 +0000)
committerJean-Baptiste Mardelle <jb@kdenlive.org>
Sat, 31 Jan 2009 22:44:09 +0000 (22:44 +0000)
svn path=/branches/KDE4/; revision=3019

src/projectitem.cpp
src/projectlist.cpp
src/projectlist.h
src/projectlistview.cpp

index 37de725083e4ae5d1f0be5ae2d6d3a6ca8ab4f06..1ae85001128815a02db53d47d80b577babe3532c 100644 (file)
@@ -60,6 +60,7 @@ ProjectItem::ProjectItem(QTreeWidget * parent, DocClipBase *clip)
     if (m_clipType != UNKNOWN) slotSetToolTip();
     setText(1, name);
     setText(2, m_clip->description());
+    if (m_clipType != SLIDESHOW && m_clipType != TEXT && m_clipType != COLOR) setData(3, Qt::UserRole, m_clip->getProperty("resource"));
     if ((m_clip->clipType() == AV || m_clip->clipType() == AUDIO) && KdenliveSettings::audiothumbnails()) m_clip->askForAudioThumbs();
     //setFlags(Qt::NoItemFlags);
     //kDebug() << "Constructed with clipId: " << m_clipId;
index fd29c7660a778c649c1a27d3bfc81e8df380e56e..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"
@@ -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() {
@@ -191,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();
     }
@@ -380,16 +383,7 @@ 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);
index 1e6c032bf7e226530b7247d4d7adb82ce80621cc..eef31c6be2f4815fd5e4ed501ff0f2efa5eac3bd 100644 (file)
 
 #include <KTreeWidgetSearchLine>
 #include <KUrl>
+#include <nepomuk/kratingpainter.h>
+#include <nepomuk/resource.h>
 
 #include "definitions.h"
 #include "timecode.h"
+#include "kdenlivesettings.h"
 
 namespace Mlt {
 class Producer;
@@ -68,14 +71,11 @@ public:
     */
     void paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const {
         if (index.column() == 1) {
-            const bool hover = option.state & (QStyle::State_Selected);
             QRect r1 = option.rect;
             painter->save();
-            if (hover) {
+            if (option.state & (QStyle::State_Selected)) {
                 painter->setPen(option.palette.color(QPalette::HighlightedText));
-                QColor backgroundColor = option.palette.color(QPalette::Highlight);
-                painter->setBrush(QBrush(backgroundColor));
-                painter->fillRect(r1, QBrush(backgroundColor));
+                painter->fillRect(r1, option.palette.highlight());
             }
             QFont font = painter->font();
             font.setBold(true);
@@ -94,6 +94,18 @@ public:
             painter->setPen(option.palette.color(QPalette::Mid));
             painter->drawText(r2, Qt::AlignLeft | Qt::AlignVCenter , subText);
             painter->restore();
+        } else if (index.column() == 3 && KdenliveSettings::activate_nepomuk()) {
+            const QString url = index.data(Qt::UserRole).toString();
+            if (url.isEmpty()) {
+                QItemDelegate::paint(painter, option, index);
+                return;
+            }
+            QRect r1 = option.rect;
+            if (option.state & (QStyle::State_Selected)) {
+                painter->fillRect(r1, option.palette.highlight());
+            }
+            Nepomuk::Resource f(url);
+            KRatingPainter::paintRating(painter, r1, Qt::AlignCenter, f.rating());
         } else {
             QItemDelegate::paint(painter, option, index);
         }
index c2aacf800e0b2d8decfcdbc92a320b6cbc49b3f1..d76e85c4ff132be9fc19a703ae3b2ff161abb17c 100644 (file)
@@ -72,7 +72,7 @@ void ProjectListView::configureColumns(const QPoint& pos) {
         const QString text = model()->headerData(i, Qt::Horizontal).toString();
         QAction* action = popup.addAction(text);
         action->setCheckable(true);
-        action->setChecked(!headerView->isSectionHidden(logicalIndex));
+        action->setChecked(!headerView->isSectionHidden(i));
         action->setData(i);
     }