QGIS API Documentation  3.8.0-Zanzibar (11aff65)
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"
28 
29 class QAction;
30 class QDialog;
31 class QFont;
32 class QMenu;
33 class QToolBar;
34 class QDockWidget;
35 class QMainWindow;
36 class QWidget;
37 
39 class QgsAttributeDialog;
42 class QgsFeature;
44 class QgsLayerTreeView;
45 class QgsLayout;
48 class QgsMapCanvas;
49 class QgsMapLayer;
50 enum class QgsMapLayerType;
52 class QgsMessageBar;
54 class QgsRasterLayer;
55 class QgsVectorLayer;
58 class QgsLocatorFilter;
59 class QgsStatusBar;
60 class QgsMeshLayer;
61 class QgsBrowserModel;
62 
63 
78 class GUI_EXPORT QgisInterface : public QObject
79 {
80  Q_OBJECT
81 
82  public:
83 
85  QgisInterface() = default;
86 
87  virtual QgsPluginManagerInterface *pluginManagerInterface() = 0;
88 
89  virtual QgsLayerTreeView *layerTreeView() = 0;
90 
103  virtual void addCustomActionForLayerType( QAction *action, QString menu,
104  QgsMapLayerType type, bool allLayers ) = 0;
105 
112  virtual void addCustomActionForLayer( QAction *action, QgsMapLayer *layer ) = 0;
113 
118  virtual bool removeCustomActionForLayerType( QAction *action ) = 0;
119 
124  virtual QList< QgsMapCanvas * > mapCanvases() = 0;
125 
131  virtual QgsMapCanvas *createNewMapCanvas( const QString &name ) = 0;
132 
138  virtual void closeMapCanvas( const QString &name ) = 0;
139 
144  virtual QSize iconSize( bool dockedToolbar = false ) const = 0;
145 
151  virtual QList<QgsMapLayer *> editableLayers( bool modified = false ) const = 0;
152 
154  virtual QgsMapLayer *activeLayer() = 0;
155 
157  virtual QgsMapCanvas *mapCanvas() = 0;
158 
164  virtual QgsLayerTreeMapCanvasBridge *layerTreeCanvasBridge() = 0;
165 
167  virtual QWidget *mainWindow() = 0;
168 
170  virtual QgsMessageBar *messageBar() = 0;
171 
176  virtual QList<QgsLayoutDesignerInterface *> openLayoutDesigners() = 0;
177 
178 
180  virtual QMap<QString, QVariant> defaultStyleSheetOptions() = 0;
181 
183  virtual QFont defaultStyleSheetFont() = 0;
184 
189  virtual QgsAdvancedDigitizingDockWidget *cadDockWidget() = 0;
190 
191  /*
192  * Accessors for inserting items into menus and toolbars.
193  * An item can be inserted before any existing action.
194  */
195 
199  virtual QMenu *projectMenu() = 0;
200 
204  virtual QMenu *editMenu() = 0;
205 
209  virtual QMenu *viewMenu() = 0;
210 
214  virtual QMenu *layerMenu() = 0;
215 
219  virtual QMenu *newLayerMenu() = 0;
220 
225  virtual QMenu *addLayerMenu() = 0;
226 
230  virtual QMenu *settingsMenu() = 0;
231 
235  virtual QMenu *pluginMenu() = 0;
236 
240  virtual QMenu *rasterMenu() = 0;
241 
245  virtual QMenu *databaseMenu() = 0;
246 
250  virtual QMenu *vectorMenu() = 0;
251 
255  virtual QMenu *webMenu() = 0;
256 
264  virtual QMenu *firstRightStandardMenu() = 0;
265 
269  virtual QMenu *windowMenu() = 0;
270 
274  virtual QMenu *helpMenu() = 0;
275 
276  // ToolBars
277 
281  virtual QToolBar *fileToolBar() = 0;
282 
286  virtual QToolBar *layerToolBar() = 0;
287 
292  virtual QToolBar *dataSourceManagerToolBar() = 0;
293 
297  virtual QToolBar *mapNavToolToolBar() = 0;
298 
302  virtual QToolBar *digitizeToolBar() = 0;
303 
307  virtual QToolBar *advancedDigitizeToolBar() = 0;
308 
313  virtual QToolBar *shapeDigitizeToolBar() = 0;
314 
318  virtual QToolBar *attributesToolBar() = 0;
319 
323  virtual QToolBar *pluginToolBar() = 0;
324 
328  virtual QToolBar *helpToolBar() = 0;
329 
333  virtual QToolBar *rasterToolBar() = 0;
334 
338  virtual QToolBar *vectorToolBar() = 0;
339 
343  virtual QToolBar *databaseToolBar() = 0;
344 
348  virtual QToolBar *webToolBar() = 0;
349 
350  // Project menu actions
352  virtual QAction *actionNewProject() = 0;
354  virtual QAction *actionOpenProject() = 0;
356  virtual QAction *actionSaveProject() = 0;
358  virtual QAction *actionSaveProjectAs() = 0;
360  virtual QAction *actionSaveMapAsImage() = 0;
362  virtual QAction *actionProjectProperties() = 0;
363 
365  virtual QAction *actionCreatePrintLayout() = 0;
366 
368  virtual QAction *actionShowLayoutManager() = 0;
370  virtual QAction *actionExit() = 0;
371 
372  // Edit menu actions
373 
375  virtual QAction *actionCutFeatures() = 0;
377  virtual QAction *actionCopyFeatures() = 0;
379  virtual QAction *actionPasteFeatures() = 0;
381  virtual QAction *actionAddFeature() = 0;
383  virtual QAction *actionDeleteSelected() = 0;
385  virtual QAction *actionMoveFeature() = 0;
387  virtual QAction *actionSplitFeatures() = 0;
389  virtual QAction *actionSplitParts() = 0;
391  virtual QAction *actionAddRing() = 0;
393  virtual QAction *actionAddPart() = 0;
395  virtual QAction *actionSimplifyFeature() = 0;
397  virtual QAction *actionDeleteRing() = 0;
399  virtual QAction *actionDeletePart() = 0;
400 
405  virtual QAction *actionVertexTool() = 0;
406 
412  virtual QAction *actionVertexToolActiveLayer() = 0;
413 
414  // View menu actions
416  virtual QAction *actionPan() = 0;
418  virtual QAction *actionPanToSelected() = 0;
420  virtual QAction *actionZoomIn() = 0;
422  virtual QAction *actionZoomOut() = 0;
424  virtual QAction *actionSelect() = 0;
426  virtual QAction *actionSelectRectangle() = 0;
428  virtual QAction *actionSelectPolygon() = 0;
430  virtual QAction *actionSelectFreehand() = 0;
432  virtual QAction *actionSelectRadius() = 0;
434  virtual QAction *actionIdentify() = 0;
436  virtual QAction *actionFeatureAction() = 0;
438  virtual QAction *actionMeasure() = 0;
440  virtual QAction *actionMeasureArea() = 0;
442  virtual QAction *actionZoomFullExtent() = 0;
444  virtual QAction *actionZoomToLayer() = 0;
446  virtual QAction *actionZoomToSelected() = 0;
448  virtual QAction *actionZoomLast() = 0;
450  virtual QAction *actionZoomNext() = 0;
452  virtual QAction *actionZoomActualSize() = 0;
454  virtual QAction *actionMapTips() = 0;
456  virtual QAction *actionNewBookmark() = 0;
458  virtual QAction *actionShowBookmarks() = 0;
460  virtual QAction *actionDraw() = 0;
461 
462  // Layer menu actions
463  virtual QAction *actionNewVectorLayer() = 0;
464  virtual QAction *actionAddOgrLayer() = 0;
465  virtual QAction *actionAddRasterLayer() = 0;
466  virtual QAction *actionAddPgLayer() = 0;
467  virtual QAction *actionAddWmsLayer() = 0;
469  virtual QAction *actionAddAfsLayer() = 0;
471  virtual QAction *actionAddAmsLayer() = 0;
472  virtual QAction *actionCopyLayerStyle() = 0;
473  virtual QAction *actionPasteLayerStyle() = 0;
474  virtual QAction *actionOpenTable() = 0;
475  virtual QAction *actionOpenFieldCalculator() = 0;
476 
481  virtual QAction *actionOpenStatisticalSummary() = 0;
482 
483  virtual QAction *actionToggleEditing() = 0;
484  virtual QAction *actionSaveActiveLayerEdits() = 0;
485  virtual QAction *actionAllEdits() = 0;
486  virtual QAction *actionSaveEdits() = 0;
487  virtual QAction *actionSaveAllEdits() = 0;
488  virtual QAction *actionRollbackEdits() = 0;
489  virtual QAction *actionRollbackAllEdits() = 0;
490  virtual QAction *actionCancelEdits() = 0;
491  virtual QAction *actionCancelAllEdits() = 0;
492  virtual QAction *actionLayerSaveAs() = 0;
493  virtual QAction *actionDuplicateLayer() = 0;
494  virtual QAction *actionLayerProperties() = 0;
495  virtual QAction *actionAddToOverview() = 0;
496  virtual QAction *actionAddAllToOverview() = 0;
497  virtual QAction *actionRemoveAllFromOverview() = 0;
498  virtual QAction *actionHideAllLayers() = 0;
499  virtual QAction *actionShowAllLayers() = 0;
500  virtual QAction *actionHideSelectedLayers() = 0;
501 
506  virtual QAction *actionHideDeselectedLayers() = 0;
507  virtual QAction *actionShowSelectedLayers() = 0;
508 
509  // Plugin menu actions
510  virtual QAction *actionManagePlugins() = 0;
511  virtual QAction *actionPluginListSeparator() = 0;
512  virtual QAction *actionShowPythonDialog() = 0;
513 
514  // Settings menu actions
515  virtual QAction *actionToggleFullScreen() = 0;
516  virtual QAction *actionOptions() = 0;
517  virtual QAction *actionCustomProjection() = 0;
518 
519  // Help menu actions
520  virtual QAction *actionHelpContents() = 0;
521  virtual QAction *actionQgisHomePage() = 0;
522  virtual QAction *actionCheckQgisVersion() = 0;
523  virtual QAction *actionAbout() = 0;
524 
532  virtual QgsVectorLayerTools *vectorLayerTools() = 0;
533 
535  virtual int messageTimeout() = 0;
536 
543  virtual QgsStatusBar *statusBarIface() = 0;
544 
552  virtual void takeAppScreenShots( const QString &saveDirectory, const int categories = 0 ) {Q_UNUSED( saveDirectory ) Q_UNUSED( categories );}
553 
554  public slots: // TODO: do these functions really need to be slots?
555 
556  /* Exposed functions */
557 
561  virtual void zoomFull() = 0;
562 
566  virtual void zoomToPrevious() = 0;
567 
571  virtual void zoomToNext() = 0;
572 
576  virtual void zoomToActiveLayer() = 0;
577 
581  virtual QgsVectorLayer *addVectorLayer( const QString &vectorLayerPath, const QString &baseName, const QString &providerKey ) = 0;
582 
586  virtual QgsRasterLayer *addRasterLayer( const QString &rasterLayerPath, const QString &baseName = QString() ) = 0;
587 
591  virtual QgsRasterLayer *addRasterLayer( const QString &url, const QString &layerName, const QString &providerKey ) = 0;
592 
596  virtual QgsMeshLayer *addMeshLayer( const QString &url, const QString &baseName, const QString &providerKey ) = 0;
597 
599  virtual bool addProject( const QString &project ) = 0;
601  virtual void newProject( bool promptToSaveFlag = false ) = 0;
602 
610  virtual void reloadConnections( ) = 0;
611 
616  virtual bool setActiveLayer( QgsMapLayer * ) = 0;
617 
622  virtual void copySelectionToClipboard( QgsMapLayer * ) = 0;
623 
628  virtual void pasteFromClipboard( QgsMapLayer * ) = 0;
629 
631  virtual int addToolBarIcon( QAction *qAction ) = 0;
632 
641  virtual QAction *addToolBarWidget( QWidget *widget SIP_TRANSFER ) = 0;
642 
644  virtual void removeToolBarIcon( QAction *qAction ) = 0;
645 
654  virtual QAction *addRasterToolBarWidget( QWidget *widget SIP_TRANSFER ) = 0;
655 
657  virtual int addRasterToolBarIcon( QAction *qAction ) = 0;
658 
660  virtual void removeRasterToolBarIcon( QAction *qAction ) = 0;
661 
663  virtual int addVectorToolBarIcon( QAction *qAction ) = 0;
664 
673  virtual QAction *addVectorToolBarWidget( QWidget *widget SIP_TRANSFER ) = 0;
674 
676  virtual void removeVectorToolBarIcon( QAction *qAction ) = 0;
677 
679  virtual int addDatabaseToolBarIcon( QAction *qAction ) = 0;
680 
689  virtual QAction *addDatabaseToolBarWidget( QWidget *widget SIP_TRANSFER ) = 0;
690 
692  virtual void removeDatabaseToolBarIcon( QAction *qAction ) = 0;
693 
695  virtual int addWebToolBarIcon( QAction *qAction ) = 0;
696 
705  virtual QAction *addWebToolBarWidget( QWidget *widget SIP_TRANSFER ) = 0;
706 
708  virtual void removeWebToolBarIcon( QAction *qAction ) = 0;
709 
711  virtual QToolBar *addToolBar( const QString &name ) = 0 SIP_FACTORY;
712 
717  virtual void addToolBar( QToolBar *toolbar SIP_TRANSFER, Qt::ToolBarArea area = Qt::TopToolBarArea ) = 0;
718 
722  virtual void openMessageLog() = 0;
723 
725  virtual void addUserInputWidget( QWidget *widget ) = 0;
726 
731  virtual void showLayoutManager() = 0;
732 
739  virtual QgsLayoutDesignerInterface *openLayoutDesigner( QgsMasterLayoutInterface *layout ) = 0;
740 
746  virtual void showOptionsDialog( QWidget *parent = nullptr, const QString &currentPage = QString() ) = 0;
747 
752  virtual void buildStyleSheet( const QMap<QString, QVariant> &opts ) = 0;
753 
755  virtual void saveStyleSheetOptions( const QMap<QString, QVariant> &opts ) = 0;
756 
758  virtual void addPluginToMenu( const QString &name, QAction *action ) = 0;
759 
761  virtual void removePluginMenu( const QString &name, QAction *action ) = 0;
762 
764  virtual void insertAddLayerAction( QAction *action ) = 0;
765 
767  virtual void removeAddLayerAction( QAction *action ) = 0;
768 
770  virtual void addPluginToDatabaseMenu( const QString &name, QAction *action ) = 0;
771 
773  virtual void removePluginDatabaseMenu( const QString &name, QAction *action ) = 0;
774 
776  virtual void addPluginToRasterMenu( const QString &name, QAction *action ) = 0;
777 
779  virtual void removePluginRasterMenu( const QString &name, QAction *action ) = 0;
780 
782  virtual void addPluginToVectorMenu( const QString &name, QAction *action ) = 0;
783 
785  virtual void removePluginVectorMenu( const QString &name, QAction *action ) = 0;
786 
788  virtual void addPluginToWebMenu( const QString &name, QAction *action ) = 0;
789 
791  virtual void removePluginWebMenu( const QString &name, QAction *action ) = 0;
792 
798  virtual void addDockWidget( Qt::DockWidgetArea area, QDockWidget *dockwidget ) = 0;
799 
805  virtual void removeDockWidget( QDockWidget *dockwidget ) = 0;
806 
808  virtual void showLayerProperties( QgsMapLayer *l ) = 0;
809 
811  virtual QDialog *showAttributeTable( QgsVectorLayer *l, const QString &filterExpression = QString() ) = 0;
812 
817  virtual void addWindow( QAction *action ) = 0;
818 
823  virtual void removeWindow( QAction *action ) = 0;
824 
826  virtual bool registerMainWindowAction( QAction *action, const QString &defaultShortcut ) = 0;
827 
829  virtual bool unregisterMainWindowAction( QAction *action ) = 0;
830 
839  virtual void registerMapLayerConfigWidgetFactory( QgsMapLayerConfigWidgetFactory *factory ) = 0;
840 
847  virtual void unregisterMapLayerConfigWidgetFactory( QgsMapLayerConfigWidgetFactory *factory ) = 0;
848 
857  virtual void registerOptionsWidgetFactory( QgsOptionsWidgetFactory *factory ) = 0;
858 
865  virtual void unregisterOptionsWidgetFactory( QgsOptionsWidgetFactory *factory ) = 0;
866 
875  virtual void registerCustomDropHandler( QgsCustomDropHandler *handler ) = 0;
876 
883  virtual void unregisterCustomDropHandler( QgsCustomDropHandler *handler ) = 0;
884 
893  virtual void registerCustomLayoutDropHandler( QgsLayoutCustomDropHandler *handler ) = 0;
894 
901  virtual void unregisterCustomLayoutDropHandler( QgsLayoutCustomDropHandler *handler ) = 0;
902 
903  // TODO is this deprecated in favour of QgsContextHelp?
904 
914 #ifndef Q_MOC_RUN
915  Q_DECL_DEPRECATED
916 #endif
917  virtual void openURL( const QString &url, bool useQgisDocDirectory = true ) = 0 SIP_DEPRECATED;
918 
927  virtual bool openFeatureForm( QgsVectorLayer *l, QgsFeature &f, bool updateFeatureOnly = false, bool showModal = true ) = 0;
928 
937  virtual QgsAttributeDialog *getFeatureForm( QgsVectorLayer *l, QgsFeature &f ) = 0;
938 
951  virtual void preloadForm( const QString &uifile ) = 0;
952 
961  virtual void registerLocatorFilter( QgsLocatorFilter *filter SIP_TRANSFER ) = 0;
962 
973  virtual void deregisterLocatorFilter( QgsLocatorFilter *filter ) = 0;
974 
982  virtual void invalidateLocatorResults() = 0;
983 
990  virtual bool askForDatumTransform( QgsCoordinateReferenceSystem sourceCrs, QgsCoordinateReferenceSystem destinationCrs ) = 0;
991 
997  virtual QgsBrowserModel *browserModel() = 0;
998 
999  signals:
1000 
1005  void currentLayerChanged( QgsMapLayer *layer );
1006 
1012  void currentThemeChanged( const QString &theme );
1013 
1019  void layoutDesignerOpened( QgsLayoutDesignerInterface *designer );
1020 
1028  void layoutDesignerWillBeClosed( QgsLayoutDesignerInterface *designer );
1029 
1036  void layoutDesignerClosed();
1037 
1041  void initializationCompleted();
1042 
1049  void projectRead();
1050 
1059  void newProjectCreated();
1060 
1065  void layerSavedAs( QgsMapLayer *l, const QString &path );
1066 
1067 };
1069 
1070 #endif //#ifndef QGISINTERFACE_H
Methods in this class are used to handle basic operations on vector layers.
Base class for all map layer types.
Definition: qgsmaplayer.h:78
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:624
A bar for displaying non-blocking messages to the user.
Definition: qgsmessagebar.h:45
A common interface for layout designer dialogs and widgets.
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:73
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:69
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:99
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:78
#define Q_NOWARN_DEPRECATED_POP
Definition: qgis.h:625
This class represents a coordinate reference system (CRS).
A factory class for creating custom options pages.
A model for showing available data sources and other items in a structured tree.
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:65
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