QGIS API Documentation  3.2.0-Bonn (bc43194)
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 
51 #include <QObject>
52 #include <QFont>
53 #include <QPair>
54 #include <map>
55 
56 #include "qgis.h"
57 #include "qgsmaplayer.h"
58 #include "qgis_gui.h"
59 
60 
75 class GUI_EXPORT QgisInterface : public QObject
76 {
77  Q_OBJECT
78 
79  public:
80 
82  QgisInterface() = default;
83 
84  virtual QgsPluginManagerInterface *pluginManagerInterface() = 0;
85 
86  virtual QgsLayerTreeView *layerTreeView() = 0;
87 
100  virtual void addCustomActionForLayerType( QAction *action, QString menu,
101  QgsMapLayer::LayerType type, bool allLayers ) = 0;
102 
109  virtual void addCustomActionForLayer( QAction *action, QgsMapLayer *layer ) = 0;
110 
115  virtual bool removeCustomActionForLayerType( QAction *action ) = 0;
116 
121  virtual QList< QgsMapCanvas * > mapCanvases() = 0;
122 
128  virtual QgsMapCanvas *createNewMapCanvas( const QString &name ) = 0;
129 
135  virtual void closeMapCanvas( const QString &name ) = 0;
136 
141  virtual QSize iconSize( bool dockedToolbar = false ) const = 0;
142 
147  virtual QList<QgsMapLayer *> editableLayers( bool modified = false ) const = 0;
148 
150  virtual QgsMapLayer *activeLayer() = 0;
151 
153  virtual QgsMapCanvas *mapCanvas() = 0;
154 
160  virtual QgsLayerTreeMapCanvasBridge *layerTreeCanvasBridge() = 0;
161 
163  virtual QWidget *mainWindow() = 0;
164 
166  virtual QgsMessageBar *messageBar() = 0;
167 
172  virtual QList<QgsLayoutDesignerInterface *> openLayoutDesigners() = 0;
173 
174 
176  virtual QMap<QString, QVariant> defaultStyleSheetOptions() = 0;
177 
179  virtual QFont defaultStyleSheetFont() = 0;
180 
185  virtual QgsAdvancedDigitizingDockWidget *cadDockWidget() = 0;
186 
187  /*
188  * Accessors for inserting items into menus and toolbars.
189  * An item can be inserted before any existing action.
190  */
191 
195  virtual QMenu *projectMenu() = 0;
196 
200  virtual QMenu *editMenu() = 0;
201 
205  virtual QMenu *viewMenu() = 0;
206 
210  virtual QMenu *layerMenu() = 0;
211 
215  virtual QMenu *newLayerMenu() = 0;
216 
221  virtual QMenu *addLayerMenu() = 0;
222 
226  virtual QMenu *settingsMenu() = 0;
227 
231  virtual QMenu *pluginMenu() = 0;
232 
236  virtual QMenu *rasterMenu() = 0;
237 
241  virtual QMenu *databaseMenu() = 0;
242 
246  virtual QMenu *vectorMenu() = 0;
247 
251  virtual QMenu *webMenu() = 0;
252 
260  virtual QMenu *firstRightStandardMenu() = 0;
261 
265  virtual QMenu *windowMenu() = 0;
266 
270  virtual QMenu *helpMenu() = 0;
271 
272  // ToolBars
273 
277  virtual QToolBar *fileToolBar() = 0;
278 
282  virtual QToolBar *layerToolBar() = 0;
283 
287  virtual QToolBar *mapNavToolToolBar() = 0;
288 
292  virtual QToolBar *digitizeToolBar() = 0;
293 
297  virtual QToolBar *advancedDigitizeToolBar() = 0;
298 
303  virtual QToolBar *shapeDigitizeToolBar() = 0;
304 
308  virtual QToolBar *attributesToolBar() = 0;
309 
313  virtual QToolBar *pluginToolBar() = 0;
314 
318  virtual QToolBar *helpToolBar() = 0;
319 
323  virtual QToolBar *rasterToolBar() = 0;
324 
328  virtual QToolBar *vectorToolBar() = 0;
329 
333  virtual QToolBar *databaseToolBar() = 0;
334 
338  virtual QToolBar *webToolBar() = 0;
339 
340  // Project menu actions
342  virtual QAction *actionNewProject() = 0;
344  virtual QAction *actionOpenProject() = 0;
346  virtual QAction *actionSaveProject() = 0;
348  virtual QAction *actionSaveProjectAs() = 0;
350  virtual QAction *actionSaveMapAsImage() = 0;
352  virtual QAction *actionProjectProperties() = 0;
353 
355  virtual QAction *actionCreatePrintLayout() = 0;
356 
358  virtual QAction *actionShowLayoutManager() = 0;
360  virtual QAction *actionExit() = 0;
361 
362  // Edit menu actions
363 
365  virtual QAction *actionCutFeatures() = 0;
367  virtual QAction *actionCopyFeatures() = 0;
369  virtual QAction *actionPasteFeatures() = 0;
371  virtual QAction *actionAddFeature() = 0;
373  virtual QAction *actionDeleteSelected() = 0;
375  virtual QAction *actionMoveFeature() = 0;
377  virtual QAction *actionSplitFeatures() = 0;
379  virtual QAction *actionSplitParts() = 0;
381  virtual QAction *actionAddRing() = 0;
383  virtual QAction *actionAddPart() = 0;
385  virtual QAction *actionSimplifyFeature() = 0;
387  virtual QAction *actionDeleteRing() = 0;
389  virtual QAction *actionDeletePart() = 0;
391  virtual QAction *actionVertexTool() = 0;
392 
393  // View menu actions
395  virtual QAction *actionPan() = 0;
397  virtual QAction *actionPanToSelected() = 0;
399  virtual QAction *actionZoomIn() = 0;
401  virtual QAction *actionZoomOut() = 0;
403  virtual QAction *actionSelect() = 0;
405  virtual QAction *actionSelectRectangle() = 0;
407  virtual QAction *actionSelectPolygon() = 0;
409  virtual QAction *actionSelectFreehand() = 0;
411  virtual QAction *actionSelectRadius() = 0;
413  virtual QAction *actionIdentify() = 0;
415  virtual QAction *actionFeatureAction() = 0;
417  virtual QAction *actionMeasure() = 0;
419  virtual QAction *actionMeasureArea() = 0;
421  virtual QAction *actionZoomFullExtent() = 0;
423  virtual QAction *actionZoomToLayer() = 0;
425  virtual QAction *actionZoomToSelected() = 0;
427  virtual QAction *actionZoomLast() = 0;
429  virtual QAction *actionZoomNext() = 0;
431  virtual QAction *actionZoomActualSize() = 0;
433  virtual QAction *actionMapTips() = 0;
435  virtual QAction *actionNewBookmark() = 0;
437  virtual QAction *actionShowBookmarks() = 0;
439  virtual QAction *actionDraw() = 0;
440 
441  // Layer menu actions
442  virtual QAction *actionNewVectorLayer() = 0;
443  virtual QAction *actionAddOgrLayer() = 0;
444  virtual QAction *actionAddRasterLayer() = 0;
445  virtual QAction *actionAddPgLayer() = 0;
446  virtual QAction *actionAddWmsLayer() = 0;
448  virtual QAction *actionAddAfsLayer() = 0;
450  virtual QAction *actionAddAmsLayer() = 0;
451  virtual QAction *actionCopyLayerStyle() = 0;
452  virtual QAction *actionPasteLayerStyle() = 0;
453  virtual QAction *actionOpenTable() = 0;
454  virtual QAction *actionOpenFieldCalculator() = 0;
455 
460  virtual QAction *actionOpenStatisticalSummary() = 0;
461 
462  virtual QAction *actionToggleEditing() = 0;
463  virtual QAction *actionSaveActiveLayerEdits() = 0;
464  virtual QAction *actionAllEdits() = 0;
465  virtual QAction *actionSaveEdits() = 0;
466  virtual QAction *actionSaveAllEdits() = 0;
467  virtual QAction *actionRollbackEdits() = 0;
468  virtual QAction *actionRollbackAllEdits() = 0;
469  virtual QAction *actionCancelEdits() = 0;
470  virtual QAction *actionCancelAllEdits() = 0;
471  virtual QAction *actionLayerSaveAs() = 0;
472  virtual QAction *actionDuplicateLayer() = 0;
473  virtual QAction *actionLayerProperties() = 0;
474  virtual QAction *actionAddToOverview() = 0;
475  virtual QAction *actionAddAllToOverview() = 0;
476  virtual QAction *actionRemoveAllFromOverview() = 0;
477  virtual QAction *actionHideAllLayers() = 0;
478  virtual QAction *actionShowAllLayers() = 0;
479  virtual QAction *actionHideSelectedLayers() = 0;
480 
485  virtual QAction *actionHideDeselectedLayers() = 0;
486  virtual QAction *actionShowSelectedLayers() = 0;
487 
488  // Plugin menu actions
489  virtual QAction *actionManagePlugins() = 0;
490  virtual QAction *actionPluginListSeparator() = 0;
491  virtual QAction *actionShowPythonDialog() = 0;
492 
493  // Settings menu actions
494  virtual QAction *actionToggleFullScreen() = 0;
495  virtual QAction *actionOptions() = 0;
496  virtual QAction *actionCustomProjection() = 0;
497 
498  // Help menu actions
499  virtual QAction *actionHelpContents() = 0;
500  virtual QAction *actionQgisHomePage() = 0;
501  virtual QAction *actionCheckQgisVersion() = 0;
502  virtual QAction *actionAbout() = 0;
503 
511  virtual QgsVectorLayerTools *vectorLayerTools() = 0;
512 
514  virtual int messageTimeout() = 0;
515 
522  virtual QgsStatusBar *statusBarIface() = 0;
523 
524  public slots: // TODO: do these functions really need to be slots?
525 
526  /* Exposed functions */
527 
529  virtual void zoomFull() = 0;
530 
532  virtual void zoomToPrevious() = 0;
533 
535  virtual void zoomToNext() = 0;
536 
538  virtual void zoomToActiveLayer() = 0;
539 
541  virtual QgsVectorLayer *addVectorLayer( const QString &vectorLayerPath, const QString &baseName, const QString &providerKey ) = 0;
542 
544  virtual QgsRasterLayer *addRasterLayer( const QString &rasterLayerPath, const QString &baseName = QString() ) = 0;
545 
547  virtual QgsRasterLayer *addRasterLayer( const QString &url, const QString &layerName, const QString &providerKey ) = 0;
548 
550  virtual bool addProject( const QString &project ) = 0;
552  virtual void newProject( bool promptToSaveFlag = false ) = 0;
553 
561  virtual void reloadConnections( ) = 0;
562 
567  virtual bool setActiveLayer( QgsMapLayer * ) = 0;
568 
573  virtual void copySelectionToClipboard( QgsMapLayer * ) = 0;
574 
579  virtual void pasteFromClipboard( QgsMapLayer * ) = 0;
580 
582  virtual int addToolBarIcon( QAction *qAction ) = 0;
583 
592  virtual QAction *addToolBarWidget( QWidget *widget SIP_TRANSFER ) = 0;
593 
595  virtual void removeToolBarIcon( QAction *qAction ) = 0;
596 
605  virtual QAction *addRasterToolBarWidget( QWidget *widget SIP_TRANSFER ) = 0;
606 
608  virtual int addRasterToolBarIcon( QAction *qAction ) = 0;
609 
611  virtual void removeRasterToolBarIcon( QAction *qAction ) = 0;
612 
614  virtual int addVectorToolBarIcon( QAction *qAction ) = 0;
615 
624  virtual QAction *addVectorToolBarWidget( QWidget *widget SIP_TRANSFER ) = 0;
625 
627  virtual void removeVectorToolBarIcon( QAction *qAction ) = 0;
628 
630  virtual int addDatabaseToolBarIcon( QAction *qAction ) = 0;
631 
640  virtual QAction *addDatabaseToolBarWidget( QWidget *widget SIP_TRANSFER ) = 0;
641 
643  virtual void removeDatabaseToolBarIcon( QAction *qAction ) = 0;
644 
646  virtual int addWebToolBarIcon( QAction *qAction ) = 0;
647 
656  virtual QAction *addWebToolBarWidget( QWidget *widget SIP_TRANSFER ) = 0;
657 
659  virtual void removeWebToolBarIcon( QAction *qAction ) = 0;
660 
662  virtual QToolBar *addToolBar( const QString &name ) = 0 SIP_FACTORY;
663 
668  virtual void addToolBar( QToolBar *toolbar SIP_TRANSFER, Qt::ToolBarArea area = Qt::TopToolBarArea ) = 0;
669 
671  virtual void openMessageLog() = 0;
672 
674  virtual void addUserInputWidget( QWidget *widget ) = 0;
675 
680  virtual void showLayoutManager() = 0;
681 
688  virtual QgsLayoutDesignerInterface *openLayoutDesigner( QgsMasterLayoutInterface *layout ) = 0;
689 
695  virtual void showOptionsDialog( QWidget *parent = nullptr, const QString &currentPage = QString() ) = 0;
696 
701  virtual void buildStyleSheet( const QMap<QString, QVariant> &opts ) = 0;
702 
704  virtual void saveStyleSheetOptions( const QMap<QString, QVariant> &opts ) = 0;
705 
707  virtual void addPluginToMenu( const QString &name, QAction *action ) = 0;
708 
710  virtual void removePluginMenu( const QString &name, QAction *action ) = 0;
711 
713  virtual void insertAddLayerAction( QAction *action ) = 0;
714 
716  virtual void removeAddLayerAction( QAction *action ) = 0;
717 
719  virtual void addPluginToDatabaseMenu( const QString &name, QAction *action ) = 0;
720 
722  virtual void removePluginDatabaseMenu( const QString &name, QAction *action ) = 0;
723 
725  virtual void addPluginToRasterMenu( const QString &name, QAction *action ) = 0;
726 
728  virtual void removePluginRasterMenu( const QString &name, QAction *action ) = 0;
729 
731  virtual void addPluginToVectorMenu( const QString &name, QAction *action ) = 0;
732 
734  virtual void removePluginVectorMenu( const QString &name, QAction *action ) = 0;
735 
737  virtual void addPluginToWebMenu( const QString &name, QAction *action ) = 0;
738 
740  virtual void removePluginWebMenu( const QString &name, QAction *action ) = 0;
741 
743  virtual void addDockWidget( Qt::DockWidgetArea area, QDockWidget *dockwidget ) = 0;
744 
746  virtual void removeDockWidget( QDockWidget *dockwidget ) = 0;
747 
749  virtual void showLayerProperties( QgsMapLayer *l ) = 0;
750 
752  virtual QDialog *showAttributeTable( QgsVectorLayer *l, const QString &filterExpression = QString() ) = 0;
753 
757  virtual void addWindow( QAction *action ) = 0;
758 
762  virtual void removeWindow( QAction *action ) = 0;
763 
765  virtual bool registerMainWindowAction( QAction *action, const QString &defaultShortcut ) = 0;
766 
768  virtual bool unregisterMainWindowAction( QAction *action ) = 0;
769 
777  virtual void registerMapLayerConfigWidgetFactory( QgsMapLayerConfigWidgetFactory *factory ) = 0;
778 
784  virtual void unregisterMapLayerConfigWidgetFactory( QgsMapLayerConfigWidgetFactory *factory ) = 0;
785 
793  virtual void registerOptionsWidgetFactory( QgsOptionsWidgetFactory *factory ) = 0;
794 
800  virtual void unregisterOptionsWidgetFactory( QgsOptionsWidgetFactory *factory ) = 0;
801 
809  virtual void registerCustomDropHandler( QgsCustomDropHandler *handler ) = 0;
810 
816  virtual void unregisterCustomDropHandler( QgsCustomDropHandler *handler ) = 0;
817 
825  virtual void registerCustomLayoutDropHandler( QgsLayoutCustomDropHandler *handler ) = 0;
826 
832  virtual void unregisterCustomLayoutDropHandler( QgsLayoutCustomDropHandler *handler ) = 0;
833 
834  // TODO is this deprecated in favour of QgsContextHelp?
835 
845 #ifndef Q_MOC_RUN
846  Q_DECL_DEPRECATED
847 #endif
848  virtual void openURL( const QString &url, bool useQgisDocDirectory = true ) = 0 SIP_DEPRECATED;
849 
857  virtual bool openFeatureForm( QgsVectorLayer *l, QgsFeature &f, bool updateFeatureOnly = false, bool showModal = true ) = 0;
858 
867  virtual QgsAttributeDialog *getFeatureForm( QgsVectorLayer *l, QgsFeature &f ) = 0;
868 
881  virtual void preloadForm( const QString &uifile ) = 0;
882 
891  virtual void registerLocatorFilter( QgsLocatorFilter *filter SIP_TRANSFER ) = 0;
892 
903  virtual void deregisterLocatorFilter( QgsLocatorFilter *filter ) = 0;
904 
912  virtual void invalidateLocatorResults() = 0;
913 
920  virtual bool askForDatumTransform( QgsCoordinateReferenceSystem sourceCrs, QgsCoordinateReferenceSystem destinationCrs ) = 0;
921 
922  signals:
923 
928  void currentLayerChanged( QgsMapLayer *layer );
929 
935  void currentThemeChanged( const QString &theme );
936 
942  void layoutDesignerOpened( QgsLayoutDesignerInterface *designer );
943 
951  void layoutDesignerWillBeClosed( QgsLayoutDesignerInterface *designer );
952 
959  void layoutDesignerClosed();
960 
964  void initializationCompleted();
965 
973  void projectRead();
974 
984  void newProjectCreated();
985 
991  void layerSavedAs( QgsMapLayer *l, const QString &path );
992 
993 };
995 
996 #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:61
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:538
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:62
Map canvas is a class for displaying all GIS data types on a canvas.
Definition: qgsmapcanvas.h:74
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:102
#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:75
#define Q_NOWARN_DEPRECATED_POP
Definition: qgis.h:539
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...
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