QGIS API Documentation  2.99.0-Master (5b186ae)
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 
72 class GUI_EXPORT QgisInterface : public QObject
73 {
74  Q_OBJECT
75 
76  public:
77 
79  QgisInterface();
80 
81  virtual QgsPluginManagerInterface *pluginManagerInterface() = 0;
82 
83  virtual QgsLayerTreeView *layerTreeView() = 0;
84 
96  virtual void addCustomActionForLayerType( QAction *action, QString menu,
97  QgsMapLayer::LayerType type, bool allLayers ) = 0;
98 
104  virtual void addCustomActionForLayer( QAction *action, QgsMapLayer *layer ) = 0;
105 
109  virtual bool removeCustomActionForLayerType( QAction *action ) = 0;
110 
115  virtual QList< QgsMapCanvas * > mapCanvases() = 0;
116 
122  virtual QgsMapCanvas *createNewMapCanvas( const QString &name ) = 0;
123 
129  virtual void closeMapCanvas( const QString &name ) = 0;
130 
131  public slots: // TODO: do these functions really need to be slots?
132 
133  /* Exposed functions */
134 
136  virtual void zoomFull() = 0;
137 
139  virtual void zoomToPrevious() = 0;
140 
142  virtual void zoomToNext() = 0;
143 
145  virtual void zoomToActiveLayer() = 0;
146 
148  virtual QgsVectorLayer *addVectorLayer( const QString &vectorLayerPath, const QString &baseName, const QString &providerKey ) = 0;
149 
151  virtual QgsRasterLayer *addRasterLayer( const QString &rasterLayerPath, const QString &baseName = QString() ) = 0;
152 
154  virtual QgsRasterLayer *addRasterLayer( const QString &url, const QString &layerName, const QString &providerKey ) = 0;
155 
157  virtual bool addProject( const QString &project ) = 0;
159  virtual void newProject( bool promptToSaveFlag = false ) = 0;
160 
162  virtual QgsMapLayer *activeLayer() = 0;
163 
166  virtual bool setActiveLayer( QgsMapLayer * ) = 0;
167 
169  virtual int addToolBarIcon( QAction *qAction ) = 0;
170 
179  virtual QAction *addToolBarWidget( QWidget *widget SIP_TRANSFER ) = 0;
180 
182  virtual void removeToolBarIcon( QAction *qAction ) = 0;
183 
192  virtual QAction *addRasterToolBarWidget( QWidget *widget SIP_TRANSFER ) = 0;
193 
195  virtual int addRasterToolBarIcon( QAction *qAction ) = 0;
196 
198  virtual void removeRasterToolBarIcon( QAction *qAction ) = 0;
199 
201  virtual int addVectorToolBarIcon( QAction *qAction ) = 0;
202 
211  virtual QAction *addVectorToolBarWidget( QWidget *widget SIP_TRANSFER ) = 0;
212 
214  virtual void removeVectorToolBarIcon( QAction *qAction ) = 0;
215 
217  virtual int addDatabaseToolBarIcon( QAction *qAction ) = 0;
218 
227  virtual QAction *addDatabaseToolBarWidget( QWidget *widget SIP_TRANSFER ) = 0;
228 
230  virtual void removeDatabaseToolBarIcon( QAction *qAction ) = 0;
231 
233  virtual int addWebToolBarIcon( QAction *qAction ) = 0;
234 
243  virtual QAction *addWebToolBarWidget( QWidget *widget SIP_TRANSFER ) = 0;
244 
246  virtual void removeWebToolBarIcon( QAction *qAction ) = 0;
247 
249  virtual QToolBar *addToolBar( const QString &name ) = 0 SIP_FACTORY;
250 
253  virtual void addToolBar( QToolBar *toolbar SIP_TRANSFER, Qt::ToolBarArea area = Qt::TopToolBarArea ) = 0;
254 
256  virtual QgsMapCanvas *mapCanvas() = 0;
257 
263  virtual QgsLayerTreeMapCanvasBridge *layerTreeCanvasBridge() = 0;
264 
266  virtual QWidget *mainWindow() = 0;
267 
269  virtual QgsMessageBar *messageBar() = 0;
270 
272  virtual void openMessageLog() = 0;
273 
275  virtual void addUserInputWidget( QWidget *widget ) = 0;
276 
281  virtual QList<QgsComposerInterface *> openComposers() = 0;
282 
290  virtual QgsComposerInterface *openComposer( QgsComposition *composition ) = 0;
291 
298  virtual void closeComposer( QgsComposition *composition ) = 0;
299 
304  virtual QList<QgsLayoutDesignerInterface *> openLayoutDesigners() = 0;
305 
313  virtual QgsLayoutDesignerInterface *openLayoutDesigner( QgsLayout *layout ) = 0;
314 
320  virtual void showOptionsDialog( QWidget *parent = nullptr, const QString &currentPage = QString() ) = 0;
321 
323  virtual QMap<QString, QVariant> defaultStyleSheetOptions() = 0;
324 
328  virtual void buildStyleSheet( const QMap<QString, QVariant> &opts ) = 0;
329 
331  virtual void saveStyleSheetOptions( const QMap<QString, QVariant> &opts ) = 0;
332 
334  virtual QFont defaultStyleSheetFont() = 0;
335 
337  virtual void addPluginToMenu( const QString &name, QAction *action ) = 0;
338 
340  virtual void removePluginMenu( const QString &name, QAction *action ) = 0;
341 
343  virtual void insertAddLayerAction( QAction *action ) = 0;
344 
346  virtual void removeAddLayerAction( QAction *action ) = 0;
347 
349  virtual void addPluginToDatabaseMenu( const QString &name, QAction *action ) = 0;
350 
352  virtual void removePluginDatabaseMenu( const QString &name, QAction *action ) = 0;
353 
355  virtual void addPluginToRasterMenu( const QString &name, QAction *action ) = 0;
356 
358  virtual void removePluginRasterMenu( const QString &name, QAction *action ) = 0;
359 
361  virtual void addPluginToVectorMenu( const QString &name, QAction *action ) = 0;
362 
364  virtual void removePluginVectorMenu( const QString &name, QAction *action ) = 0;
365 
367  virtual void addPluginToWebMenu( const QString &name, QAction *action ) = 0;
368 
370  virtual void removePluginWebMenu( const QString &name, QAction *action ) = 0;
371 
373  virtual void addDockWidget( Qt::DockWidgetArea area, QDockWidget *dockwidget ) = 0;
374 
376  virtual void removeDockWidget( QDockWidget *dockwidget ) = 0;
377 
381  virtual QgsAdvancedDigitizingDockWidget *cadDockWidget() = 0;
382 
384  virtual void showLayerProperties( QgsMapLayer *l ) = 0;
385 
387  virtual QDialog *showAttributeTable( QgsVectorLayer *l, const QString &filterExpression = QString() ) = 0;
388 
391  virtual void addWindow( QAction *action ) = 0;
392 
395  virtual void removeWindow( QAction *action ) = 0;
396 
398  virtual bool registerMainWindowAction( QAction *action, const QString &defaultShortcut ) = 0;
399 
401  virtual bool unregisterMainWindowAction( QAction *action ) = 0;
402 
408  virtual void registerMapLayerConfigWidgetFactory( QgsMapLayerConfigWidgetFactory *factory ) = 0;
409 
414  virtual void unregisterMapLayerConfigWidgetFactory( QgsMapLayerConfigWidgetFactory *factory ) = 0;
415 
421  virtual void registerOptionsWidgetFactory( QgsOptionsWidgetFactory *factory ) = 0;
422 
427  virtual void unregisterOptionsWidgetFactory( QgsOptionsWidgetFactory *factory ) = 0;
428 
434  virtual void registerCustomDropHandler( QgsCustomDropHandler *handler ) = 0;
435 
439  virtual void unregisterCustomDropHandler( QgsCustomDropHandler *handler ) = 0;
440 
441  // @todo is this deprecated in favour of QgsContextHelp?
442 
451 #ifndef Q_MOC_RUN
452  Q_DECL_DEPRECATED
453 #endif
454  virtual void openURL( const QString &url, bool useQgisDocDirectory = true ) = 0 SIP_DEPRECATED;
455 
456 
461  // Menus
462  virtual QMenu *projectMenu() = 0;
463  virtual QMenu *editMenu() = 0;
464  virtual QMenu *viewMenu() = 0;
465  virtual QMenu *layerMenu() = 0;
466  virtual QMenu *newLayerMenu() = 0;
468  virtual QMenu *addLayerMenu() = 0;
469  virtual QMenu *settingsMenu() = 0;
470  virtual QMenu *pluginMenu() = 0;
471  virtual QMenu *rasterMenu() = 0;
472  virtual QMenu *databaseMenu() = 0;
473  virtual QMenu *vectorMenu() = 0;
474  virtual QMenu *webMenu() = 0;
475  virtual QMenu *firstRightStandardMenu() = 0;
476  virtual QMenu *windowMenu() = 0;
477  virtual QMenu *helpMenu() = 0;
478 
479  // ToolBars
480  virtual QToolBar *fileToolBar() = 0;
481  virtual QToolBar *layerToolBar() = 0;
482  virtual QToolBar *mapNavToolToolBar() = 0;
483  virtual QToolBar *digitizeToolBar() = 0;
484  virtual QToolBar *advancedDigitizeToolBar() = 0;
485  virtual QToolBar *attributesToolBar() = 0;
486  virtual QToolBar *pluginToolBar() = 0;
487  virtual QToolBar *helpToolBar() = 0;
488  virtual QToolBar *rasterToolBar() = 0;
489  virtual QToolBar *vectorToolBar() = 0;
490  virtual QToolBar *databaseToolBar() = 0;
491  virtual QToolBar *webToolBar() = 0;
492 
493  // Project menu actions
494  virtual QAction *actionNewProject() = 0;
495  virtual QAction *actionOpenProject() = 0;
496  virtual QAction *actionSaveProject() = 0;
497  virtual QAction *actionSaveProjectAs() = 0;
498  virtual QAction *actionSaveMapAsImage() = 0;
499  virtual QAction *actionProjectProperties() = 0;
500  virtual QAction *actionPrintComposer() = 0;
501  virtual QAction *actionShowComposerManager() = 0;
502  virtual QAction *actionExit() = 0;
503 
504  // Edit menu actions
505  virtual QAction *actionCutFeatures() = 0;
506  virtual QAction *actionCopyFeatures() = 0;
507  virtual QAction *actionPasteFeatures() = 0;
508  virtual QAction *actionAddFeature() = 0;
509  virtual QAction *actionDeleteSelected() = 0;
510  virtual QAction *actionMoveFeature() = 0;
511  virtual QAction *actionSplitFeatures() = 0;
512  virtual QAction *actionSplitParts() = 0;
513  virtual QAction *actionAddRing() = 0;
514  virtual QAction *actionAddPart() = 0;
515  virtual QAction *actionSimplifyFeature() = 0;
516  virtual QAction *actionDeleteRing() = 0;
517  virtual QAction *actionDeletePart() = 0;
518  virtual QAction *actionNodeTool() = 0;
519 
520  // View menu actions
522  virtual QAction *actionPan() = 0;
524  virtual QAction *actionPanToSelected() = 0;
526  virtual QAction *actionZoomIn() = 0;
528  virtual QAction *actionZoomOut() = 0;
530  virtual QAction *actionSelect() = 0;
532  virtual QAction *actionSelectRectangle() = 0;
534  virtual QAction *actionSelectPolygon() = 0;
536  virtual QAction *actionSelectFreehand() = 0;
538  virtual QAction *actionSelectRadius() = 0;
540  virtual QAction *actionIdentify() = 0;
542  virtual QAction *actionFeatureAction() = 0;
544  virtual QAction *actionMeasure() = 0;
546  virtual QAction *actionMeasureArea() = 0;
548  virtual QAction *actionZoomFullExtent() = 0;
550  virtual QAction *actionZoomToLayer() = 0;
552  virtual QAction *actionZoomToSelected() = 0;
554  virtual QAction *actionZoomLast() = 0;
556  virtual QAction *actionZoomNext() = 0;
558  virtual QAction *actionZoomActualSize() = 0;
560  virtual QAction *actionMapTips() = 0;
562  virtual QAction *actionNewBookmark() = 0;
564  virtual QAction *actionShowBookmarks() = 0;
566  virtual QAction *actionDraw() = 0;
567 
568  // Layer menu actions
569  virtual QAction *actionNewVectorLayer() = 0;
570  virtual QAction *actionAddOgrLayer() = 0;
571  virtual QAction *actionAddRasterLayer() = 0;
572  virtual QAction *actionAddPgLayer() = 0;
573  virtual QAction *actionAddWmsLayer() = 0;
575  virtual QAction *actionAddAfsLayer() = 0;
577  virtual QAction *actionAddAmsLayer() = 0;
578  virtual QAction *actionCopyLayerStyle() = 0;
579  virtual QAction *actionPasteLayerStyle() = 0;
580  virtual QAction *actionOpenTable() = 0;
581  virtual QAction *actionOpenFieldCalculator() = 0;
582  virtual QAction *actionToggleEditing() = 0;
583  virtual QAction *actionSaveActiveLayerEdits() = 0;
584  virtual QAction *actionAllEdits() = 0;
585  virtual QAction *actionSaveEdits() = 0;
586  virtual QAction *actionSaveAllEdits() = 0;
587  virtual QAction *actionRollbackEdits() = 0;
588  virtual QAction *actionRollbackAllEdits() = 0;
589  virtual QAction *actionCancelEdits() = 0;
590  virtual QAction *actionCancelAllEdits() = 0;
591  virtual QAction *actionLayerSaveAs() = 0;
592  virtual QAction *actionDuplicateLayer() = 0;
593  virtual QAction *actionLayerProperties() = 0;
594  virtual QAction *actionAddToOverview() = 0;
595  virtual QAction *actionAddAllToOverview() = 0;
596  virtual QAction *actionRemoveAllFromOverview() = 0;
597  virtual QAction *actionHideAllLayers() = 0;
598  virtual QAction *actionShowAllLayers() = 0;
599  virtual QAction *actionHideSelectedLayers() = 0;
600 
605  virtual QAction *actionHideDeselectedLayers() = 0;
606  virtual QAction *actionShowSelectedLayers() = 0;
607 
608  // Plugin menu actions
609  virtual QAction *actionManagePlugins() = 0;
610  virtual QAction *actionPluginListSeparator() = 0;
611  virtual QAction *actionShowPythonDialog() = 0;
612 
613  // Settings menu actions
614  virtual QAction *actionToggleFullScreen() = 0;
615  virtual QAction *actionOptions() = 0;
616  virtual QAction *actionCustomProjection() = 0;
617 
618  // Help menu actions
619  virtual QAction *actionHelpContents() = 0;
620  virtual QAction *actionQgisHomePage() = 0;
621  virtual QAction *actionCheckQgisVersion() = 0;
622  virtual QAction *actionAbout() = 0;
623 
631  virtual bool openFeatureForm( QgsVectorLayer *l, QgsFeature &f, bool updateFeatureOnly = false, bool showModal = true ) = 0;
632 
641  virtual QgsAttributeDialog *getFeatureForm( QgsVectorLayer *l, QgsFeature &f ) = 0;
642 
650  virtual QgsVectorLayerTools *vectorLayerTools() = 0;
651 
663  virtual void preloadForm( const QString &uifile ) = 0;
664 
668  virtual QList<QgsMapLayer *> editableLayers( bool modified = false ) const = 0;
669 
671  virtual int messageTimeout() = 0;
672 
679  virtual QgsStatusBar *statusBarIface() = 0;
680 
689  virtual void registerLocatorFilter( QgsLocatorFilter *filter SIP_TRANSFER ) = 0;
690 
701  virtual void deregisterLocatorFilter( QgsLocatorFilter *filter ) = 0;
702 
703 
704  signals:
705 
709  void currentLayerChanged( QgsMapLayer *layer );
710 
715  void currentThemeChanged( const QString &theme );
716 
722  void composerOpened( QgsComposerInterface *composer );
723 
731  void composerWillBeClosed( QgsComposerInterface *composer );
732 
739  void composerClosed( QgsComposerInterface *composer );
740 
746  void layoutDesignerOpened( QgsLayoutDesignerInterface *designer );
747 
755  void layoutDesignerWillBeClosed( QgsLayoutDesignerInterface *designer );
756 
763  void layoutDesignerClosed();
764 
768  void initializationCompleted();
769 
776  void projectRead();
777 
786  void newProjectCreated();
787 
792  void layerSavedAs( QgsMapLayer *l, const QString &path );
793 };
794 
795 #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.
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:28
#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:72
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