diff --git a/kcms/baloo/configwidget.ui b/kcms/baloo/configwidget.ui
--- a/kcms/baloo/configwidget.ui
+++ b/kcms/baloo/configwidget.ui
@@ -61,6 +61,16 @@
+ -
+
+
+ Rebuild Index Database
+
+
+
+
+
+
-
diff --git a/kcms/baloo/kcm.h b/kcms/baloo/kcm.h
--- a/kcms/baloo/kcm.h
+++ b/kcms/baloo/kcm.h
@@ -39,8 +39,8 @@
void save() override;
void defaults() override;
void indexingEnabledChanged();
-
void onDirectoryListChanged();
+ void rebuildIndexDatabase();
private:
bool m_previouslyEnabled;
/**
diff --git a/kcms/baloo/kcm.cpp b/kcms/baloo/kcm.cpp
--- a/kcms/baloo/kcm.cpp
+++ b/kcms/baloo/kcm.cpp
@@ -31,9 +31,11 @@
#include
#include
#include
+#include
#include
#include
#include
+#include
#include
#include
@@ -77,6 +79,8 @@
this, SLOT(changed()));
connect(m_enableCheckbox, SIGNAL(stateChanged(int)),
this, SLOT(indexingEnabledChanged()));
+ connect(m_rebuildDatabaseButton, SIGNAL(clicked()),
+ this, SLOT(rebuildIndexDatabase()));
}
@@ -182,4 +186,33 @@
return false;
}
+void ServerConfigModule::rebuildIndexDatabase()
+{
+ // balooctl stop && rm -r .local/share/baloo && balooctl start
+ QProcess *proc = new QProcess(this);
+ const QString dataDir = QStandardPaths::writableLocation(
+ QStandardPaths::GenericDataLocation
+ ) + QStringLiteral("/baloo");
+ const QString rm = QStandardPaths::findExecutable(QStringLiteral("rm"));
+ const QString balooctl = QStandardPaths::findExecutable(QStringLiteral("balooctl"));
+ const QString baloofile = QStandardPaths::findExecutable(QStringLiteral("baloo_file"));
+
+ QStringList args1;
+ args1 << QStringLiteral("stop");
+ proc->start(balooctl, args1);
+ proc->waitForFinished();
+
+ QStringList args2;
+ args2 << QStringLiteral("-r") << dataDir;
+ proc->start(rm, args2);
+ proc->waitForFinished();
+
+ // "balooctl start" isn't reliable, so here we run "baloo_file" directly
+ QProcess::startDetached(baloofile, QStringList());
+
+ QMessageBox msgBox;
+ msgBox.setText(i18n("Index database has been rebuilt successfully!"));
+ msgBox.exec();
+}
+
#include "kcm.moc"