QGIS API Documentation  2.99.0-Master (0a63d1f)
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;
30 class QgsComposerView;
32 class QgsFeature;
34 class QgsLayerTreeView;
35 class QgsMapCanvas;
36 class QgsMapLayer;
38 class QgsMessageBar;
40 class QgsRasterLayer;
41 class QgsSnappingUtils;
42 class QgsVectorLayer;
44 
45 #include <QObject>
46 #include <QFont>
47 #include <QPair>
48 #include <map>
49 
50 #include "qgis.h"
51 #include "qgsmaplayer.h"
52 #include "qgis_gui.h"
53 
54 
67 class GUI_EXPORT QgisInterface : public QObject
68 {
69  Q_OBJECT
70 
71  public:
72 
74  QgisInterface();
75 
76  virtual QgsPluginManagerInterface* pluginManagerInterface() = 0;
77 
78  virtual QgsLayerTreeView* layerTreeView() = 0;
79 
91  virtual void addCustomActionForLayerType( QAction* action, QString menu,
92  QgsMapLayer::LayerType type, bool allLayers ) = 0;
93 
99  virtual void addCustomActionForLayer( QAction* action, QgsMapLayer* layer ) = 0;
100 
104  virtual bool removeCustomActionForLayerType( QAction* action ) = 0;
105 
106  public slots: // TODO: do these functions really need to be slots?
107 
108  /* Exposed functions */
109 
111  virtual void zoomFull() = 0;
112 
114  virtual void zoomToPrevious() = 0;
115 
117  virtual void zoomToNext() = 0;
118 
120  virtual void zoomToActiveLayer() = 0;
121 
123  virtual QgsVectorLayer* addVectorLayer( const QString& vectorLayerPath, const QString& baseName, const QString& providerKey ) = 0;
124 
126  virtual QgsRasterLayer* addRasterLayer( const QString& rasterLayerPath, const QString& baseName = QString() ) = 0;
127 
129  virtual QgsRasterLayer* addRasterLayer( const QString& url, const QString& layerName, const QString& providerKey ) = 0;
130 
132  virtual bool addProject( const QString& theProject ) = 0;
134  virtual void newProject( bool thePromptToSaveFlag = false ) = 0;
135 
137  virtual QgsMapLayer *activeLayer() = 0;
138 
141  virtual bool setActiveLayer( QgsMapLayer * ) = 0;
142 
144  virtual int addToolBarIcon( QAction *qAction ) = 0;
145 
154  virtual QAction* addToolBarWidget( QWidget* widget ) = 0;
155 
157  virtual void removeToolBarIcon( QAction *qAction ) = 0;
158 
167  virtual QAction* addRasterToolBarWidget( QWidget* widget ) = 0;
168 
170  virtual int addRasterToolBarIcon( QAction *qAction ) = 0;
171 
173  virtual void removeRasterToolBarIcon( QAction *qAction ) = 0;
174 
176  virtual int addVectorToolBarIcon( QAction *qAction ) = 0;
177 
186  virtual QAction* addVectorToolBarWidget( QWidget* widget ) = 0;
187 
189  virtual void removeVectorToolBarIcon( QAction *qAction ) = 0;
190 
192  virtual int addDatabaseToolBarIcon( QAction *qAction ) = 0;
193 
202  virtual QAction* addDatabaseToolBarWidget( QWidget* widget ) = 0;
203 
205  virtual void removeDatabaseToolBarIcon( QAction *qAction ) = 0;
206 
208  virtual int addWebToolBarIcon( QAction *qAction ) = 0;
209 
218  virtual QAction* addWebToolBarWidget( QWidget* widget ) = 0;
219 
221  virtual void removeWebToolBarIcon( QAction *qAction ) = 0;
222 
224  virtual QToolBar *addToolBar( const QString& name ) = 0;
225 
228  virtual void addToolBar( QToolBar* toolbar, Qt::ToolBarArea area = Qt::TopToolBarArea ) = 0;
229 
231  virtual QgsMapCanvas * mapCanvas() = 0;
232 
238  virtual QgsLayerTreeMapCanvasBridge* layerTreeCanvasBridge() = 0;
239 
241  virtual QWidget * mainWindow() = 0;
242 
244  virtual QgsMessageBar * messageBar() = 0;
245 
247  virtual void openMessageLog() = 0;
248 
250  virtual void addUserInputWidget( QWidget* widget ) = 0;
251 
253  virtual QList<QgsComposerView*> activeComposers() = 0;
254 
260  virtual QgsComposerView* createNewComposer( const QString& title = QString() ) = 0;
261 
268  virtual QgsComposerView* duplicateComposer( QgsComposerView* composerView, const QString& title = QString() ) = 0;
269 
271  virtual void deleteComposer( QgsComposerView* composerView ) = 0;
272 
274  virtual QMap<QString, QVariant> defaultStyleSheetOptions() = 0;
275 
279  virtual void buildStyleSheet( const QMap<QString, QVariant>& opts ) = 0;
280 
282  virtual void saveStyleSheetOptions( const QMap<QString, QVariant>& opts ) = 0;
283 
285  virtual QFont defaultStyleSheetFont() = 0;
286 
288  virtual void addPluginToMenu( const QString& name, QAction* action ) = 0;
289 
291  virtual void removePluginMenu( const QString& name, QAction* action ) = 0;
292 
294  virtual void insertAddLayerAction( QAction *action ) = 0;
295 
297  virtual void removeAddLayerAction( QAction *action ) = 0;
298 
300  virtual void addPluginToDatabaseMenu( const QString& name, QAction* action ) = 0;
301 
303  virtual void removePluginDatabaseMenu( const QString& name, QAction* action ) = 0;
304 
306  virtual void addPluginToRasterMenu( const QString& name, QAction* action ) = 0;
307 
309  virtual void removePluginRasterMenu( const QString& name, QAction* action ) = 0;
310 
312  virtual void addPluginToVectorMenu( const QString& name, QAction* action ) = 0;
313 
315  virtual void removePluginVectorMenu( const QString& name, QAction* action ) = 0;
316 
318  virtual void addPluginToWebMenu( const QString& name, QAction* action ) = 0;
319 
321  virtual void removePluginWebMenu( const QString& name, QAction* action ) = 0;
322 
324  virtual void addDockWidget( Qt::DockWidgetArea area, QDockWidget * dockwidget ) = 0;
325 
327  virtual void removeDockWidget( QDockWidget * dockwidget ) = 0;
328 
332  virtual QgsAdvancedDigitizingDockWidget* cadDockWidget() = 0;
333 
335  virtual void showLayerProperties( QgsMapLayer *l ) = 0;
336 
338  virtual QDialog* showAttributeTable( QgsVectorLayer *l, const QString& filterExpression = QString() ) = 0;
339 
342  virtual void addWindow( QAction *action ) = 0;
343 
346  virtual void removeWindow( QAction *action ) = 0;
347 
349  virtual bool registerMainWindowAction( QAction* action, const QString& defaultShortcut ) = 0;
350 
352  virtual bool unregisterMainWindowAction( QAction* action ) = 0;
353 
359  virtual void registerMapLayerConfigWidgetFactory( QgsMapLayerConfigWidgetFactory* factory ) = 0;
360 
365  virtual void unregisterMapLayerConfigWidgetFactory( QgsMapLayerConfigWidgetFactory* factory ) = 0;
366 
372  virtual void registerCustomDropHandler( QgsCustomDropHandler* handler ) = 0;
373 
377  virtual void unregisterCustomDropHandler( QgsCustomDropHandler* handler ) = 0;
378 
379  // @todo is this deprecated in favour of QgsContextHelp?
380 
389 #ifndef Q_MOC_RUN
390  Q_DECL_DEPRECATED
391 #endif
392  virtual void openURL( const QString& url, bool useQgisDocDirectory = true ) = 0;
393 
394 
399  // Menus
400  virtual QMenu *projectMenu() = 0;
401  virtual QMenu *editMenu() = 0;
402  virtual QMenu *viewMenu() = 0;
403  virtual QMenu *layerMenu() = 0;
404  virtual QMenu *newLayerMenu() = 0;
406  virtual QMenu *addLayerMenu() = 0;
407  virtual QMenu *settingsMenu() = 0;
408  virtual QMenu *pluginMenu() = 0;
409  virtual QMenu *rasterMenu() = 0;
410  virtual QMenu *databaseMenu() = 0;
411  virtual QMenu *vectorMenu() = 0;
412  virtual QMenu *webMenu() = 0;
413  virtual QMenu *firstRightStandardMenu() = 0;
414  virtual QMenu *windowMenu() = 0;
415  virtual QMenu *helpMenu() = 0;
416 
417  // ToolBars
418  virtual QToolBar *fileToolBar() = 0;
419  virtual QToolBar *layerToolBar() = 0;
420  virtual QToolBar *mapNavToolToolBar() = 0;
421  virtual QToolBar *digitizeToolBar() = 0;
422  virtual QToolBar *advancedDigitizeToolBar() = 0;
423  virtual QToolBar *attributesToolBar() = 0;
424  virtual QToolBar *pluginToolBar() = 0;
425  virtual QToolBar *helpToolBar() = 0;
426  virtual QToolBar *rasterToolBar() = 0;
427  virtual QToolBar *vectorToolBar() = 0;
428  virtual QToolBar *databaseToolBar() = 0;
429  virtual QToolBar *webToolBar() = 0;
430 
431  // Project menu actions
432  virtual QAction *actionNewProject() = 0;
433  virtual QAction *actionOpenProject() = 0;
434  virtual QAction *actionSaveProject() = 0;
435  virtual QAction *actionSaveProjectAs() = 0;
436  virtual QAction *actionSaveMapAsImage() = 0;
437  virtual QAction *actionProjectProperties() = 0;
438  virtual QAction *actionPrintComposer() = 0;
439  virtual QAction *actionShowComposerManager() = 0;
440  virtual QAction *actionExit() = 0;
441 
442  // Edit menu actions
443  virtual QAction *actionCutFeatures() = 0;
444  virtual QAction *actionCopyFeatures() = 0;
445  virtual QAction *actionPasteFeatures() = 0;
446  virtual QAction *actionAddFeature() = 0;
447  virtual QAction *actionDeleteSelected() = 0;
448  virtual QAction *actionMoveFeature() = 0;
449  virtual QAction *actionSplitFeatures() = 0;
450  virtual QAction *actionSplitParts() = 0;
451  virtual QAction *actionAddRing() = 0;
452  virtual QAction *actionAddPart() = 0;
453  virtual QAction *actionSimplifyFeature() = 0;
454  virtual QAction *actionDeleteRing() = 0;
455  virtual QAction *actionDeletePart() = 0;
456  virtual QAction *actionNodeTool() = 0;
457 
458  // View menu actions
460  virtual QAction *actionPan() = 0;
462  virtual QAction *actionTouch() = 0;
464  virtual QAction *actionPanToSelected() = 0;
466  virtual QAction *actionZoomIn() = 0;
468  virtual QAction *actionZoomOut() = 0;
470  virtual QAction *actionSelect() = 0;
472  virtual QAction *actionSelectRectangle() = 0;
474  virtual QAction *actionSelectPolygon() = 0;
476  virtual QAction *actionSelectFreehand() = 0;
478  virtual QAction *actionSelectRadius() = 0;
480  virtual QAction *actionIdentify() = 0;
482  virtual QAction *actionFeatureAction() = 0;
484  virtual QAction *actionMeasure() = 0;
486  virtual QAction *actionMeasureArea() = 0;
488  virtual QAction *actionZoomFullExtent() = 0;
490  virtual QAction *actionZoomToLayer() = 0;
492  virtual QAction *actionZoomToSelected() = 0;
494  virtual QAction *actionZoomLast() = 0;
496  virtual QAction *actionZoomNext() = 0;
498  virtual QAction *actionZoomActualSize() = 0;
500  virtual QAction *actionMapTips() = 0;
502  virtual QAction *actionNewBookmark() = 0;
504  virtual QAction *actionShowBookmarks() = 0;
506  virtual QAction *actionDraw() = 0;
507 
508  // Layer menu actions
509  virtual QAction *actionNewVectorLayer() = 0;
510  virtual QAction *actionAddOgrLayer() = 0;
511  virtual QAction *actionAddRasterLayer() = 0;
512  virtual QAction *actionAddPgLayer() = 0;
513  virtual QAction *actionAddWmsLayer() = 0;
515  virtual QAction *actionAddAfsLayer() = 0;
517  virtual QAction *actionAddAmsLayer() = 0;
518  virtual QAction *actionCopyLayerStyle() = 0;
519  virtual QAction *actionPasteLayerStyle() = 0;
520  virtual QAction *actionOpenTable() = 0;
521  virtual QAction *actionOpenFieldCalculator() = 0;
522  virtual QAction *actionToggleEditing() = 0;
523  virtual QAction *actionSaveActiveLayerEdits() = 0;
524  virtual QAction *actionAllEdits() = 0;
525  virtual QAction *actionSaveEdits() = 0;
526  virtual QAction *actionSaveAllEdits() = 0;
527  virtual QAction *actionRollbackEdits() = 0;
528  virtual QAction *actionRollbackAllEdits() = 0;
529  virtual QAction *actionCancelEdits() = 0;
530  virtual QAction *actionCancelAllEdits() = 0;
531  virtual QAction *actionLayerSaveAs() = 0;
532  virtual QAction *actionDuplicateLayer() = 0;
533  virtual QAction *actionLayerProperties() = 0;
534  virtual QAction *actionAddToOverview() = 0;
535  virtual QAction *actionAddAllToOverview() = 0;
536  virtual QAction *actionRemoveAllFromOverview() = 0;
537  virtual QAction *actionHideAllLayers() = 0;
538  virtual QAction *actionShowAllLayers() = 0;
539  virtual QAction *actionHideSelectedLayers() = 0;
540 
545  virtual QAction *actionHideDeselectedLayers() = 0;
546  virtual QAction *actionShowSelectedLayers() = 0;
547 
548  // Plugin menu actions
549  virtual QAction *actionManagePlugins() = 0;
550  virtual QAction *actionPluginListSeparator() = 0;
551  virtual QAction *actionShowPythonDialog() = 0;
552 
553  // Settings menu actions
554  virtual QAction *actionToggleFullScreen() = 0;
555  virtual QAction *actionOptions() = 0;
556  virtual QAction *actionCustomProjection() = 0;
557 
558  // Help menu actions
559  virtual QAction *actionHelpContents() = 0;
560  virtual QAction *actionQgisHomePage() = 0;
561  virtual QAction *actionCheckQgisVersion() = 0;
562  virtual QAction *actionAbout() = 0;
563 
571  virtual bool openFeatureForm( QgsVectorLayer *l, QgsFeature &f, bool updateFeatureOnly = false, bool showModal = true ) = 0;
572 
581  virtual QgsAttributeDialog* getFeatureForm( QgsVectorLayer *l, QgsFeature &f ) = 0;
582 
590  virtual QgsVectorLayerTools* vectorLayerTools() = 0;
591 
603  virtual void preloadForm( const QString& uifile ) = 0;
604 
608  virtual QList<QgsMapLayer *> editableLayers( bool modified = false ) const = 0;
609 
611  virtual int messageTimeout() = 0;
612 
613  signals:
614 
618  void currentLayerChanged( QgsMapLayer * layer );
619 
623  void composerAdded( QgsComposerView* v );
624 
628  void composerWillBeRemoved( QgsComposerView* v );
629 
633  void composerRemoved( QgsComposerView* v );
634 
638  void initializationCompleted();
639 
646  void projectRead();
647 
656  void newProjectCreated();
657 
662  void layerSavedAs( QgsMapLayer* l, const QString& path );
663 };
664 
665 #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:50
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:136
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:59
Widget to display the composer items.
QgisInterface Abstract base class defining interfaces exposed by QgisApp and made available to plugin...
Definition: qgisinterface.h:67
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.