Baloo

queryrunnable.cpp
1 /*
2  This file is part of the KDE Baloo Project
3  SPDX-FileCopyrightText: 2013 Vishesh Handa <[email protected]>
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 
11 using namespace Baloo;
12 
13 class BALOO_CORE_NO_EXPORT QueryRunnable::Private {
14 public:
15  Query m_query;
16  QAtomicInt m_stop;
17 
18  bool stopRequested() const {
19  return m_stop.loadRelaxed();
20  }
21 
22 };
23 
24 QueryRunnable::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 
32 QueryRunnable::~QueryRunnable()
33 {
34  delete d;
35 }
36 
38 {
39  d->m_stop.storeRelaxed(true);
40 }
41 
42 void QueryRunnable::run()
43 {
44  ResultIterator it = d->m_query.exec();
45  while (!d->stopRequested() && it.next()) {
46  Q_EMIT queryResult(this, it.filePath());
47  }
48 
49  Q_EMIT finished(this);
50 }
51 
52 #include "moc_queryrunnable.cpp"
std::optional< QSqlQuery > query(const QString &queryStatement)
void stop(Ekos::AlignState mode)
T loadRelaxed() const const
Implements storage for docIds without any associated data Instantiated for:
Definition: coding.cpp:11
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Mon Dec 11 2023 03:53:57 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.