From 93465171bc56f353796bad77e2accaa8d9fe9204 Mon Sep 17 00:00:00 2001 From: Vishesh Handa Date: Tue, 14 Oct 2014 15:51:51 +0200 Subject: [PATCH] Port Dolphin to the new Baloo APIs REVIEW: 120582 --- src/CMakeLists.txt | 3 +-- src/kitemviews/kfileitemmodelrolesupdater.cpp | 25 ++++++------------- src/kitemviews/kfileitemmodelrolesupdater.h | 1 - .../private/kbaloorolesprovider.cpp | 8 +++--- src/search/dolphinsearchbox.cpp | 8 +++--- 5 files changed, 17 insertions(+), 28 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index c308bc09dd..523ee03a96 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -104,8 +104,7 @@ if(HAVE_BALOO) target_link_libraries( dolphinprivate PUBLIC KF5::FileMetaData - KF5::BalooCore - KF5::BalooFiles + KF5::Baloo KF5::BalooNaturalQueryParser KF5::BalooWidgets ) diff --git a/src/kitemviews/kfileitemmodelrolesupdater.cpp b/src/kitemviews/kfileitemmodelrolesupdater.cpp index b8c56bd532..256527c9ea 100644 --- a/src/kitemviews/kfileitemmodelrolesupdater.cpp +++ b/src/kitemviews/kfileitemmodelrolesupdater.cpp @@ -45,7 +45,6 @@ #ifdef HAVE_BALOO #include "private/kbaloorolesprovider.h" #include - #include #include #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(); + Baloo::File file(item.localPath()); + file.load(); const KBalooRolesProvider& rolesProvider = KBalooRolesProvider::instance(); QHash data; @@ -731,8 +717,7 @@ void KFileItemModelRolesUpdater::applyChangedBalooRolesJobFinished(KJob* kjob) data.insert(role, QVariant()); } - Baloo::FileFetchJob* job = static_cast(kjob); - QHashIterator it(rolesProvider.roleValues(job->file(), m_roles)); + QHashIterator 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 } diff --git a/src/kitemviews/kfileitemmodelrolesupdater.h b/src/kitemviews/kfileitemmodelrolesupdater.h index e9652e3b56..4a96b1f49c 100644 --- a/src/kitemviews/kfileitemmodelrolesupdater.h +++ b/src/kitemviews/kfileitemmodelrolesupdater.h @@ -205,7 +205,6 @@ private slots: void resolveRecentlyChangedItems(); void applyChangedBalooRoles(const QString& file); - void applyChangedBalooRolesJobFinished(KJob* job); void slotDirectoryContentsCountReceived(const QString& path, int count); diff --git a/src/kitemviews/private/kbaloorolesprovider.cpp b/src/kitemviews/private/kbaloorolesprovider.cpp index 5096ef096b..74f789e236 100644 --- a/src/kitemviews/private/kbaloorolesprovider.cpp +++ b/src/kitemviews/private/kbaloorolesprovider.cpp @@ -26,6 +26,7 @@ #include #include +#include #include #include @@ -99,14 +100,15 @@ QHash 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; diff --git a/src/search/dolphinsearchbox.cpp b/src/search/dolphinsearchbox.cpp index de73c2c42d..b8b1dbbca4 100644 --- a/src/search/dolphinsearchbox.cpp +++ b/src/search/dolphinsearchbox.cpp @@ -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()); }