Changeset View
Changeset View
Standalone View
Standalone View
kcms/baloo/kcm.cpp
Show All 25 Lines | |||||
26 | #include <KAboutData> | 26 | #include <KAboutData> | ||
27 | #include <QDebug> | 27 | #include <QDebug> | ||
28 | #include <QStandardPaths> | 28 | #include <QStandardPaths> | ||
29 | #include <KLocalizedString> | 29 | #include <KLocalizedString> | ||
30 | 30 | | |||
31 | #include <QPushButton> | 31 | #include <QPushButton> | ||
32 | #include <QDir> | 32 | #include <QDir> | ||
33 | #include <QProcess> | 33 | #include <QProcess> | ||
34 | #include <QMessageBox> | ||||
34 | #include <QDBusConnection> | 35 | #include <QDBusConnection> | ||
35 | #include <QDBusMessage> | 36 | #include <QDBusMessage> | ||
36 | #include <QDBusPendingCall> | 37 | #include <QDBusPendingCall> | ||
38 | #include <QStandardPaths> | ||||
37 | #include <QStorageInfo> | 39 | #include <QStorageInfo> | ||
38 | 40 | | |||
39 | #include <Baloo/IndexerConfig> | 41 | #include <Baloo/IndexerConfig> | ||
40 | 42 | | |||
41 | K_PLUGIN_FACTORY(BalooConfigModuleFactory, registerPlugin<Baloo::ServerConfigModule>();) | 43 | K_PLUGIN_FACTORY(BalooConfigModuleFactory, registerPlugin<Baloo::ServerConfigModule>();) | ||
42 | K_EXPORT_PLUGIN(BalooConfigModuleFactory("kcm_baloofile")) | 44 | K_EXPORT_PLUGIN(BalooConfigModuleFactory("kcm_baloofile")) | ||
43 | 45 | | |||
44 | 46 | | |||
Show All 27 Lines | 60 | { | |||
72 | connect(m_excludeFolders_FSW, &FolderSelectionWidget::changed, | 74 | connect(m_excludeFolders_FSW, &FolderSelectionWidget::changed, | ||
73 | this, &ServerConfigModule::onDirectoryListChanged); | 75 | this, &ServerConfigModule::onDirectoryListChanged); | ||
74 | connect(m_enableCheckbox, SIGNAL(stateChanged(int)), | 76 | connect(m_enableCheckbox, SIGNAL(stateChanged(int)), | ||
75 | this, SLOT(changed())); | 77 | this, SLOT(changed())); | ||
76 | connect(m_enableContentIndexing, SIGNAL(stateChanged(int)), | 78 | connect(m_enableContentIndexing, SIGNAL(stateChanged(int)), | ||
77 | this, SLOT(changed())); | 79 | this, SLOT(changed())); | ||
78 | connect(m_enableCheckbox, SIGNAL(stateChanged(int)), | 80 | connect(m_enableCheckbox, SIGNAL(stateChanged(int)), | ||
79 | this, SLOT(indexingEnabledChanged())); | 81 | this, SLOT(indexingEnabledChanged())); | ||
82 | connect(m_rebuildDatabaseButton, SIGNAL(clicked()), | ||||
83 | this, SLOT(rebuildIndexDatabase())); | ||||
80 | } | 84 | } | ||
81 | 85 | | |||
82 | 86 | | |||
83 | ServerConfigModule::~ServerConfigModule() | 87 | ServerConfigModule::~ServerConfigModule() | ||
84 | { | 88 | { | ||
85 | } | 89 | } | ||
86 | 90 | | |||
87 | 91 | | |||
▲ Show 20 Lines • Show All 89 Lines • ▼ Show 20 Line(s) | 174 | { | |||
177 | 181 | | |||
178 | if (excluded.toSet() == mountPoints.toSet()) { | 182 | if (excluded.toSet() == mountPoints.toSet()) { | ||
179 | return true; | 183 | return true; | ||
180 | } | 184 | } | ||
181 | 185 | | |||
182 | return false; | 186 | return false; | ||
183 | } | 187 | } | ||
184 | 188 | | |||
189 | void ServerConfigModule::rebuildIndexDatabase() | ||||
190 | { | ||||
191 | // balooctl stop && rm -r .local/share/baloo && balooctl start | ||||
192 | QProcess *proc = new QProcess(this); | ||||
193 | const QString dataDir = QStandardPaths::writableLocation( | ||||
194 | QStandardPaths::GenericDataLocation | ||||
195 | ) + QStringLiteral("/baloo"); | ||||
196 | const QString rm = QStandardPaths::findExecutable(QStringLiteral("rm")); | ||||
197 | const QString balooctl = QStandardPaths::findExecutable(QStringLiteral("balooctl")); | ||||
bruns: IMHO this whole block should be a single, blocking command in balooctl, i.e. move the whole… | |||||
guoyunhe: Will try. | |||||
198 | const QString baloofile = QStandardPaths::findExecutable(QStringLiteral("baloo_file")); | ||||
199 | | ||||
200 | QStringList args1; | ||||
201 | args1 << QStringLiteral("stop"); | ||||
202 | proc->start(balooctl, args1); | ||||
203 | proc->waitForFinished(); | ||||
204 | | ||||
205 | QStringList args2; | ||||
206 | args2 << QStringLiteral("-r") << dataDir; | ||||
207 | proc->start(rm, args2); | ||||
208 | proc->waitForFinished(); | ||||
209 | | ||||
This whole section could benefit from a few more line breaks to separate the commands into logical groups. ngraham: This whole section could benefit from a few more line breaks to separate the commands into… | |||||
210 | // "balooctl start" isn't reliable, so here we run "baloo_file" directly | ||||
bruns: Care to elaborate? | |||||
If I run "balooctl start" in QProcess, baloo_file always fail to start. I didn't figure out the reason. But running baloo_file directly always works. guoyunhe: If I run "balooctl start" in QProcess, baloo_file always fail to start. I didn't figure out the… | |||||
211 | QProcess::startDetached(baloofile, QStringList()); | ||||
212 | | ||||
213 | QMessageBox msgBox; | ||||
214 | msgBox.setText(i18n("Index database has been rebuilt successfully!")); | ||||
215 | msgBox.exec(); | ||||
216 | } | ||||
217 | | ||||
185 | #include "kcm.moc" | 218 | #include "kcm.moc" |
IMHO this whole block should be a single, blocking command in balooctl, i.e. move the whole logic to balooctl.