QGIS API Documentation  2.99.0-Master (11bb234)
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 
46 #include <QObject>
47 #include <QFont>
48 #include <QPair>
49 #include <map>
50 
51 #include "qgis.h"
52 #include "qgsmaplayer.h"
53 #include "qgis_gui.h"
54 
55 
68 class GUI_EXPORT QgisInterface : public QObject
69 {
70  Q_OBJECT
71 
72  public:
73 
75  QgisInterface();
76 
77  virtual QgsPluginManagerInterface *pluginManagerInterface() = 0;
78 
79  virtual QgsLayerTreeView *layerTreeView() = 0;
80 
92  virtual void addCustomActionForLayerType( QAction *action, QString menu,
93  QgsMapLayer::LayerType type, bool allLayers ) = 0;
94 
100  virtual void addCustomActionForLayer( QAction *action, QgsMapLayer *layer ) = 0;
101 
105  virtual bool removeCustomActionForLayerType( QAction *action ) = 0;
106 
111  virtual QList< QgsMapCanvas * > mapCanvases() = 0;
112 
118  virtual QgsMapCanvas *createNewMapCanvas( const QString &name ) = 0;
119 
125  virtual void closeMapCanvas( const QString &name ) = 0;
126 
127  public slots: // TODO: do these functions really need to be slots?
128 
129  /* Exposed functions */
130 
132  virtual void zoomFull() = 0;
133 
135  virtual void zoomToPrevious() = 0;
136 
138  virtual void zoomToNext() = 0;
139 
141  virtual void zoomToActiveLayer() = 0;
142 
144  virtual QgsVectorLayer *addVectorLayer( const QString &vectorLayerPath, const QString &baseName, const QString &providerKey ) = 0;
145 
147  virtual QgsRasterLayer *addRasterLayer( const QString &rasterLayerPath, const QString &baseName = QString() ) = 0;
148 
150  virtual QgsRasterLayer *addRasterLayer( const QString &url, const QString &layerName, const QString &providerKey ) = 0;
151 
153  virtual bool addProject( const QString &project ) = 0;
155  virtual void newProject( bool promptToSaveFlag = false ) = 0;
156 
158  virtual QgsMapLayer *activeLayer() = 0;
159 
162  virtual bool setActiveLayer( QgsMapLayer * ) = 0;
163 
165  virtual int addToolBarIcon( QAction *qAction ) = 0;
166 
175  virtual QAction *addToolBarWidget( QWidget *widget ) = 0;
176 
178  virtual void removeToolBarIcon( QAction *qAction ) = 0;
179 
188  virtual QAction *addRasterToolBarWidget( QWidget *widget ) = 0;
189 
191  virtual int addRasterToolBarIcon( QAction *qAction ) = 0;
192 
194  virtual void removeRasterToolBarIcon( QAction *qAction ) = 0;
195 
197  virtual int addVectorToolBarIcon( QAction *qAction ) = 0;
198 
207  virtual QAction *addVectorToolBarWidget( QWidget *widget ) = 0;
208 
210  virtual void removeVectorToolBarIcon( QAction *qAction ) = 0;
211 
213  virtual int addDatabaseToolBarIcon( QAction *qAction ) = 0;
214 
223  virtual QAction *addDatabaseToolBarWidget( QWidget *widget ) = 0;
224 
226  virtual void removeDatabaseToolBarIcon( QAction *qAction ) = 0;
227 
229  virtual int addWebToolBarIcon( QAction *qAction ) = 0;
230 
239  virtual QAction *addWebToolBarWidget( QWidget *widget ) = 0;
240 
242  virtual void removeWebToolBarIcon( QAction *qAction ) = 0;
243 
245  virtual QToolBar *addToolBar( const QString &name ) = 0;
246 
249  virtual void addToolBar( QToolBar *toolbar, Qt::ToolBarArea area = Qt::TopToolBarArea ) = 0;
250 
252  virtual QgsMapCanvas *mapCanvas() = 0;
253 
259  virtual QgsLayerTreeMapCanvasBridge *layerTreeCanvasBridge() = 0;
260 
262  virtual QWidget *mainWindow() = 0;
263 
265  virtual QgsMessageBar *messageBar() = 0;
266 
268  virtual void openMessageLog() = 0;
269 
271  virtual void addUserInputWidget( QWidget *widget ) = 0;
272 
277  virtual QList<QgsComposerInterface *> openComposers() = 0;
278 
286  virtual QgsComposerInterface *openComposer( QgsComposition *composition ) = 0;
287 
294  virtual void closeComposer( QgsComposition *composition ) = 0;
295 
301  virtual void showOptionsDialog( QWidget *parent = nullptr, const QString &currentPage = QString() ) = 0;
302 
304  virtual QMap<QString, QVariant> defaultStyleSheetOptions() = 0;
305 
309  virtual void buildStyleSheet( const QMap<QString, QVariant> &opts ) = 0;
310 
312  virtual void saveStyleSheetOptions( const QMap<QString, QVariant> &opts ) = 0;
313 
315  virtual QFont defaultStyleSheetFont() = 0;
316 
318  virtual void addPluginToMenu( const QString &name, QAction *action ) = 0;
319 
321  virtual void removePluginMenu( const QString &name, QAction *action ) = 0;
322 
324  virtual void insertAddLayerAction( QAction *action ) = 0;
325 
327  virtual void removeAddLayerAction( QAction *action ) = 0;
328 
330  virtual void addPluginToDatabaseMenu( const QString &name, QAction *action ) = 0;
331 
333  virtual void removePluginDatabaseMenu( const QString &name, QAction *action ) = 0;
334 
336  virtual void addPluginToRasterMenu( const QString &name, QAction *action ) = 0;
337 
339  virtual void removePluginRasterMenu( const QString &name, QAction *action ) = 0;
340 
342  virtual void addPluginToVectorMenu( const QString &name, QAction *action ) = 0;
343 
345  virtual void removePluginVectorMenu( const QString &name, QAction *action ) = 0;
346 
348  virtual void addPluginToWebMenu( const QString &name, QAction *action ) = 0;
349 
351  virtual void removePluginWebMenu( const QString &name, QAction *action ) = 0;
352 
354  virtual void addDockWidget( Qt::DockWidgetArea area, QDockWidget *dockwidget ) = 0;
355 
357  virtual void removeDockWidget( QDockWidget *dockwidget ) = 0;
358 
362  virtual QgsAdvancedDigitizingDockWidget *cadDockWidget() = 0;
363 
365  virtual void showLayerProperties( QgsMapLayer *l ) = 0;
366 
368  virtual QDialog *showAttributeTable( QgsVectorLayer *l, const QString &filterExpression = QString() ) = 0;
369 
372  virtual void addWindow( QAction *action ) = 0;
373 
376  virtual void removeWindow( QAction *action ) = 0;
377 
379  virtual bool registerMainWindowAction( QAction *action, const QString &defaultShortcut ) = 0;
380 
382  virtual bool unregisterMainWindowAction( QAction *action ) = 0;
383 
389  virtual void registerMapLayerConfigWidgetFactory( QgsMapLayerConfigWidgetFactory *factory ) = 0;
390 
395  virtual void unregisterMapLayerConfigWidgetFactory( QgsMapLayerConfigWidgetFactory *factory ) = 0;
396 
402  virtual void registerOptionsWidgetFactory( QgsOptionsWidgetFactory *factory ) = 0;
403 
408  virtual void unregisterOptionsWidgetFactory( QgsOptionsWidgetFactory *factory ) = 0;
409 
415  virtual void registerCustomDropHandler( QgsCustomDropHandler *handler ) = 0;
416 
420  virtual void unregisterCustomDropHandler( QgsCustomDropHandler *handler ) = 0;
421 
422  // @todo is this deprecated in favour of QgsContextHelp?
423 
432 #ifndef Q_MOC_RUN
433  Q_DECL_DEPRECATED
434 #endif
435  virtual void openURL( const QString &url, bool useQgisDocDirectory = true ) = 0;
436 
437 
442  // Menus
443  virtual QMenu *projectMenu() = 0;
444  virtual QMenu *editMenu() = 0;
445  virtual QMenu *viewMenu() = 0;
446  virtual QMenu *layerMenu() = 0;
447  virtual QMenu *newLayerMenu() = 0;
449  virtual QMenu *addLayerMenu() = 0;
450  virtual QMenu *settingsMenu() = 0;
451  virtual QMenu *pluginMenu() = 0;
452  virtual QMenu *rasterMenu() = 0;
453  virtual QMenu *databaseMenu() = 0;
454  virtual QMenu *vectorMenu() = 0;
455  virtual QMenu *webMenu() = 0;
456  virtual QMenu *firstRightStandardMenu() = 0;
457  virtual QMenu *windowMenu() = 0;
458  virtual QMenu *helpMenu() = 0;
459 
460  // ToolBars
461  virtual QToolBar *fileToolBar() = 0;
462  virtual QToolBar *layerToolBar() = 0;
463  virtual QToolBar *mapNavToolToolBar() = 0;
464  virtual QToolBar *digitizeToolBar() = 0;
465  virtual QToolBar *advancedDigitizeToolBar() = 0;
466  virtual QToolBar *attributesToolBar() = 0;
467  virtual QToolBar *pluginToolBar() = 0;
468  virtual QToolBar *helpToolBar() = 0;
469  virtual QToolBar *rasterToolBar() = 0;
470  virtual QToolBar *vectorToolBar() = 0;
471  virtual QToolBar *databaseToolBar() = 0;
472  virtual QToolBar *webToolBar() = 0;
473 
474  // Project menu actions
475  virtual QAction *actionNewProject() = 0;
476  virtual QAction *actionOpenProject() = 0;
477  virtual QAction *actionSaveProject() = 0;
478  virtual QAction *actionSaveProjectAs() = 0;
479  virtual QAction *actionSaveMapAsImage() = 0;
480  virtual QAction *actionProjectProperties() = 0;
481  virtual QAction *actionPrintComposer() = 0;
482  virtual QAction *actionShowComposerManager() = 0;
483  virtual QAction *actionExit() = 0;
484 
485  // Edit menu actions
486  virtual QAction *actionCutFeatures() = 0;
487  virtual QAction *actionCopyFeatures() = 0;
488  virtual QAction *actionPasteFeatures() = 0;
489  virtual QAction *actionAddFeature() = 0;
490  virtual QAction *actionDeleteSelected() = 0;
491  virtual QAction *actionMoveFeature() = 0;
492  virtual QAction *actionSplitFeatures() = 0;
493  virtual QAction *actionSplitParts() = 0;
494  virtual QAction *actionAddRing() = 0;
495  virtual QAction *actionAddPart() = 0;
496  virtual QAction *actionSimplifyFeature() = 0;
497  virtual QAction *actionDeleteRing() = 0;
498  virtual QAction *actionDeletePart() = 0;
499  virtual QAction *actionNodeTool() = 0;
500 
501  // View menu actions
503  virtual QAction *actionPan() = 0;
505  virtual QAction *actionPanToSelected() = 0;
507  virtual QAction *actionZoomIn() = 0;
509  virtual QAction *actionZoomOut() = 0;
511  virtual QAction *actionSelect() = 0;
513  virtual QAction *actionSelectRectangle() = 0;
515  virtual QAction *actionSelectPolygon() = 0;
517  virtual QAction *actionSelectFreehand() = 0;
519  virtual QAction *actionSelectRadius() = 0;
521  virtual QAction *actionIdentify() = 0;
523  virtual QAction *actionFeatureAction() = 0;
525  virtual QAction *actionMeasure() = 0;
527  virtual QAction *actionMeasureArea() = 0;
529  virtual QAction *actionZoomFullExtent() = 0;
531  virtual QAction *actionZoomToLayer() = 0;
533  virtual QAction *actionZoomToSelected() = 0;
535  virtual QAction *actionZoomLast() = 0;
537  virtual QAction *actionZoomNext() = 0;
539  virtual QAction *actionZoomActualSize() = 0;
541  virtual QAction *actionMapTips() = 0;
543  virtual QAction *actionNewBookmark() = 0;
545  virtual QAction *actionShowBookmarks() = 0;
547  virtual QAction *actionDraw() = 0;
548 
549  // Layer menu actions
550  virtual QAction *actionNewVectorLayer() = 0;
551  virtual QAction *actionAddOgrLayer() = 0;
552  virtual QAction *actionAddRasterLayer() = 0;
553  virtual QAction *actionAddPgLayer() = 0;
554  virtual QAction *actionAddWmsLayer() = 0;
556  virtual QAction *actionAddAfsLayer() = 0;
558  virtual QAction *actionAddAmsLayer() = 0;
559  virtual QAction *actionCopyLayerStyle() = 0;
560  virtual QAction *actionPasteLayerStyle() = 0;
561  virtual QAction *actionOpenTable() = 0;
562  virtual QAction *actionOpenFieldCalculator() = 0;
563  virtual QAction *actionToggleEditing() = 0;
564  virtual QAction *actionSaveActiveLayerEdits() = 0;
565  virtual QAction *actionAllEdits() = 0;
566  virtual QAction *actionSaveEdits() = 0;
567  virtual QAction *actionSaveAllEdits() = 0;
568  virtual QAction *actionRollbackEdits() = 0;
569  virtual QAction *actionRollbackAllEdits() = 0;
570  virtual QAction *actionCancelEdits() = 0;
571  virtual QAction *actionCancelAllEdits() = 0;
572  virtual QAction *actionLayerSaveAs() = 0;
573  virtual QAction *actionDuplicateLayer() = 0;
574  virtual QAction *actionLayerProperties() = 0;
575  virtual QAction *actionAddToOverview() = 0;
576  virtual QAction *actionAddAllToOverview() = 0;
577  virtual QAction *actionRemoveAllFromOverview() = 0;
578  virtual QAction *actionHideAllLayers() = 0;
579  virtual QAction *actionShowAllLayers() = 0;
580  virtual QAction *actionHideSelectedLayers() = 0;
581 
586  virtual QAction *actionHideDeselectedLayers() = 0;
587  virtual QAction *actionShowSelectedLayers() = 0;
588 
589  // Plugin menu actions
590  virtual QAction *actionManagePlugins() = 0;
591  virtual QAction *actionPluginListSeparator() = 0;
592  virtual QAction *actionShowPythonDialog() = 0;
593 
594  // Settings menu actions
595  virtual QAction *actionToggleFullScreen() = 0;
596  virtual QAction *actionOptions() = 0;
597  virtual QAction *actionCustomProjection() = 0;
598 
599  // Help menu actions
600  virtual QAction *actionHelpContents() = 0;
601  virtual QAction *actionQgisHomePage() = 0;
602  virtual QAction *actionCheckQgisVersion() = 0;
603  virtual QAction *actionAbout() = 0;
604 
612  virtual bool openFeatureForm( QgsVectorLayer *l, QgsFeature &f, bool updateFeatureOnly = false, bool showModal = true ) = 0;
613 
622  virtual QgsAttributeDialog *getFeatureForm( QgsVectorLayer *l, QgsFeature &f ) = 0;
623 
631  virtual QgsVectorLayerTools *vectorLayerTools() = 0;
632 
644  virtual void preloadForm( const QString &uifile ) = 0;
645 
649  virtual QList<QgsMapLayer *> editableLayers( bool modified = false ) const = 0;
650 
652  virtual int messageTimeout() = 0;
653 
654  signals:
655 
659  void currentLayerChanged( QgsMapLayer *layer );
660 
665  void currentThemeChanged( const QString &theme );
666 
672  void composerOpened( QgsComposerInterface *composer );
673 
681  void composerWillBeClosed( QgsComposerInterface *composer );
682 
689  void composerClosed( QgsComposerInterface *composer );
690 
694  void initializationCompleted();
695 
702  void projectRead();
703 
712  void newProjectCreated();
713 
718  void layerSavedAs( QgsMapLayer *l, const QString &path );
719 };
720 
721 #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:53
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:43
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:72
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:90
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:68
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.