QGIS API Documentation  3.3.0-Master (fde813c)
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 class QAction;
22 class QMenu;
23 class QToolBar;
24 class QDockWidget;
25 class QMainWindow;
26 class QWidget;
27 
29 class QgsAttributeDialog;
31 class QgsLayoutCustomDropHandler;
32 class QgsFeature;
34 class QgsLayerTreeView;
35 class QgsLayout;
37 class QgsLayoutDesignerInterface;
38 class QgsMapCanvas;
39 class QgsMapLayer;
41 class QgsMessageBar;
43 class QgsRasterLayer;
44 class QgsSnappingUtils;
45 class QgsVectorLayer;
48 class QgsLocatorFilter;
49 class QgsStatusBar;
50 class QgsMeshLayer;
51 
52 #include <QObject>
53 #include <QFont>
54 #include <QPair>
55 #include <map>
56 
57 #include "qgis.h"
58 #include "qgsmaplayer.h"
59 #include "qgis_gui.h"
60 
61 
76 class GUI_EXPORT QgisInterface : public QObject
77 {
78  Q_OBJECT
79 
80  public:
81 
83  QgisInterface() = default;
84 
85  virtual QgsPluginManagerInterface *pluginManagerInterface() = 0;
86 
87  virtual QgsLayerTreeView *layerTreeView() = 0;
88 
101  virtual void addCustomActionForLayerType( QAction *action, QString menu,
102  QgsMapLayer::LayerType type, bool allLayers ) = 0;
103 
110  virtual void addCustomActionForLayer( QAction *action, QgsMapLayer *layer ) = 0;
111 
116  virtual bool removeCustomActionForLayerType( QAction *action ) = 0;
117 
122  virtual QList< QgsMapCanvas * > mapCanvases() = 0;
123 
129  virtual QgsMapCanvas *createNewMapCanvas( const QString &name ) = 0;
130 
136  virtual void closeMapCanvas( const QString &name ) = 0;
137 
142  virtual QSize iconSize( bool dockedToolbar = false ) const = 0;
143 
148  virtual QList<QgsMapLayer *> editableLayers( bool modified = false ) const = 0;
149 
151  virtual QgsMapLayer *activeLayer() = 0;
152 
154  virtual QgsMapCanvas *mapCanvas() = 0;
155 
161  virtual QgsLayerTreeMapCanvasBridge *layerTreeCanvasBridge() = 0;
162 
164  virtual QWidget *mainWindow() = 0;
165 
167  virtual QgsMessageBar *messageBar() = 0;
168 
173  virtual QList<QgsLayoutDesignerInterface *> openLayoutDesigners() = 0;
174 
175 
177  virtual QMap<QString, QVariant> defaultStyleSheetOptions() = 0;
178 
180  virtual QFont defaultStyleSheetFont() = 0;
181 
186  virtual QgsAdvancedDigitizingDockWidget *cadDockWidget() = 0;
187 
188  /*
189  * Accessors for inserting items into menus and toolbars.
190  * An item can be inserted before any existing action.
191  */
192 
196  virtual QMenu *projectMenu() = 0;
197 
201  virtual QMenu *editMenu() = 0;
202 
206  virtual QMenu *viewMenu() = 0;
207 
211  virtual QMenu *layerMenu() = 0;
212 
216  virtual QMenu *newLayerMenu() = 0;
217 
222  virtual QMenu *addLayerMenu() = 0;
223 
227  virtual QMenu *settingsMenu() = 0;
228 
232  virtual QMenu *pluginMenu() = 0;
233 
237  virtual QMenu *rasterMenu() = 0;
238 
242  virtual QMenu *databaseMenu() = 0;
243 
247  virtual QMenu *vectorMenu() = 0;
248 
252  virtual QMenu *webMenu() = 0;
253 
261  virtual QMenu *firstRightStandardMenu() = 0;
262 
266  virtual QMenu *windowMenu() = 0;
267 
271  virtual QMenu *helpMenu() = 0;
272 
273  // ToolBars
274 
278  virtual QToolBar *fileToolBar() = 0;
279 
283  virtual QToolBar *layerToolBar() = 0;
284 
289  virtual QToolBar *dataSourceManagerToolBar() = 0;
290 
294  virtual QToolBar *mapNavToolToolBar() = 0;
295 
299  virtual QToolBar *digitizeToolBar() = 0;
300 
304  virtual QToolBar *advancedDigitizeToolBar() = 0;
305 
310  virtual QToolBar *shapeDigitizeToolBar() = 0;
311 
315  virtual QToolBar *attributesToolBar() = 0;
316 
320  virtual QToolBar *pluginToolBar() = 0;
321 
325  virtual QToolBar *helpToolBar() = 0;
326 
330  virtual QToolBar *rasterToolBar() = 0;
331 
335  virtual QToolBar *vectorToolBar() = 0;
336 
340  virtual QToolBar *databaseToolBar() = 0;
341 
345  virtual QToolBar *webToolBar() = 0;
346 
347  // Project menu actions
349  virtual QAction *actionNewProject() = 0;
351  virtual QAction *actionOpenProject() = 0;
353  virtual QAction *actionSaveProject() = 0;
355  virtual QAction *actionSaveProjectAs() = 0;
357  virtual QAction *actionSaveMapAsImage() = 0;
359  virtual QAction *actionProjectProperties() = 0;
360 
362  virtual QAction *actionCreatePrintLayout() = 0;
363 
365  virtual QAction *actionShowLayoutManager() = 0;
367  virtual QAction *actionExit() = 0;
368 
369  // Edit menu actions
370 
372  virtual QAction *actionCutFeatures() = 0;
374  virtual QAction *actionCopyFeatures() = 0;
376  virtual QAction *actionPasteFeatures() = 0;
378  virtual QAction *actionAddFeature() = 0;
380  virtual QAction *actionDeleteSelected() = 0;
382  virtual QAction *actionMoveFeature() = 0;
384  virtual QAction *actionSplitFeatures() = 0;
386  virtual QAction *actionSplitParts() = 0;
388  virtual QAction *actionAddRing() = 0;
390  virtual QAction *actionAddPart() = 0;
392  virtual QAction *actionSimplifyFeature() = 0;
394  virtual QAction *actionDeleteRing() = 0;
396  virtual QAction *actionDeletePart() = 0;
398  virtual QAction *actionVertexTool() = 0;
399 
400  // View menu actions
402  virtual QAction *actionPan() = 0;
404  virtual QAction *actionPanToSelected() = 0;
406  virtual QAction *actionZoomIn() = 0;
408  virtual QAction *actionZoomOut() = 0;
410  virtual QAction *actionSelect() = 0;
412  virtual QAction *actionSelectRectangle() = 0;
414  virtual QAction *actionSelectPolygon() = 0;
416  virtual QAction *actionSelectFreehand() = 0;
418  virtual QAction *actionSelectRadius() = 0;
420  virtual QAction *actionIdentify() = 0;
422  virtual QAction *actionFeatureAction() = 0;
424  virtual QAction *actionMeasure() = 0;
426  virtual QAction *actionMeasureArea() = 0;
428  virtual QAction *actionZoomFullExtent() = 0;
430  virtual QAction *actionZoomToLayer() = 0;
432  virtual QAction *actionZoomToSelected() = 0;
434  virtual QAction *actionZoomLast() = 0;
436  virtual QAction *actionZoomNext() = 0;
438  virtual QAction *actionZoomActualSize() = 0;
440  virtual QAction *actionMapTips() = 0;
442  virtual QAction *actionNewBookmark() = 0;
444  virtual QAction *actionShowBookmarks() = 0;
446  virtual QAction *actionDraw() = 0;
447 
448  // Layer menu actions
449  virtual QAction *actionNewVectorLayer() = 0;
450  virtual QAction *actionAddOgrLayer() = 0;
451  virtual QAction *actionAddRasterLayer() = 0;
452  virtual QAction *actionAddPgLayer() = 0;
453  virtual QAction *actionAddWmsLayer() = 0;
455  virtual QAction *actionAddAfsLayer() = 0;
457  virtual QAction *actionAddAmsLayer() = 0;
458  virtual QAction *actionCopyLayerStyle() = 0;
459  virtual QAction *actionPasteLayerStyle() = 0;
460  virtual QAction *actionOpenTable() = 0;
461  virtual QAction *actionOpenFieldCalculator() = 0;
462 
467  virtual QAction *actionOpenStatisticalSummary() = 0;
468 
469  virtual QAction *actionToggleEditing() = 0;
470  virtual QAction *actionSaveActiveLayerEdits() = 0;
471  virtual QAction *actionAllEdits() = 0;
472  virtual QAction *actionSaveEdits() = 0;
473  virtual QAction *actionSaveAllEdits() = 0;
474  virtual QAction *actionRollbackEdits() = 0;
475  virtual QAction *actionRollbackAllEdits() = 0;
476  virtual QAction *actionCancelEdits() = 0;
477  virtual QAction *actionCancelAllEdits() = 0;
478  virtual QAction *actionLayerSaveAs() = 0;
479  virtual QAction *actionDuplicateLayer() = 0;
480  virtual QAction *actionLayerProperties() = 0;
481  virtual QAction *actionAddToOverview() = 0;
482  virtual QAction *actionAddAllToOverview() = 0;
483  virtual QAction *actionRemoveAllFromOverview() = 0;
484  virtual QAction *actionHideAllLayers() = 0;
485  virtual QAction *actionShowAllLayers() = 0;
486  virtual QAction *actionHideSelectedLayers() = 0;
487 
492  virtual QAction *actionHideDeselectedLayers() = 0;
493  virtual QAction *actionShowSelectedLayers() = 0;
494 
495  // Plugin menu actions
496  virtual QAction *actionManagePlugins() = 0;
497  virtual QAction *actionPluginListSeparator() = 0;
498  virtual QAction *actionShowPythonDialog() = 0;
499 
500  // Settings menu actions
501  virtual QAction *actionToggleFullScreen() = 0;
502  virtual QAction *actionOptions() = 0;
503  virtual QAction *actionCustomProjection() = 0;
504 
505  // Help menu actions
506  virtual QAction *actionHelpContents() = 0;
507  virtual QAction *actionQgisHomePage() = 0;
508  virtual QAction *actionCheckQgisVersion() = 0;
509  virtual QAction *actionAbout() = 0;
510 
518  virtual QgsVectorLayerTools *vectorLayerTools() = 0;
519 
521  virtual int messageTimeout() = 0;
522 
529  virtual QgsStatusBar *statusBarIface() = 0;
530 
531  public slots: // TODO: do these functions really need to be slots?
532 
533  /* Exposed functions */
534 
536  virtual void zoomFull() = 0;
537 
539  virtual void zoomToPrevious() = 0;
540 
542  virtual void zoomToNext() = 0;
543 
545  virtual void zoomToActiveLayer() = 0;
546 
548  virtual QgsVectorLayer *addVectorLayer( const QString &vectorLayerPath, const QString &baseName, const QString &providerKey ) = 0;
549 
551  virtual QgsRasterLayer *addRasterLayer( const QString &rasterLayerPath, const QString &baseName = QString() ) = 0;
552 
554  virtual QgsRasterLayer *addRasterLayer( const QString &url, const QString &layerName, const QString &providerKey ) = 0;
555 
557  virtual QgsMeshLayer *addMeshLayer( const QString &url, const QString &baseName, const QString &providerKey ) = 0;
558 
560  virtual bool addProject( const QString &project ) = 0;
562  virtual void newProject( bool promptToSaveFlag = false ) = 0;
563 
571  virtual void reloadConnections( ) = 0;
572 
577  virtual bool setActiveLayer( QgsMapLayer * ) = 0;
578 
583  virtual void copySelectionToClipboard( QgsMapLayer * ) = 0;
584 
589  virtual void pasteFromClipboard( QgsMapLayer * ) = 0;
590 
592  virtual int addToolBarIcon( QAction *qAction ) = 0;
593 
602  virtual QAction *addToolBarWidget( QWidget *widget SIP_TRANSFER ) = 0;
603 
605  virtual void removeToolBarIcon( QAction *qAction ) = 0;
606 
615  virtual QAction *addRasterToolBarWidget( QWidget *widget SIP_TRANSFER ) = 0;
616 
618  virtual int addRasterToolBarIcon( QAction *qAction ) = 0;
619 
621  virtual void removeRasterToolBarIcon( QAction *qAction ) = 0;
622 
624  virtual int addVectorToolBarIcon( QAction *qAction ) = 0;
625 
634  virtual QAction *addVectorToolBarWidget( QWidget *widget SIP_TRANSFER ) = 0;
635 
637  virtual void removeVectorToolBarIcon( QAction *qAction ) = 0;
638 
640  virtual int addDatabaseToolBarIcon( QAction *qAction ) = 0;
641 
650  virtual QAction *addDatabaseToolBarWidget( QWidget *widget SIP_TRANSFER ) = 0;
651 
653  virtual void removeDatabaseToolBarIcon( QAction *qAction ) = 0;
654 
656  virtual int addWebToolBarIcon( QAction *qAction ) = 0;
657 
666  virtual QAction *addWebToolBarWidget( QWidget *widget SIP_TRANSFER ) = 0;
667 
669  virtual void removeWebToolBarIcon( QAction *qAction ) = 0;
670 
672  virtual QToolBar *addToolBar( const QString &name ) = 0 SIP_FACTORY;
673 
678  virtual void addToolBar( QToolBar *toolbar SIP_TRANSFER, Qt::ToolBarArea area = Qt::TopToolBarArea ) = 0;
679 
681  virtual void openMessageLog() = 0;
682 
684  virtual void addUserInputWidget( QWidget *widget ) = 0;
685 
690  virtual void showLayoutManager() = 0;
691 
698  virtual QgsLayoutDesignerInterface *openLayoutDesigner( QgsMasterLayoutInterface *layout ) = 0;
699 
705  virtual void showOptionsDialog( QWidget *parent = nullptr, const QString &currentPage = QString() ) = 0;
706 
711  virtual void buildStyleSheet( const QMap<QString, QVariant> &opts ) = 0;
712 
714  virtual void saveStyleSheetOptions( const QMap<QString, QVariant> &opts ) = 0;
715 
717  virtual void addPluginToMenu( const QString &name, QAction *action ) = 0;
718 
720  virtual void removePluginMenu( const QString &name, QAction *action ) = 0;
721 
723  virtual void insertAddLayerAction( QAction *action ) = 0;
724 
726  virtual void removeAddLayerAction( QAction *action ) = 0;
727 
729  virtual void addPluginToDatabaseMenu( const QString &name, QAction *action ) = 0;
730 
732  virtual void removePluginDatabaseMenu( const QString &name, QAction *action ) = 0;
733 
735  virtual void addPluginToRasterMenu( const QString &name, QAction *action ) = 0;
736 
738  virtual void removePluginRasterMenu( const QString &name, QAction *action ) = 0;
739 
741  virtual void addPluginToVectorMenu( const QString &name, QAction *action ) = 0;
742 
744  virtual void removePluginVectorMenu( const QString &name, QAction *action ) = 0;
745 
747  virtual void addPluginToWebMenu( const QString &name, QAction *action ) = 0;
748 
750  virtual void removePluginWebMenu( const QString &name, QAction *action ) = 0;
751 
753  virtual void addDockWidget( Qt::DockWidgetArea area, QDockWidget *dockwidget ) = 0;
754 
756  virtual void removeDockWidget( QDockWidget *dockwidget ) = 0;
757 
759  virtual void showLayerProperties( QgsMapLayer *l ) = 0;
760 
762  virtual QDialog *showAttributeTable( QgsVectorLayer *l, const QString &filterExpression = QString() ) = 0;
763 
767  virtual void addWindow( QAction *action ) = 0;
768 
772  virtual void removeWindow( QAction *action ) = 0;
773 
775  virtual bool registerMainWindowAction( QAction *action, const QString &defaultShortcut ) = 0;
776 
778  virtual bool unregisterMainWindowAction( QAction *action ) = 0;
779 
787  virtual void registerMapLayerConfigWidgetFactory( QgsMapLayerConfigWidgetFactory *factory ) = 0;
788 
794  virtual void unregisterMapLayerConfigWidgetFactory( QgsMapLayerConfigWidgetFactory *factory ) = 0;
795 
803  virtual void registerOptionsWidgetFactory( QgsOptionsWidgetFactory *factory ) = 0;
804 
810  virtual void unregisterOptionsWidgetFactory( QgsOptionsWidgetFactory *factory ) = 0;
811 
819  virtual void registerCustomDropHandler( QgsCustomDropHandler *handler ) = 0;
820 
826  virtual void unregisterCustomDropHandler( QgsCustomDropHandler *handler ) = 0;
827 
835  virtual void registerCustomLayoutDropHandler( QgsLayoutCustomDropHandler *handler ) = 0;
836 
842  virtual void unregisterCustomLayoutDropHandler( QgsLayoutCustomDropHandler *handler ) = 0;
843 
844  // TODO is this deprecated in favour of QgsContextHelp?
845 
855 #ifndef Q_MOC_RUN
856  Q_DECL_DEPRECATED
857 #endif
858  virtual void openURL( const QString &url, bool useQgisDocDirectory = true ) = 0 SIP_DEPRECATED;
859 
867  virtual bool openFeatureForm( QgsVectorLayer *l, QgsFeature &f, bool updateFeatureOnly = false, bool showModal = true ) = 0;
868 
877  virtual QgsAttributeDialog *getFeatureForm( QgsVectorLayer *l, QgsFeature &f ) = 0;
878 
891  virtual void preloadForm( const QString &uifile ) = 0;
892 
901  virtual void registerLocatorFilter( QgsLocatorFilter *filter SIP_TRANSFER ) = 0;
902 
913  virtual void deregisterLocatorFilter( QgsLocatorFilter *filter ) = 0;
914 
922  virtual void invalidateLocatorResults() = 0;
923 
930  virtual bool askForDatumTransform( QgsCoordinateReferenceSystem sourceCrs, QgsCoordinateReferenceSystem destinationCrs ) = 0;
931 
932  signals:
933 
938  void currentLayerChanged( QgsMapLayer *layer );
939 
945  void currentThemeChanged( const QString &theme );
946 
952  void layoutDesignerOpened( QgsLayoutDesignerInterface *designer );
953 
961  void layoutDesignerWillBeClosed( QgsLayoutDesignerInterface *designer );
962 
969  void layoutDesignerClosed();
970 
974  void initializationCompleted();
975 
982  void projectRead();
983 
992  void newProjectCreated();
993 
998  void layerSavedAs( QgsMapLayer *l, const QString &path );
999 
1000 };
1002 
1003 #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:63
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:569
A bar for displaying non-blocking messages to the user.
Definition: qgsmessagebar.h:45
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
Definition: qgsfeature.h:54
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...
LayerType
Types of layers that can be added to a map.
Definition: qgsmaplayer.h:105
#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
QgisInterface Abstract base class defining interfaces exposed by QgisApp and made available to plugin...
Definition: qgisinterface.h:76
#define Q_NOWARN_DEPRECATED_POP
Definition: qgis.h:570
This class represents a coordinate reference system (CRS).
A factory class for creating custom options pages.
This class has all the configuration of snapping and can return answers to snapping queries...
Represents a mesh layer supporting display of data on structured or unstructured meshes.
Definition: qgsmeshlayer.h:88
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.
A proxy widget for QStatusBar.
Definition: qgsstatusbar.h:45