File indexing completed on 2024-03-24 03:52:41
0001 // SPDX-License-Identifier: LGPL-2.1-or-later 0002 // 0003 // SPDX-FileCopyrightText: 2010 Dennis Nienhüser <nienhueser@kde.org> 0004 // SPDX-FileCopyrightText: 2011 Thibaut Gridel <tgridel@free.fr> 0005 // SPDX-FileCopyrightText: 2012 Bernhard Beschow <bbeschow@cs.tu-berlin.de> 0006 // 0007 0008 #ifndef MARBLE_ROUTINGRUNNERPLUGIN_H 0009 #define MARBLE_ROUTINGRUNNERPLUGIN_H 0010 0011 #include <QObject> 0012 #include "PluginInterface.h" 0013 0014 #include <QHash> 0015 #include <QWidget> 0016 0017 #include "routing/RoutingProfilesModel.h" 0018 0019 namespace Marble 0020 { 0021 0022 class MarbleAbstractRunner; 0023 class RoutingRunner; 0024 0025 /** 0026 * A plugin for Marble to execute a routing task. 0027 */ 0028 class MARBLE_EXPORT RoutingRunnerPlugin : public QObject, public PluginInterface 0029 { 0030 Q_OBJECT 0031 0032 public: 0033 /** Constructor with optional parent object */ 0034 explicit RoutingRunnerPlugin( QObject* parent = nullptr ); 0035 0036 /** Destructor */ 0037 ~RoutingRunnerPlugin() override; 0038 0039 /** 0040 * @brief Returns the string that should appear in the user interface. 0041 * 0042 * For example, "OpenRouteService" should be returned for the OpenRouteService routing plugin. 0043 */ 0044 virtual QString guiString() const = 0; 0045 0046 /** Plugin factory method to create a new runner instance. 0047 * Method caller gets ownership of the returned object 0048 */ 0049 virtual RoutingRunner *newRunner() const = 0; 0050 0051 /** True if the plugin supports its tasks on the given planet */ 0052 bool supportsCelestialBody( const QString &celestialBodyId ) const; 0053 0054 /** True if the plugin can execute its tasks without network access */ 0055 bool canWorkOffline() const; 0056 0057 /** 0058 * @brief Returns @code true @endcode if the plugin is able to perform its claimed task. 0059 * 0060 * The default implementation returns @code true @endcode. This method can be 0061 * overridden for example to indicate an incomplete installation. 0062 */ 0063 virtual bool canWork() const; 0064 0065 // Overridden methods with default implementations 0066 0067 QIcon icon() const override; 0068 0069 /** A status message showing whether the plugin will be able to deliver results */ 0070 QString statusMessage() const; 0071 0072 class ConfigWidget : public QWidget 0073 { 0074 public: 0075 virtual void loadSettings( const QHash<QString, QVariant> &settings ) = 0; 0076 virtual QHash<QString, QVariant> settings() const = 0; 0077 }; 0078 /** 0079 * @brief Method for getting a pointer to the configuration widget of the plugin. 0080 * 0081 * @return The configuration widget or, if no configuration widget exists, 0. 0082 */ 0083 virtual ConfigWidget *configWidget(); 0084 0085 /** True if the plugin supports the given routing profile template */ 0086 virtual bool supportsTemplate( RoutingProfilesModel::ProfileTemplate profileTemplate ) const; 0087 0088 /** Settings for the given routing profile template */ 0089 virtual QHash<QString, QVariant> templateSettings( RoutingProfilesModel::ProfileTemplate profileTemplate ) const; 0090 0091 protected: 0092 void setStatusMessage( const QString &message ); 0093 0094 void setSupportedCelestialBodies( const QStringList &celestialBodies ); 0095 0096 void setCanWorkOffline( bool canWorkOffline ); 0097 0098 private: 0099 class Private; 0100 Private *const d; 0101 }; 0102 0103 } 0104 0105 Q_DECLARE_INTERFACE( Marble::RoutingRunnerPlugin, "org.kde.Marble.RunnerRunnerPlugin/1.01" ) 0106 0107 #endif // MARBLE_ROUTINGRUNNERPLUGIN_H