File indexing completed on 2024-04-28 15:17:40
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() 0033 { 0034 delete d; 0035 } 0036 0037 void QueryRunnable::stop() 0038 { 0039 d->m_stop.storeRelaxed(true); 0040 } 0041 0042 void QueryRunnable::run() 0043 { 0044 ResultIterator it = d->m_query.exec(); 0045 while (!d->stopRequested() && it.next()) { 0046 Q_EMIT queryResult(this, it.filePath()); 0047 } 0048 0049 Q_EMIT finished(this); 0050 } 0051 0052 #include "moc_queryrunnable.cpp"