From: Jean-Baptiste Mardelle Date: Sat, 31 Jan 2009 22:44:09 +0000 (+0000) Subject: Show Nepomuk rating in appropriate column X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=35ff94d85a5b01e0d96eac2504a6e166ae5cef9e;p=kdenlive Show Nepomuk rating in appropriate column svn path=/branches/KDE4/; revision=3019 --- diff --git a/src/projectitem.cpp b/src/projectitem.cpp index 37de7250..1ae85001 100644 --- a/src/projectitem.cpp +++ b/src/projectitem.cpp @@ -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; diff --git a/src/projectlist.cpp b/src/projectlist.cpp index fd29c766..7ff691f0 100644 --- a/src/projectlist.cpp +++ b/src/projectlist.cpp @@ -33,8 +33,8 @@ #include #include -#include -#include +#include +//#include #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 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); diff --git a/src/projectlist.h b/src/projectlist.h index 1e6c032b..eef31c6b 100644 --- a/src/projectlist.h +++ b/src/projectlist.h @@ -32,9 +32,12 @@ #include #include +#include +#include #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); } diff --git a/src/projectlistview.cpp b/src/projectlistview.cpp index c2aacf80..d76e85c4 100644 --- a/src/projectlistview.cpp +++ b/src/projectlistview.cpp @@ -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); }