Changeset View
Changeset View
Standalone View
Standalone View
src/tools/balooctl/configcommand.cpp
Show All 15 Lines | |||||
16 | * License along with this library; if not, write to the Free Software | 16 | * License along with this library; if not, write to the Free Software | ||
17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
18 | * | 18 | * | ||
19 | */ | 19 | */ | ||
20 | 20 | | |||
21 | #include "configcommand.h" | 21 | #include "configcommand.h" | ||
22 | #include "indexerconfig.h" | 22 | #include "indexerconfig.h" | ||
23 | 23 | | |||
24 | #include <QDir> | ||||
24 | #include <QTextStream> | 25 | #include <QTextStream> | ||
25 | #include <QFileInfo> | 26 | #include <QFileInfo> | ||
26 | 27 | | |||
27 | #include <KLocalizedString> | 28 | #include <KLocalizedString> | ||
28 | 29 | | |||
29 | using namespace Baloo; | 30 | using namespace Baloo; | ||
30 | 31 | | |||
31 | /* | 32 | /* | ||
▲ Show 20 Lines • Show All 125 Lines • ▼ Show 20 Line(s) | 147 | if (command == QStringLiteral("rm") || command == QStringLiteral("remove")) { | |||
157 | IndexerConfig config; | 158 | IndexerConfig config; | ||
158 | QString value = args.takeFirst(); | 159 | QString value = args.takeFirst(); | ||
159 | if (value.compare(QLatin1String("includeFolders"), Qt::CaseInsensitive) == 0) { | 160 | if (value.compare(QLatin1String("includeFolders"), Qt::CaseInsensitive) == 0) { | ||
160 | if (args.isEmpty()) { | 161 | if (args.isEmpty()) { | ||
161 | out << i18n("A folder must be provided") << endl; | 162 | out << i18n("A folder must be provided") << endl; | ||
162 | return 1; | 163 | return 1; | ||
163 | } | 164 | } | ||
164 | 165 | | |||
165 | auto fileInfo = QFileInfo(args.takeFirst()); | 166 | QString path = args.takeFirst().replace('$HOME', QDir::homePath()); | ||
166 | if (!fileInfo.exists()) { | | |||
167 | out << i18n("Path does not exist") << endl; | | |||
168 | return 1; | | |||
169 | } | | |||
170 | | ||||
171 | if (!fileInfo.isDir()) { | | |||
172 | out << i18n("Path is not a directory") << endl; | | |||
173 | return 1; | | |||
174 | } | | |||
175 | | ||||
176 | auto path = fileInfo.absoluteFilePath(); | | |||
177 | QStringList folders = config.includeFolders(); | 167 | QStringList folders = config.includeFolders(); | ||
178 | if (!folders.contains(path)) { | 168 | if (!folders.contains(path)) { | ||
179 | out << i18n("%1 is not in the list of include folders", path) << endl; | 169 | out << i18n("%1 is not in the list of include folders", path) << endl; | ||
180 | return 1; | 170 | return 1; | ||
181 | } | 171 | } | ||
182 | 172 | | |||
183 | folders.removeAll(path); | 173 | folders.removeAll(path); | ||
184 | config.setIncludeFolders(folders); | 174 | config.setIncludeFolders(folders); | ||
185 | 175 | | |||
186 | return 0; | 176 | return 0; | ||
187 | } | 177 | } | ||
188 | 178 | | |||
189 | if (value.compare(QLatin1String("excludeFolders"), Qt::CaseInsensitive) == 0) { | 179 | if (value.compare(QLatin1String("excludeFolders"), Qt::CaseInsensitive) == 0) { | ||
190 | if (args.isEmpty()) { | 180 | if (args.isEmpty()) { | ||
191 | out << i18n("A folder must be provided") << endl; | 181 | out << i18n("A folder must be provided") << endl; | ||
192 | return 1; | 182 | return 1; | ||
193 | } | 183 | } | ||
194 | 184 | | |||
195 | auto fileInfo = QFileInfo(args.takeFirst()); | 185 | QString path = args.takeFirst().replace('$HOME', QDir::homePath()); | ||
196 | if (!fileInfo.exists()) { | | |||
197 | out << i18n("Path does not exist") << endl; | | |||
198 | return 1; | | |||
199 | } | | |||
200 | | ||||
201 | if (!fileInfo.isDir()) { | | |||
202 | out << i18n("Path is not a directory") << endl; | | |||
203 | return 1; | | |||
204 | } | | |||
205 | | ||||
206 | auto path = fileInfo.absoluteFilePath(); | | |||
207 | QStringList folders = config.excludeFolders(); | 186 | QStringList folders = config.excludeFolders(); | ||
208 | if (!folders.contains(path)) { | 187 | if (!folders.contains(path)) { | ||
209 | out << i18n("%1 is not in the list of exclude folders", path) << endl; | 188 | out << i18n("%1 is not in the list of exclude folders", path) << endl; | ||
210 | return 1; | 189 | return 1; | ||
211 | } | 190 | } | ||
212 | 191 | | |||
213 | folders.removeAll(path); | 192 | folders.removeAll(path); | ||
214 | config.setExcludeFolders(folders); | 193 | config.setExcludeFolders(folders); | ||
▲ Show 20 Lines • Show All 250 Lines • Show Last 20 Lines |