QGIS API Documentation  2.99.0-Master (9caa722)
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 
73 class GUI_EXPORT QgisInterface : public QObject
74 {
75  Q_OBJECT
76 
77  public:
78 
80  QgisInterface() = default;
81 
82  virtual QgsPluginManagerInterface *pluginManagerInterface() = 0;
83 
84  virtual QgsLayerTreeView *layerTreeView() = 0;
85 
97  virtual void addCustomActionForLayerType( QAction *action, QString menu,
98  QgsMapLayer::LayerType type, bool allLayers ) = 0;
99 
105  virtual void addCustomActionForLayer( QAction *action, QgsMapLayer *layer ) = 0;
106 
110  virtual bool removeCustomActionForLayerType( QAction *action ) = 0;
111 
116  virtual QList< QgsMapCanvas * > mapCanvases() = 0;
117 
123  virtual QgsMapCanvas *createNewMapCanvas( const QString &name ) = 0;
124 
130  virtual void closeMapCanvas( const QString &name ) = 0;
131 
136  virtual QSize iconSize( bool dockedToolbar = false ) const = 0;
137 
138  public slots: // TODO: do these functions really need to be slots?
139 
140  /* Exposed functions */
141 
143  virtual void zoomFull() = 0;
144 
146  virtual void zoomToPrevious() = 0;
147 
149  virtual void zoomToNext() = 0;
150 
152  virtual void zoomToActiveLayer() = 0;
153 
155  virtual QgsVectorLayer *addVectorLayer( const QString &vectorLayerPath, const QString &baseName, const QString &providerKey ) = 0;
156 
158  virtual QgsRasterLayer *addRasterLayer( const QString &rasterLayerPath, const QString &baseName = QString() ) = 0;
159 
161  virtual QgsRasterLayer *addRasterLayer( const QString &url, const QString &layerName, const QString &providerKey ) = 0;
162 
164  virtual bool addProject( const QString &project ) = 0;
166  virtual void newProject( bool promptToSaveFlag = false ) = 0;
167 
175  virtual void reloadConnections( ) = 0;
176 
178  virtual QgsMapLayer *activeLayer() = 0;
179 
182  virtual bool setActiveLayer( QgsMapLayer * ) = 0;
183 
185  virtual int addToolBarIcon( QAction *qAction ) = 0;
186 
195  virtual QAction *addToolBarWidget( QWidget *widget SIP_TRANSFER ) = 0;
196 
198  virtual void removeToolBarIcon( QAction *qAction ) = 0;
199 
208  virtual QAction *addRasterToolBarWidget( QWidget *widget SIP_TRANSFER ) = 0;
209 
211  virtual int addRasterToolBarIcon( QAction *qAction ) = 0;
212 
214  virtual void removeRasterToolBarIcon( QAction *qAction ) = 0;
215 
217  virtual int addVectorToolBarIcon( QAction *qAction ) = 0;
218 
227  virtual QAction *addVectorToolBarWidget( QWidget *widget SIP_TRANSFER ) = 0;
228 
230  virtual void removeVectorToolBarIcon( QAction *qAction ) = 0;
231 
233  virtual int addDatabaseToolBarIcon( QAction *qAction ) = 0;
234 
243  virtual QAction *addDatabaseToolBarWidget( QWidget *widget SIP_TRANSFER ) = 0;
244 
246  virtual void removeDatabaseToolBarIcon( QAction *qAction ) = 0;
247 
249  virtual int addWebToolBarIcon( QAction *qAction ) = 0;
250 
259  virtual QAction *addWebToolBarWidget( QWidget *widget SIP_TRANSFER ) = 0;
260 
262  virtual void removeWebToolBarIcon( QAction *qAction ) = 0;
263 
265  virtual QToolBar *addToolBar( const QString &name ) = 0 SIP_FACTORY;
266 
269  virtual void addToolBar( QToolBar *toolbar SIP_TRANSFER, Qt::ToolBarArea area = Qt::TopToolBarArea ) = 0;
270 
272  virtual QgsMapCanvas *mapCanvas() = 0;
273 
279  virtual QgsLayerTreeMapCanvasBridge *layerTreeCanvasBridge() = 0;
280 
282  virtual QWidget *mainWindow() = 0;
283 
285  virtual QgsMessageBar *messageBar() = 0;
286 
288  virtual void openMessageLog() = 0;
289 
291  virtual void addUserInputWidget( QWidget *widget ) = 0;
292 
297  virtual QList<QgsComposerInterface *> openComposers() = 0;
298 
306  virtual QgsComposerInterface *openComposer( QgsComposition *composition ) = 0;
307 
314  virtual void closeComposer( QgsComposition *composition ) = 0;
315 
320  virtual QList<QgsLayoutDesignerInterface *> openLayoutDesigners() = 0;
321 
329  virtual QgsLayoutDesignerInterface *openLayoutDesigner( QgsLayout *layout ) = 0;
330 
336  virtual void showOptionsDialog( QWidget *parent = nullptr, const QString &currentPage = QString() ) = 0;
337 
339  virtual QMap<QString, QVariant> defaultStyleSheetOptions() = 0;
340 
344  virtual void buildStyleSheet( const QMap<QString, QVariant> &opts ) = 0;
345 
347  virtual void saveStyleSheetOptions( const QMap<QString, QVariant> &opts ) = 0;
348 
350  virtual QFont defaultStyleSheetFont() = 0;
351 
353  virtual void addPluginToMenu( const QString &name, QAction *action ) = 0;
354 
356  virtual void removePluginMenu( const QString &name, QAction *action ) = 0;
357 
359  virtual void insertAddLayerAction( QAction *action ) = 0;
360 
362  virtual void removeAddLayerAction( QAction *action ) = 0;
363 
365  virtual void addPluginToDatabaseMenu( const QString &name, QAction *action ) = 0;
366 
368  virtual void removePluginDatabaseMenu( const QString &name, QAction *action ) = 0;
369 
371  virtual void addPluginToRasterMenu( const QString &name, QAction *action ) = 0;
372 
374  virtual void removePluginRasterMenu( const QString &name, QAction *action ) = 0;
375 
377  virtual void addPluginToVectorMenu( const QString &name, QAction *action ) = 0;
378 
380  virtual void removePluginVectorMenu( const QString &name, QAction *action ) = 0;
381 
383  virtual void addPluginToWebMenu( const QString &name, QAction *action ) = 0;
384 
386  virtual void removePluginWebMenu( const QString &name, QAction *action ) = 0;
387 
389  virtual void addDockWidget( Qt::DockWidgetArea area, QDockWidget *dockwidget ) = 0;
390 
392  virtual void removeDockWidget( QDockWidget *dockwidget ) = 0;
393 
397  virtual QgsAdvancedDigitizingDockWidget *cadDockWidget() = 0;
398 
400  virtual void showLayerProperties( QgsMapLayer *l ) = 0;
401 
403  virtual QDialog *showAttributeTable( QgsVectorLayer *l, const QString &filterExpression = QString() ) = 0;
404 
407  virtual void addWindow( QAction *action ) = 0;
408 
411  virtual void removeWindow( QAction *action ) = 0;
412 
414  virtual bool registerMainWindowAction( QAction *action, const QString &defaultShortcut ) = 0;
415 
417  virtual bool unregisterMainWindowAction( QAction *action ) = 0;
418 
424  virtual void registerMapLayerConfigWidgetFactory( QgsMapLayerConfigWidgetFactory *factory ) = 0;
425 
430  virtual void unregisterMapLayerConfigWidgetFactory( QgsMapLayerConfigWidgetFactory *factory ) = 0;
431 
437  virtual void registerOptionsWidgetFactory( QgsOptionsWidgetFactory *factory ) = 0;
438 
443  virtual void unregisterOptionsWidgetFactory( QgsOptionsWidgetFactory *factory ) = 0;
444 
450  virtual void registerCustomDropHandler( QgsCustomDropHandler *handler ) = 0;
451 
455  virtual void unregisterCustomDropHandler( QgsCustomDropHandler *handler ) = 0;
456 
457  // @todo is this deprecated in favour of QgsContextHelp?
458 
467 #ifndef Q_MOC_RUN
468  Q_DECL_DEPRECATED
469 #endif
470  virtual void openURL( const QString &url, bool useQgisDocDirectory = true ) = 0 SIP_DEPRECATED;
471 
476  // Menus
477  virtual QMenu *projectMenu() = 0;
478  virtual QMenu *editMenu() = 0;
479  virtual QMenu *viewMenu() = 0;
480  virtual QMenu *layerMenu() = 0;
481  virtual QMenu *newLayerMenu() = 0;
483  virtual QMenu *addLayerMenu() = 0;
484  virtual QMenu *settingsMenu() = 0;
485  virtual QMenu *pluginMenu() = 0;
486  virtual QMenu *rasterMenu() = 0;
487  virtual QMenu *databaseMenu() = 0;
488  virtual QMenu *vectorMenu() = 0;
489  virtual QMenu *webMenu() = 0;
490  virtual QMenu *firstRightStandardMenu() = 0;
491  virtual QMenu *windowMenu() = 0;
492  virtual QMenu *helpMenu() = 0;
493 
494  // ToolBars
495  virtual QToolBar *fileToolBar() = 0;
496  virtual QToolBar *layerToolBar() = 0;
497  virtual QToolBar *mapNavToolToolBar() = 0;
498  virtual QToolBar *digitizeToolBar() = 0;
499  virtual QToolBar *advancedDigitizeToolBar() = 0;
500  virtual QToolBar *attributesToolBar() = 0;
501  virtual QToolBar *pluginToolBar() = 0;
502  virtual QToolBar *helpToolBar() = 0;
503  virtual QToolBar *rasterToolBar() = 0;
504  virtual QToolBar *vectorToolBar() = 0;
505  virtual QToolBar *databaseToolBar() = 0;
506  virtual QToolBar *webToolBar() = 0;
507 
508  // Project menu actions
509  virtual QAction *actionNewProject() = 0;
510  virtual QAction *actionOpenProject() = 0;
511  virtual QAction *actionSaveProject() = 0;
512  virtual QAction *actionSaveProjectAs() = 0;
513  virtual QAction *actionSaveMapAsImage() = 0;
514  virtual QAction *actionProjectProperties() = 0;
515  virtual QAction *actionPrintComposer() = 0;
516  virtual QAction *actionShowComposerManager() = 0;
517  virtual QAction *actionExit() = 0;
518 
519  // Edit menu actions
520  virtual QAction *actionCutFeatures() = 0;
521  virtual QAction *actionCopyFeatures() = 0;
522  virtual QAction *actionPasteFeatures() = 0;
523  virtual QAction *actionAddFeature() = 0;
524  virtual QAction *actionDeleteSelected() = 0;
525  virtual QAction *actionMoveFeature() = 0;
526  virtual QAction *actionSplitFeatures() = 0;
527  virtual QAction *actionSplitParts() = 0;
528  virtual QAction *actionAddRing() = 0;
529  virtual QAction *actionAddPart() = 0;
530  virtual QAction *actionSimplifyFeature() = 0;
531  virtual QAction *actionDeleteRing() = 0;
532  virtual QAction *actionDeletePart() = 0;
533  virtual QAction *actionNodeTool() = 0;
534 
535  // View menu actions
537  virtual QAction *actionPan() = 0;
539  virtual QAction *actionPanToSelected() = 0;
541  virtual QAction *actionZoomIn() = 0;
543  virtual QAction *actionZoomOut() = 0;
545  virtual QAction *actionSelect() = 0;
547  virtual QAction *actionSelectRectangle() = 0;
549  virtual QAction *actionSelectPolygon() = 0;
551  virtual QAction *actionSelectFreehand() = 0;
553  virtual QAction *actionSelectRadius() = 0;
555  virtual QAction *actionIdentify() = 0;
557  virtual QAction *actionFeatureAction() = 0;
559  virtual QAction *actionMeasure() = 0;
561  virtual QAction *actionMeasureArea() = 0;
563  virtual QAction *actionZoomFullExtent() = 0;
565  virtual QAction *actionZoomToLayer() = 0;
567  virtual QAction *actionZoomToSelected() = 0;
569  virtual QAction *actionZoomLast() = 0;
571  virtual QAction *actionZoomNext() = 0;
573  virtual QAction *actionZoomActualSize() = 0;
575  virtual QAction *actionMapTips() = 0;
577  virtual QAction *actionNewBookmark() = 0;
579  virtual QAction *actionShowBookmarks() = 0;
581  virtual QAction *actionDraw() = 0;
582 
583  // Layer menu actions
584  virtual QAction *actionNewVectorLayer() = 0;
585  virtual QAction *actionAddOgrLayer() = 0;
586  virtual QAction *actionAddRasterLayer() = 0;
587  virtual QAction *actionAddPgLayer() = 0;
588  virtual QAction *actionAddWmsLayer() = 0;
590  virtual QAction *actionAddAfsLayer() = 0;
592  virtual QAction *actionAddAmsLayer() = 0;
593  virtual QAction *actionCopyLayerStyle() = 0;
594  virtual QAction *actionPasteLayerStyle() = 0;
595  virtual QAction *actionOpenTable() = 0;
596  virtual QAction *actionOpenFieldCalculator() = 0;
597  virtual QAction *actionToggleEditing() = 0;
598  virtual QAction *actionSaveActiveLayerEdits() = 0;
599  virtual QAction *actionAllEdits() = 0;
600  virtual QAction *actionSaveEdits() = 0;
601  virtual QAction *actionSaveAllEdits() = 0;
602  virtual QAction *actionRollbackEdits() = 0;
603  virtual QAction *actionRollbackAllEdits() = 0;
604  virtual QAction *actionCancelEdits() = 0;
605  virtual QAction *actionCancelAllEdits() = 0;
606  virtual QAction *actionLayerSaveAs() = 0;
607  virtual QAction *actionDuplicateLayer() = 0;
608  virtual QAction *actionLayerProperties() = 0;
609  virtual QAction *actionAddToOverview() = 0;
610  virtual QAction *actionAddAllToOverview() = 0;
611  virtual QAction *actionRemoveAllFromOverview() = 0;
612  virtual QAction *actionHideAllLayers() = 0;
613  virtual QAction *actionShowAllLayers() = 0;
614  virtual QAction *actionHideSelectedLayers() = 0;
615 
620  virtual QAction *actionHideDeselectedLayers() = 0;
621  virtual QAction *actionShowSelectedLayers() = 0;
622 
623  // Plugin menu actions
624  virtual QAction *actionManagePlugins() = 0;
625  virtual QAction *actionPluginListSeparator() = 0;
626  virtual QAction *actionShowPythonDialog() = 0;
627 
628  // Settings menu actions
629  virtual QAction *actionToggleFullScreen() = 0;
630  virtual QAction *actionOptions() = 0;
631  virtual QAction *actionCustomProjection() = 0;
632 
633  // Help menu actions
634  virtual QAction *actionHelpContents() = 0;
635  virtual QAction *actionQgisHomePage() = 0;
636  virtual QAction *actionCheckQgisVersion() = 0;
637  virtual QAction *actionAbout() = 0;
638 
646  virtual bool openFeatureForm( QgsVectorLayer *l, QgsFeature &f, bool updateFeatureOnly = false, bool showModal = true ) = 0;
647 
656  virtual QgsAttributeDialog *getFeatureForm( QgsVectorLayer *l, QgsFeature &f ) = 0;
657 
665  virtual QgsVectorLayerTools *vectorLayerTools() = 0;
666 
678  virtual void preloadForm( const QString &uifile ) = 0;
679 
683  virtual QList<QgsMapLayer *> editableLayers( bool modified = false ) const = 0;
684 
686  virtual int messageTimeout() = 0;
687 
694  virtual QgsStatusBar *statusBarIface() = 0;
695 
704  virtual void registerLocatorFilter( QgsLocatorFilter *filter SIP_TRANSFER ) = 0;
705 
716  virtual void deregisterLocatorFilter( QgsLocatorFilter *filter ) = 0;
717 
718 
719  signals:
720 
724  void currentLayerChanged( QgsMapLayer *layer );
725 
730  void currentThemeChanged( const QString &theme );
731 
737  void composerOpened( QgsComposerInterface *composer );
738 
746  void composerWillBeClosed( QgsComposerInterface *composer );
747 
754  void composerClosed( QgsComposerInterface *composer );
755 
761  void layoutDesignerOpened( QgsLayoutDesignerInterface *designer );
762 
770  void layoutDesignerWillBeClosed( QgsLayoutDesignerInterface *designer );
771 
778  void layoutDesignerClosed();
779 
783  void initializationCompleted();
784 
791  void projectRead();
792 
801  void newProjectCreated();
802 
807  void layerSavedAs( QgsMapLayer *l, const QString &path );
808 
809 };
811 
812 #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:54
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:402
A bar for displaying non-blocking messages to the user.
Definition: qgsmessagebar.h:44
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
Definition: qgsfeature.h:61
Map canvas is a class for displaying all GIS data types on a canvas.
Definition: qgsmapcanvas.h:73
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:92
#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:37
#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:73
#define Q_NOWARN_DEPRECATED_POP
Definition: qgis.h:403
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