QGIS API Documentation
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;
37 class QgsMessageBar;
39 class QgsRasterLayer;
40 class QgsSnappingUtils;
41 class QgsVectorLayer;
43 
44 #include <QObject>
45 #include <QFont>
46 #include <QPair>
47 #include <map>
48 
49 #include "qgis.h"
50 
51 
64 class GUI_EXPORT QgisInterface : public QObject
65 {
66  Q_OBJECT
67 
68  public:
69 
71  QgisInterface();
72 
74  virtual ~QgisInterface();
75 
77  virtual QgsLegendInterface* legendInterface() = 0;
78 
79  virtual QgsPluginManagerInterface* pluginManagerInterface() = 0;
80 
81  virtual QgsLayerTreeView* layerTreeView() = 0;
82 
83  public slots: // TODO: do these functions really need to be slots?
84 
85  /* Exposed functions */
86 
88  virtual void zoomFull() = 0;
89 
91  virtual void zoomToPrevious() = 0;
92 
94  virtual void zoomToNext() = 0;
95 
97  virtual void zoomToActiveLayer() = 0;
98 
100  virtual QgsVectorLayer* addVectorLayer( const QString& vectorLayerPath, const QString& baseName, const QString& providerKey ) = 0;
101 
103  virtual QgsRasterLayer* addRasterLayer( const QString& rasterLayerPath, const QString& baseName = QString() ) = 0;
104 
106  virtual QgsRasterLayer* addRasterLayer( const QString& url, const QString& layerName, const QString& providerKey ) = 0;
107 
109  virtual bool addProject( const QString& theProject ) = 0;
111  virtual void newProject( bool thePromptToSaveFlag = false ) = 0;
112 
114  virtual QgsMapLayer *activeLayer() = 0;
115 
118  virtual bool setActiveLayer( QgsMapLayer * ) = 0;
119 
121  virtual int addToolBarIcon( QAction *qAction ) = 0;
122 
131  virtual QAction* addToolBarWidget( QWidget* widget ) = 0;
132 
134  virtual void removeToolBarIcon( QAction *qAction ) = 0;
135 
144  virtual QAction* addRasterToolBarWidget( QWidget* widget ) = 0;
145 
147  virtual int addRasterToolBarIcon( QAction *qAction ) = 0;
148 
150  virtual void removeRasterToolBarIcon( QAction *qAction ) = 0;
151 
153  virtual int addVectorToolBarIcon( QAction *qAction ) = 0;
154 
163  virtual QAction* addVectorToolBarWidget( QWidget* widget ) = 0;
164 
166  virtual void removeVectorToolBarIcon( QAction *qAction ) = 0;
167 
169  virtual int addDatabaseToolBarIcon( QAction *qAction ) = 0;
170 
179  virtual QAction* addDatabaseToolBarWidget( QWidget* widget ) = 0;
180 
182  virtual void removeDatabaseToolBarIcon( QAction *qAction ) = 0;
183 
185  virtual int addWebToolBarIcon( QAction *qAction ) = 0;
186 
195  virtual QAction* addWebToolBarWidget( QWidget* widget ) = 0;
196 
198  virtual void removeWebToolBarIcon( QAction *qAction ) = 0;
199 
201  virtual QToolBar *addToolBar( const QString& name ) = 0;
202 
205  virtual void addToolBar( QToolBar* toolbar, Qt::ToolBarArea area = Qt::TopToolBarArea ) = 0;
206 
208  virtual QgsMapCanvas * mapCanvas() = 0;
209 
215  virtual QgsLayerTreeMapCanvasBridge* layerTreeCanvasBridge() = 0;
216 
218  virtual QWidget * mainWindow() = 0;
219 
221  virtual QgsMessageBar * messageBar() = 0;
222 
224  virtual void openMessageLog() = 0;
225 
227  virtual void addUserInputWidget( QWidget* widget ) = 0;
228 
230  virtual QList<QgsComposerView*> activeComposers() = 0;
231 
237  virtual QgsComposerView* createNewComposer( const QString& title = QString() ) = 0;
238 
245  virtual QgsComposerView* duplicateComposer( QgsComposerView* composerView, const QString& title = QString() ) = 0;
246 
248  virtual void deleteComposer( QgsComposerView* composerView ) = 0;
249 
251  virtual QMap<QString, QVariant> defaultStyleSheetOptions() = 0;
252 
256  virtual void buildStyleSheet( const QMap<QString, QVariant>& opts ) = 0;
257 
259  virtual void saveStyleSheetOptions( const QMap<QString, QVariant>& opts ) = 0;
260 
262  virtual QFont defaultStyleSheetFont() = 0;
263 
265  virtual void addPluginToMenu( const QString& name, QAction* action ) = 0;
266 
268  virtual void removePluginMenu( const QString& name, QAction* action ) = 0;
269 
271  virtual void insertAddLayerAction( QAction *action ) = 0;
272 
274  virtual void removeAddLayerAction( QAction *action ) = 0;
275 
277  virtual void addPluginToDatabaseMenu( const QString& name, QAction* action ) = 0;
278 
280  virtual void removePluginDatabaseMenu( const QString& name, QAction* action ) = 0;
281 
283  virtual void addPluginToRasterMenu( const QString& name, QAction* action ) = 0;
284 
286  virtual void removePluginRasterMenu( const QString& name, QAction* action ) = 0;
287 
289  virtual void addPluginToVectorMenu( const QString& name, QAction* action ) = 0;
290 
292  virtual void removePluginVectorMenu( const QString& name, QAction* action ) = 0;
293 
295  virtual void addPluginToWebMenu( const QString& name, QAction* action ) = 0;
296 
298  virtual void removePluginWebMenu( const QString& name, QAction* action ) = 0;
299 
301  virtual void addDockWidget( Qt::DockWidgetArea area, QDockWidget * dockwidget ) = 0;
302 
304  virtual void removeDockWidget( QDockWidget * dockwidget ) = 0;
305 
309  virtual QgsAdvancedDigitizingDockWidget* cadDockWidget() = 0;
310 
312  virtual void showLayerProperties( QgsMapLayer *l ) = 0;
313 
315  virtual QDialog* showAttributeTable( QgsVectorLayer *l, const QString& filterExpression = QString() ) = 0;
316 
319  virtual void addWindow( QAction *action ) = 0;
320 
323  virtual void removeWindow( QAction *action ) = 0;
324 
326  virtual bool registerMainWindowAction( QAction* action, const QString& defaultShortcut ) = 0;
327 
329  virtual bool unregisterMainWindowAction( QAction* action ) = 0;
330 
331  // @todo is this deprecated in favour of QgsContextHelp?
340 #ifndef Q_MOC_RUN
341  Q_DECL_DEPRECATED
342 #endif
343  virtual void openURL( const QString& url, bool useQgisDocDirectory = true ) = 0;
344 
345 
350  // Menus
351 #ifndef Q_MOC_RUN
352  Q_DECL_DEPRECATED
353 #endif
354  virtual QMenu *fileMenu() = 0;
355  virtual QMenu *projectMenu() = 0;
356  virtual QMenu *editMenu() = 0;
357  virtual QMenu *viewMenu() = 0;
358  virtual QMenu *layerMenu() = 0;
359  virtual QMenu *newLayerMenu() = 0;
361  virtual QMenu *addLayerMenu() = 0;
362  virtual QMenu *settingsMenu() = 0;
363  virtual QMenu *pluginMenu() = 0;
364  virtual QMenu *rasterMenu() = 0;
365  virtual QMenu *databaseMenu() = 0;
366  virtual QMenu *vectorMenu() = 0;
367  virtual QMenu *webMenu() = 0;
368  virtual QMenu *firstRightStandardMenu() = 0;
369  virtual QMenu *windowMenu() = 0;
370  virtual QMenu *helpMenu() = 0;
371 
372  // ToolBars
373  virtual QToolBar *fileToolBar() = 0;
374  virtual QToolBar *layerToolBar() = 0;
375  virtual QToolBar *mapNavToolToolBar() = 0;
376  virtual QToolBar *digitizeToolBar() = 0;
377  virtual QToolBar *advancedDigitizeToolBar() = 0;
378  virtual QToolBar *attributesToolBar() = 0;
379  virtual QToolBar *pluginToolBar() = 0;
380  virtual QToolBar *helpToolBar() = 0;
381  virtual QToolBar *rasterToolBar() = 0;
382  virtual QToolBar *vectorToolBar() = 0;
383  virtual QToolBar *databaseToolBar() = 0;
384  virtual QToolBar *webToolBar() = 0;
385 
386  // Project menu actions
387  virtual QAction *actionNewProject() = 0;
388  virtual QAction *actionOpenProject() = 0;
389  virtual QAction *actionSaveProject() = 0;
390  virtual QAction *actionSaveProjectAs() = 0;
391  virtual QAction *actionSaveMapAsImage() = 0;
392  virtual QAction *actionProjectProperties() = 0;
393  virtual QAction *actionPrintComposer() = 0;
394  virtual QAction *actionShowComposerManager() = 0;
395  virtual QAction *actionExit() = 0;
396 
397  // Edit menu actions
398  virtual QAction *actionCutFeatures() = 0;
399  virtual QAction *actionCopyFeatures() = 0;
400  virtual QAction *actionPasteFeatures() = 0;
401  virtual QAction *actionAddFeature() = 0;
402  virtual QAction *actionDeleteSelected() = 0;
403  virtual QAction *actionMoveFeature() = 0;
404  virtual QAction *actionSplitFeatures() = 0;
405  virtual QAction *actionSplitParts() = 0;
406  virtual QAction *actionAddRing() = 0;
407  virtual QAction *actionAddPart() = 0;
408  virtual QAction *actionSimplifyFeature() = 0;
409  virtual QAction *actionDeleteRing() = 0;
410  virtual QAction *actionDeletePart() = 0;
411  virtual QAction *actionNodeTool() = 0;
412 
413  // View menu actions
415  virtual QAction *actionPan() = 0;
417  virtual QAction *actionTouch() = 0;
419  virtual QAction *actionPanToSelected() = 0;
421  virtual QAction *actionZoomIn() = 0;
423  virtual QAction *actionZoomOut() = 0;
425  virtual QAction *actionSelect() = 0;
427  virtual QAction *actionSelectRectangle() = 0;
429  virtual QAction *actionSelectPolygon() = 0;
431  virtual QAction *actionSelectFreehand() = 0;
433  virtual QAction *actionSelectRadius() = 0;
435  virtual QAction *actionIdentify() = 0;
437  virtual QAction *actionFeatureAction() = 0;
439  virtual QAction *actionMeasure() = 0;
441  virtual QAction *actionMeasureArea() = 0;
443  virtual QAction *actionZoomFullExtent() = 0;
445  virtual QAction *actionZoomToLayer() = 0;
447  virtual QAction *actionZoomToSelected() = 0;
449  virtual QAction *actionZoomLast() = 0;
451  virtual QAction *actionZoomNext() = 0;
453  virtual QAction *actionZoomActualSize() = 0;
455  virtual QAction *actionMapTips() = 0;
457  virtual QAction *actionNewBookmark() = 0;
459  virtual QAction *actionShowBookmarks() = 0;
461  virtual QAction *actionDraw() = 0;
462 
463  // Layer menu actions
464  virtual QAction *actionNewVectorLayer() = 0;
465  virtual QAction *actionAddOgrLayer() = 0;
466  virtual QAction *actionAddRasterLayer() = 0;
467  virtual QAction *actionAddPgLayer() = 0;
468  virtual QAction *actionAddWmsLayer() = 0;
469  virtual QAction *actionCopyLayerStyle() = 0;
470  virtual QAction *actionPasteLayerStyle() = 0;
471  virtual QAction *actionOpenTable() = 0;
472  virtual QAction *actionOpenFieldCalculator() = 0;
473  virtual QAction *actionToggleEditing() = 0;
474  virtual QAction *actionSaveActiveLayerEdits() = 0;
475  virtual QAction *actionAllEdits() = 0;
476  virtual QAction *actionSaveEdits() = 0;
477  virtual QAction *actionSaveAllEdits() = 0;
478  virtual QAction *actionRollbackEdits() = 0;
479  virtual QAction *actionRollbackAllEdits() = 0;
480  virtual QAction *actionCancelEdits() = 0;
481  virtual QAction *actionCancelAllEdits() = 0;
482  virtual QAction *actionLayerSaveAs() = 0;
484 #ifndef Q_MOC_RUN
485  Q_DECL_DEPRECATED
486 #endif
487  virtual QAction *actionLayerSelectionSaveAs() = 0;
488  virtual QAction *actionRemoveLayer() = 0;
489  virtual QAction *actionDuplicateLayer() = 0;
490  virtual QAction *actionLayerProperties() = 0;
491  virtual QAction *actionAddToOverview() = 0;
492  virtual QAction *actionAddAllToOverview() = 0;
493  virtual QAction *actionRemoveAllFromOverview() = 0;
494  virtual QAction *actionHideAllLayers() = 0;
495  virtual QAction *actionShowAllLayers() = 0;
496  virtual QAction *actionHideSelectedLayers() = 0;
497  virtual QAction *actionShowSelectedLayers() = 0;
498 
499  // Plugin menu actions
500  virtual QAction *actionManagePlugins() = 0;
501  virtual QAction *actionPluginListSeparator() = 0;
502  virtual QAction *actionShowPythonDialog() = 0;
503 
504  // Settings menu actions
505  virtual QAction *actionToggleFullScreen() = 0;
506  virtual QAction *actionOptions() = 0;
507  virtual QAction *actionCustomProjection() = 0;
508 
509  // Help menu actions
510  virtual QAction *actionHelpContents() = 0;
511  virtual QAction *actionQgisHomePage() = 0;
512  virtual QAction *actionCheckQgisVersion() = 0;
513  virtual QAction *actionAbout() = 0;
514 
522  virtual bool openFeatureForm( QgsVectorLayer *l, QgsFeature &f, bool updateFeatureOnly = false, bool showModal = true ) = 0;
523 
532  virtual QgsAttributeDialog* getFeatureForm( QgsVectorLayer *l, QgsFeature &f ) = 0;
533 
541  virtual QgsVectorLayerTools* vectorLayerTools() = 0;
542 
554  virtual void preloadForm( const QString& uifile ) = 0;
555 
559  virtual QList<QgsMapLayer *> editableLayers( bool modified = false ) const = 0;
560 
562  virtual int messageTimeout() = 0;
563 
564  signals:
568  void currentLayerChanged( QgsMapLayer * layer );
569 
573  void composerAdded( QgsComposerView* v );
574 
578  void composerWillBeRemoved( QgsComposerView* v );
579 
583  void composerRemoved( QgsComposerView* v );
584 
588  void initializationCompleted();
595  void projectRead();
604  void newProjectCreated();
605 
610  void layerSavedAs( QgsMapLayer* l, const QString& path );
611 };
612 
613 #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:108
Widget to display the composer items.
QgisInterface Abstract base class defining interfaces exposed by QgisApp and made available to plugin...
Definition: qgisinterface.h:64
This class has all the configuration of snapping and can return answers to snapping queries...
The QgsAdvancedDigitizingDock class is a dockable widget used to handle the CAD tools on top of a sel...
Represents a vector layer which manages a vector based data sets.