QGIS API Documentation  2.99.0-Master (6c64c5a)
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 *attributesToolBar() = 0;
217  virtual QToolBar *pluginToolBar() = 0;
218  virtual QToolBar *helpToolBar() = 0;
219  virtual QToolBar *rasterToolBar() = 0;
220  virtual QToolBar *vectorToolBar() = 0;
221  virtual QToolBar *databaseToolBar() = 0;
222  virtual QToolBar *webToolBar() = 0;
223 
224  // Project menu actions
225  virtual QAction *actionNewProject() = 0;
226  virtual QAction *actionOpenProject() = 0;
227  virtual QAction *actionSaveProject() = 0;
228  virtual QAction *actionSaveProjectAs() = 0;
229  virtual QAction *actionSaveMapAsImage() = 0;
230  virtual QAction *actionProjectProperties() = 0;
231 
233  virtual QAction *actionCreatePrintLayout() = 0;
234 
236  virtual QAction *actionShowLayoutManager() = 0;
237  virtual QAction *actionExit() = 0;
238 
239  // Edit menu actions
240  virtual QAction *actionCutFeatures() = 0;
241  virtual QAction *actionCopyFeatures() = 0;
242  virtual QAction *actionPasteFeatures() = 0;
243  virtual QAction *actionAddFeature() = 0;
244  virtual QAction *actionDeleteSelected() = 0;
245  virtual QAction *actionMoveFeature() = 0;
246  virtual QAction *actionSplitFeatures() = 0;
247  virtual QAction *actionSplitParts() = 0;
248  virtual QAction *actionAddRing() = 0;
249  virtual QAction *actionAddPart() = 0;
250  virtual QAction *actionSimplifyFeature() = 0;
251  virtual QAction *actionDeleteRing() = 0;
252  virtual QAction *actionDeletePart() = 0;
253  virtual QAction *actionVertexTool() = 0;
254 
255  // View menu actions
257  virtual QAction *actionPan() = 0;
259  virtual QAction *actionPanToSelected() = 0;
261  virtual QAction *actionZoomIn() = 0;
263  virtual QAction *actionZoomOut() = 0;
265  virtual QAction *actionSelect() = 0;
267  virtual QAction *actionSelectRectangle() = 0;
269  virtual QAction *actionSelectPolygon() = 0;
271  virtual QAction *actionSelectFreehand() = 0;
273  virtual QAction *actionSelectRadius() = 0;
275  virtual QAction *actionIdentify() = 0;
277  virtual QAction *actionFeatureAction() = 0;
279  virtual QAction *actionMeasure() = 0;
281  virtual QAction *actionMeasureArea() = 0;
283  virtual QAction *actionZoomFullExtent() = 0;
285  virtual QAction *actionZoomToLayer() = 0;
287  virtual QAction *actionZoomToSelected() = 0;
289  virtual QAction *actionZoomLast() = 0;
291  virtual QAction *actionZoomNext() = 0;
293  virtual QAction *actionZoomActualSize() = 0;
295  virtual QAction *actionMapTips() = 0;
297  virtual QAction *actionNewBookmark() = 0;
299  virtual QAction *actionShowBookmarks() = 0;
301  virtual QAction *actionDraw() = 0;
302 
303  // Layer menu actions
304  virtual QAction *actionNewVectorLayer() = 0;
305  virtual QAction *actionAddOgrLayer() = 0;
306  virtual QAction *actionAddRasterLayer() = 0;
307  virtual QAction *actionAddPgLayer() = 0;
308  virtual QAction *actionAddWmsLayer() = 0;
310  virtual QAction *actionAddAfsLayer() = 0;
312  virtual QAction *actionAddAmsLayer() = 0;
313  virtual QAction *actionCopyLayerStyle() = 0;
314  virtual QAction *actionPasteLayerStyle() = 0;
315  virtual QAction *actionOpenTable() = 0;
316  virtual QAction *actionOpenFieldCalculator() = 0;
317 
322  virtual QAction *actionOpenStatisticalSummary() = 0;
323 
324  virtual QAction *actionToggleEditing() = 0;
325  virtual QAction *actionSaveActiveLayerEdits() = 0;
326  virtual QAction *actionAllEdits() = 0;
327  virtual QAction *actionSaveEdits() = 0;
328  virtual QAction *actionSaveAllEdits() = 0;
329  virtual QAction *actionRollbackEdits() = 0;
330  virtual QAction *actionRollbackAllEdits() = 0;
331  virtual QAction *actionCancelEdits() = 0;
332  virtual QAction *actionCancelAllEdits() = 0;
333  virtual QAction *actionLayerSaveAs() = 0;
334  virtual QAction *actionDuplicateLayer() = 0;
335  virtual QAction *actionLayerProperties() = 0;
336  virtual QAction *actionAddToOverview() = 0;
337  virtual QAction *actionAddAllToOverview() = 0;
338  virtual QAction *actionRemoveAllFromOverview() = 0;
339  virtual QAction *actionHideAllLayers() = 0;
340  virtual QAction *actionShowAllLayers() = 0;
341  virtual QAction *actionHideSelectedLayers() = 0;
342 
347  virtual QAction *actionHideDeselectedLayers() = 0;
348  virtual QAction *actionShowSelectedLayers() = 0;
349 
350  // Plugin menu actions
351  virtual QAction *actionManagePlugins() = 0;
352  virtual QAction *actionPluginListSeparator() = 0;
353  virtual QAction *actionShowPythonDialog() = 0;
354 
355  // Settings menu actions
356  virtual QAction *actionToggleFullScreen() = 0;
357  virtual QAction *actionOptions() = 0;
358  virtual QAction *actionCustomProjection() = 0;
359 
360  // Help menu actions
361  virtual QAction *actionHelpContents() = 0;
362  virtual QAction *actionQgisHomePage() = 0;
363  virtual QAction *actionCheckQgisVersion() = 0;
364  virtual QAction *actionAbout() = 0;
365 
373  virtual QgsVectorLayerTools *vectorLayerTools() = 0;
374 
376  virtual int messageTimeout() = 0;
377 
384  virtual QgsStatusBar *statusBarIface() = 0;
385 
386  public slots: // TODO: do these functions really need to be slots?
387 
388  /* Exposed functions */
389 
391  virtual void zoomFull() = 0;
392 
394  virtual void zoomToPrevious() = 0;
395 
397  virtual void zoomToNext() = 0;
398 
400  virtual void zoomToActiveLayer() = 0;
401 
403  virtual QgsVectorLayer *addVectorLayer( const QString &vectorLayerPath, const QString &baseName, const QString &providerKey ) = 0;
404 
406  virtual QgsRasterLayer *addRasterLayer( const QString &rasterLayerPath, const QString &baseName = QString() ) = 0;
407 
409  virtual QgsRasterLayer *addRasterLayer( const QString &url, const QString &layerName, const QString &providerKey ) = 0;
410 
412  virtual bool addProject( const QString &project ) = 0;
414  virtual void newProject( bool promptToSaveFlag = false ) = 0;
415 
423  virtual void reloadConnections( ) = 0;
424 
429  virtual bool setActiveLayer( QgsMapLayer * ) = 0;
430 
435  virtual void copySelectionToClipboard( QgsMapLayer * ) = 0;
436 
441  virtual void pasteFromClipboard( QgsMapLayer * ) = 0;
442 
444  virtual int addToolBarIcon( QAction *qAction ) = 0;
445 
454  virtual QAction *addToolBarWidget( QWidget *widget SIP_TRANSFER ) = 0;
455 
457  virtual void removeToolBarIcon( QAction *qAction ) = 0;
458 
467  virtual QAction *addRasterToolBarWidget( QWidget *widget SIP_TRANSFER ) = 0;
468 
470  virtual int addRasterToolBarIcon( QAction *qAction ) = 0;
471 
473  virtual void removeRasterToolBarIcon( QAction *qAction ) = 0;
474 
476  virtual int addVectorToolBarIcon( QAction *qAction ) = 0;
477 
486  virtual QAction *addVectorToolBarWidget( QWidget *widget SIP_TRANSFER ) = 0;
487 
489  virtual void removeVectorToolBarIcon( QAction *qAction ) = 0;
490 
492  virtual int addDatabaseToolBarIcon( QAction *qAction ) = 0;
493 
502  virtual QAction *addDatabaseToolBarWidget( QWidget *widget SIP_TRANSFER ) = 0;
503 
505  virtual void removeDatabaseToolBarIcon( QAction *qAction ) = 0;
506 
508  virtual int addWebToolBarIcon( QAction *qAction ) = 0;
509 
518  virtual QAction *addWebToolBarWidget( QWidget *widget SIP_TRANSFER ) = 0;
519 
521  virtual void removeWebToolBarIcon( QAction *qAction ) = 0;
522 
524  virtual QToolBar *addToolBar( const QString &name ) = 0 SIP_FACTORY;
525 
530  virtual void addToolBar( QToolBar *toolbar SIP_TRANSFER, Qt::ToolBarArea area = Qt::TopToolBarArea ) = 0;
531 
533  virtual void openMessageLog() = 0;
534 
536  virtual void addUserInputWidget( QWidget *widget ) = 0;
537 
542  virtual void showLayoutManager() = 0;
543 
550  virtual QgsLayoutDesignerInterface *openLayoutDesigner( QgsMasterLayoutInterface *layout ) = 0;
551 
557  virtual void showOptionsDialog( QWidget *parent = nullptr, const QString &currentPage = QString() ) = 0;
558 
563  virtual void buildStyleSheet( const QMap<QString, QVariant> &opts ) = 0;
564 
566  virtual void saveStyleSheetOptions( const QMap<QString, QVariant> &opts ) = 0;
567 
569  virtual void addPluginToMenu( const QString &name, QAction *action ) = 0;
570 
572  virtual void removePluginMenu( const QString &name, QAction *action ) = 0;
573 
575  virtual void insertAddLayerAction( QAction *action ) = 0;
576 
578  virtual void removeAddLayerAction( QAction *action ) = 0;
579 
581  virtual void addPluginToDatabaseMenu( const QString &name, QAction *action ) = 0;
582 
584  virtual void removePluginDatabaseMenu( const QString &name, QAction *action ) = 0;
585 
587  virtual void addPluginToRasterMenu( const QString &name, QAction *action ) = 0;
588 
590  virtual void removePluginRasterMenu( const QString &name, QAction *action ) = 0;
591 
593  virtual void addPluginToVectorMenu( const QString &name, QAction *action ) = 0;
594 
596  virtual void removePluginVectorMenu( const QString &name, QAction *action ) = 0;
597 
599  virtual void addPluginToWebMenu( const QString &name, QAction *action ) = 0;
600 
602  virtual void removePluginWebMenu( const QString &name, QAction *action ) = 0;
603 
605  virtual void addDockWidget( Qt::DockWidgetArea area, QDockWidget *dockwidget ) = 0;
606 
608  virtual void removeDockWidget( QDockWidget *dockwidget ) = 0;
609 
611  virtual void showLayerProperties( QgsMapLayer *l ) = 0;
612 
614  virtual QDialog *showAttributeTable( QgsVectorLayer *l, const QString &filterExpression = QString() ) = 0;
615 
619  virtual void addWindow( QAction *action ) = 0;
620 
624  virtual void removeWindow( QAction *action ) = 0;
625 
627  virtual bool registerMainWindowAction( QAction *action, const QString &defaultShortcut ) = 0;
628 
630  virtual bool unregisterMainWindowAction( QAction *action ) = 0;
631 
638  virtual void registerMapLayerConfigWidgetFactory( QgsMapLayerConfigWidgetFactory *factory ) = 0;
639 
645  virtual void unregisterMapLayerConfigWidgetFactory( QgsMapLayerConfigWidgetFactory *factory ) = 0;
646 
653  virtual void registerOptionsWidgetFactory( QgsOptionsWidgetFactory *factory ) = 0;
654 
660  virtual void unregisterOptionsWidgetFactory( QgsOptionsWidgetFactory *factory ) = 0;
661 
668  virtual void registerCustomDropHandler( QgsCustomDropHandler *handler ) = 0;
669 
674  virtual void unregisterCustomDropHandler( QgsCustomDropHandler *handler ) = 0;
675 
682  virtual void registerCustomLayoutDropHandler( QgsLayoutCustomDropHandler *handler ) = 0;
683 
688  virtual void unregisterCustomLayoutDropHandler( QgsLayoutCustomDropHandler *handler ) = 0;
689 
690  // @todo is this deprecated in favour of QgsContextHelp?
691 
701 #ifndef Q_MOC_RUN
702  Q_DECL_DEPRECATED
703 #endif
704  virtual void openURL( const QString &url, bool useQgisDocDirectory = true ) = 0 SIP_DEPRECATED;
705 
713  virtual bool openFeatureForm( QgsVectorLayer *l, QgsFeature &f, bool updateFeatureOnly = false, bool showModal = true ) = 0;
714 
723  virtual QgsAttributeDialog *getFeatureForm( QgsVectorLayer *l, QgsFeature &f ) = 0;
724 
737  virtual void preloadForm( const QString &uifile ) = 0;
738 
747  virtual void registerLocatorFilter( QgsLocatorFilter *filter SIP_TRANSFER ) = 0;
748 
759  virtual void deregisterLocatorFilter( QgsLocatorFilter *filter ) = 0;
760 
767  virtual bool askForDatumTransform( QgsCoordinateReferenceSystem sourceCrs, QgsCoordinateReferenceSystem destinationCrs ) = 0;
768 
769  signals:
770 
775  void currentLayerChanged( QgsMapLayer *layer );
776 
782  void currentThemeChanged( const QString &theme );
783 
789  void layoutDesignerOpened( QgsLayoutDesignerInterface *designer );
790 
798  void layoutDesignerWillBeClosed( QgsLayoutDesignerInterface *designer );
799 
806  void layoutDesignerClosed();
807 
811  void initializationCompleted();
812 
820  void projectRead();
821 
831  void newProjectCreated();
832 
838  void layerSavedAs( QgsMapLayer *l, const QString &path );
839 
840 };
842 
843 #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