File indexing completed on 2024-04-21 03:51:48
0001 /* 0002 This file is part of the KDE Baloo Project 0003 SPDX-FileCopyrightText: 2013 Vishesh Handa <me@vhanda.in> 0004 0005 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL 0006 */ 0007 0008 #include "queryrunnable.h" 0009 #include <QAtomicInt> 0010 0011 using namespace Baloo; 0012 0013 class BALOO_CORE_NO_EXPORT QueryRunnable::Private { 0014 public: 0015 Query m_query; 0016 QAtomicInt m_stop; 0017 0018 bool stopRequested() const { 0019 return m_stop.loadRelaxed(); 0020 } 0021 0022 }; 0023 0024 QueryRunnable::QueryRunnable(const Query& query, QObject* parent) 0025 : QObject(parent) 0026 , d(new Private) 0027 { 0028 d->m_query = query; 0029 d->m_stop = false; 0030 } 0031 0032 QueryRunnable::~QueryRunnable() = default; 0033 0034 void QueryRunnable::stop() 0035 { 0036 d->m_stop.storeRelaxed(true); 0037 } 0038 0039 void QueryRunnable::run() 0040 { 0041 ResultIterator it = d->m_query.exec(); 0042 while (!d->stopRequested() && it.next()) { 0043 Q_EMIT queryResult(this, it.filePath()); 0044 } 0045 0046 Q_EMIT finished(this); 0047 } 0048 0049 #include "moc_queryrunnable.cpp"