QGIS API Documentation  3.0.2-Girona (307d082)
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 
192  // Menus
193  virtual QMenu *projectMenu() = 0;
194  virtual QMenu *editMenu() = 0;
195  virtual QMenu *viewMenu() = 0;
196  virtual QMenu *layerMenu() = 0;
197  virtual QMenu *newLayerMenu() = 0;
199  virtual QMenu *addLayerMenu() = 0;
200  virtual QMenu *settingsMenu() = 0;
201  virtual QMenu *pluginMenu() = 0;
202  virtual QMenu *rasterMenu() = 0;
203  virtual QMenu *databaseMenu() = 0;
204  virtual QMenu *vectorMenu() = 0;
205  virtual QMenu *webMenu() = 0;
206  virtual QMenu *firstRightStandardMenu() = 0;
207  virtual QMenu *windowMenu() = 0;
208  virtual QMenu *helpMenu() = 0;
209 
210  // ToolBars
211  virtual QToolBar *fileToolBar() = 0;
212  virtual QToolBar *layerToolBar() = 0;
213  virtual QToolBar *mapNavToolToolBar() = 0;
214  virtual QToolBar *digitizeToolBar() = 0;
215  virtual QToolBar *advancedDigitizeToolBar() = 0;
216  virtual QToolBar *shapeDigitizeToolBar() = 0;
217  virtual QToolBar *attributesToolBar() = 0;
218  virtual QToolBar *pluginToolBar() = 0;
219  virtual QToolBar *helpToolBar() = 0;
220  virtual QToolBar *rasterToolBar() = 0;
221  virtual QToolBar *vectorToolBar() = 0;
222  virtual QToolBar *databaseToolBar() = 0;
223  virtual QToolBar *webToolBar() = 0;
224 
225  // Project menu actions
226  virtual QAction *actionNewProject() = 0;
227  virtual QAction *actionOpenProject() = 0;
228  virtual QAction *actionSaveProject() = 0;
229  virtual QAction *actionSaveProjectAs() = 0;
230  virtual QAction *actionSaveMapAsImage() = 0;
231  virtual QAction *actionProjectProperties() = 0;
232 
234  virtual QAction *actionCreatePrintLayout() = 0;
235 
237  virtual QAction *actionShowLayoutManager() = 0;
238  virtual QAction *actionExit() = 0;
239 
240  // Edit menu actions
241  virtual QAction *actionCutFeatures() = 0;
242  virtual QAction *actionCopyFeatures() = 0;
243  virtual QAction *actionPasteFeatures() = 0;
244  virtual QAction *actionAddFeature() = 0;
245  virtual QAction *actionDeleteSelected() = 0;
246  virtual QAction *actionMoveFeature() = 0;
247  virtual QAction *actionSplitFeatures() = 0;
248  virtual QAction *actionSplitParts() = 0;
249  virtual QAction *actionAddRing() = 0;
250  virtual QAction *actionAddPart() = 0;
251  virtual QAction *actionSimplifyFeature() = 0;
252  virtual QAction *actionDeleteRing() = 0;
253  virtual QAction *actionDeletePart() = 0;
254  virtual QAction *actionVertexTool() = 0;
255 
256  // View menu actions
258  virtual QAction *actionPan() = 0;
260  virtual QAction *actionPanToSelected() = 0;
262  virtual QAction *actionZoomIn() = 0;
264  virtual QAction *actionZoomOut() = 0;
266  virtual QAction *actionSelect() = 0;
268  virtual QAction *actionSelectRectangle() = 0;
270  virtual QAction *actionSelectPolygon() = 0;
272  virtual QAction *actionSelectFreehand() = 0;
274  virtual QAction *actionSelectRadius() = 0;
276  virtual QAction *actionIdentify() = 0;
278  virtual QAction *actionFeatureAction() = 0;
280  virtual QAction *actionMeasure() = 0;
282  virtual QAction *actionMeasureArea() = 0;
284  virtual QAction *actionZoomFullExtent() = 0;
286  virtual QAction *actionZoomToLayer() = 0;
288  virtual QAction *actionZoomToSelected() = 0;
290  virtual QAction *actionZoomLast() = 0;
292  virtual QAction *actionZoomNext() = 0;
294  virtual QAction *actionZoomActualSize() = 0;
296  virtual QAction *actionMapTips() = 0;
298  virtual QAction *actionNewBookmark() = 0;
300  virtual QAction *actionShowBookmarks() = 0;
302  virtual QAction *actionDraw() = 0;
303 
304  // Layer menu actions
305  virtual QAction *actionNewVectorLayer() = 0;
306  virtual QAction *actionAddOgrLayer() = 0;
307  virtual QAction *actionAddRasterLayer() = 0;
308  virtual QAction *actionAddPgLayer() = 0;
309  virtual QAction *actionAddWmsLayer() = 0;
311  virtual QAction *actionAddAfsLayer() = 0;
313  virtual QAction *actionAddAmsLayer() = 0;
314  virtual QAction *actionCopyLayerStyle() = 0;
315  virtual QAction *actionPasteLayerStyle() = 0;
316  virtual QAction *actionOpenTable() = 0;
317  virtual QAction *actionOpenFieldCalculator() = 0;
318 
323  virtual QAction *actionOpenStatisticalSummary() = 0;
324 
325  virtual QAction *actionToggleEditing() = 0;
326  virtual QAction *actionSaveActiveLayerEdits() = 0;
327  virtual QAction *actionAllEdits() = 0;
328  virtual QAction *actionSaveEdits() = 0;
329  virtual QAction *actionSaveAllEdits() = 0;
330  virtual QAction *actionRollbackEdits() = 0;
331  virtual QAction *actionRollbackAllEdits() = 0;
332  virtual QAction *actionCancelEdits() = 0;
333  virtual QAction *actionCancelAllEdits() = 0;
334  virtual QAction *actionLayerSaveAs() = 0;
335  virtual QAction *actionDuplicateLayer() = 0;
336  virtual QAction *actionLayerProperties() = 0;
337  virtual QAction *actionAddToOverview() = 0;
338  virtual QAction *actionAddAllToOverview() = 0;
339  virtual QAction *actionRemoveAllFromOverview() = 0;
340  virtual QAction *actionHideAllLayers() = 0;
341  virtual QAction *actionShowAllLayers() = 0;
342  virtual QAction *actionHideSelectedLayers() = 0;
343 
348  virtual QAction *actionHideDeselectedLayers() = 0;
349  virtual QAction *actionShowSelectedLayers() = 0;
350 
351  // Plugin menu actions
352  virtual QAction *actionManagePlugins() = 0;
353  virtual QAction *actionPluginListSeparator() = 0;
354  virtual QAction *actionShowPythonDialog() = 0;
355 
356  // Settings menu actions
357  virtual QAction *actionToggleFullScreen() = 0;
358  virtual QAction *actionOptions() = 0;
359  virtual QAction *actionCustomProjection() = 0;
360 
361  // Help menu actions
362  virtual QAction *actionHelpContents() = 0;
363  virtual QAction *actionQgisHomePage() = 0;
364  virtual QAction *actionCheckQgisVersion() = 0;
365  virtual QAction *actionAbout() = 0;
366 
374  virtual QgsVectorLayerTools *vectorLayerTools() = 0;
375 
377  virtual int messageTimeout() = 0;
378 
385  virtual QgsStatusBar *statusBarIface() = 0;
386 
387  public slots: // TODO: do these functions really need to be slots?
388 
389  /* Exposed functions */
390 
392  virtual void zoomFull() = 0;
393 
395  virtual void zoomToPrevious() = 0;
396 
398  virtual void zoomToNext() = 0;
399 
401  virtual void zoomToActiveLayer() = 0;
402 
404  virtual QgsVectorLayer *addVectorLayer( const QString &vectorLayerPath, const QString &baseName, const QString &providerKey ) = 0;
405 
407  virtual QgsRasterLayer *addRasterLayer( const QString &rasterLayerPath, const QString &baseName = QString() ) = 0;
408 
410  virtual QgsRasterLayer *addRasterLayer( const QString &url, const QString &layerName, const QString &providerKey ) = 0;
411 
413  virtual bool addProject( const QString &project ) = 0;
415  virtual void newProject( bool promptToSaveFlag = false ) = 0;
416 
424  virtual void reloadConnections( ) = 0;
425 
430  virtual bool setActiveLayer( QgsMapLayer * ) = 0;
431 
436  virtual void copySelectionToClipboard( QgsMapLayer * ) = 0;
437 
442  virtual void pasteFromClipboard( QgsMapLayer * ) = 0;
443 
445  virtual int addToolBarIcon( QAction *qAction ) = 0;
446 
455  virtual QAction *addToolBarWidget( QWidget *widget SIP_TRANSFER ) = 0;
456 
458  virtual void removeToolBarIcon( QAction *qAction ) = 0;
459 
468  virtual QAction *addRasterToolBarWidget( QWidget *widget SIP_TRANSFER ) = 0;
469 
471  virtual int addRasterToolBarIcon( QAction *qAction ) = 0;
472 
474  virtual void removeRasterToolBarIcon( QAction *qAction ) = 0;
475 
477  virtual int addVectorToolBarIcon( QAction *qAction ) = 0;
478 
487  virtual QAction *addVectorToolBarWidget( QWidget *widget SIP_TRANSFER ) = 0;
488 
490  virtual void removeVectorToolBarIcon( QAction *qAction ) = 0;
491 
493  virtual int addDatabaseToolBarIcon( QAction *qAction ) = 0;
494 
503  virtual QAction *addDatabaseToolBarWidget( QWidget *widget SIP_TRANSFER ) = 0;
504 
506  virtual void removeDatabaseToolBarIcon( QAction *qAction ) = 0;
507 
509  virtual int addWebToolBarIcon( QAction *qAction ) = 0;
510 
519  virtual QAction *addWebToolBarWidget( QWidget *widget SIP_TRANSFER ) = 0;
520 
522  virtual void removeWebToolBarIcon( QAction *qAction ) = 0;
523 
525  virtual QToolBar *addToolBar( const QString &name ) = 0 SIP_FACTORY;
526 
531  virtual void addToolBar( QToolBar *toolbar SIP_TRANSFER, Qt::ToolBarArea area = Qt::TopToolBarArea ) = 0;
532 
534  virtual void openMessageLog() = 0;
535 
537  virtual void addUserInputWidget( QWidget *widget ) = 0;
538 
543  virtual void showLayoutManager() = 0;
544 
551  virtual QgsLayoutDesignerInterface *openLayoutDesigner( QgsMasterLayoutInterface *layout ) = 0;
552 
558  virtual void showOptionsDialog( QWidget *parent = nullptr, const QString &currentPage = QString() ) = 0;
559 
564  virtual void buildStyleSheet( const QMap<QString, QVariant> &opts ) = 0;
565 
567  virtual void saveStyleSheetOptions( const QMap<QString, QVariant> &opts ) = 0;
568 
570  virtual void addPluginToMenu( const QString &name, QAction *action ) = 0;
571 
573  virtual void removePluginMenu( const QString &name, QAction *action ) = 0;
574 
576  virtual void insertAddLayerAction( QAction *action ) = 0;
577 
579  virtual void removeAddLayerAction( QAction *action ) = 0;
580 
582  virtual void addPluginToDatabaseMenu( const QString &name, QAction *action ) = 0;
583 
585  virtual void removePluginDatabaseMenu( const QString &name, QAction *action ) = 0;
586 
588  virtual void addPluginToRasterMenu( const QString &name, QAction *action ) = 0;
589 
591  virtual void removePluginRasterMenu( const QString &name, QAction *action ) = 0;
592 
594  virtual void addPluginToVectorMenu( const QString &name, QAction *action ) = 0;
595 
597  virtual void removePluginVectorMenu( const QString &name, QAction *action ) = 0;
598 
600  virtual void addPluginToWebMenu( const QString &name, QAction *action ) = 0;
601 
603  virtual void removePluginWebMenu( const QString &name, QAction *action ) = 0;
604 
606  virtual void addDockWidget( Qt::DockWidgetArea area, QDockWidget *dockwidget ) = 0;
607 
609  virtual void removeDockWidget( QDockWidget *dockwidget ) = 0;
610 
612  virtual void showLayerProperties( QgsMapLayer *l ) = 0;
613 
615  virtual QDialog *showAttributeTable( QgsVectorLayer *l, const QString &filterExpression = QString() ) = 0;
616 
620  virtual void addWindow( QAction *action ) = 0;
621 
625  virtual void removeWindow( QAction *action ) = 0;
626 
628  virtual bool registerMainWindowAction( QAction *action, const QString &defaultShortcut ) = 0;
629 
631  virtual bool unregisterMainWindowAction( QAction *action ) = 0;
632 
639  virtual void registerMapLayerConfigWidgetFactory( QgsMapLayerConfigWidgetFactory *factory ) = 0;
640 
646  virtual void unregisterMapLayerConfigWidgetFactory( QgsMapLayerConfigWidgetFactory *factory ) = 0;
647 
654  virtual void registerOptionsWidgetFactory( QgsOptionsWidgetFactory *factory ) = 0;
655 
661  virtual void unregisterOptionsWidgetFactory( QgsOptionsWidgetFactory *factory ) = 0;
662 
669  virtual void registerCustomDropHandler( QgsCustomDropHandler *handler ) = 0;
670 
675  virtual void unregisterCustomDropHandler( QgsCustomDropHandler *handler ) = 0;
676 
683  virtual void registerCustomLayoutDropHandler( QgsLayoutCustomDropHandler *handler ) = 0;
684 
689  virtual void unregisterCustomLayoutDropHandler( QgsLayoutCustomDropHandler *handler ) = 0;
690 
691  // @todo is this deprecated in favour of QgsContextHelp?
692 
702 #ifndef Q_MOC_RUN
703  Q_DECL_DEPRECATED
704 #endif
705  virtual void openURL( const QString &url, bool useQgisDocDirectory = true ) = 0 SIP_DEPRECATED;
706 
714  virtual bool openFeatureForm( QgsVectorLayer *l, QgsFeature &f, bool updateFeatureOnly = false, bool showModal = true ) = 0;
715 
724  virtual QgsAttributeDialog *getFeatureForm( QgsVectorLayer *l, QgsFeature &f ) = 0;
725 
738  virtual void preloadForm( const QString &uifile ) = 0;
739 
748  virtual void registerLocatorFilter( QgsLocatorFilter *filter SIP_TRANSFER ) = 0;
749 
760  virtual void deregisterLocatorFilter( QgsLocatorFilter *filter ) = 0;
761 
768  virtual bool askForDatumTransform( QgsCoordinateReferenceSystem sourceCrs, QgsCoordinateReferenceSystem destinationCrs ) = 0;
769 
770  signals:
771 
776  void currentLayerChanged( QgsMapLayer *layer );
777 
783  void currentThemeChanged( const QString &theme );
784 
790  void layoutDesignerOpened( QgsLayoutDesignerInterface *designer );
791 
799  void layoutDesignerWillBeClosed( QgsLayoutDesignerInterface *designer );
800 
807  void layoutDesignerClosed();
808 
812  void initializationCompleted();
813 
821  void projectRead();
822 
832  void newProjectCreated();
833 
839  void layerSavedAs( QgsMapLayer *l, const QString &path );
840 
841 };
843 
844 #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:56
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.
#define Q_NOWARN_DEPRECATED_PUSH
Definition: qgis.h:516
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:94
#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:517
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