QGIS API Documentation  2.15.0-Master (02a0ebe)
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;
31 class QgsFeature;
33 class QgsLayerTreeView;
34 class QgsLegendInterface;
35 class QgsMapCanvas;
36 class QgsMapLayer;
39 class QgsMessageBar;
41 class QgsRasterLayer;
42 class QgsSnappingUtils;
43 class QgsVectorLayer;
45 
46 #include <QObject>
47 #include <QFont>
48 #include <QPair>
49 #include <map>
50 
51 #include "qgis.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 
79  virtual QgsLegendInterface* legendInterface() = 0;
80 
81  virtual QgsPluginManagerInterface* pluginManagerInterface() = 0;
82 
83  virtual QgsLayerTreeView* layerTreeView() = 0;
84 
85  public slots: // TODO: do these functions really need to be slots?
86 
87  /* Exposed functions */
88 
90  virtual void zoomFull() = 0;
91 
93  virtual void zoomToPrevious() = 0;
94 
96  virtual void zoomToNext() = 0;
97 
99  virtual void zoomToActiveLayer() = 0;
100 
102  virtual QgsVectorLayer* addVectorLayer( const QString& vectorLayerPath, const QString& baseName, const QString& providerKey ) = 0;
103 
105  virtual QgsRasterLayer* addRasterLayer( const QString& rasterLayerPath, const QString& baseName = QString() ) = 0;
106 
108  virtual QgsRasterLayer* addRasterLayer( const QString& url, const QString& layerName, const QString& providerKey ) = 0;
109 
111  virtual bool addProject( const QString& theProject ) = 0;
113  virtual void newProject( bool thePromptToSaveFlag = false ) = 0;
114 
116  virtual QgsMapLayer *activeLayer() = 0;
117 
120  virtual bool setActiveLayer( QgsMapLayer * ) = 0;
121 
123  virtual int addToolBarIcon( QAction *qAction ) = 0;
124 
133  virtual QAction* addToolBarWidget( QWidget* widget ) = 0;
134 
136  virtual void removeToolBarIcon( QAction *qAction ) = 0;
137 
146  virtual QAction* addRasterToolBarWidget( QWidget* widget ) = 0;
147 
149  virtual int addRasterToolBarIcon( QAction *qAction ) = 0;
150 
152  virtual void removeRasterToolBarIcon( QAction *qAction ) = 0;
153 
155  virtual int addVectorToolBarIcon( QAction *qAction ) = 0;
156 
165  virtual QAction* addVectorToolBarWidget( QWidget* widget ) = 0;
166 
168  virtual void removeVectorToolBarIcon( QAction *qAction ) = 0;
169 
171  virtual int addDatabaseToolBarIcon( QAction *qAction ) = 0;
172 
181  virtual QAction* addDatabaseToolBarWidget( QWidget* widget ) = 0;
182 
184  virtual void removeDatabaseToolBarIcon( QAction *qAction ) = 0;
185 
187  virtual int addWebToolBarIcon( QAction *qAction ) = 0;
188 
197  virtual QAction* addWebToolBarWidget( QWidget* widget ) = 0;
198 
200  virtual void removeWebToolBarIcon( QAction *qAction ) = 0;
201 
203  virtual QToolBar *addToolBar( const QString& name ) = 0;
204 
207  virtual void addToolBar( QToolBar* toolbar, Qt::ToolBarArea area = Qt::TopToolBarArea ) = 0;
208 
210  virtual QgsMapCanvas * mapCanvas() = 0;
211 
217  virtual QgsLayerTreeMapCanvasBridge* layerTreeCanvasBridge() = 0;
218 
220  virtual QWidget * mainWindow() = 0;
221 
223  virtual QgsMessageBar * messageBar() = 0;
224 
226  virtual void openMessageLog() = 0;
227 
229  virtual void addUserInputWidget( QWidget* widget ) = 0;
230 
232  virtual QList<QgsComposerView*> activeComposers() = 0;
233 
239  virtual QgsComposerView* createNewComposer( const QString& title = QString() ) = 0;
240 
247  virtual QgsComposerView* duplicateComposer( QgsComposerView* composerView, const QString& title = QString() ) = 0;
248 
250  virtual void deleteComposer( QgsComposerView* composerView ) = 0;
251 
253  virtual QMap<QString, QVariant> defaultStyleSheetOptions() = 0;
254 
258  virtual void buildStyleSheet( const QMap<QString, QVariant>& opts ) = 0;
259 
261  virtual void saveStyleSheetOptions( const QMap<QString, QVariant>& opts ) = 0;
262 
264  virtual QFont defaultStyleSheetFont() = 0;
265 
267  virtual void addPluginToMenu( const QString& name, QAction* action ) = 0;
268 
270  virtual void removePluginMenu( const QString& name, QAction* action ) = 0;
271 
273  virtual void insertAddLayerAction( QAction *action ) = 0;
274 
276  virtual void removeAddLayerAction( QAction *action ) = 0;
277 
279  virtual void addPluginToDatabaseMenu( const QString& name, QAction* action ) = 0;
280 
282  virtual void removePluginDatabaseMenu( const QString& name, QAction* action ) = 0;
283 
285  virtual void addPluginToRasterMenu( const QString& name, QAction* action ) = 0;
286 
288  virtual void removePluginRasterMenu( const QString& name, QAction* action ) = 0;
289 
291  virtual void addPluginToVectorMenu( const QString& name, QAction* action ) = 0;
292 
294  virtual void removePluginVectorMenu( const QString& name, QAction* action ) = 0;
295 
297  virtual void addPluginToWebMenu( const QString& name, QAction* action ) = 0;
298 
300  virtual void removePluginWebMenu( const QString& name, QAction* action ) = 0;
301 
303  virtual void addDockWidget( Qt::DockWidgetArea area, QDockWidget * dockwidget ) = 0;
304 
306  virtual void removeDockWidget( QDockWidget * dockwidget ) = 0;
307 
311  virtual QgsAdvancedDigitizingDockWidget* cadDockWidget() = 0;
312 
314  virtual void showLayerProperties( QgsMapLayer *l ) = 0;
315 
317  virtual QDialog* showAttributeTable( QgsVectorLayer *l, const QString& filterExpression = QString() ) = 0;
318 
321  virtual void addWindow( QAction *action ) = 0;
322 
325  virtual void removeWindow( QAction *action ) = 0;
326 
328  virtual bool registerMainWindowAction( QAction* action, const QString& defaultShortcut ) = 0;
329 
331  virtual bool unregisterMainWindowAction( QAction* action ) = 0;
332 
338  virtual void registerMapLayerPropertiesFactory( QgsMapLayerPropertiesFactory* factory ) = 0;
339 
344  virtual void unregisterMapLayerPropertiesFactory( QgsMapLayerPropertiesFactory* factory ) = 0;
345 
347  virtual void registerMapStylePanelFactory( QgsLayerStylingPanelFactory* factory ) = 0;
348 
350  virtual void unregisterMapStylePanelFactory( QgsLayerStylingPanelFactory* factory ) = 0;
351 
352  // @todo is this deprecated in favour of QgsContextHelp?
361 #ifndef Q_MOC_RUN
362  Q_DECL_DEPRECATED
363 #endif
364  virtual void openURL( const QString& url, bool useQgisDocDirectory = true ) = 0;
365 
366 
371  // Menus
372 #ifndef Q_MOC_RUN
373  Q_DECL_DEPRECATED
374 #endif
375  virtual QMenu *fileMenu() = 0;
376  virtual QMenu *projectMenu() = 0;
377  virtual QMenu *editMenu() = 0;
378  virtual QMenu *viewMenu() = 0;
379  virtual QMenu *layerMenu() = 0;
380  virtual QMenu *newLayerMenu() = 0;
382  virtual QMenu *addLayerMenu() = 0;
383  virtual QMenu *settingsMenu() = 0;
384  virtual QMenu *pluginMenu() = 0;
385  virtual QMenu *rasterMenu() = 0;
386  virtual QMenu *databaseMenu() = 0;
387  virtual QMenu *vectorMenu() = 0;
388  virtual QMenu *webMenu() = 0;
389  virtual QMenu *firstRightStandardMenu() = 0;
390  virtual QMenu *windowMenu() = 0;
391  virtual QMenu *helpMenu() = 0;
392 
393  // ToolBars
394  virtual QToolBar *fileToolBar() = 0;
395  virtual QToolBar *layerToolBar() = 0;
396  virtual QToolBar *mapNavToolToolBar() = 0;
397  virtual QToolBar *digitizeToolBar() = 0;
398  virtual QToolBar *advancedDigitizeToolBar() = 0;
399  virtual QToolBar *attributesToolBar() = 0;
400  virtual QToolBar *pluginToolBar() = 0;
401  virtual QToolBar *helpToolBar() = 0;
402  virtual QToolBar *rasterToolBar() = 0;
403  virtual QToolBar *vectorToolBar() = 0;
404  virtual QToolBar *databaseToolBar() = 0;
405  virtual QToolBar *webToolBar() = 0;
406 
407  // Project menu actions
408  virtual QAction *actionNewProject() = 0;
409  virtual QAction *actionOpenProject() = 0;
410  virtual QAction *actionSaveProject() = 0;
411  virtual QAction *actionSaveProjectAs() = 0;
412  virtual QAction *actionSaveMapAsImage() = 0;
413  virtual QAction *actionProjectProperties() = 0;
414  virtual QAction *actionPrintComposer() = 0;
415  virtual QAction *actionShowComposerManager() = 0;
416  virtual QAction *actionExit() = 0;
417 
418  // Edit menu actions
419  virtual QAction *actionCutFeatures() = 0;
420  virtual QAction *actionCopyFeatures() = 0;
421  virtual QAction *actionPasteFeatures() = 0;
422  virtual QAction *actionAddFeature() = 0;
423  virtual QAction *actionDeleteSelected() = 0;
424  virtual QAction *actionMoveFeature() = 0;
425  virtual QAction *actionSplitFeatures() = 0;
426  virtual QAction *actionSplitParts() = 0;
427  virtual QAction *actionAddRing() = 0;
428  virtual QAction *actionAddPart() = 0;
429  virtual QAction *actionSimplifyFeature() = 0;
430  virtual QAction *actionDeleteRing() = 0;
431  virtual QAction *actionDeletePart() = 0;
432  virtual QAction *actionNodeTool() = 0;
433 
434  // View menu actions
436  virtual QAction *actionPan() = 0;
438  virtual QAction *actionTouch() = 0;
440  virtual QAction *actionPanToSelected() = 0;
442  virtual QAction *actionZoomIn() = 0;
444  virtual QAction *actionZoomOut() = 0;
446  virtual QAction *actionSelect() = 0;
448  virtual QAction *actionSelectRectangle() = 0;
450  virtual QAction *actionSelectPolygon() = 0;
452  virtual QAction *actionSelectFreehand() = 0;
454  virtual QAction *actionSelectRadius() = 0;
456  virtual QAction *actionIdentify() = 0;
458  virtual QAction *actionFeatureAction() = 0;
460  virtual QAction *actionMeasure() = 0;
462  virtual QAction *actionMeasureArea() = 0;
464  virtual QAction *actionZoomFullExtent() = 0;
466  virtual QAction *actionZoomToLayer() = 0;
468  virtual QAction *actionZoomToSelected() = 0;
470  virtual QAction *actionZoomLast() = 0;
472  virtual QAction *actionZoomNext() = 0;
474  virtual QAction *actionZoomActualSize() = 0;
476  virtual QAction *actionMapTips() = 0;
478  virtual QAction *actionNewBookmark() = 0;
480  virtual QAction *actionShowBookmarks() = 0;
482  virtual QAction *actionDraw() = 0;
483 
484  // Layer menu actions
485  virtual QAction *actionNewVectorLayer() = 0;
486  virtual QAction *actionAddOgrLayer() = 0;
487  virtual QAction *actionAddRasterLayer() = 0;
488  virtual QAction *actionAddPgLayer() = 0;
489  virtual QAction *actionAddWmsLayer() = 0;
491  virtual QAction *actionAddAfsLayer() = 0;
493  virtual QAction *actionAddAmsLayer() = 0;
494  virtual QAction *actionCopyLayerStyle() = 0;
495  virtual QAction *actionPasteLayerStyle() = 0;
496  virtual QAction *actionOpenTable() = 0;
497  virtual QAction *actionOpenFieldCalculator() = 0;
498  virtual QAction *actionToggleEditing() = 0;
499  virtual QAction *actionSaveActiveLayerEdits() = 0;
500  virtual QAction *actionAllEdits() = 0;
501  virtual QAction *actionSaveEdits() = 0;
502  virtual QAction *actionSaveAllEdits() = 0;
503  virtual QAction *actionRollbackEdits() = 0;
504  virtual QAction *actionRollbackAllEdits() = 0;
505  virtual QAction *actionCancelEdits() = 0;
506  virtual QAction *actionCancelAllEdits() = 0;
507  virtual QAction *actionLayerSaveAs() = 0;
509 #ifndef Q_MOC_RUN
510  Q_DECL_DEPRECATED
511 #endif
512  virtual QAction *actionLayerSelectionSaveAs() = 0;
513  virtual QAction *actionRemoveLayer() = 0;
514  virtual QAction *actionDuplicateLayer() = 0;
515  virtual QAction *actionLayerProperties() = 0;
516  virtual QAction *actionAddToOverview() = 0;
517  virtual QAction *actionAddAllToOverview() = 0;
518  virtual QAction *actionRemoveAllFromOverview() = 0;
519  virtual QAction *actionHideAllLayers() = 0;
520  virtual QAction *actionShowAllLayers() = 0;
521  virtual QAction *actionHideSelectedLayers() = 0;
522  virtual QAction *actionShowSelectedLayers() = 0;
523 
524  // Plugin menu actions
525  virtual QAction *actionManagePlugins() = 0;
526  virtual QAction *actionPluginListSeparator() = 0;
527  virtual QAction *actionShowPythonDialog() = 0;
528 
529  // Settings menu actions
530  virtual QAction *actionToggleFullScreen() = 0;
531  virtual QAction *actionOptions() = 0;
532  virtual QAction *actionCustomProjection() = 0;
533 
534  // Help menu actions
535  virtual QAction *actionHelpContents() = 0;
536  virtual QAction *actionQgisHomePage() = 0;
537  virtual QAction *actionCheckQgisVersion() = 0;
538  virtual QAction *actionAbout() = 0;
539 
547  virtual bool openFeatureForm( QgsVectorLayer *l, QgsFeature &f, bool updateFeatureOnly = false, bool showModal = true ) = 0;
548 
557  virtual QgsAttributeDialog* getFeatureForm( QgsVectorLayer *l, QgsFeature &f ) = 0;
558 
566  virtual QgsVectorLayerTools* vectorLayerTools() = 0;
567 
579  virtual void preloadForm( const QString& uifile ) = 0;
580 
584  virtual QList<QgsMapLayer *> editableLayers( bool modified = false ) const = 0;
585 
587  virtual int messageTimeout() = 0;
588 
589  signals:
593  void currentLayerChanged( QgsMapLayer * layer );
594 
598  void composerAdded( QgsComposerView* v );
599 
603  void composerWillBeRemoved( QgsComposerView* v );
604 
608  void composerRemoved( QgsComposerView* v );
609 
613  void initializationCompleted();
620  void projectRead();
629  void newProjectCreated();
630 
635  void layerSavedAs( QgsMapLayer* l, const QString& path );
636 };
637 
638 #endif //#ifndef QGISINTERFACE_H
Methods in this class are used to handle basic operations on vector layers.
QgsLegendInterface Abstract base class to make QgsLegend available to plugins.
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:187
Map canvas is a class for displaying all GIS data types on a canvas.
Definition: qgsmapcanvas.h:109
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.