File indexing completed on 2024-04-21 03:49:54

0001 // SPDX-License-Identifier: LGPL-2.1-or-later
0002 //
0003 // SPDX-FileCopyrightText: 2008 Henry de Valence <hdevalence@gmail.com>
0004 // SPDX-FileCopyrightText: 2010 Dennis Nienhüser <nienhueser@kde.org>
0005 // SPDX-FileCopyrightText: 2010-2013 Bernhard Beschow <bbeschow@cs.tu-berlin.de>
0006 // SPDX-FileCopyrightText: 2011 Thibaut Gridel <tgridel@free.fr>
0007 
0008 #ifndef MARBLE_REVERSEGEOCODINGRUNNERMANAGER_H
0009 #define MARBLE_REVERSEGEOCODINGRUNNERMANAGER_H
0010 
0011 #include <QObject>
0012 
0013 #include "marble_export.h"
0014 
0015 class QAbstractItemModel;
0016 
0017 namespace Marble
0018 {
0019 
0020 class GeoDataCoordinates;
0021 class GeoDataPlacemark;
0022 class MarbleModel;
0023 class ReverseGeocodingTask;
0024 
0025 class MARBLE_EXPORT ReverseGeocodingRunnerManager : public QObject
0026 {
0027     Q_OBJECT
0028 
0029 public:
0030     /**
0031      * Constructor.
0032      * @param pluginManager The plugin manager that gives access to RunnerPlugins
0033      * @param parent Optional parent object
0034      */
0035     explicit ReverseGeocodingRunnerManager( const MarbleModel *marbleModel, QObject *parent = nullptr );
0036 
0037     ~ReverseGeocodingRunnerManager() override;
0038 
0039     /**
0040      * Find the address and other meta information for a given geoposition.
0041      * @see reverseGeocoding is asynchronous with currently one result
0042      * returned using the @see reverseGeocodingFinished signal.
0043      * @see searchReverseGeocoding is blocking.
0044      * @see reverseGeocodingFinished signal indicates all runners are finished.
0045      */
0046     void reverseGeocoding( const GeoDataCoordinates &coordinates );
0047     QString searchReverseGeocoding( const GeoDataCoordinates &coordinates, int timeout = 30000 );
0048 
0049 Q_SIGNALS:
0050     /**
0051      * The reverse geocoding request is finished, the result is stored
0052      * in the given placemark. This signal is emitted when the first
0053      * runner found a result, subsequent results are discarded and do not
0054      * emit further signals. If no result is found, this signal is emitted
0055      * with an empty (default constructed) placemark.
0056      */
0057     void reverseGeocodingFinished( const GeoDataCoordinates &coordinates, const GeoDataPlacemark &placemark );
0058 
0059     /**
0060      * Emitted whenever all runners are finished for the query
0061      */
0062     void reverseGeocodingFinished();
0063 
0064 private:
0065     Q_PRIVATE_SLOT( d, void addReverseGeocodingResult( const GeoDataCoordinates &coordinates, const GeoDataPlacemark &placemark ) )
0066     Q_PRIVATE_SLOT( d, void cleanupReverseGeocodingTask( ReverseGeocodingTask *task ) )
0067 
0068     class Private;
0069     friend class Private;
0070     Private *const d;
0071 };
0072 
0073 }
0074 
0075 #endif