QGIS API Documentation  2.99.0-Master (19b062c)
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;
32 class QgsFeature;
34 class QgsLayerTreeView;
35 class QgsLayout;
36 class QgsLayoutDesignerInterface;
37 class QgsMapCanvas;
38 class QgsMapLayer;
40 class QgsMessageBar;
42 class QgsRasterLayer;
43 class QgsSnappingUtils;
44 class QgsVectorLayer;
47 class QgsLocatorFilter;
48 class QgsStatusBar;
49 
50 #include <QObject>
51 #include <QFont>
52 #include <QPair>
53 #include <map>
54 
55 #include "qgis.h"
56 #include "qgsmaplayer.h"
57 #include "qgis_gui.h"
58 
59 
74 class GUI_EXPORT QgisInterface : public QObject
75 {
76  Q_OBJECT
77 
78  public:
79 
81  QgisInterface() = default;
82 
83  virtual QgsPluginManagerInterface *pluginManagerInterface() = 0;
84 
85  virtual QgsLayerTreeView *layerTreeView() = 0;
86 
99  virtual void addCustomActionForLayerType( QAction *action, QString menu,
100  QgsMapLayer::LayerType type, bool allLayers ) = 0;
101 
108  virtual void addCustomActionForLayer( QAction *action, QgsMapLayer *layer ) = 0;
109 
114  virtual bool removeCustomActionForLayerType( QAction *action ) = 0;
115 
120  virtual QList< QgsMapCanvas * > mapCanvases() = 0;
121 
127  virtual QgsMapCanvas *createNewMapCanvas( const QString &name ) = 0;
128 
134  virtual void closeMapCanvas( const QString &name ) = 0;
135 
140  virtual QSize iconSize( bool dockedToolbar = false ) const = 0;
141 
146  virtual QList<QgsMapLayer *> editableLayers( bool modified = false ) const = 0;
147 
149  virtual QgsMapLayer *activeLayer() = 0;
150 
152  virtual QgsMapCanvas *mapCanvas() = 0;
153 
159  virtual QgsLayerTreeMapCanvasBridge *layerTreeCanvasBridge() = 0;
160 
162  virtual QWidget *mainWindow() = 0;
163 
165  virtual QgsMessageBar *messageBar() = 0;
166 
171  virtual QList<QgsComposerInterface *> openComposers() = 0;
172 
177  virtual QList<QgsLayoutDesignerInterface *> openLayoutDesigners() = 0;
178 
179 
181  virtual QMap<QString, QVariant> defaultStyleSheetOptions() = 0;
182 
184  virtual QFont defaultStyleSheetFont() = 0;
185 
190  virtual QgsAdvancedDigitizingDockWidget *cadDockWidget() = 0;
191 
197  // Menus
198  virtual QMenu *projectMenu() = 0;
199  virtual QMenu *editMenu() = 0;
200  virtual QMenu *viewMenu() = 0;
201  virtual QMenu *layerMenu() = 0;
202  virtual QMenu *newLayerMenu() = 0;
204  virtual QMenu *addLayerMenu() = 0;
205  virtual QMenu *settingsMenu() = 0;
206  virtual QMenu *pluginMenu() = 0;
207  virtual QMenu *rasterMenu() = 0;
208  virtual QMenu *databaseMenu() = 0;
209  virtual QMenu *vectorMenu() = 0;
210  virtual QMenu *webMenu() = 0;
211  virtual QMenu *firstRightStandardMenu() = 0;
212  virtual QMenu *windowMenu() = 0;
213  virtual QMenu *helpMenu() = 0;
214 
215  // ToolBars
216  virtual QToolBar *fileToolBar() = 0;
217  virtual QToolBar *layerToolBar() = 0;
218  virtual QToolBar *mapNavToolToolBar() = 0;
219  virtual QToolBar *digitizeToolBar() = 0;
220  virtual QToolBar *advancedDigitizeToolBar() = 0;
221  virtual QToolBar *attributesToolBar() = 0;
222  virtual QToolBar *pluginToolBar() = 0;
223  virtual QToolBar *helpToolBar() = 0;
224  virtual QToolBar *rasterToolBar() = 0;
225  virtual QToolBar *vectorToolBar() = 0;
226  virtual QToolBar *databaseToolBar() = 0;
227  virtual QToolBar *webToolBar() = 0;
228 
229  // Project menu actions
230  virtual QAction *actionNewProject() = 0;
231  virtual QAction *actionOpenProject() = 0;
232  virtual QAction *actionSaveProject() = 0;
233  virtual QAction *actionSaveProjectAs() = 0;
234  virtual QAction *actionSaveMapAsImage() = 0;
235  virtual QAction *actionProjectProperties() = 0;
236  virtual QAction *actionPrintComposer() = 0;
237  virtual QAction *actionShowComposerManager() = 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 *actionNodeTool() = 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  virtual QAction *actionToggleEditing() = 0;
319  virtual QAction *actionSaveActiveLayerEdits() = 0;
320  virtual QAction *actionAllEdits() = 0;
321  virtual QAction *actionSaveEdits() = 0;
322  virtual QAction *actionSaveAllEdits() = 0;
323  virtual QAction *actionRollbackEdits() = 0;
324  virtual QAction *actionRollbackAllEdits() = 0;
325  virtual QAction *actionCancelEdits() = 0;
326  virtual QAction *actionCancelAllEdits() = 0;
327  virtual QAction *actionLayerSaveAs() = 0;
328  virtual QAction *actionDuplicateLayer() = 0;
329  virtual QAction *actionLayerProperties() = 0;
330  virtual QAction *actionAddToOverview() = 0;
331  virtual QAction *actionAddAllToOverview() = 0;
332  virtual QAction *actionRemoveAllFromOverview() = 0;
333  virtual QAction *actionHideAllLayers() = 0;
334  virtual QAction *actionShowAllLayers() = 0;
335  virtual QAction *actionHideSelectedLayers() = 0;
336 
341  virtual QAction *actionHideDeselectedLayers() = 0;
342  virtual QAction *actionShowSelectedLayers() = 0;
343 
344  // Plugin menu actions
345  virtual QAction *actionManagePlugins() = 0;
346  virtual QAction *actionPluginListSeparator() = 0;
347  virtual QAction *actionShowPythonDialog() = 0;
348 
349  // Settings menu actions
350  virtual QAction *actionToggleFullScreen() = 0;
351  virtual QAction *actionOptions() = 0;
352  virtual QAction *actionCustomProjection() = 0;
353 
354  // Help menu actions
355  virtual QAction *actionHelpContents() = 0;
356  virtual QAction *actionQgisHomePage() = 0;
357  virtual QAction *actionCheckQgisVersion() = 0;
358  virtual QAction *actionAbout() = 0;
359 
367  virtual QgsVectorLayerTools *vectorLayerTools() = 0;
368 
370  virtual int messageTimeout() = 0;
371 
378  virtual QgsStatusBar *statusBarIface() = 0;
379 
380  public slots: // TODO: do these functions really need to be slots?
381 
382  /* Exposed functions */
383 
385  virtual void zoomFull() = 0;
386 
388  virtual void zoomToPrevious() = 0;
389 
391  virtual void zoomToNext() = 0;
392 
394  virtual void zoomToActiveLayer() = 0;
395 
397  virtual QgsVectorLayer *addVectorLayer( const QString &vectorLayerPath, const QString &baseName, const QString &providerKey ) = 0;
398 
400  virtual QgsRasterLayer *addRasterLayer( const QString &rasterLayerPath, const QString &baseName = QString() ) = 0;
401 
403  virtual QgsRasterLayer *addRasterLayer( const QString &url, const QString &layerName, const QString &providerKey ) = 0;
404 
406  virtual bool addProject( const QString &project ) = 0;
408  virtual void newProject( bool promptToSaveFlag = false ) = 0;
409 
417  virtual void reloadConnections( ) = 0;
418 
423  virtual bool setActiveLayer( QgsMapLayer * ) = 0;
424 
429  virtual void copySelectionToClipboard( QgsMapLayer * ) = 0;
430 
435  virtual void pasteFromClipboard( QgsMapLayer * ) = 0;
436 
438  virtual int addToolBarIcon( QAction *qAction ) = 0;
439 
448  virtual QAction *addToolBarWidget( QWidget *widget SIP_TRANSFER ) = 0;
449 
451  virtual void removeToolBarIcon( QAction *qAction ) = 0;
452 
461  virtual QAction *addRasterToolBarWidget( QWidget *widget SIP_TRANSFER ) = 0;
462 
464  virtual int addRasterToolBarIcon( QAction *qAction ) = 0;
465 
467  virtual void removeRasterToolBarIcon( QAction *qAction ) = 0;
468 
470  virtual int addVectorToolBarIcon( QAction *qAction ) = 0;
471 
480  virtual QAction *addVectorToolBarWidget( QWidget *widget SIP_TRANSFER ) = 0;
481 
483  virtual void removeVectorToolBarIcon( QAction *qAction ) = 0;
484 
486  virtual int addDatabaseToolBarIcon( QAction *qAction ) = 0;
487 
496  virtual QAction *addDatabaseToolBarWidget( QWidget *widget SIP_TRANSFER ) = 0;
497 
499  virtual void removeDatabaseToolBarIcon( QAction *qAction ) = 0;
500 
502  virtual int addWebToolBarIcon( QAction *qAction ) = 0;
503 
512  virtual QAction *addWebToolBarWidget( QWidget *widget SIP_TRANSFER ) = 0;
513 
515  virtual void removeWebToolBarIcon( QAction *qAction ) = 0;
516 
518  virtual QToolBar *addToolBar( const QString &name ) = 0 SIP_FACTORY;
519 
524  virtual void addToolBar( QToolBar *toolbar SIP_TRANSFER, Qt::ToolBarArea area = Qt::TopToolBarArea ) = 0;
525 
527  virtual void openMessageLog() = 0;
528 
530  virtual void addUserInputWidget( QWidget *widget ) = 0;
531 
539  virtual QgsComposerInterface *openComposer( QgsComposition *composition ) = 0;
540 
547  virtual void closeComposer( QgsComposition *composition ) = 0;
548 
556  virtual QgsLayoutDesignerInterface *openLayoutDesigner( QgsLayout *layout ) = 0;
557 
563  virtual void showOptionsDialog( QWidget *parent = nullptr, const QString &currentPage = QString() ) = 0;
564 
569  virtual void buildStyleSheet( const QMap<QString, QVariant> &opts ) = 0;
570 
572  virtual void saveStyleSheetOptions( const QMap<QString, QVariant> &opts ) = 0;
573 
575  virtual void addPluginToMenu( const QString &name, QAction *action ) = 0;
576 
578  virtual void removePluginMenu( const QString &name, QAction *action ) = 0;
579 
581  virtual void insertAddLayerAction( QAction *action ) = 0;
582 
584  virtual void removeAddLayerAction( QAction *action ) = 0;
585 
587  virtual void addPluginToDatabaseMenu( const QString &name, QAction *action ) = 0;
588 
590  virtual void removePluginDatabaseMenu( const QString &name, QAction *action ) = 0;
591 
593  virtual void addPluginToRasterMenu( const QString &name, QAction *action ) = 0;
594 
596  virtual void removePluginRasterMenu( const QString &name, QAction *action ) = 0;
597 
599  virtual void addPluginToVectorMenu( const QString &name, QAction *action ) = 0;
600 
602  virtual void removePluginVectorMenu( const QString &name, QAction *action ) = 0;
603 
605  virtual void addPluginToWebMenu( const QString &name, QAction *action ) = 0;
606 
608  virtual void removePluginWebMenu( const QString &name, QAction *action ) = 0;
609 
611  virtual void addDockWidget( Qt::DockWidgetArea area, QDockWidget *dockwidget ) = 0;
612 
614  virtual void removeDockWidget( QDockWidget *dockwidget ) = 0;
615 
617  virtual void showLayerProperties( QgsMapLayer *l ) = 0;
618 
620  virtual QDialog *showAttributeTable( QgsVectorLayer *l, const QString &filterExpression = QString() ) = 0;
621 
625  virtual void addWindow( QAction *action ) = 0;
626 
630  virtual void removeWindow( QAction *action ) = 0;
631 
633  virtual bool registerMainWindowAction( QAction *action, const QString &defaultShortcut ) = 0;
634 
636  virtual bool unregisterMainWindowAction( QAction *action ) = 0;
637 
644  virtual void registerMapLayerConfigWidgetFactory( QgsMapLayerConfigWidgetFactory *factory ) = 0;
645 
651  virtual void unregisterMapLayerConfigWidgetFactory( QgsMapLayerConfigWidgetFactory *factory ) = 0;
652 
659  virtual void registerOptionsWidgetFactory( QgsOptionsWidgetFactory *factory ) = 0;
660 
666  virtual void unregisterOptionsWidgetFactory( QgsOptionsWidgetFactory *factory ) = 0;
667 
674  virtual void registerCustomDropHandler( QgsCustomDropHandler *handler ) = 0;
675 
680  virtual void unregisterCustomDropHandler( QgsCustomDropHandler *handler ) = 0;
681 
682  // @todo is this deprecated in favour of QgsContextHelp?
683 
693 #ifndef Q_MOC_RUN
694  Q_DECL_DEPRECATED
695 #endif
696  virtual void openURL( const QString &url, bool useQgisDocDirectory = true ) = 0 SIP_DEPRECATED;
697 
705  virtual bool openFeatureForm( QgsVectorLayer *l, QgsFeature &f, bool updateFeatureOnly = false, bool showModal = true ) = 0;
706 
715  virtual QgsAttributeDialog *getFeatureForm( QgsVectorLayer *l, QgsFeature &f ) = 0;
716 
729  virtual void preloadForm( const QString &uifile ) = 0;
730 
739  virtual void registerLocatorFilter( QgsLocatorFilter *filter SIP_TRANSFER ) = 0;
740 
751  virtual void deregisterLocatorFilter( QgsLocatorFilter *filter ) = 0;
752 
753  signals:
754 
759  void currentLayerChanged( QgsMapLayer *layer );
760 
766  void currentThemeChanged( const QString &theme );
767 
773  void composerOpened( QgsComposerInterface *composer );
774 
782  void composerWillBeClosed( QgsComposerInterface *composer );
783 
790  void composerClosed( QgsComposerInterface *composer );
791 
797  void layoutDesignerOpened( QgsLayoutDesignerInterface *designer );
798 
806  void layoutDesignerWillBeClosed( QgsLayoutDesignerInterface *designer );
807 
814  void layoutDesignerClosed();
815 
819  void initializationCompleted();
820 
828  void projectRead();
829 
839  void newProjectCreated();
840 
846  void layerSavedAs( QgsMapLayer *l, const QString &path );
847 
848 };
850 
851 #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:480
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:40
#define SIP_DEPRECATED
Definition: qgis_sip.h:99
Graphics scene for map printing.
A common interface for composer dialogs.
QgisInterface Abstract base class defining interfaces exposed by QgisApp and made available to plugin...
Definition: qgisinterface.h:74
#define Q_NOWARN_DEPRECATED_POP
Definition: qgis.h:481
A factory class for creating custom options pages.
This class has all the configuration of snapping and can return answers to snapping queries...
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