Baloo

queryrunnable.cpp
1/*
2 This file is part of the KDE Baloo Project
3 SPDX-FileCopyrightText: 2013 Vishesh Handa <me@vhanda.in>
4
5 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
6*/
7
8#include "queryrunnable.h"
9#include <QAtomicInt>
10
11using namespace Baloo;
12
13class BALOO_CORE_NO_EXPORT QueryRunnable::Private {
14public:
15 Query m_query;
16 QAtomicInt m_stop;
17
18 bool stopRequested() const {
19 return m_stop.loadRelaxed();
20 }
21
22};
23
24QueryRunnable::QueryRunnable(const Query& query, QObject* parent)
25 : QObject(parent)
26 , d(new Private)
27{
28 d->m_query = query;
29 d->m_stop = false;
30}
31
32QueryRunnable::~QueryRunnable() = default;
33
34void QueryRunnable::stop()
35{
36 d->m_stop.storeRelaxed(true);
37}
38
39void QueryRunnable::run()
40{
41 ResultIterator it = d->m_query.exec();
42 while (!d->stopRequested() && it.next()) {
43 Q_EMIT queryResult(this, it.filePath());
44 }
45
46 Q_EMIT finished(this);
47}
48
49#include "moc_queryrunnable.cpp"
The Query class is the central class to query to search for files from the Index.
Definition query.h:54
std::optional< QSqlQuery > query(const QString &queryStatement)
Implements storage for docIds without any associated data Instantiated for:
Definition coding.cpp:11
T loadRelaxed() const const
Q_EMITQ_EMIT
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.