File indexing completed on 2024-12-15 05:02:05
0001 /* 0002 SPDX-FileCopyrightText: 2016 Ivan Čukić <ivan.cukic(at)kde.org> 0003 0004 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL 0005 */ 0006 0007 #ifndef BLADE_ABSTRACT_RUNNER_H 0008 #define BLADE_ABSTRACT_RUNNER_H 0009 0010 #include <runners/Result.h> 0011 #include <QCoreApplication> 0012 0013 // #include "blade_plugin_export.h" 0014 0015 // #define BLADE_EXPORT_PLUGIN(libname, classname, jsonFile) \ 0016 // K_PLUGIN_FACTORY_WITH_JSON(factory, jsonFile, registerPlugin<classname>();) 0017 0018 #define BLADE_PLUGIN_EXPORT 0019 0020 class BLADE_PLUGIN_EXPORT AbstractRunner: public QObject { 0021 Q_OBJECT 0022 0023 public: 0024 AbstractRunner(QObject *parent); 0025 virtual ~AbstractRunner(); 0026 0027 void runQuery(const QString &queryString); 0028 virtual void cancelQuery(); 0029 0030 protected: 0031 virtual void query() = 0; 0032 0033 inline void yield() const { 0034 QCoreApplication::processEvents(); 0035 } 0036 0037 void reportNewResults(const ResultList &results); 0038 0039 QString queryString() const; 0040 0041 Q_SIGNALS: 0042 void startedProcessingQuery(); 0043 void newResultsAppeared(const ResultList &results); 0044 void finishedProcessingQuery(); 0045 0046 private: 0047 QString m_queryString; 0048 0049 }; 0050 0051 #endif // include guard end 0052