mirror of
https://invent.kde.org/system/dolphin
synced 2024-08-22 01:40:02 +00:00
Port Dolphin to the new Baloo APIs
REVIEW: 120582
This commit is contained in:
parent
7d41ad943a
commit
93465171bc
|
@ -104,8 +104,7 @@ if(HAVE_BALOO)
|
|||
target_link_libraries(
|
||||
dolphinprivate PUBLIC
|
||||
KF5::FileMetaData
|
||||
KF5::BalooCore
|
||||
KF5::BalooFiles
|
||||
KF5::Baloo
|
||||
KF5::BalooNaturalQueryParser
|
||||
KF5::BalooWidgets
|
||||
)
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
@ -205,7 +205,6 @@ private slots:
|
|||
void resolveRecentlyChangedItems();
|
||||
|
||||
void applyChangedBalooRoles(const QString& file);
|
||||
void applyChangedBalooRolesJobFinished(KJob* job);
|
||||
|
||||
void slotDirectoryContentsCountReceived(const QString& path, int count);
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue