From 4990696d5459af62020d1bb306551c96935a3830 Mon Sep 17 00:00:00 2001 From: Montel Laurent Date: Wed, 22 May 2013 17:04:16 +0200 Subject: [PATCH] Better to use nepomukcore --- src/CMakeLists.txt | 20 +++++++++++++++----- src/clipproperties.cpp | 31 ++++++++++++++++++++++++++++++- src/projectlist.cpp | 15 +++++++++++++++ src/projectlist.h | 10 ++++++++++ src/utils/resourcewidget.cpp | 20 ++++++++++++++++++++ 5 files changed, 90 insertions(+), 6 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 0e51aab4..73983ce9 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -66,6 +66,10 @@ macro_log_feature(Nepomuk_FOUND "http://nepomuk.semanticdesktop.org" ) +find_package(NepomukCore QUIET CONFIG) +set_package_properties(NepomukCore PROPERTIES DESCRIPTION "The Nepomuk Core libraries" URL "http://www.kde.org" TYPE RECOMMENDED PURPOSE "Support for the Nepomuk semantic desktop system") + + macro_log_feature(QJSON_FOUND "QJson" "Qt-based library that maps JSON data to QVariant objects" @@ -344,11 +348,17 @@ if(SDL_FOUND) target_link_libraries(kdenlive ${SDL_LIBRARY}) endif(SDL_FOUND) -if(Nepomuk_FOUND) - add_definitions(-DUSE_NEPOMUK) - include_directories(${NEPOMUK_INCLUDES}) - target_link_libraries(kdenlive ${NEPOMUK_LIBRARIES}) -endif(Nepomuk_FOUND) +if(NepomukCore_FOUND) + add_definitions(-DUSE_NEPOMUKCORE) + include_directories(${NEPOMUK_CORE_INCLUDE_DIR}) + target_link_libraries(kdenlive ${NEPOMUK_CORE_LIBRARY}) +else(NepomukWidgets_FOUND) + if(Nepomuk_FOUND) + add_definitions(-DUSE_NEPOMUK) + include_directories(${NEPOMUK_INCLUDES}) + target_link_libraries(kdenlive ${NEPOMUK_LIBRARIES}) + endif(Nepomuk_FOUND) +endif() if(QJSON_FOUND) add_definitions(-DUSE_QJSON) diff --git a/src/clipproperties.cpp b/src/clipproperties.cpp index 82c536f1..a9e6afe6 100644 --- a/src/clipproperties.cpp +++ b/src/clipproperties.cpp @@ -40,6 +40,12 @@ #include #endif #endif +#ifdef USE_NEPOMUKCORE +#include +#include +#include +#include +#endif #include @@ -490,6 +496,7 @@ ClipProperties::ClipProperties(DocClipBase *clip, const Timecode &tc, double fps // Check for Nepomuk metadata #ifdef USE_NEPOMUK + #if KDE_IS_VERSION(4,6,0) if (!url.isEmpty()) { Nepomuk::ResourceManager::instance()->init(); @@ -509,10 +516,32 @@ ClipProperties::ClipProperties(DocClipBase *clip, const Timecode &tc, double fps #else m_view.clip_license->setHidden(true); #endif + +#else + +#ifdef USE_NEPOMUKCORE + + if (!url.isEmpty()) { + Nepomuk2::ResourceManager::instance()->init(); + Nepomuk2::Resource res( url.path() ); + // Check if file has a license + if (res.hasProperty(Nepomuk2::Vocabulary::NIE::license())) { + QString ltype = res.property(Nepomuk2::Vocabulary::NIE::licenseType()).toString(); + m_view.clip_license->setText(i18n("License: %1", res.property(Nepomuk2::Vocabulary::NIE::license()).toString())); + if (ltype.startsWith("http")) { + m_view.clip_license->setUrl(ltype); + connect(m_view.clip_license, SIGNAL(leftClickedUrl(QString)), this, SLOT(slotOpenUrl(QString))); + } + } + else m_view.clip_license->setHidden(true); + } + else m_view.clip_license->setHidden(true); #else m_view.clip_license->setHidden(true); #endif - + +#endif + slotFillMarkersList(m_clip); slotUpdateAnalysisData(m_clip); diff --git a/src/projectlist.cpp b/src/projectlist.cpp index 51488ee1..0c395164 100644 --- a/src/projectlist.cpp +++ b/src/projectlist.cpp @@ -69,6 +69,11 @@ //#include #endif +#ifdef USE_NEPOMUKCORE +#include +#include +#endif + #include #include #include @@ -341,6 +346,16 @@ ProjectList::ProjectList(QWidget *parent) : } } #endif +#ifdef USE_NEPOMUKCORE + if (KdenliveSettings::activate_nepomuk()) { + Nepomuk2::ResourceManager::instance()->init(); + if (!Nepomuk2::ResourceManager::instance()->initialized()) { + kDebug() << "Cannot communicate with Nepomuk, DISABLING it"; + KdenliveSettings::setActivate_nepomuk(false); + } + } +#endif + } ProjectList::~ProjectList() diff --git a/src/projectlist.h b/src/projectlist.h index 070bb4ac..3470239d 100644 --- a/src/projectlist.h +++ b/src/projectlist.h @@ -47,6 +47,12 @@ #include #endif +#ifdef NEPOMUKCORE +#include +#include +#endif + + #include "definitions.h" #include "timecode.h" #include "kdenlivesettings.h" @@ -219,6 +225,10 @@ public: #ifdef NEPOMUK KRatingPainter::paintRating(painter, r1, Qt::AlignCenter, index.data().toInt()); #endif +#ifdef NEPOMUKCORE + KRatingPainter::paintRating(painter, r1, Qt::AlignCenter, index.data().toInt()); +#endif + } else { QStyledItemDelegate::paint(painter, option, index); } diff --git a/src/utils/resourcewidget.cpp b/src/utils/resourcewidget.cpp index 4771540e..9935f674 100644 --- a/src/utils/resourcewidget.cpp +++ b/src/utils/resourcewidget.cpp @@ -57,6 +57,15 @@ #endif #endif +#ifdef USE_NEPOMUKCORE +#include +#include +#include +#include +#include +#include +#endif + ResourceWidget::ResourceWidget(const QString & folder, QWidget * parent) : QDialog(parent), m_folder(folder), @@ -261,6 +270,17 @@ void ResourceWidget::slotGotFile(KJob *job) //res.setProperty( Soprano::Vocabulary::NAO::description(), #endif #endif + +#ifdef USE_NEPOMUKCORE + Nepomuk2::Resource res( filePath ); + res.setProperty( Nepomuk2::Vocabulary::NIE::license(), (Nepomuk2::Variant) job->property("license") ); + res.setProperty( Nepomuk2::Vocabulary::NIE::licenseType(), (Nepomuk2::Variant) job->property("licenseurl") ); + res.setProperty( Nepomuk2::Vocabulary::NDO::copiedFrom(), (Nepomuk2::Variant) job->property("originurl") ); + res.setProperty( Nepomuk2::Vocabulary::NCO::creator(), (Nepomuk2::Variant) job->property("author") ); + //res.setDescription(item_description->toPlainText()); + //res.setProperty( Soprano::Vocabulary::NAO::description(), +#endif + emit addClip(filePath, stringMap()); } -- 2.39.2