QGIS API Documentation  2.99.0-Master (37c43df)
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 
53 
66 class GUI_EXPORT QgisInterface : public QObject
67 {
68  Q_OBJECT
69 
70  public:
71 
73  QgisInterface();
74 
76  virtual ~QgisInterface();
77 
78  virtual QgsPluginManagerInterface* pluginManagerInterface() = 0;
79 
80  virtual QgsLayerTreeView* layerTreeView() = 0;
81 
93  virtual void addCustomActionForLayerType( QAction* action, QString menu,
94  QgsMapLayer::LayerType type, bool allLayers ) = 0;
95 
101  virtual void addCustomActionForLayer( QAction* action, QgsMapLayer* layer ) = 0;
102 
106  virtual bool removeCustomActionForLayerType( QAction* action ) = 0;
107 
108  public slots: // TODO: do these functions really need to be slots?
109 
110  /* Exposed functions */
111 
113  virtual void zoomFull() = 0;
114 
116  virtual void zoomToPrevious() = 0;
117 
119  virtual void zoomToNext() = 0;
120 
122  virtual void zoomToActiveLayer() = 0;
123 
125  virtual QgsVectorLayer* addVectorLayer( const QString& vectorLayerPath, const QString& baseName, const QString& providerKey ) = 0;
126 
128  virtual QgsRasterLayer* addRasterLayer( const QString& rasterLayerPath, const QString& baseName = QString() ) = 0;
129 
131  virtual QgsRasterLayer* addRasterLayer( const QString& url, const QString& layerName, const QString& providerKey ) = 0;
132 
134  virtual bool addProject( const QString& theProject ) = 0;
136  virtual void newProject( bool thePromptToSaveFlag = false ) = 0;
137 
139  virtual QgsMapLayer *activeLayer() = 0;
140 
143  virtual bool setActiveLayer( QgsMapLayer * ) = 0;
144 
146  virtual int addToolBarIcon( QAction *qAction ) = 0;
147 
156  virtual QAction* addToolBarWidget( QWidget* widget ) = 0;
157 
159  virtual void removeToolBarIcon( QAction *qAction ) = 0;
160 
169  virtual QAction* addRasterToolBarWidget( QWidget* widget ) = 0;
170 
172  virtual int addRasterToolBarIcon( QAction *qAction ) = 0;
173 
175  virtual void removeRasterToolBarIcon( QAction *qAction ) = 0;
176 
178  virtual int addVectorToolBarIcon( QAction *qAction ) = 0;
179 
188  virtual QAction* addVectorToolBarWidget( QWidget* widget ) = 0;
189 
191  virtual void removeVectorToolBarIcon( QAction *qAction ) = 0;
192 
194  virtual int addDatabaseToolBarIcon( QAction *qAction ) = 0;
195 
204  virtual QAction* addDatabaseToolBarWidget( QWidget* widget ) = 0;
205 
207  virtual void removeDatabaseToolBarIcon( QAction *qAction ) = 0;
208 
210  virtual int addWebToolBarIcon( QAction *qAction ) = 0;
211 
220  virtual QAction* addWebToolBarWidget( QWidget* widget ) = 0;
221 
223  virtual void removeWebToolBarIcon( QAction *qAction ) = 0;
224 
226  virtual QToolBar *addToolBar( const QString& name ) = 0;
227 
230  virtual void addToolBar( QToolBar* toolbar, Qt::ToolBarArea area = Qt::TopToolBarArea ) = 0;
231 
233  virtual QgsMapCanvas * mapCanvas() = 0;
234 
240  virtual QgsLayerTreeMapCanvasBridge* layerTreeCanvasBridge() = 0;
241 
243  virtual QWidget * mainWindow() = 0;
244 
246  virtual QgsMessageBar * messageBar() = 0;
247 
249  virtual void openMessageLog() = 0;
250 
252  virtual void addUserInputWidget( QWidget* widget ) = 0;
253 
255  virtual QList<QgsComposerView*> activeComposers() = 0;
256 
262  virtual QgsComposerView* createNewComposer( const QString& title = QString() ) = 0;
263 
270  virtual QgsComposerView* duplicateComposer( QgsComposerView* composerView, const QString& title = QString() ) = 0;
271 
273  virtual void deleteComposer( QgsComposerView* composerView ) = 0;
274 
276  virtual QMap<QString, QVariant> defaultStyleSheetOptions() = 0;
277 
281  virtual void buildStyleSheet( const QMap<QString, QVariant>& opts ) = 0;
282 
284  virtual void saveStyleSheetOptions( const QMap<QString, QVariant>& opts ) = 0;
285 
287  virtual QFont defaultStyleSheetFont() = 0;
288 
290  virtual void addPluginToMenu( const QString& name, QAction* action ) = 0;
291 
293  virtual void removePluginMenu( const QString& name, QAction* action ) = 0;
294 
296  virtual void insertAddLayerAction( QAction *action ) = 0;
297 
299  virtual void removeAddLayerAction( QAction *action ) = 0;
300 
302  virtual void addPluginToDatabaseMenu( const QString& name, QAction* action ) = 0;
303 
305  virtual void removePluginDatabaseMenu( const QString& name, QAction* action ) = 0;
306 
308  virtual void addPluginToRasterMenu( const QString& name, QAction* action ) = 0;
309 
311  virtual void removePluginRasterMenu( const QString& name, QAction* action ) = 0;
312 
314  virtual void addPluginToVectorMenu( const QString& name, QAction* action ) = 0;
315 
317  virtual void removePluginVectorMenu( const QString& name, QAction* action ) = 0;
318 
320  virtual void addPluginToWebMenu( const QString& name, QAction* action ) = 0;
321 
323  virtual void removePluginWebMenu( const QString& name, QAction* action ) = 0;
324 
326  virtual void addDockWidget( Qt::DockWidgetArea area, QDockWidget * dockwidget ) = 0;
327 
329  virtual void removeDockWidget( QDockWidget * dockwidget ) = 0;
330 
334  virtual QgsAdvancedDigitizingDockWidget* cadDockWidget() = 0;
335 
337  virtual void showLayerProperties( QgsMapLayer *l ) = 0;
338 
340  virtual QDialog* showAttributeTable( QgsVectorLayer *l, const QString& filterExpression = QString() ) = 0;
341 
344  virtual void addWindow( QAction *action ) = 0;
345 
348  virtual void removeWindow( QAction *action ) = 0;
349 
351  virtual bool registerMainWindowAction( QAction* action, const QString& defaultShortcut ) = 0;
352 
354  virtual bool unregisterMainWindowAction( QAction* action ) = 0;
355 
361  virtual void registerMapLayerConfigWidgetFactory( QgsMapLayerConfigWidgetFactory* factory ) = 0;
362 
367  virtual void unregisterMapLayerConfigWidgetFactory( QgsMapLayerConfigWidgetFactory* factory ) = 0;
368 
374  virtual void registerCustomDropHandler( QgsCustomDropHandler* handler ) = 0;
375 
379  virtual void unregisterCustomDropHandler( QgsCustomDropHandler* handler ) = 0;
380 
381  // @todo is this deprecated in favour of QgsContextHelp?
382 
391 #ifndef Q_MOC_RUN
392  Q_DECL_DEPRECATED
393 #endif
394  virtual void openURL( const QString& url, bool useQgisDocDirectory = true ) = 0;
395 
396 
401  // Menus
402  virtual QMenu *projectMenu() = 0;
403  virtual QMenu *editMenu() = 0;
404  virtual QMenu *viewMenu() = 0;
405  virtual QMenu *layerMenu() = 0;
406  virtual QMenu *newLayerMenu() = 0;
408  virtual QMenu *addLayerMenu() = 0;
409  virtual QMenu *settingsMenu() = 0;
410  virtual QMenu *pluginMenu() = 0;
411  virtual QMenu *rasterMenu() = 0;
412  virtual QMenu *databaseMenu() = 0;
413  virtual QMenu *vectorMenu() = 0;
414  virtual QMenu *webMenu() = 0;
415  virtual QMenu *firstRightStandardMenu() = 0;
416  virtual QMenu *windowMenu() = 0;
417  virtual QMenu *helpMenu() = 0;
418 
419  // ToolBars
420  virtual QToolBar *fileToolBar() = 0;
421  virtual QToolBar *layerToolBar() = 0;
422  virtual QToolBar *mapNavToolToolBar() = 0;
423  virtual QToolBar *digitizeToolBar() = 0;
424  virtual QToolBar *advancedDigitizeToolBar() = 0;
425  virtual QToolBar *attributesToolBar() = 0;
426  virtual QToolBar *pluginToolBar() = 0;
427  virtual QToolBar *helpToolBar() = 0;
428  virtual QToolBar *rasterToolBar() = 0;
429  virtual QToolBar *vectorToolBar() = 0;
430  virtual QToolBar *databaseToolBar() = 0;
431  virtual QToolBar *webToolBar() = 0;
432 
433  // Project menu actions
434  virtual QAction *actionNewProject() = 0;
435  virtual QAction *actionOpenProject() = 0;
436  virtual QAction *actionSaveProject() = 0;
437  virtual QAction *actionSaveProjectAs() = 0;
438  virtual QAction *actionSaveMapAsImage() = 0;
439  virtual QAction *actionProjectProperties() = 0;
440  virtual QAction *actionPrintComposer() = 0;
441  virtual QAction *actionShowComposerManager() = 0;
442  virtual QAction *actionExit() = 0;
443 
444  // Edit menu actions
445  virtual QAction *actionCutFeatures() = 0;
446  virtual QAction *actionCopyFeatures() = 0;
447  virtual QAction *actionPasteFeatures() = 0;
448  virtual QAction *actionAddFeature() = 0;
449  virtual QAction *actionDeleteSelected() = 0;
450  virtual QAction *actionMoveFeature() = 0;
451  virtual QAction *actionSplitFeatures() = 0;
452  virtual QAction *actionSplitParts() = 0;
453  virtual QAction *actionAddRing() = 0;
454  virtual QAction *actionAddPart() = 0;
455  virtual QAction *actionSimplifyFeature() = 0;
456  virtual QAction *actionDeleteRing() = 0;
457  virtual QAction *actionDeletePart() = 0;
458  virtual QAction *actionNodeTool() = 0;
459 
460  // View menu actions
462  virtual QAction *actionPan() = 0;
464  virtual QAction *actionTouch() = 0;
466  virtual QAction *actionPanToSelected() = 0;
468  virtual QAction *actionZoomIn() = 0;
470  virtual QAction *actionZoomOut() = 0;
472  virtual QAction *actionSelect() = 0;
474  virtual QAction *actionSelectRectangle() = 0;
476  virtual QAction *actionSelectPolygon() = 0;
478  virtual QAction *actionSelectFreehand() = 0;
480  virtual QAction *actionSelectRadius() = 0;
482  virtual QAction *actionIdentify() = 0;
484  virtual QAction *actionFeatureAction() = 0;
486  virtual QAction *actionMeasure() = 0;
488  virtual QAction *actionMeasureArea() = 0;
490  virtual QAction *actionZoomFullExtent() = 0;
492  virtual QAction *actionZoomToLayer() = 0;
494  virtual QAction *actionZoomToSelected() = 0;
496  virtual QAction *actionZoomLast() = 0;
498  virtual QAction *actionZoomNext() = 0;
500  virtual QAction *actionZoomActualSize() = 0;
502  virtual QAction *actionMapTips() = 0;
504  virtual QAction *actionNewBookmark() = 0;
506  virtual QAction *actionShowBookmarks() = 0;
508  virtual QAction *actionDraw() = 0;
509 
510  // Layer menu actions
511  virtual QAction *actionNewVectorLayer() = 0;
512  virtual QAction *actionAddOgrLayer() = 0;
513  virtual QAction *actionAddRasterLayer() = 0;
514  virtual QAction *actionAddPgLayer() = 0;
515  virtual QAction *actionAddWmsLayer() = 0;
517  virtual QAction *actionAddAfsLayer() = 0;
519  virtual QAction *actionAddAmsLayer() = 0;
520  virtual QAction *actionCopyLayerStyle() = 0;
521  virtual QAction *actionPasteLayerStyle() = 0;
522  virtual QAction *actionOpenTable() = 0;
523  virtual QAction *actionOpenFieldCalculator() = 0;
524  virtual QAction *actionToggleEditing() = 0;
525  virtual QAction *actionSaveActiveLayerEdits() = 0;
526  virtual QAction *actionAllEdits() = 0;
527  virtual QAction *actionSaveEdits() = 0;
528  virtual QAction *actionSaveAllEdits() = 0;
529  virtual QAction *actionRollbackEdits() = 0;
530  virtual QAction *actionRollbackAllEdits() = 0;
531  virtual QAction *actionCancelEdits() = 0;
532  virtual QAction *actionCancelAllEdits() = 0;
533  virtual QAction *actionLayerSaveAs() = 0;
534  virtual QAction *actionDuplicateLayer() = 0;
535  virtual QAction *actionLayerProperties() = 0;
536  virtual QAction *actionAddToOverview() = 0;
537  virtual QAction *actionAddAllToOverview() = 0;
538  virtual QAction *actionRemoveAllFromOverview() = 0;
539  virtual QAction *actionHideAllLayers() = 0;
540  virtual QAction *actionShowAllLayers() = 0;
541  virtual QAction *actionHideSelectedLayers() = 0;
542  virtual QAction *actionShowSelectedLayers() = 0;
543 
544  // Plugin menu actions
545  virtual QAction *actionManagePlugins() = 0;
546  virtual QAction *actionPluginListSeparator() = 0;
547  virtual QAction *actionShowPythonDialog() = 0;
548 
549  // Settings menu actions
550  virtual QAction *actionToggleFullScreen() = 0;
551  virtual QAction *actionOptions() = 0;
552  virtual QAction *actionCustomProjection() = 0;
553 
554  // Help menu actions
555  virtual QAction *actionHelpContents() = 0;
556  virtual QAction *actionQgisHomePage() = 0;
557  virtual QAction *actionCheckQgisVersion() = 0;
558  virtual QAction *actionAbout() = 0;
559 
567  virtual bool openFeatureForm( QgsVectorLayer *l, QgsFeature &f, bool updateFeatureOnly = false, bool showModal = true ) = 0;
568 
577  virtual QgsAttributeDialog* getFeatureForm( QgsVectorLayer *l, QgsFeature &f ) = 0;
578 
586  virtual QgsVectorLayerTools* vectorLayerTools() = 0;
587 
599  virtual void preloadForm( const QString& uifile ) = 0;
600 
604  virtual QList<QgsMapLayer *> editableLayers( bool modified = false ) const = 0;
605 
607  virtual int messageTimeout() = 0;
608 
609  signals:
610 
614  void currentLayerChanged( QgsMapLayer * layer );
615 
619  void composerAdded( QgsComposerView* v );
620 
624  void composerWillBeRemoved( QgsComposerView* v );
625 
629  void composerRemoved( QgsComposerView* v );
630 
634  void initializationCompleted();
635 
642  void projectRead();
643 
652  void newProjectCreated();
653 
658  void layerSavedAs( QgsMapLayer* l, const QString& path );
659 };
660 
661 #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:49
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:42
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
Definition: qgsfeature.h:135
Map canvas is a class for displaying all GIS data types on a canvas.
Definition: qgsmapcanvas.h:106
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:58
Widget to display the composer items.
QgisInterface Abstract base class defining interfaces exposed by QgisApp and made available to plugin...
Definition: qgisinterface.h:66
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.