QGIS API Documentation  3.10.0-A Coruña (6c816b4204)
qgisinterface.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgisinterface.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 QGISINTERFACE_H
19 #define QGISINTERFACE_H
20 
21 #include <QObject>
22 #include <map>
23 
24 #include "qgis.h"
25 #include "qgis_sip.h"
26 #include "qgis_gui.h"
29 
30 class QAction;
31 class QDialog;
32 class QFont;
33 class QMenu;
34 class QToolBar;
35 class QDockWidget;
36 class QMainWindow;
37 class QWidget;
38 
40 class QgsAttributeDialog;
43 class QgsFeature;
45 class QgsLayerTreeView;
46 class QgsLayerTreeGroup;
47 class QgsLayout;
50 class QgsMapCanvas;
51 class QgsMapLayer;
52 enum class QgsMapLayerType;
54 class QgsMessageBar;
56 class QgsRasterLayer;
57 class QgsVectorLayer;
60 class QgsLocatorFilter;
61 class QgsStatusBar;
62 class QgsMeshLayer;
63 class QgsBrowserGuiModel;
64 
65 
80 class GUI_EXPORT QgisInterface : public QObject
81 {
82  Q_OBJECT
83 
84  public:
85 
87  QgisInterface() = default;
88 
89  virtual QgsPluginManagerInterface *pluginManagerInterface() = 0;
90 
91  virtual QgsLayerTreeView *layerTreeView() = 0;
92 
105  virtual void addCustomActionForLayerType( QAction *action, QString menu,
106  QgsMapLayerType type, bool allLayers ) = 0;
107 
114  virtual void addCustomActionForLayer( QAction *action, QgsMapLayer *layer ) = 0;
115 
120  virtual bool removeCustomActionForLayerType( QAction *action ) = 0;
121 
126  virtual QList< QgsMapCanvas * > mapCanvases() = 0;
127 
133  virtual QgsMapCanvas *createNewMapCanvas( const QString &name ) = 0;
134 
140  virtual void closeMapCanvas( const QString &name ) = 0;
141 
146  virtual QSize iconSize( bool dockedToolbar = false ) const = 0;
147 
153  virtual QList<QgsMapLayer *> editableLayers( bool modified = false ) const = 0;
154 
156  virtual QgsMapLayer *activeLayer() = 0;
157 
159  virtual QgsMapCanvas *mapCanvas() = 0;
160 
166  virtual QgsLayerTreeMapCanvasBridge *layerTreeCanvasBridge() = 0;
167 
169  virtual QWidget *mainWindow() = 0;
170 
172  virtual QgsMessageBar *messageBar() = 0;
173 
178  virtual QList<QgsLayoutDesignerInterface *> openLayoutDesigners() = 0;
179 
180 
182  virtual QMap<QString, QVariant> defaultStyleSheetOptions() = 0;
183 
185  virtual QFont defaultStyleSheetFont() = 0;
186 
191  virtual QgsAdvancedDigitizingDockWidget *cadDockWidget() = 0;
192 
193  /*
194  * Accessors for inserting items into menus and toolbars.
195  * An item can be inserted before any existing action.
196  */
197 
201  virtual QMenu *projectMenu() = 0;
202 
206  virtual QMenu *editMenu() = 0;
207 
211  virtual QMenu *viewMenu() = 0;
212 
216  virtual QMenu *layerMenu() = 0;
217 
221  virtual QMenu *newLayerMenu() = 0;
222 
227  virtual QMenu *addLayerMenu() = 0;
228 
232  virtual QMenu *settingsMenu() = 0;
233 
237  virtual QMenu *pluginMenu() = 0;
238 
247  virtual QMenu *pluginHelpMenu() = 0;
248 
252  virtual QMenu *rasterMenu() = 0;
253 
257  virtual QMenu *databaseMenu() = 0;
258 
262  virtual QMenu *vectorMenu() = 0;
263 
267  virtual QMenu *webMenu() = 0;
268 
276  virtual QMenu *firstRightStandardMenu() = 0;
277 
281  virtual QMenu *windowMenu() = 0;
282 
286  virtual QMenu *helpMenu() = 0;
287 
288  // ToolBars
289 
293  virtual QToolBar *fileToolBar() = 0;
294 
298  virtual QToolBar *layerToolBar() = 0;
299 
304  virtual QToolBar *dataSourceManagerToolBar() = 0;
305 
309  virtual QToolBar *mapNavToolToolBar() = 0;
310 
314  virtual QToolBar *digitizeToolBar() = 0;
315 
319  virtual QToolBar *advancedDigitizeToolBar() = 0;
320 
325  virtual QToolBar *shapeDigitizeToolBar() = 0;
326 
330  virtual QToolBar *attributesToolBar() = 0;
331 
335  virtual QToolBar *pluginToolBar() = 0;
336 
340  virtual QToolBar *helpToolBar() = 0;
341 
345  virtual QToolBar *rasterToolBar() = 0;
346 
350  virtual QToolBar *vectorToolBar() = 0;
351 
355  virtual QToolBar *databaseToolBar() = 0;
356 
360  virtual QToolBar *webToolBar() = 0;
361 
362  // Project menu actions
364  virtual QAction *actionNewProject() = 0;
366  virtual QAction *actionOpenProject() = 0;
368  virtual QAction *actionSaveProject() = 0;
370  virtual QAction *actionSaveProjectAs() = 0;
372  virtual QAction *actionSaveMapAsImage() = 0;
374  virtual QAction *actionProjectProperties() = 0;
375 
377  virtual QAction *actionCreatePrintLayout() = 0;
378 
380  virtual QAction *actionShowLayoutManager() = 0;
382  virtual QAction *actionExit() = 0;
383 
384  // Edit menu actions
385 
387  virtual QAction *actionCutFeatures() = 0;
389  virtual QAction *actionCopyFeatures() = 0;
391  virtual QAction *actionPasteFeatures() = 0;
393  virtual QAction *actionAddFeature() = 0;
395  virtual QAction *actionDeleteSelected() = 0;
397  virtual QAction *actionMoveFeature() = 0;
399  virtual QAction *actionSplitFeatures() = 0;
401  virtual QAction *actionSplitParts() = 0;
403  virtual QAction *actionAddRing() = 0;
405  virtual QAction *actionAddPart() = 0;
407  virtual QAction *actionSimplifyFeature() = 0;
409  virtual QAction *actionDeleteRing() = 0;
411  virtual QAction *actionDeletePart() = 0;
412 
417  virtual QAction *actionVertexTool() = 0;
418 
424  virtual QAction *actionVertexToolActiveLayer() = 0;
425 
426  // View menu actions
428  virtual QAction *actionPan() = 0;
430  virtual QAction *actionPanToSelected() = 0;
432  virtual QAction *actionZoomIn() = 0;
434  virtual QAction *actionZoomOut() = 0;
436  virtual QAction *actionSelect() = 0;
438  virtual QAction *actionSelectRectangle() = 0;
440  virtual QAction *actionSelectPolygon() = 0;
442  virtual QAction *actionSelectFreehand() = 0;
444  virtual QAction *actionSelectRadius() = 0;
446  virtual QAction *actionIdentify() = 0;
448  virtual QAction *actionFeatureAction() = 0;
450  virtual QAction *actionMeasure() = 0;
452  virtual QAction *actionMeasureArea() = 0;
454  virtual QAction *actionZoomFullExtent() = 0;
456  virtual QAction *actionZoomToLayer() = 0;
458  virtual QAction *actionZoomToSelected() = 0;
460  virtual QAction *actionZoomLast() = 0;
462  virtual QAction *actionZoomNext() = 0;
464  virtual QAction *actionZoomActualSize() = 0;
466  virtual QAction *actionMapTips() = 0;
468  virtual QAction *actionNewBookmark() = 0;
470  virtual QAction *actionShowBookmarks() = 0;
472  virtual QAction *actionDraw() = 0;
473 
474  // Layer menu actions
475  virtual QAction *actionNewVectorLayer() = 0;
476  virtual QAction *actionAddOgrLayer() = 0;
477  virtual QAction *actionAddRasterLayer() = 0;
478  virtual QAction *actionAddPgLayer() = 0;
479  virtual QAction *actionAddWmsLayer() = 0;
481  virtual QAction *actionAddAfsLayer() = 0;
483  virtual QAction *actionAddAmsLayer() = 0;
484  virtual QAction *actionCopyLayerStyle() = 0;
485  virtual QAction *actionPasteLayerStyle() = 0;
486  virtual QAction *actionOpenTable() = 0;
487  virtual QAction *actionOpenFieldCalculator() = 0;
488 
493  virtual QAction *actionOpenStatisticalSummary() = 0;
494 
495  virtual QAction *actionToggleEditing() = 0;
496  virtual QAction *actionSaveActiveLayerEdits() = 0;
497  virtual QAction *actionAllEdits() = 0;
498  virtual QAction *actionSaveEdits() = 0;
499  virtual QAction *actionSaveAllEdits() = 0;
500  virtual QAction *actionRollbackEdits() = 0;
501  virtual QAction *actionRollbackAllEdits() = 0;
502  virtual QAction *actionCancelEdits() = 0;
503  virtual QAction *actionCancelAllEdits() = 0;
504  virtual QAction *actionLayerSaveAs() = 0;
505  virtual QAction *actionDuplicateLayer() = 0;
506  virtual QAction *actionLayerProperties() = 0;
507  virtual QAction *actionAddToOverview() = 0;
508  virtual QAction *actionAddAllToOverview() = 0;
509  virtual QAction *actionRemoveAllFromOverview() = 0;
510  virtual QAction *actionHideAllLayers() = 0;
511  virtual QAction *actionShowAllLayers() = 0;
512  virtual QAction *actionHideSelectedLayers() = 0;
513 
518  virtual QAction *actionHideDeselectedLayers() = 0;
519  virtual QAction *actionShowSelectedLayers() = 0;
520 
521  // Plugin menu actions
522  virtual QAction *actionManagePlugins() = 0;
523  virtual QAction *actionPluginListSeparator() = 0;
524  virtual QAction *actionShowPythonDialog() = 0;
525 
526  // Settings menu actions
527  virtual QAction *actionToggleFullScreen() = 0;
528  virtual QAction *actionOptions() = 0;
529  virtual QAction *actionCustomProjection() = 0;
530 
531  // Help menu actions
532  virtual QAction *actionHelpContents() = 0;
533  virtual QAction *actionQgisHomePage() = 0;
534  virtual QAction *actionCheckQgisVersion() = 0;
535  virtual QAction *actionAbout() = 0;
536 
544  virtual QgsVectorLayerTools *vectorLayerTools() = 0;
545 
547  virtual int messageTimeout() = 0;
548 
555  virtual QgsStatusBar *statusBarIface() = 0;
556 
564  virtual void takeAppScreenShots( const QString &saveDirectory, const int categories = 0 ) {Q_UNUSED( saveDirectory ) Q_UNUSED( categories );}
565 
571  virtual QgsLayerTreeRegistryBridge::InsertionPoint layerTreeInsertionPoint() = 0;
572 
573  public slots: // TODO: do these functions really need to be slots?
574 
575  /* Exposed functions */
576 
580  virtual void zoomFull() = 0;
581 
585  virtual void zoomToPrevious() = 0;
586 
590  virtual void zoomToNext() = 0;
591 
595  virtual void zoomToActiveLayer() = 0;
596 
600  virtual QgsVectorLayer *addVectorLayer( const QString &vectorLayerPath, const QString &baseName, const QString &providerKey ) = 0;
601 
605  virtual QgsRasterLayer *addRasterLayer( const QString &rasterLayerPath, const QString &baseName = QString() ) = 0;
606 
610  virtual QgsRasterLayer *addRasterLayer( const QString &url, const QString &layerName, const QString &providerKey ) = 0;
611 
615  virtual QgsMeshLayer *addMeshLayer( const QString &url, const QString &baseName, const QString &providerKey ) = 0;
616 
618  virtual bool addProject( const QString &project ) = 0;
620  virtual void newProject( bool promptToSaveFlag = false ) = 0;
621 
629  virtual void reloadConnections( ) = 0;
630 
635  virtual bool setActiveLayer( QgsMapLayer * ) = 0;
636 
641  virtual void copySelectionToClipboard( QgsMapLayer * ) = 0;
642 
647  virtual void pasteFromClipboard( QgsMapLayer * ) = 0;
648 
650  virtual int addToolBarIcon( QAction *qAction ) = 0;
651 
660  virtual QAction *addToolBarWidget( QWidget *widget SIP_TRANSFER ) = 0;
661 
663  virtual void removeToolBarIcon( QAction *qAction ) = 0;
664 
673  virtual QAction *addRasterToolBarWidget( QWidget *widget SIP_TRANSFER ) = 0;
674 
676  virtual int addRasterToolBarIcon( QAction *qAction ) = 0;
677 
679  virtual void removeRasterToolBarIcon( QAction *qAction ) = 0;
680 
682  virtual int addVectorToolBarIcon( QAction *qAction ) = 0;
683 
692  virtual QAction *addVectorToolBarWidget( QWidget *widget SIP_TRANSFER ) = 0;
693 
695  virtual void removeVectorToolBarIcon( QAction *qAction ) = 0;
696 
698  virtual int addDatabaseToolBarIcon( QAction *qAction ) = 0;
699 
708  virtual QAction *addDatabaseToolBarWidget( QWidget *widget SIP_TRANSFER ) = 0;
709 
711  virtual void removeDatabaseToolBarIcon( QAction *qAction ) = 0;
712 
714  virtual int addWebToolBarIcon( QAction *qAction ) = 0;
715 
724  virtual QAction *addWebToolBarWidget( QWidget *widget SIP_TRANSFER ) = 0;
725 
727  virtual void removeWebToolBarIcon( QAction *qAction ) = 0;
728 
730  virtual QToolBar *addToolBar( const QString &name ) = 0 SIP_FACTORY;
731 
736  virtual void addToolBar( QToolBar *toolbar SIP_TRANSFER, Qt::ToolBarArea area = Qt::TopToolBarArea ) = 0;
737 
741  virtual void openMessageLog() = 0;
742 
744  virtual void addUserInputWidget( QWidget *widget ) = 0;
745 
750  virtual void showLayoutManager() = 0;
751 
758  virtual QgsLayoutDesignerInterface *openLayoutDesigner( QgsMasterLayoutInterface *layout ) = 0;
759 
765  virtual void showOptionsDialog( QWidget *parent = nullptr, const QString &currentPage = QString() ) = 0;
766 
771  virtual void buildStyleSheet( const QMap<QString, QVariant> &opts ) = 0;
772 
774  virtual void saveStyleSheetOptions( const QMap<QString, QVariant> &opts ) = 0;
775 
777  virtual void addPluginToMenu( const QString &name, QAction *action ) = 0;
778 
780  virtual void removePluginMenu( const QString &name, QAction *action ) = 0;
781 
783  virtual void insertAddLayerAction( QAction *action ) = 0;
784 
786  virtual void removeAddLayerAction( QAction *action ) = 0;
787 
789  virtual void addPluginToDatabaseMenu( const QString &name, QAction *action ) = 0;
790 
792  virtual void removePluginDatabaseMenu( const QString &name, QAction *action ) = 0;
793 
795  virtual void addPluginToRasterMenu( const QString &name, QAction *action ) = 0;
796 
798  virtual void removePluginRasterMenu( const QString &name, QAction *action ) = 0;
799 
801  virtual void addPluginToVectorMenu( const QString &name, QAction *action ) = 0;
802 
804  virtual void removePluginVectorMenu( const QString &name, QAction *action ) = 0;
805 
807  virtual void addPluginToWebMenu( const QString &name, QAction *action ) = 0;
808 
810  virtual void removePluginWebMenu( const QString &name, QAction *action ) = 0;
811 
817  virtual void addDockWidget( Qt::DockWidgetArea area, QDockWidget *dockwidget ) = 0;
818 
824  virtual void removeDockWidget( QDockWidget *dockwidget ) = 0;
825 
827  virtual void showLayerProperties( QgsMapLayer *l ) = 0;
828 
830  virtual QDialog *showAttributeTable( QgsVectorLayer *l, const QString &filterExpression = QString() ) = 0;
831 
836  virtual void addWindow( QAction *action ) = 0;
837 
842  virtual void removeWindow( QAction *action ) = 0;
843 
845  virtual bool registerMainWindowAction( QAction *action, const QString &defaultShortcut ) = 0;
846 
848  virtual bool unregisterMainWindowAction( QAction *action ) = 0;
849 
858  virtual void registerMapLayerConfigWidgetFactory( QgsMapLayerConfigWidgetFactory *factory ) = 0;
859 
866  virtual void unregisterMapLayerConfigWidgetFactory( QgsMapLayerConfigWidgetFactory *factory ) = 0;
867 
876  virtual void registerOptionsWidgetFactory( QgsOptionsWidgetFactory *factory ) = 0;
877 
884  virtual void unregisterOptionsWidgetFactory( QgsOptionsWidgetFactory *factory ) = 0;
885 
894  virtual void registerCustomDropHandler( QgsCustomDropHandler *handler ) = 0;
895 
902  virtual void unregisterCustomDropHandler( QgsCustomDropHandler *handler ) = 0;
903 
912  virtual void registerCustomLayoutDropHandler( QgsLayoutCustomDropHandler *handler ) = 0;
913 
920  virtual void unregisterCustomLayoutDropHandler( QgsLayoutCustomDropHandler *handler ) = 0;
921 
922  // TODO is this deprecated in favour of QgsContextHelp?
923 
933 #ifndef Q_MOC_RUN
934  Q_DECL_DEPRECATED
935 #endif
936  virtual void openURL( const QString &url, bool useQgisDocDirectory = true ) = 0 SIP_DEPRECATED;
937 
946  virtual bool openFeatureForm( QgsVectorLayer *l, QgsFeature &f, bool updateFeatureOnly = false, bool showModal = true ) = 0;
947 
956  virtual QgsAttributeDialog *getFeatureForm( QgsVectorLayer *l, QgsFeature &f ) = 0;
957 
970  virtual void preloadForm( const QString &uifile ) = 0;
971 
978  virtual void locatorSearch( const QString &searchText ) = 0;
979 
988  virtual void registerLocatorFilter( QgsLocatorFilter *filter SIP_TRANSFER ) = 0;
989 
1000  virtual void deregisterLocatorFilter( QgsLocatorFilter *filter ) = 0;
1001 
1009  virtual void invalidateLocatorResults() = 0;
1010 
1017  virtual bool askForDatumTransform( QgsCoordinateReferenceSystem sourceCrs, QgsCoordinateReferenceSystem destinationCrs ) = 0;
1018 
1024  virtual QgsBrowserGuiModel *browserModel() = 0;
1025 
1026  signals:
1027 
1032  void currentLayerChanged( QgsMapLayer *layer );
1033 
1039  void currentThemeChanged( const QString &theme );
1040 
1046  void layoutDesignerOpened( QgsLayoutDesignerInterface *designer );
1047 
1055  void layoutDesignerWillBeClosed( QgsLayoutDesignerInterface *designer );
1056 
1063  void layoutDesignerClosed();
1064 
1068  void initializationCompleted();
1069 
1076  void projectRead();
1077 
1086  void newProjectCreated();
1087 
1092  void layerSavedAs( QgsMapLayer *l, const QString &path );
1093 
1094 };
1096 
1097 #endif //#ifndef QGISINTERFACE_H
Methods in this class are used to handle basic operations on vector layers.
Layer tree group node serves as a container for layers and further groups.
Base class for all map layer types.
Definition: qgsmaplayer.h:79
The QgsLayerTreeView class extends QTreeView and provides some additional functionality when working ...
The QgsLayerTreeMapCanvasBridge class takes care of updates of layer set for QgsMapCanvas from a laye...
This class provides qgis with the ability to render raster datasets onto the mapcanvas.
Factory class for creating custom map layer property pages.
#define Q_NOWARN_DEPRECATED_PUSH
Definition: qgis.h:649
A bar for displaying non-blocking messages to the user.
Definition: qgsmessagebar.h:45
A common interface for layout designer dialogs and widgets.
A model for showing available data sources and other items in a structured tree.
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
Definition: qgsfeature.h:55
Abstract base class that may be implemented to handle new types of data to be dropped in QGIS layouts...
Map canvas is a class for displaying all GIS data types on a canvas.
Definition: qgsmapcanvas.h:75
Abstract base class that may be implemented to handle new types of data to be dropped in QGIS...
#define SIP_TRANSFER
Definition: qgis_sip.h:36
Abstract base class for filters which collect locator results.
#define SIP_FACTORY
Definition: qgis_sip.h:76
Base class for layouts, which can contain items such as maps, labels, scalebars, etc.
Definition: qgslayout.h:49
#define SIP_DEPRECATED
Definition: qgis_sip.h:106
QSize iconSize(bool dockableToolbar)
Returns the user-preferred size of a window&#39;s toolbar icons.
QgisInterface Abstract base class defining interfaces exposed by QgisApp and made available to plugin...
Definition: qgisinterface.h:80
#define Q_NOWARN_DEPRECATED_POP
Definition: qgis.h:650
This class represents a coordinate reference system (CRS).
A factory class for creating custom options pages.
Represents a mesh layer supporting display of data on structured or unstructured meshes.
Definition: qgsmeshlayer.h:90
QgsMapLayerType
Types of layers that can be added to a map.
Definition: qgsmaplayer.h:66
A structure to define the insertion point to the layer tree.
Interface for master layout type objects, such as print layouts and reports.
The QgsAdvancedDigitizingDockWidget class is a dockable widget used to handle the CAD tools on top of...
Represents a vector layer which manages a vector based data sets.
virtual void takeAppScreenShots(const QString &saveDirectory, const int categories=0)
Take screenshots for user documentation.
A proxy widget for QStatusBar.
Definition: qgsstatusbar.h:46