1 /*************************************************************************** 2 qgisappinterface.h 3 Interface class for exposing functions in QgisApp for use by plugins 4 ------------------- 5 begin : 2004-02-11 6 copyright : (C) 2004 by Gary E.Sherman 7 email : sherman at mrcc.com 8 ***************************************************************************/ 9 10 /*************************************************************************** 11 * * 12 * This program is free software; you can redistribute it and/or modify * 13 * it under the terms of the GNU General Public License as published by * 14 * the Free Software Foundation; either version 2 of the License, or * 15 * (at your option) any later version. * 16 * * 17 ***************************************************************************/ 18 #ifndef QGISIFACE_H 19 #define QGISIFACE_H 20 21 #include "qgis_app.h" 22 #include "qgisinterface.h" 23 #include "qgsapppluginmanagerinterface.h" 24 25 class QTimer; 26 27 class QgisApp; 28 29 /** 30 * \class QgisAppInterface 31 * \brief Interface class to provide access to private methods in QgisApp 32 * for use by plugins. 33 * 34 * Only those functions "exposed" by QgisInterface can be called from within a 35 * plugin. 36 */ 37 38 Q_NOWARN_DEPRECATED_PUSH 39 class APP_EXPORT QgisAppInterface : public QgisInterface 40 { 41 Q_OBJECT 42 43 public: 44 45 /** 46 * Constructor. 47 * \param qgis Pointer to the QgisApp object 48 */ 49 QgisAppInterface( QgisApp *qgisapp ); 50 51 QgisAppInterface( QgisAppInterface const & ) = delete; 52 QgisAppInterface &operator=( QgisAppInterface const & ) = delete; 53 54 QgsPluginManagerInterface *pluginManagerInterface() override; 55 56 QgsLayerTreeView *layerTreeView() override; 57 58 void addCustomActionForLayerType( QAction *action, QString menu, 59 QgsMapLayerType type, bool allLayers ) override; 60 void addCustomActionForLayer( QAction *action, QgsMapLayer *layer ) override; 61 bool removeCustomActionForLayerType( QAction *action ) override; 62 63 /* Exposed functions */ 64 65 void zoomFull() override; 66 void zoomToPrevious() override; 67 void zoomToNext() override; 68 void zoomToActiveLayer() override; 69 QgsVectorLayer *addVectorLayer( const QString &vectorLayerPath, const QString &baseName, const QString &providerKey ) override; 70 QgsRasterLayer *addRasterLayer( const QString &rasterLayerPath, const QString &baseName ) override; 71 QgsRasterLayer *addRasterLayer( const QString &url, const QString &baseName, const QString &providerKey ) override; 72 QgsMeshLayer *addMeshLayer( const QString &url, const QString &baseName, const QString &providerKey ) override; 73 QgsVectorTileLayer *addVectorTileLayer( const QString &url, const QString &baseName ) override; 74 bool addProject( const QString &projectName ) override; 75 bool newProject( bool promptToSaveFlag = false ) override; 76 void reloadConnections( ) override; 77 QgsMapLayer *activeLayer() override; 78 bool setActiveLayer( QgsMapLayer *layer ) override; 79 void copySelectionToClipboard( QgsMapLayer *layer ) override; 80 void pasteFromClipboard( QgsMapLayer *layer ) override; 81 int addToolBarIcon( QAction *qAction ) override; 82 QAction *addToolBarWidget( QWidget *widget ) override; 83 void removeToolBarIcon( QAction *qAction ) override; 84 int addRasterToolBarIcon( QAction *qAction ) override; 85 QAction *addRasterToolBarWidget( QWidget *widget ) override; 86 void removeRasterToolBarIcon( QAction *qAction ) override; 87 int addVectorToolBarIcon( QAction *qAction ) override; 88 QAction *addVectorToolBarWidget( QWidget *widget ) override; 89 void removeVectorToolBarIcon( QAction *qAction ) override; 90 int addDatabaseToolBarIcon( QAction *qAction ) override; 91 QAction *addDatabaseToolBarWidget( QWidget *widget ) override; 92 void removeDatabaseToolBarIcon( QAction *qAction ) override; 93 int addWebToolBarIcon( QAction *qAction ) override; 94 QAction *addWebToolBarWidget( QWidget *widget ) override; 95 void removeWebToolBarIcon( QAction *qAction ) override; 96 QToolBar *addToolBar( const QString &name ) override; 97 void addToolBar( QToolBar *toolbar, Qt::ToolBarArea area = Qt::TopToolBarArea ) override; 98 99 #ifndef Q_MOC_RUN 100 Q_DECL_DEPRECATED 101 #endif 102 void openURL( const QString &url, bool useQgisDocDirectory = true ) override; 103 104 QgsMapCanvas *mapCanvas() override; 105 QList< QgsMapCanvas * > mapCanvases() override; 106 QgsMapCanvas *createNewMapCanvas( const QString &name ) override; 107 void closeMapCanvas( const QString &name ) override; 108 QSize iconSize( bool dockedToolbar = false ) const override; 109 QgsLayerTreeMapCanvasBridge *layerTreeCanvasBridge() override; 110 QWidget *mainWindow() override; 111 QgsMessageBar *messageBar() override; 112 void openMessageLog() override; 113 void addUserInputWidget( QWidget *widget ) override; 114 void showLayoutManager() override; 115 QList<QgsLayoutDesignerInterface *> openLayoutDesigners() override; 116 QgsLayoutDesignerInterface *openLayoutDesigner( QgsMasterLayoutInterface *layout ) override; 117 void showOptionsDialog( QWidget *parent = nullptr, const QString ¤tPage = QString() ) override; 118 void showProjectPropertiesDialog( const QString ¤tPage = QString() ) override; 119 QMap<QString, QVariant> defaultStyleSheetOptions() override; 120 void buildStyleSheet( const QMap<QString, QVariant> &opts ) override; 121 void saveStyleSheetOptions( const QMap<QString, QVariant> &opts ) override; 122 QFont defaultStyleSheetFont() override; 123 void addPluginToMenu( const QString &name, QAction *action ) override; 124 void removePluginMenu( const QString &name, QAction *action ) override; 125 void addPluginToDatabaseMenu( const QString &name, QAction *action ) override; 126 void removePluginDatabaseMenu( const QString &name, QAction *action ) override; 127 void addPluginToRasterMenu( const QString &name, QAction *action ) override; 128 void removePluginRasterMenu( const QString &name, QAction *action ) override; 129 void addPluginToVectorMenu( const QString &name, QAction *action ) override; 130 void removePluginVectorMenu( const QString &name, QAction *action ) override; 131 void addPluginToWebMenu( const QString &name, QAction *action ) override; 132 void removePluginWebMenu( const QString &name, QAction *action ) override; 133 void insertAddLayerAction( QAction *action ) override; 134 void removeAddLayerAction( QAction *action ) override; 135 void addDockWidget( Qt::DockWidgetArea area, QDockWidget *dockwidget ) override; 136 void addTabifiedDockWidget( Qt::DockWidgetArea area, QDockWidget *dockwidget, const QStringList &tabifyWith = QStringList(), bool raiseTab = false ) override; 137 void removeDockWidget( QDockWidget *dockwidget ) override; 138 QgsAdvancedDigitizingDockWidget *cadDockWidget() override; 139 void showLayerProperties( QgsMapLayer *l ) override; 140 QDialog *showAttributeTable( QgsVectorLayer *l, const QString &filterExpression = QString() ) override; 141 void addWindow( QAction *action ) override; 142 void removeWindow( QAction *action ) override; 143 bool registerMainWindowAction( QAction *action, const QString &defaultShortcut ) override; 144 bool unregisterMainWindowAction( QAction *action ) override; 145 void registerMapLayerConfigWidgetFactory( QgsMapLayerConfigWidgetFactory *factory ) override; 146 void unregisterMapLayerConfigWidgetFactory( QgsMapLayerConfigWidgetFactory *factory ) override; 147 void registerOptionsWidgetFactory( QgsOptionsWidgetFactory *factory ) override; 148 void unregisterOptionsWidgetFactory( QgsOptionsWidgetFactory *factory ) override; 149 void registerProjectPropertiesWidgetFactory( QgsOptionsWidgetFactory *factory ) override; 150 void unregisterProjectPropertiesWidgetFactory( QgsOptionsWidgetFactory *factory ) override; 151 void registerDevToolWidgetFactory( QgsDevToolWidgetFactory *factory ) override; 152 void unregisterDevToolWidgetFactory( QgsDevToolWidgetFactory *factory ) override; 153 void registerApplicationExitBlocker( QgsApplicationExitBlockerInterface *blocker ) override; 154 void unregisterApplicationExitBlocker( QgsApplicationExitBlockerInterface *blocker ) override; 155 void registerMapToolHandler( QgsAbstractMapToolHandler *handler ) override; 156 void unregisterMapToolHandler( QgsAbstractMapToolHandler *handler ) override; 157 void registerCustomDropHandler( QgsCustomDropHandler *handler ) override; 158 void unregisterCustomDropHandler( QgsCustomDropHandler *handler ) override; 159 void registerCustomProjectOpenHandler( QgsCustomProjectOpenHandler *handler ) override; 160 void unregisterCustomProjectOpenHandler( QgsCustomProjectOpenHandler *handler ) override; 161 void registerCustomLayoutDropHandler( QgsLayoutCustomDropHandler *handler ) override; 162 void unregisterCustomLayoutDropHandler( QgsLayoutCustomDropHandler *handler ) override; 163 QMenu *projectMenu() override; 164 QMenu *editMenu() override; 165 QMenu *viewMenu() override; 166 QMenu *layerMenu() override; 167 QMenu *newLayerMenu() override; 168 QMenu *addLayerMenu() override; 169 QMenu *settingsMenu() override; 170 QMenu *pluginMenu() override; 171 QMenu *pluginHelpMenu() override; 172 QMenu *rasterMenu() override; 173 QMenu *vectorMenu() override; 174 QMenu *databaseMenu() override; 175 QMenu *webMenu() override; 176 QMenu *firstRightStandardMenu() override; 177 QMenu *windowMenu() override; 178 QMenu *helpMenu() override; 179 QToolBar *fileToolBar() override; 180 QToolBar *layerToolBar() override; 181 QToolBar *dataSourceManagerToolBar() override; 182 QToolBar *mapNavToolToolBar() override; 183 QToolBar *digitizeToolBar() override; 184 QToolBar *advancedDigitizeToolBar() override; 185 QToolBar *shapeDigitizeToolBar() override; 186 QToolBar *attributesToolBar() override; 187 QToolBar *selectionToolBar() override; 188 QToolBar *pluginToolBar() override; 189 QToolBar *helpToolBar() override; 190 QToolBar *rasterToolBar() override; 191 QToolBar *vectorToolBar() override; 192 QToolBar *databaseToolBar() override; 193 QToolBar *webToolBar() override; 194 QActionGroup *mapToolActionGroup() override; 195 QAction *actionNewProject() override; 196 QAction *actionOpenProject() override; 197 QAction *actionSaveProject() override; 198 QAction *actionSaveProjectAs() override; 199 QAction *actionSaveMapAsImage() override; 200 QAction *actionProjectProperties() override; 201 QAction *actionCreatePrintLayout() override; 202 QAction *actionShowLayoutManager() override; 203 QAction *actionExit() override; 204 QAction *actionCutFeatures() override; 205 QAction *actionCopyFeatures() override; 206 QAction *actionPasteFeatures() override; 207 QAction *actionAddFeature() override; 208 QAction *actionDeleteSelected() override; 209 QAction *actionMoveFeature() override; 210 QAction *actionSplitFeatures() override; 211 QAction *actionSplitParts() override; 212 QAction *actionAddRing() override; 213 QAction *actionAddPart() override; 214 QAction *actionSimplifyFeature() override; 215 QAction *actionDeleteRing() override; 216 QAction *actionDeletePart() override; 217 QAction *actionVertexTool() override; 218 QAction *actionVertexToolActiveLayer() override; 219 QAction *actionPan() override; 220 QAction *actionPanToSelected() override; 221 QAction *actionZoomIn() override; 222 QAction *actionZoomOut() override; 223 QAction *actionSelect() override; 224 QAction *actionSelectRectangle() override; 225 QAction *actionSelectPolygon() override; 226 QAction *actionSelectFreehand() override; 227 QAction *actionSelectRadius() override; 228 QAction *actionIdentify() override; 229 QAction *actionFeatureAction() override; 230 QAction *actionMeasure() override; 231 QAction *actionMeasureArea() override; 232 QAction *actionZoomFullExtent() override; 233 QAction *actionZoomToLayer() override; 234 QAction *actionZoomToSelected() override; 235 QAction *actionZoomLast() override; 236 QAction *actionZoomNext() override; 237 QAction *actionZoomActualSize() override; 238 QAction *actionMapTips() override; 239 QAction *actionNewBookmark() override; 240 QAction *actionShowBookmarks() override; 241 QAction *actionDraw() override; 242 QAction *actionNewVectorLayer() override; 243 QAction *actionAddOgrLayer() override; 244 QAction *actionAddRasterLayer() override; 245 QAction *actionAddPgLayer() override; 246 QAction *actionAddWmsLayer() override; 247 QAction *actionAddXyzLayer() override; 248 QAction *actionAddVectorTileLayer() override; 249 QAction *actionAddAfsLayer() override; 250 QAction *actionAddAmsLayer() override; 251 QAction *actionCopyLayerStyle() override; 252 QAction *actionPasteLayerStyle() override; 253 QAction *actionOpenTable() override; 254 QAction *actionOpenFieldCalculator() override; 255 QAction *actionOpenStatisticalSummary() override; 256 QAction *actionToggleEditing() override; 257 QAction *actionSaveActiveLayerEdits() override; 258 QAction *actionAllEdits() override; 259 QAction *actionSaveEdits() override; 260 QAction *actionSaveAllEdits() override; 261 QAction *actionRollbackEdits() override; 262 QAction *actionRollbackAllEdits() override; 263 QAction *actionCancelEdits() override; 264 QAction *actionCancelAllEdits() override; 265 QAction *actionLayerSaveAs() override; 266 QAction *actionDuplicateLayer() override; 267 QAction *actionLayerProperties() override; 268 QAction *actionAddToOverview() override; 269 QAction *actionAddAllToOverview() override; 270 QAction *actionRemoveAllFromOverview() override; 271 QAction *actionHideAllLayers() override; 272 QAction *actionShowAllLayers() override; 273 QAction *actionHideSelectedLayers() override; 274 QAction *actionToggleSelectedLayers() override; 275 QAction *actionToggleSelectedLayersIndependently() override; 276 QAction *actionHideDeselectedLayers() override; 277 QAction *actionShowSelectedLayers() override; 278 QAction *actionManagePlugins() override; 279 QAction *actionPluginListSeparator() override; 280 QAction *actionShowPythonDialog() override; 281 QAction *actionToggleFullScreen() override; 282 QAction *actionOptions() override; 283 QAction *actionCustomProjection() override; 284 QAction *actionHelpContents() override; 285 QAction *actionQgisHomePage() override; 286 QAction *actionCheckQgisVersion() override; 287 QAction *actionAbout() override; 288 QAction *actionCircle2Points() override; 289 QAction *actionCircle3Points() override; 290 QAction *actionCircle3Tangents() override; 291 QAction *actionCircle2TangentsPoint() override; 292 QAction *actionCircleCenterPoint() override; 293 QAction *actionEllipseCenter2Points() override; 294 QAction *actionEllipseCenterPoint() override; 295 QAction *actionEllipseExtent() override; 296 QAction *actionEllipseFoci() override; 297 QAction *actionRectangleCenterPoint() override; 298 QAction *actionRectangleExtent() override; 299 QAction *actionRectangle3PointsDistance() override; 300 QAction *actionRectangle3PointsProjected() override; 301 QAction *actionRegularPolygon2Points() override; 302 QAction *actionRegularPolygonCenterPoint() override; 303 QAction *actionRegularPolygonCenterCorner() override; 304 305 bool openFeatureForm( QgsVectorLayer *l, QgsFeature &f, bool updateFeatureOnly = false, bool showModal = true ) override; 306 QgsAttributeDialog *getFeatureForm( QgsVectorLayer *layer, QgsFeature &feature ) override; 307 QgsVectorLayerTools *vectorLayerTools() override; 308 void preloadForm( const QString &uifile ) override; 309 QList<QgsMapLayer *> editableLayers( bool modified = false ) const override; 310 int messageTimeout() override; 311 QgsStatusBar *statusBarIface() override; 312 void locatorSearch( const QString &searchText ) override; 313 void registerLocatorFilter( QgsLocatorFilter *filter ) override; 314 void deregisterLocatorFilter( QgsLocatorFilter *filter ) override; 315 void invalidateLocatorResults() override; 316 bool askForDatumTransform( QgsCoordinateReferenceSystem sourceCrs, QgsCoordinateReferenceSystem destinationCrs ) override; 317 void takeAppScreenShots( const QString &saveDirectory, const int categories = 0 ) override; 318 QgsBrowserGuiModel *browserModel() override; 319 QgsLayerTreeRegistryBridge::InsertionPoint layerTreeInsertionPoint() override; 320 void setGpsPanelConnection( QgsGpsConnection *connection ) override; 321 322 private slots: 323 324 void cacheloadForm( const QString &uifile = QString() ); 325 326 private: 327 328 //! Pointer to the QgisApp object 329 QgisApp *qgis = nullptr; 330 331 //! Pointer to the PluginManagerInterface object 332 QgsAppPluginManagerInterface pluginManagerIface; 333 }; 334 Q_NOWARN_DEPRECATED_POP 335 336 #endif //#define QGISAPPINTERFACE_H 337