]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Port Dolphin to the new Baloo APIs
authorVishesh Handa <me@vhanda.in>
Tue, 14 Oct 2014 13:51:51 +0000 (15:51 +0200)
committerVishesh Handa <me@vhanda.in>
Tue, 14 Oct 2014 16:08:18 +0000 (18:08 +0200)
REVIEW: 120582

src/CMakeLists.txt
src/kitemviews/kfileitemmodelrolesupdater.cpp
src/kitemviews/kfileitemmodelrolesupdater.h
src/kitemviews/private/kbaloorolesprovider.cpp
src/search/dolphinsearchbox.cpp

index c308bc09ddf28c31895fc535550d77be68bb1324..523ee03a96a44570ff0321f8a48b067127ced9df 100644 (file)
@@ -104,8 +104,7 @@ if(HAVE_BALOO)
     target_link_libraries(
         dolphinprivate PUBLIC
         KF5::FileMetaData
-        KF5::BalooCore
-        KF5::BalooFiles
+        KF5::Baloo
         KF5::BalooNaturalQueryParser
         KF5::BalooWidgets
     )
index b8c56bd532e90c4904da2b8d2344d3637ba833e5..256527c9ea8d1124cd61bccb04c9fd0c8b6164c7 100644 (file)
@@ -45,7 +45,6 @@
 #ifdef HAVE_BALOO
     #include "private/kbaloorolesprovider.h"
     #include <Baloo/File>
-    #include <Baloo/FileFetchJob>
     #include <Baloo/FileMonitor>
 #endif
 
@@ -705,21 +704,8 @@ void KFileItemModelRolesUpdater::applyChangedBalooRoles(const QString& itemUrl)
         return;
     }
 
-    Baloo::FileFetchJob* job = new Baloo::FileFetchJob(item.localPath());
-    connect(job, &Baloo::FileFetchJob::finished, this, &KFileItemModelRolesUpdater::applyChangedBalooRolesJobFinished);
-    job->setProperty("item", QVariant::fromValue(item));
-    job->start();
-#else
-#ifndef Q_CC_MSVC
-    Q_UNUSED(itemUrl);
-#endif
-#endif
-}
-
-void KFileItemModelRolesUpdater::applyChangedBalooRolesJobFinished(KJob* kjob)
-{
-#ifdef HAVE_BALOO
-    const KFileItem item = kjob->property("item").value<KFileItem>();
+    Baloo::File file(item.localPath());
+    file.load();
 
     const KBalooRolesProvider& rolesProvider = KBalooRolesProvider::instance();
     QHash<QByteArray, QVariant> data;
@@ -731,8 +717,7 @@ void KFileItemModelRolesUpdater::applyChangedBalooRolesJobFinished(KJob* kjob)
         data.insert(role, QVariant());
     }
 
-    Baloo::FileFetchJob* job = static_cast<Baloo::FileFetchJob*>(kjob);
-    QHashIterator<QByteArray, QVariant> it(rolesProvider.roleValues(job->file(), m_roles));
+    QHashIterator<QByteArray, QVariant> it(rolesProvider.roleValues(file, m_roles));
     while (it.hasNext()) {
         it.next();
         data.insert(it.key(), it.value());
@@ -744,6 +729,10 @@ void KFileItemModelRolesUpdater::applyChangedBalooRolesJobFinished(KJob* kjob)
     m_model->setData(index, data);
     connect(m_model, &KFileItemModel::itemsChanged,
             this,    &KFileItemModelRolesUpdater::slotItemsChanged);
+#else
+#ifndef Q_CC_MSVC
+    Q_UNUSED(itemUrl);
+#endif
 #endif
 }
 
index e9652e3b563126c7e4334b131c4fd01c84c4daf4..4a96b1f49c6cc948cbfeff9b29562b1bfb03c6fe 100644 (file)
@@ -205,7 +205,6 @@ private slots:
     void resolveRecentlyChangedItems();
 
     void applyChangedBalooRoles(const QString& file);
-    void applyChangedBalooRolesJobFinished(KJob* job);
 
     void slotDirectoryContentsCountReceived(const QString& path, int count);
 
index 5096ef096b01f3a62d9ff5d034ce929f8f1e90ee..74f789e236cf5dede0f215db9d640c4f523faa08 100644 (file)
@@ -26,6 +26,7 @@
 
 #include <Baloo/File>
 #include <KFileMetaData/PropertyInfo>
+#include <KFileMetaData/UserMetaData>
 
 #include <QTime>
 #include <QMap>
@@ -99,14 +100,15 @@ QHash<QByteArray, QVariant> KBalooRolesProvider::roleValues(const Baloo::File& f
         }
     }
 
+    KFileMetaData::UserMetaData md(file.path());
     if (roles.contains("tags")) {
-        values.insert("tags", tagsFromValues(file.tags()));
+        values.insert("tags", tagsFromValues(md.tags()));
     }
     if (roles.contains("rating")) {
-        values.insert("rating", QString::number(file.rating()));
+        values.insert("rating", QString::number(md.rating()));
     }
     if (roles.contains("comment")) {
-        values.insert("comment", file.userComment());
+        values.insert("comment", md.userComment());
     }
 
     return values;
index de73c2c42d67ed34158502c20a21b3bdca410f5f..b8b1dbbca403a5f0afc20c597d1eefca96c54aa7 100644 (file)
@@ -479,7 +479,7 @@ KUrl DolphinSearchBox::balooUrlForSearching() const
     }
 
     if (m_fromHereButton->isChecked()) {
-        query.addCustomOption("includeFolder", m_searchPath.toLocalFile());
+        query.setIncludeFolder(m_searchPath.toLocalFile());
     }
 
     return query.toSearchUrl(i18nc("@title UDS_DISPLAY_NAME for a KIO directory listing. %1 is the query the user entered.",
@@ -499,9 +499,9 @@ void DolphinSearchBox::fromBalooSearchUrl(const KUrl& url)
     // while we adjust the search text and the facet widget.
     blockSignals(true);
 
-    const QVariantMap customOptions = query.customOptions();
-    if (customOptions.contains("includeFolder")) {
-        setSearchPath(customOptions.value("includeFolder").toString());
+    const QString customDir = query.includeFolder();
+    if (!customDir.isEmpty()) {
+        setSearchPath(customDir);
     } else {
         setSearchPath(QDir::homePath());
     }