QGIS API Documentation  2.99.0-Master (13a3f2f)
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 QgsMapCanvas;
36 class QgsMapLayer;
38 class QgsMessageBar;
40 class QgsRasterLayer;
41 class QgsSnappingUtils;
42 class QgsVectorLayer;
45 class QgsLocatorFilter;
46 class QgsStatusBar;
47 
48 #include <QObject>
49 #include <QFont>
50 #include <QPair>
51 #include <map>
52 
53 #include "qgis.h"
54 #include "qgsmaplayer.h"
55 #include "qgis_gui.h"
56 
57 
70 class GUI_EXPORT QgisInterface : public QObject
71 {
72  Q_OBJECT
73 
74  public:
75 
77  QgisInterface();
78 
79  virtual QgsPluginManagerInterface *pluginManagerInterface() = 0;
80 
81  virtual QgsLayerTreeView *layerTreeView() = 0;
82 
94  virtual void addCustomActionForLayerType( QAction *action, QString menu,
95  QgsMapLayer::LayerType type, bool allLayers ) = 0;
96 
102  virtual void addCustomActionForLayer( QAction *action, QgsMapLayer *layer ) = 0;
103 
107  virtual bool removeCustomActionForLayerType( QAction *action ) = 0;
108 
113  virtual QList< QgsMapCanvas * > mapCanvases() = 0;
114 
120  virtual QgsMapCanvas *createNewMapCanvas( const QString &name ) = 0;
121 
127  virtual void closeMapCanvas( const QString &name ) = 0;
128 
129  public slots: // TODO: do these functions really need to be slots?
130 
131  /* Exposed functions */
132 
134  virtual void zoomFull() = 0;
135 
137  virtual void zoomToPrevious() = 0;
138 
140  virtual void zoomToNext() = 0;
141 
143  virtual void zoomToActiveLayer() = 0;
144 
146  virtual QgsVectorLayer *addVectorLayer( const QString &vectorLayerPath, const QString &baseName, const QString &providerKey ) = 0;
147 
149  virtual QgsRasterLayer *addRasterLayer( const QString &rasterLayerPath, const QString &baseName = QString() ) = 0;
150 
152  virtual QgsRasterLayer *addRasterLayer( const QString &url, const QString &layerName, const QString &providerKey ) = 0;
153 
155  virtual bool addProject( const QString &project ) = 0;
157  virtual void newProject( bool promptToSaveFlag = false ) = 0;
158 
160  virtual QgsMapLayer *activeLayer() = 0;
161 
164  virtual bool setActiveLayer( QgsMapLayer * ) = 0;
165 
167  virtual int addToolBarIcon( QAction *qAction ) = 0;
168 
177  virtual QAction *addToolBarWidget( QWidget *widget SIP_TRANSFER ) = 0;
178 
180  virtual void removeToolBarIcon( QAction *qAction ) = 0;
181 
190  virtual QAction *addRasterToolBarWidget( QWidget *widget SIP_TRANSFER ) = 0;
191 
193  virtual int addRasterToolBarIcon( QAction *qAction ) = 0;
194 
196  virtual void removeRasterToolBarIcon( QAction *qAction ) = 0;
197 
199  virtual int addVectorToolBarIcon( QAction *qAction ) = 0;
200 
209  virtual QAction *addVectorToolBarWidget( QWidget *widget SIP_TRANSFER ) = 0;
210 
212  virtual void removeVectorToolBarIcon( QAction *qAction ) = 0;
213 
215  virtual int addDatabaseToolBarIcon( QAction *qAction ) = 0;
216 
225  virtual QAction *addDatabaseToolBarWidget( QWidget *widget SIP_TRANSFER ) = 0;
226 
228  virtual void removeDatabaseToolBarIcon( QAction *qAction ) = 0;
229 
231  virtual int addWebToolBarIcon( QAction *qAction ) = 0;
232 
241  virtual QAction *addWebToolBarWidget( QWidget *widget SIP_TRANSFER ) = 0;
242 
244  virtual void removeWebToolBarIcon( QAction *qAction ) = 0;
245 
247  virtual QToolBar *addToolBar( const QString &name ) = 0 SIP_FACTORY;
248 
251  virtual void addToolBar( QToolBar *toolbar SIP_TRANSFER, Qt::ToolBarArea area = Qt::TopToolBarArea ) = 0;
252 
254  virtual QgsMapCanvas *mapCanvas() = 0;
255 
261  virtual QgsLayerTreeMapCanvasBridge *layerTreeCanvasBridge() = 0;
262 
264  virtual QWidget *mainWindow() = 0;
265 
267  virtual QgsMessageBar *messageBar() = 0;
268 
270  virtual void openMessageLog() = 0;
271 
273  virtual void addUserInputWidget( QWidget *widget ) = 0;
274 
279  virtual QList<QgsComposerInterface *> openComposers() = 0;
280 
288  virtual QgsComposerInterface *openComposer( QgsComposition *composition ) = 0;
289 
296  virtual void closeComposer( QgsComposition *composition ) = 0;
297 
303  virtual void showOptionsDialog( QWidget *parent = nullptr, const QString &currentPage = QString() ) = 0;
304 
306  virtual QMap<QString, QVariant> defaultStyleSheetOptions() = 0;
307 
311  virtual void buildStyleSheet( const QMap<QString, QVariant> &opts ) = 0;
312 
314  virtual void saveStyleSheetOptions( const QMap<QString, QVariant> &opts ) = 0;
315 
317  virtual QFont defaultStyleSheetFont() = 0;
318 
320  virtual void addPluginToMenu( const QString &name, QAction *action ) = 0;
321 
323  virtual void removePluginMenu( const QString &name, QAction *action ) = 0;
324 
326  virtual void insertAddLayerAction( QAction *action ) = 0;
327 
329  virtual void removeAddLayerAction( QAction *action ) = 0;
330 
332  virtual void addPluginToDatabaseMenu( const QString &name, QAction *action ) = 0;
333 
335  virtual void removePluginDatabaseMenu( const QString &name, QAction *action ) = 0;
336 
338  virtual void addPluginToRasterMenu( const QString &name, QAction *action ) = 0;
339 
341  virtual void removePluginRasterMenu( const QString &name, QAction *action ) = 0;
342 
344  virtual void addPluginToVectorMenu( const QString &name, QAction *action ) = 0;
345 
347  virtual void removePluginVectorMenu( const QString &name, QAction *action ) = 0;
348 
350  virtual void addPluginToWebMenu( const QString &name, QAction *action ) = 0;
351 
353  virtual void removePluginWebMenu( const QString &name, QAction *action ) = 0;
354 
356  virtual void addDockWidget( Qt::DockWidgetArea area, QDockWidget *dockwidget ) = 0;
357 
359  virtual void removeDockWidget( QDockWidget *dockwidget ) = 0;
360 
364  virtual QgsAdvancedDigitizingDockWidget *cadDockWidget() = 0;
365 
367  virtual void showLayerProperties( QgsMapLayer *l ) = 0;
368 
370  virtual QDialog *showAttributeTable( QgsVectorLayer *l, const QString &filterExpression = QString() ) = 0;
371 
374  virtual void addWindow( QAction *action ) = 0;
375 
378  virtual void removeWindow( QAction *action ) = 0;
379 
381  virtual bool registerMainWindowAction( QAction *action, const QString &defaultShortcut ) = 0;
382 
384  virtual bool unregisterMainWindowAction( QAction *action ) = 0;
385 
391  virtual void registerMapLayerConfigWidgetFactory( QgsMapLayerConfigWidgetFactory *factory ) = 0;
392 
397  virtual void unregisterMapLayerConfigWidgetFactory( QgsMapLayerConfigWidgetFactory *factory ) = 0;
398 
404  virtual void registerOptionsWidgetFactory( QgsOptionsWidgetFactory *factory ) = 0;
405 
410  virtual void unregisterOptionsWidgetFactory( QgsOptionsWidgetFactory *factory ) = 0;
411 
417  virtual void registerCustomDropHandler( QgsCustomDropHandler *handler ) = 0;
418 
422  virtual void unregisterCustomDropHandler( QgsCustomDropHandler *handler ) = 0;
423 
424  // @todo is this deprecated in favour of QgsContextHelp?
425 
434 #ifndef Q_MOC_RUN
435  Q_DECL_DEPRECATED
436 #endif
437  virtual void openURL( const QString &url, bool useQgisDocDirectory = true ) = 0 SIP_DEPRECATED;
438 
439 
444  // Menus
445  virtual QMenu *projectMenu() = 0;
446  virtual QMenu *editMenu() = 0;
447  virtual QMenu *viewMenu() = 0;
448  virtual QMenu *layerMenu() = 0;
449  virtual QMenu *newLayerMenu() = 0;
451  virtual QMenu *addLayerMenu() = 0;
452  virtual QMenu *settingsMenu() = 0;
453  virtual QMenu *pluginMenu() = 0;
454  virtual QMenu *rasterMenu() = 0;
455  virtual QMenu *databaseMenu() = 0;
456  virtual QMenu *vectorMenu() = 0;
457  virtual QMenu *webMenu() = 0;
458  virtual QMenu *firstRightStandardMenu() = 0;
459  virtual QMenu *windowMenu() = 0;
460  virtual QMenu *helpMenu() = 0;
461 
462  // ToolBars
463  virtual QToolBar *fileToolBar() = 0;
464  virtual QToolBar *layerToolBar() = 0;
465  virtual QToolBar *mapNavToolToolBar() = 0;
466  virtual QToolBar *digitizeToolBar() = 0;
467  virtual QToolBar *advancedDigitizeToolBar() = 0;
468  virtual QToolBar *attributesToolBar() = 0;
469  virtual QToolBar *pluginToolBar() = 0;
470  virtual QToolBar *helpToolBar() = 0;
471  virtual QToolBar *rasterToolBar() = 0;
472  virtual QToolBar *vectorToolBar() = 0;
473  virtual QToolBar *databaseToolBar() = 0;
474  virtual QToolBar *webToolBar() = 0;
475 
476  // Project menu actions
477  virtual QAction *actionNewProject() = 0;
478  virtual QAction *actionOpenProject() = 0;
479  virtual QAction *actionSaveProject() = 0;
480  virtual QAction *actionSaveProjectAs() = 0;
481  virtual QAction *actionSaveMapAsImage() = 0;
482  virtual QAction *actionProjectProperties() = 0;
483  virtual QAction *actionPrintComposer() = 0;
484  virtual QAction *actionShowComposerManager() = 0;
485  virtual QAction *actionExit() = 0;
486 
487  // Edit menu actions
488  virtual QAction *actionCutFeatures() = 0;
489  virtual QAction *actionCopyFeatures() = 0;
490  virtual QAction *actionPasteFeatures() = 0;
491  virtual QAction *actionAddFeature() = 0;
492  virtual QAction *actionDeleteSelected() = 0;
493  virtual QAction *actionMoveFeature() = 0;
494  virtual QAction *actionSplitFeatures() = 0;
495  virtual QAction *actionSplitParts() = 0;
496  virtual QAction *actionAddRing() = 0;
497  virtual QAction *actionAddPart() = 0;
498  virtual QAction *actionSimplifyFeature() = 0;
499  virtual QAction *actionDeleteRing() = 0;
500  virtual QAction *actionDeletePart() = 0;
501  virtual QAction *actionNodeTool() = 0;
502 
503  // View menu actions
505  virtual QAction *actionPan() = 0;
507  virtual QAction *actionPanToSelected() = 0;
509  virtual QAction *actionZoomIn() = 0;
511  virtual QAction *actionZoomOut() = 0;
513  virtual QAction *actionSelect() = 0;
515  virtual QAction *actionSelectRectangle() = 0;
517  virtual QAction *actionSelectPolygon() = 0;
519  virtual QAction *actionSelectFreehand() = 0;
521  virtual QAction *actionSelectRadius() = 0;
523  virtual QAction *actionIdentify() = 0;
525  virtual QAction *actionFeatureAction() = 0;
527  virtual QAction *actionMeasure() = 0;
529  virtual QAction *actionMeasureArea() = 0;
531  virtual QAction *actionZoomFullExtent() = 0;
533  virtual QAction *actionZoomToLayer() = 0;
535  virtual QAction *actionZoomToSelected() = 0;
537  virtual QAction *actionZoomLast() = 0;
539  virtual QAction *actionZoomNext() = 0;
541  virtual QAction *actionZoomActualSize() = 0;
543  virtual QAction *actionMapTips() = 0;
545  virtual QAction *actionNewBookmark() = 0;
547  virtual QAction *actionShowBookmarks() = 0;
549  virtual QAction *actionDraw() = 0;
550 
551  // Layer menu actions
552  virtual QAction *actionNewVectorLayer() = 0;
553  virtual QAction *actionAddOgrLayer() = 0;
554  virtual QAction *actionAddRasterLayer() = 0;
555  virtual QAction *actionAddPgLayer() = 0;
556  virtual QAction *actionAddWmsLayer() = 0;
558  virtual QAction *actionAddAfsLayer() = 0;
560  virtual QAction *actionAddAmsLayer() = 0;
561  virtual QAction *actionCopyLayerStyle() = 0;
562  virtual QAction *actionPasteLayerStyle() = 0;
563  virtual QAction *actionOpenTable() = 0;
564  virtual QAction *actionOpenFieldCalculator() = 0;
565  virtual QAction *actionToggleEditing() = 0;
566  virtual QAction *actionSaveActiveLayerEdits() = 0;
567  virtual QAction *actionAllEdits() = 0;
568  virtual QAction *actionSaveEdits() = 0;
569  virtual QAction *actionSaveAllEdits() = 0;
570  virtual QAction *actionRollbackEdits() = 0;
571  virtual QAction *actionRollbackAllEdits() = 0;
572  virtual QAction *actionCancelEdits() = 0;
573  virtual QAction *actionCancelAllEdits() = 0;
574  virtual QAction *actionLayerSaveAs() = 0;
575  virtual QAction *actionDuplicateLayer() = 0;
576  virtual QAction *actionLayerProperties() = 0;
577  virtual QAction *actionAddToOverview() = 0;
578  virtual QAction *actionAddAllToOverview() = 0;
579  virtual QAction *actionRemoveAllFromOverview() = 0;
580  virtual QAction *actionHideAllLayers() = 0;
581  virtual QAction *actionShowAllLayers() = 0;
582  virtual QAction *actionHideSelectedLayers() = 0;
583 
588  virtual QAction *actionHideDeselectedLayers() = 0;
589  virtual QAction *actionShowSelectedLayers() = 0;
590 
591  // Plugin menu actions
592  virtual QAction *actionManagePlugins() = 0;
593  virtual QAction *actionPluginListSeparator() = 0;
594  virtual QAction *actionShowPythonDialog() = 0;
595 
596  // Settings menu actions
597  virtual QAction *actionToggleFullScreen() = 0;
598  virtual QAction *actionOptions() = 0;
599  virtual QAction *actionCustomProjection() = 0;
600 
601  // Help menu actions
602  virtual QAction *actionHelpContents() = 0;
603  virtual QAction *actionQgisHomePage() = 0;
604  virtual QAction *actionCheckQgisVersion() = 0;
605  virtual QAction *actionAbout() = 0;
606 
614  virtual bool openFeatureForm( QgsVectorLayer *l, QgsFeature &f, bool updateFeatureOnly = false, bool showModal = true ) = 0;
615 
624  virtual QgsAttributeDialog *getFeatureForm( QgsVectorLayer *l, QgsFeature &f ) = 0;
625 
633  virtual QgsVectorLayerTools *vectorLayerTools() = 0;
634 
646  virtual void preloadForm( const QString &uifile ) = 0;
647 
651  virtual QList<QgsMapLayer *> editableLayers( bool modified = false ) const = 0;
652 
654  virtual int messageTimeout() = 0;
655 
662  virtual QgsStatusBar *statusBarIface() = 0;
663 
672  virtual void registerLocatorFilter( QgsLocatorFilter *filter SIP_TRANSFER ) = 0;
673 
684  virtual void deregisterLocatorFilter( QgsLocatorFilter *filter ) = 0;
685 
686 
687  signals:
688 
692  void currentLayerChanged( QgsMapLayer *layer );
693 
698  void currentThemeChanged( const QString &theme );
699 
705  void composerOpened( QgsComposerInterface *composer );
706 
714  void composerWillBeClosed( QgsComposerInterface *composer );
715 
722  void composerClosed( QgsComposerInterface *composer );
723 
727  void initializationCompleted();
728 
735  void projectRead();
736 
745  void newProjectCreated();
746 
751  void layerSavedAs( QgsMapLayer *l, const QString &path );
752 };
753 
754 #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:24
Abstract base class for filters which collect locator results.
#define SIP_FACTORY
Definition: qgis_sip.h:57
#define SIP_DEPRECATED
Definition: qgis_sip.h:87
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:70
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