File indexing completed on 2024-04-28 03:49:31
0001 // SPDX-License-Identifier: LGPL-2.1-or-later 0002 // 0003 // SPDX-FileCopyrightText: 2010 Dennis Nienhüser <nienhueser@kde.org> 0004 // 0005 0006 #ifndef MARBLE_ROUTINGWIDGET_H 0007 #define MARBLE_ROUTINGWIDGET_H 0008 0009 #include "RoutingManager.h" 0010 #include "marble_export.h" 0011 0012 #include <QWidget> 0013 0014 class QModelIndex; 0015 0016 namespace Marble 0017 { 0018 0019 class MarbleWidget; 0020 class RoutingInputWidget; 0021 class RoutingWidgetPrivate; 0022 class RouteSyncManager; 0023 class GeoDataCoordinates; 0024 0025 /** 0026 * A widget consisting of input fields for places / routing destinations, 0027 * a list view showing routing instructions and a interactive paint layer 0028 * showing placemarks and the route 0029 */ 0030 class MARBLE_EXPORT RoutingWidget : public QWidget 0031 { 0032 Q_OBJECT 0033 0034 public: 0035 /** 0036 * @brief Constructor 0037 * @param marbleWidget The marble widget used to register an event handler 0038 * on. Must not be null. 0039 * @param parent Optional parent widget 0040 */ 0041 explicit RoutingWidget( MarbleWidget *marbleWidget, QWidget *parent ); 0042 0043 /** Destructor */ 0044 ~RoutingWidget() override; 0045 0046 /** Show or hide the "open file..." button. Default is false (not visible) */ 0047 void setShowDirectionsButtonVisible( bool visible ); 0048 0049 void setRouteSyncManager(RouteSyncManager* manager); 0050 0051 public Q_SLOTS: 0052 /** Ask the user for a kml file to open */ 0053 void openRoute(); 0054 0055 /** Ask the user for a kml file to save the current route to */ 0056 void saveRoute(); 0057 0058 /** Upload route to the cloud */ 0059 void uploadToCloud(); 0060 0061 /** Open cloud routes dialog */ 0062 void openCloudRoutesDialog(); 0063 0064 /** Add another input field at the end */ 0065 void addInputWidget(); 0066 0067 private Q_SLOTS: 0068 /** Retrieve route directions */ 0069 void retrieveRoute(); 0070 0071 /** User activated a route instruction element in the list view, synchronize paint layer */ 0072 void activateItem ( const QModelIndex &index ); 0073 0074 /** Placemark search is finished in an input field, switch to its placemark model */ 0075 void handleSearchResult( RoutingInputWidget *widget ); 0076 0077 /** Switch to the placemark model of an input field */ 0078 void centerOnInputWidget( RoutingInputWidget *widget ); 0079 0080 /** A placemark was selected in the map, synchronize list view */ 0081 void activatePlacemark( const QModelIndex &index ); 0082 0083 /** Insert another input field at the given position */ 0084 void insertInputWidget( int index ); 0085 0086 /** Remove an existing input field */ 0087 void removeInputWidget( RoutingInputWidget *widget ); 0088 0089 /** Remove an existing input field */ 0090 void removeInputWidget( int index ); 0091 0092 /** Route state changed */ 0093 void updateRouteState( RoutingManager::State state ); 0094 0095 /** An input field requests a position input from the map */ 0096 void requestMapPosition( RoutingInputWidget *widget, bool enabled ); 0097 0098 /** Position in the map selected by the user after a previous slotMapInputRequested */ 0099 void retrieveSelectedPoint( const GeoDataCoordinates &coordinates ); 0100 0101 /** Update the text of the Search / GetDirections button */ 0102 void adjustSearchButton(); 0103 0104 /** The user canceled point selection from the map */ 0105 void pointSelectionCanceled(); 0106 0107 /** show profile configuration dialog */ 0108 void configureProfile(); 0109 0110 /** Progress animation update */ 0111 void updateProgress(); 0112 0113 /** Toggle visibility of alternative routes */ 0114 void updateAlternativeRoutes(); 0115 0116 /** Select the first routing profile if none is selected yet */ 0117 void selectFirstProfile(); 0118 0119 /** Show the directions ListView */ 0120 void showDirections(); 0121 0122 /** Update the route request with the given profile */ 0123 void setRoutingProfile( int index ); 0124 0125 /** Change selected routing profile to the one set in the shared request */ 0126 void updateActiveRoutingProfile(); 0127 0128 /** Toggle cloud sync button visibility based on whether route sync is enabled */ 0129 void updateCloudSyncButtons(); 0130 0131 /** Open a remote route and center on it */ 0132 void openCloudRoute( const QString &identifier ); 0133 0134 void updateUploadProgress( qint64 sent, qint64 total ); 0135 0136 void centerOn( const GeoDataCoordinates &coordinates ); 0137 0138 void seekTourToStart(); 0139 0140 void initializeTour(); 0141 0142 void clearTour(); 0143 0144 void toggleRoutePlay(); 0145 0146 void handlePlanetChange(); 0147 0148 protected: 0149 bool eventFilter( QObject *o, QEvent *e ) override; 0150 void resizeEvent(QResizeEvent *e) override; 0151 0152 private: 0153 RoutingWidgetPrivate *const d; 0154 }; 0155 0156 } // namespace Marble 0157 0158 #endif