]> git.sesse.net Git - kdenlive/blobdiff - src/utils/resourcewidget.cpp
includemocs
[kdenlive] / src / utils / resourcewidget.cpp
index bace39db92fe683bbd10e9214a0baeb045d29b06..7201aedb8bb34a2e004ba18a3fd8a3074958ad1d 100644 (file)
 #endif
 #endif
 
+#ifdef USE_NEPOMUKCORE
+#include <Nepomuk2/Variant>
+#include <Nepomuk2/Resource>
+#include <Nepomuk2/ResourceManager>
+#include <Nepomuk2/Vocabulary/NIE>
+#include <Nepomuk2/Vocabulary/NCO>
+#include <Nepomuk2/Vocabulary/NDO>
+#endif
+
 ResourceWidget::ResourceWidget(const QString & folder, QWidget * parent) :
-        QDialog(parent),
-        m_folder(folder),
-        m_currentService(NULL)
+    QDialog(parent),
+    m_folder(folder),
+    m_currentService(NULL)
 {
     setFont(KGlobalSettings::toolBarFont());
     setupUi(this);
@@ -113,7 +122,7 @@ ResourceWidget::ResourceWidget(const QString & folder, QWidget * parent) :
 
 ResourceWidget::~ResourceWidget()
 {
-    if (m_currentService) delete m_currentService;
+    delete m_currentService;
     KIO::NetAccess::removeTempFile(m_tmpThumbFile);
 }
 
@@ -167,7 +176,7 @@ void ResourceWidget::slotUpdateCurrentSound()
 }
 
 
-void ResourceWidget::slotLoadThumb(const QString url)
+void ResourceWidget::slotLoadThumb(const QString &url)
 {
     KUrl img(url);
     if (img.isEmpty()) return;
@@ -175,7 +184,7 @@ void ResourceWidget::slotLoadThumb(const QString url)
         if (KIO::NetAccess::download(img, m_tmpThumbFile, this)) {
             slotSetImage(m_tmpThumbFile);
             /*QPixmap pix(tmpFile);
-            
+
             int newHeight = pix.height() * item_image->width() / pix.width();
             if (newHeight > 200) {
                 item_image->setScaledContents(false);
@@ -191,7 +200,7 @@ void ResourceWidget::slotLoadThumb(const QString url)
 }
 
 
-void ResourceWidget::slotDisplayMetaInfo(QMap <QString, QString> metaInfo)
+void ResourceWidget::slotDisplayMetaInfo(const QMap<QString, QString> &metaInfo)
 {
     if (metaInfo.contains("license")) {
         parseLicense(metaInfo.value("license"));
@@ -211,7 +220,7 @@ void ResourceWidget::slotPlaySound()
 }
 
 
-void ResourceWidget::slotSaveItem(const QString originalUrl)
+void ResourceWidget::slotSaveItem(const QString &originalUrl)
 {
     //if (m_currentUrl.isEmpty()) return;
     QListWidgetItem *item = search_results->currentItem();
@@ -234,7 +243,7 @@ void ResourceWidget::slotSaveItem(const QString originalUrl)
     if (saveUrl.isEmpty() || !KIO::NetAccess::stat(srcUrl, entry, this)) return;
     KIO::FileCopyJob * getJob = KIO::file_copy(srcUrl, KUrl(saveUrl), -1, KIO::Overwrite);
     
-    KFileItem info(entry, srcUrl); 
+    KFileItem info(entry, srcUrl);
     getJob->setSourceSize(info.size());
     getJob->setProperty("license", item_license->text());
     getJob->setProperty("licenseurl", item_license->url());
@@ -252,16 +261,27 @@ void ResourceWidget::slotGotFile(KJob *job)
     const KUrl filePath = copyJob->destUrl();
 #ifdef USE_NEPOMUK
 #if KDE_IS_VERSION(4,6,0)
-        Nepomuk::Resource res( filePath );
-        res.setProperty( Nepomuk::Vocabulary::NIE::license(), (Nepomuk::Variant) job->property("license") );
-        res.setProperty( Nepomuk::Vocabulary::NIE::licenseType(), (Nepomuk::Variant) job->property("licenseurl") );
-        res.setProperty( Nepomuk::Vocabulary::NDO::copiedFrom(), (Nepomuk::Variant) job->property("originurl") );
-        res.setProperty( Nepomuk::Vocabulary::NCO::creator(), (Nepomuk::Variant) job->property("author") );
-        //res.setDescription(item_description->toPlainText());
-        //res.setProperty( Soprano::Vocabulary::NAO::description(), 
+    Nepomuk::Resource res( filePath );
+    res.setProperty( Nepomuk::Vocabulary::NIE::license(), (Nepomuk::Variant) job->property("license") );
+    res.setProperty( Nepomuk::Vocabulary::NIE::licenseType(), (Nepomuk::Variant) job->property("licenseurl") );
+    res.setProperty( Nepomuk::Vocabulary::NDO::copiedFrom(), (Nepomuk::Variant) job->property("originurl") );
+    res.setProperty( Nepomuk::Vocabulary::NCO::creator(), (Nepomuk::Variant) job->property("author") );
+    //res.setDescription(item_description->toPlainText());
+    //res.setProperty( Soprano::Vocabulary::NAO::description(),
 #endif
 #endif
-        emit addClip(filePath, stringMap());
+
+#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());
 }
 
 void ResourceWidget::slotOpenUrl(const QString &url)
@@ -370,25 +390,25 @@ void ResourceWidget::slotOpenLink(const QUrl &url)
     }
 }
 
-void ResourceWidget::slotSetDescription(const QString desc)
+void ResourceWidget::slotSetDescription(const QString &desc)
 {
     m_desc = desc;
     updateLayout();
 }
 
-void ResourceWidget::slotSetMetadata(const QString desc)
+void ResourceWidget::slotSetMetadata(const QString &desc)
 {
     m_meta = desc;
     updateLayout();
 }
 
-void ResourceWidget::slotSetImage(const QString desc)
+void ResourceWidget::slotSetImage(const QString &desc)
 {
     m_image = QString("<img src=\"%1\" style=\"max-height:150px\" max-width=\"%2px\" />").arg(desc).arg((int) (info_browser->width() * 0.9));
     updateLayout();
 }
 
-void ResourceWidget::slotSetTitle(const QString desc)
+void ResourceWidget::slotSetTitle(const QString &desc)
 {
     m_title = desc;
     updateLayout();
@@ -403,3 +423,5 @@ void ResourceWidget::updateLayout()
     info_browser->setHtml(content);
 }
 
+
+#include "resourcewidget.moc"