1 // SPDX-License-Identifier: LGPL-2.1-or-later 2 // 3 // SPDX-FileCopyrightText: 2008 Henry de Valence <hdevalence@gmail.com> 4 // SPDX-FileCopyrightText: 2010 Dennis Nienhüser <nienhueser@kde.org> 5 // SPDX-FileCopyrightText: 2010-2013 Bernhard Beschow <bbeschow@cs.tu-berlin.de> 6 // SPDX-FileCopyrightText: 2011 Thibaut Gridel <tgridel@free.fr> 7 8 #ifndef MARBLE_SEARCHRUNNERMANAGER_H 9 #define MARBLE_SEARCHRUNNERMANAGER_H 10 11 #include "GeoDataLatLonBox.h" 12 13 #include "marble_export.h" 14 15 #include <QObject> 16 #include <QVector> 17 18 class QAbstractItemModel; 19 class QString; 20 21 namespace Marble 22 { 23 24 class GeoDataPlacemark; 25 class MarbleModel; 26 class SearchTask; 27 28 class MARBLE_EXPORT SearchRunnerManager : public QObject 29 { 30 Q_OBJECT 31 32 public: 33 /** 34 * Constructor. 35 * @param pluginManager The plugin manager that gives access to RunnerPlugins 36 * @param parent Optional parent object 37 */ 38 explicit SearchRunnerManager( const MarbleModel *marbleModel, QObject *parent = nullptr ); 39 40 ~SearchRunnerManager() override; 41 42 /** 43 * Search for placemarks matching the given search term. 44 * @see findPlacemark is asynchronous with results returned using the 45 * @see searchResultChanged signal. 46 * @see searchPlacemark is blocking. 47 * @see searchFinished signal indicates all runners are finished. 48 */ 49 void findPlacemarks( const QString &searchTerm, const GeoDataLatLonBox &preferred = GeoDataLatLonBox() ); 50 QVector<GeoDataPlacemark *> searchPlacemarks( const QString &searchTerm, const GeoDataLatLonBox &preferred = GeoDataLatLonBox(), int timeout = 30000 ); 51 52 Q_SIGNALS: 53 /** 54 * Placemarks were added to or removed from the model 55 * @todo FIXME: this sounds like a duplication of QAbstractItemModel signals 56 */ 57 void searchResultChanged( QAbstractItemModel *model ); 58 void searchResultChanged( const QVector<GeoDataPlacemark *> &result ); 59 60 /** 61 * The search request for the given search term has finished, i.e. all 62 * runners are finished and reported their results via the 63 * @see searchResultChanged signal 64 */ 65 void searchFinished( const QString &searchTerm ); 66 67 /** 68 * Emitted whenever all runners are finished for the query 69 */ 70 void placemarkSearchFinished(); 71 72 private: 73 Q_PRIVATE_SLOT( d, void addSearchResult( const QVector<GeoDataPlacemark *> &result ) ) 74 Q_PRIVATE_SLOT( d, void cleanupSearchTask( SearchTask *task ) ) 75 76 class Private; 77 friend class Private; 78 Private *const d; 79 }; 80 81 } 82 83 #endif 84