Baloo

clearcommand.cpp
1/*
2 SPDX-FileCopyrightText: 2012-2015 Vishesh Handa <me@vhanda.in>
3
4 SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
5*/
6
7#include <QFile>
8
9#include <KLocalizedString>
10#include <QFileInfo>
11#include <QTextStream>
12
13#include "command.h"
14#include "database.h"
15#include "global.h"
16#include "transaction.h"
17
18#include "clearcommand.h"
19#include "clearentry.h"
20
21using namespace Baloo;
22
23QString ClearCommand::command()
24{
25 return QStringLiteral("clear");
26}
27
28QString ClearCommand::description()
29{
30 return i18n("Immediately clear entries from the index");
31}
32
33// ClearCommand::exec
34// Sets up output stream and calls clearEntryNow for each of the arguments
35
36int ClearCommand::exec(const QCommandLineParser &parser)
37{
38 QTextStream out(stdout);
39
40 if (parser.positionalArguments().size() < 2) {
41 out << "Enter a filename to index\n";
42 return 1;
43 }
44
45 Database *db = globalDatabaseInstance();
46 if (!db->open(Database::ReadWriteDatabase)) {
47 out << "Baloo Index could not be opened\n";
48 return 1;
49 }
50
51 ClearEntry collection(db, out);
52
53 for (int i = 1; i < parser.positionalArguments().size(); ++i) {
54 collection.clearEntryNow(parser.positionalArguments().at(i));
55 }
56
57 collection.commit();
58 out << "File(s) cleared\n";
59
60 return 0;
61}
QString i18n(const char *text, const TYPE &arg...)
Implements storage for docIds without any associated data Instantiated for:
Definition coding.cpp:11
QStringList positionalArguments() const const
const_reference at(qsizetype i) const const
qsizetype size() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 16:56:58 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.