Changeset View
Changeset View
Standalone View
Standalone View
kcms/baloo/kcm.cpp
Show All 28 Lines | |||||
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 <QDBusConnection> | 34 | #include <QDBusConnection> | ||
35 | #include <QDBusMessage> | 35 | #include <QDBusMessage> | ||
36 | #include <QDBusPendingCall> | 36 | #include <QDBusPendingCall> | ||
37 | #include <QStandardPaths> | ||||
37 | #include <QStorageInfo> | 38 | #include <QStorageInfo> | ||
38 | 39 | | |||
39 | #include <Baloo/IndexerConfig> | 40 | #include <Baloo/IndexerConfig> | ||
40 | 41 | | |||
41 | K_PLUGIN_FACTORY(BalooConfigModuleFactory, registerPlugin<Baloo::ServerConfigModule>();) | 42 | K_PLUGIN_FACTORY(BalooConfigModuleFactory, registerPlugin<Baloo::ServerConfigModule>();) | ||
42 | K_EXPORT_PLUGIN(BalooConfigModuleFactory("kcm_baloofile")) | 43 | K_EXPORT_PLUGIN(BalooConfigModuleFactory("kcm_baloofile")) | ||
43 | 44 | | |||
44 | 45 | | |||
Show All 27 Lines | 59 | { | |||
72 | connect(m_excludeFolders_FSW, &FolderSelectionWidget::changed, | 73 | connect(m_excludeFolders_FSW, &FolderSelectionWidget::changed, | ||
73 | this, &ServerConfigModule::onDirectoryListChanged); | 74 | this, &ServerConfigModule::onDirectoryListChanged); | ||
74 | connect(m_enableCheckbox, SIGNAL(stateChanged(int)), | 75 | connect(m_enableCheckbox, SIGNAL(stateChanged(int)), | ||
75 | this, SLOT(changed())); | 76 | this, SLOT(changed())); | ||
76 | connect(m_enableContentIndexing, SIGNAL(stateChanged(int)), | 77 | connect(m_enableContentIndexing, SIGNAL(stateChanged(int)), | ||
77 | this, SLOT(changed())); | 78 | this, SLOT(changed())); | ||
78 | connect(m_enableCheckbox, SIGNAL(stateChanged(int)), | 79 | connect(m_enableCheckbox, SIGNAL(stateChanged(int)), | ||
79 | this, SLOT(indexingEnabledChanged())); | 80 | this, SLOT(indexingEnabledChanged())); | ||
81 | connect(m_rebuildDatabaseButton, SIGNAL(clicked()), | ||||
82 | this, SLOT(rebuildIndexDatabase())); | ||||
80 | } | 83 | } | ||
81 | 84 | | |||
82 | 85 | | |||
83 | ServerConfigModule::~ServerConfigModule() | 86 | ServerConfigModule::~ServerConfigModule() | ||
84 | { | 87 | { | ||
85 | } | 88 | } | ||
86 | 89 | | |||
87 | 90 | | |||
▲ Show 20 Lines • Show All 89 Lines • ▼ Show 20 Line(s) | 173 | { | |||
177 | 180 | | |||
178 | if (excluded.toSet() == mountPoints.toSet()) { | 181 | if (excluded.toSet() == mountPoints.toSet()) { | ||
179 | return true; | 182 | return true; | ||
180 | } | 183 | } | ||
181 | 184 | | |||
182 | return false; | 185 | return false; | ||
183 | } | 186 | } | ||
184 | 187 | | |||
188 | void ServerConfigModule::rebuildIndexDatabase() | ||||
189 | { | ||||
190 | // balooctl stop && rm -r .local/share/baloo && balooctl start | ||||
191 | QProcess *proc = new QProcess(this); | ||||
192 | const QString dataDir = QStandardPaths::writableLocation( | ||||
193 | QStandardPaths::GenericDataLocation | ||||
194 | ) + QStringLiteral("/baloo"); | ||||
195 | const QString rm = QStandardPaths::findExecutable(QStringLiteral("rm")); | ||||
196 | 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. | |||||
197 | QStringList args1; | ||||
198 | args1 << QStringLiteral("stop"); | ||||
199 | proc->start(balooctl, args1); | ||||
200 | proc->waitForFinished(); | ||||
201 | QStringList args2; | ||||
202 | args2 << QStringLiteral("-r") << dataDir; | ||||
203 | proc->start(rm, args2); | ||||
204 | proc->waitForFinished(); | ||||
205 | QStringList args3; | ||||
206 | args3 << QStringLiteral("start"); | ||||
207 | proc->start(balooctl, args3); | ||||
208 | proc->waitForFinished(); | ||||
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… | |||||
209 | } | ||||
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… | |||||
210 | | ||||
185 | #include "kcm.moc" | 211 | #include "kcm.moc" |
IMHO this whole block should be a single, blocking command in balooctl, i.e. move the whole logic to balooctl.