QGIS API Documentation  2.7.0-Master
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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 
28 class QgsAttributeDialog;
29 class QgsComposerView;
30 class QgsFeature;
31 class QgsLayerTreeView;
32 class QgsLegendInterface;
33 class QgsMapCanvas;
34 class QgsMapLayer;
35 class QgsMessageBar;
37 class QgsRasterLayer;
38 class QgsVectorLayer;
40 
41 #include <QObject>
42 #include <QFont>
43 #include <QPair>
44 #include <map>
45 
46 #include <qgis.h>
47 
48 
61 class GUI_EXPORT QgisInterface : public QObject
62 {
63  Q_OBJECT
64 
65  public:
66 
68  QgisInterface();
69 
71  virtual ~QgisInterface();
72 
74  virtual QgsLegendInterface* legendInterface() = 0;
75 
76  virtual QgsPluginManagerInterface* pluginManagerInterface() = 0;
77 
78  virtual QgsLayerTreeView* layerTreeView() = 0;
79 
80  public slots: // TODO: do these functions really need to be slots?
81 
82  /* Exposed functions */
83 
85  virtual void zoomFull() = 0;
86 
88  virtual void zoomToPrevious() = 0;
89 
91  virtual void zoomToNext() = 0;
92 
94  virtual void zoomToActiveLayer() = 0;
95 
97  virtual QgsVectorLayer* addVectorLayer( QString vectorLayerPath, QString baseName, QString providerKey ) = 0;
98 
100  virtual QgsRasterLayer* addRasterLayer( QString rasterLayerPath, QString baseName = QString() ) = 0;
101 
103  virtual QgsRasterLayer* addRasterLayer( const QString& url, const QString& layerName, const QString& providerKey ) = 0;
104 
106  virtual bool addProject( QString theProject ) = 0;
108  virtual void newProject( bool thePromptToSaveFlag = false ) = 0;
109 
111  virtual QgsMapLayer *activeLayer() = 0;
112 
115  virtual bool setActiveLayer( QgsMapLayer * ) = 0;
116 
118  virtual int addToolBarIcon( QAction *qAction ) = 0;
119 
128  virtual QAction* addToolBarWidget( QWidget* widget ) = 0;
129 
131  virtual void removeToolBarIcon( QAction *qAction ) = 0;
132 
141  virtual QAction* addRasterToolBarWidget( QWidget* widget ) = 0;
142 
144  virtual int addRasterToolBarIcon( QAction *qAction ) = 0;
145 
147  virtual void removeRasterToolBarIcon( QAction *qAction ) = 0;
148 
150  virtual int addVectorToolBarIcon( QAction *qAction ) = 0;
151 
160  virtual QAction* addVectorToolBarWidget( QWidget* widget ) = 0;
161 
163  virtual void removeVectorToolBarIcon( QAction *qAction ) = 0;
164 
166  virtual int addDatabaseToolBarIcon( QAction *qAction ) = 0;
167 
176  virtual QAction* addDatabaseToolBarWidget( QWidget* widget ) = 0;
177 
179  virtual void removeDatabaseToolBarIcon( QAction *qAction ) = 0;
180 
182  virtual int addWebToolBarIcon( QAction *qAction ) = 0;
183 
192  virtual QAction* addWebToolBarWidget( QWidget* widget ) = 0;
193 
195  virtual void removeWebToolBarIcon( QAction *qAction ) = 0;
196 
198  virtual QToolBar *addToolBar( QString name ) = 0;
199 
202  virtual void addToolBar( QToolBar* toolbar, Qt::ToolBarArea area = Qt::TopToolBarArea ) = 0;
203 
205  virtual QgsMapCanvas * mapCanvas() = 0;
206 
208  virtual QWidget * mainWindow() = 0;
209 
211  virtual QgsMessageBar * messageBar() = 0;
212 
214  virtual QList<QgsComposerView*> activeComposers() = 0;
215 
221  virtual QgsComposerView* createNewComposer( QString title = QString( "" ) ) = 0;
222 
229  virtual QgsComposerView* duplicateComposer( QgsComposerView* composerView, QString title = QString( "" ) ) = 0;
230 
232  virtual void deleteComposer( QgsComposerView* composerView ) = 0;
233 
235  virtual QMap<QString, QVariant> defaultStyleSheetOptions() = 0;
236 
240  virtual void buildStyleSheet( const QMap<QString, QVariant>& opts ) = 0;
241 
243  virtual void saveStyleSheetOptions( const QMap<QString, QVariant>& opts ) = 0;
244 
246  virtual QFont defaultStyleSheetFont() = 0;
247 
249  virtual void addPluginToMenu( QString name, QAction* action ) = 0;
250 
252  virtual void removePluginMenu( QString name, QAction* action ) = 0;
253 
255  virtual void insertAddLayerAction( QAction *action ) = 0;
256 
258  virtual void removeAddLayerAction( QAction *action ) = 0;
259 
261  virtual void addPluginToDatabaseMenu( QString name, QAction* action ) = 0;
262 
264  virtual void removePluginDatabaseMenu( QString name, QAction* action ) = 0;
265 
267  virtual void addPluginToRasterMenu( QString name, QAction* action ) = 0;
268 
270  virtual void removePluginRasterMenu( QString name, QAction* action ) = 0;
271 
273  virtual void addPluginToVectorMenu( QString name, QAction* action ) = 0;
274 
276  virtual void removePluginVectorMenu( QString name, QAction* action ) = 0;
277 
279  virtual void addPluginToWebMenu( QString name, QAction* action ) = 0;
280 
282  virtual void removePluginWebMenu( QString name, QAction* action ) = 0;
283 
285  virtual void addDockWidget( Qt::DockWidgetArea area, QDockWidget * dockwidget ) = 0;
286 
288  virtual void removeDockWidget( QDockWidget * dockwidget ) = 0;
289 
291  virtual void showLayerProperties( QgsMapLayer *l ) = 0;
292 
294  virtual void showAttributeTable( QgsVectorLayer *l ) = 0;
295 
298  virtual void addWindow( QAction *action ) = 0;
299 
302  virtual void removeWindow( QAction *action ) = 0;
303 
305  virtual bool registerMainWindowAction( QAction* action, QString defaultShortcut ) = 0;
306 
308  virtual bool unregisterMainWindowAction( QAction* action ) = 0;
309 
310  // @todo is this deprecated in favour of QgsContextHelp?
319 #ifndef Q_MOC_RUN
320  Q_DECL_DEPRECATED
321 #endif
322  virtual void openURL( QString url, bool useQgisDocDirectory = true ) = 0;
323 
324 
329  // Menus
330 #ifndef Q_MOC_RUN
331  Q_DECL_DEPRECATED
332 #endif
333  virtual QMenu *fileMenu() = 0;
334  virtual QMenu *projectMenu() = 0;
335  virtual QMenu *editMenu() = 0;
336  virtual QMenu *viewMenu() = 0;
337  virtual QMenu *layerMenu() = 0;
338  virtual QMenu *newLayerMenu() = 0;
340  virtual QMenu *addLayerMenu() = 0;
341  virtual QMenu *settingsMenu() = 0;
342  virtual QMenu *pluginMenu() = 0;
343  virtual QMenu *rasterMenu() = 0;
344  virtual QMenu *databaseMenu() = 0;
345  virtual QMenu *vectorMenu() = 0;
346  virtual QMenu *webMenu() = 0;
347  virtual QMenu *firstRightStandardMenu() = 0;
348  virtual QMenu *windowMenu() = 0;
349  virtual QMenu *helpMenu() = 0;
350 
351  // ToolBars
352  virtual QToolBar *fileToolBar() = 0;
353  virtual QToolBar *layerToolBar() = 0;
354  virtual QToolBar *mapNavToolToolBar() = 0;
355  virtual QToolBar *digitizeToolBar() = 0;
356  virtual QToolBar *advancedDigitizeToolBar() = 0;
357  virtual QToolBar *attributesToolBar() = 0;
358  virtual QToolBar *pluginToolBar() = 0;
359  virtual QToolBar *helpToolBar() = 0;
360  virtual QToolBar *rasterToolBar() = 0;
361  virtual QToolBar *vectorToolBar() = 0;
362  virtual QToolBar *databaseToolBar() = 0;
363  virtual QToolBar *webToolBar() = 0;
364 
365  // Project menu actions
366  virtual QAction *actionNewProject() = 0;
367  virtual QAction *actionOpenProject() = 0;
368  virtual QAction *actionSaveProject() = 0;
369  virtual QAction *actionSaveProjectAs() = 0;
370  virtual QAction *actionSaveMapAsImage() = 0;
371  virtual QAction *actionProjectProperties() = 0;
372  virtual QAction *actionPrintComposer() = 0;
373  virtual QAction *actionShowComposerManager() = 0;
374  virtual QAction *actionExit() = 0;
375 
376  // Edit menu actions
377  virtual QAction *actionCutFeatures() = 0;
378  virtual QAction *actionCopyFeatures() = 0;
379  virtual QAction *actionPasteFeatures() = 0;
380  virtual QAction *actionAddFeature() = 0;
381  virtual QAction *actionDeleteSelected() = 0;
382  virtual QAction *actionMoveFeature() = 0;
383  virtual QAction *actionSplitFeatures() = 0;
384  virtual QAction *actionSplitParts() = 0;
385  virtual QAction *actionAddRing() = 0;
386  virtual QAction *actionAddPart() = 0;
387  virtual QAction *actionSimplifyFeature() = 0;
388  virtual QAction *actionDeleteRing() = 0;
389  virtual QAction *actionDeletePart() = 0;
390  virtual QAction *actionNodeTool() = 0;
391 
392  // View menu actions
394  virtual QAction *actionPan() = 0;
396  virtual QAction *actionTouch() = 0;
398  virtual QAction *actionPanToSelected() = 0;
400  virtual QAction *actionZoomIn() = 0;
402  virtual QAction *actionZoomOut() = 0;
404  virtual QAction *actionSelect() = 0;
406  virtual QAction *actionSelectRectangle() = 0;
408  virtual QAction *actionSelectPolygon() = 0;
410  virtual QAction *actionSelectFreehand() = 0;
412  virtual QAction *actionSelectRadius() = 0;
414  virtual QAction *actionIdentify() = 0;
416  virtual QAction *actionFeatureAction() = 0;
418  virtual QAction *actionMeasure() = 0;
420  virtual QAction *actionMeasureArea() = 0;
422  virtual QAction *actionZoomFullExtent() = 0;
424  virtual QAction *actionZoomToLayer() = 0;
426  virtual QAction *actionZoomToSelected() = 0;
428  virtual QAction *actionZoomLast() = 0;
430  virtual QAction *actionZoomNext() = 0;
432  virtual QAction *actionZoomActualSize() = 0;
434  virtual QAction *actionMapTips() = 0;
436  virtual QAction *actionNewBookmark() = 0;
438  virtual QAction *actionShowBookmarks() = 0;
440  virtual QAction *actionDraw() = 0;
441 
442  // Layer menu actions
443  virtual QAction *actionNewVectorLayer() = 0;
444  virtual QAction *actionAddOgrLayer() = 0;
445  virtual QAction *actionAddRasterLayer() = 0;
446  virtual QAction *actionAddPgLayer() = 0;
447  virtual QAction *actionAddWmsLayer() = 0;
448  virtual QAction *actionCopyLayerStyle() = 0;
449  virtual QAction *actionPasteLayerStyle() = 0;
450  virtual QAction *actionOpenTable() = 0;
451  virtual QAction *actionOpenFieldCalculator() = 0;
452  virtual QAction *actionToggleEditing() = 0;
453  virtual QAction *actionSaveActiveLayerEdits() = 0;
454  virtual QAction *actionAllEdits() = 0;
455  virtual QAction *actionSaveEdits() = 0;
456  virtual QAction *actionSaveAllEdits() = 0;
457  virtual QAction *actionRollbackEdits() = 0;
458  virtual QAction *actionRollbackAllEdits() = 0;
459  virtual QAction *actionCancelEdits() = 0;
460  virtual QAction *actionCancelAllEdits() = 0;
461  virtual QAction *actionLayerSaveAs() = 0;
463 #ifndef Q_MOC_RUN
464  Q_DECL_DEPRECATED
465 #endif
466  virtual QAction *actionLayerSelectionSaveAs() = 0;
467  virtual QAction *actionRemoveLayer() = 0;
468  virtual QAction *actionDuplicateLayer() = 0;
469  virtual QAction *actionLayerProperties() = 0;
470  virtual QAction *actionAddToOverview() = 0;
471  virtual QAction *actionAddAllToOverview() = 0;
472  virtual QAction *actionRemoveAllFromOverview() = 0;
473  virtual QAction *actionHideAllLayers() = 0;
474  virtual QAction *actionShowAllLayers() = 0;
475  virtual QAction *actionHideSelectedLayers() = 0;
476  virtual QAction *actionShowSelectedLayers() = 0;
477 
478  // Plugin menu actions
479  virtual QAction *actionManagePlugins() = 0;
480  virtual QAction *actionPluginListSeparator() = 0;
481  virtual QAction *actionShowPythonDialog() = 0;
482 
483  // Settings menu actions
484  virtual QAction *actionToggleFullScreen() = 0;
485  virtual QAction *actionOptions() = 0;
486  virtual QAction *actionCustomProjection() = 0;
487 
488  // Help menu actions
489  virtual QAction *actionHelpContents() = 0;
490  virtual QAction *actionQgisHomePage() = 0;
491  virtual QAction *actionCheckQgisVersion() = 0;
492  virtual QAction *actionAbout() = 0;
493 
501  virtual bool openFeatureForm( QgsVectorLayer *l, QgsFeature &f, bool updateFeatureOnly = false, bool showModal = true ) = 0;
502 
511  virtual QgsAttributeDialog* getFeatureForm( QgsVectorLayer *l, QgsFeature &f ) = 0;
512 
520  virtual QgsVectorLayerTools* vectorLayerTools() = 0;
521 
533  virtual void preloadForm( QString uifile ) = 0;
534 
538  virtual QList<QgsMapLayer *> editableLayers( bool modified = false ) const = 0;
539 
541  virtual int messageTimeout() = 0;
542 
543  signals:
547  void currentLayerChanged( QgsMapLayer * layer );
548 
552  void composerAdded( QgsComposerView* v );
553 
557  void composerWillBeRemoved( QgsComposerView* v );
561  void initializationCompleted();
568  void projectRead();
577  void newProjectCreated();
578 
583  void layerSavedAs( QgsMapLayer* l, QString path );
584 };
585 
586 // FIXME: also in core/qgis.h
587 #ifndef QGISEXTERN
588 #ifdef WIN32
589 # define QGISEXTERN extern "C" __declspec( dllexport )
590 #else
591 # define QGISEXTERN extern "C"
592 #endif
593 #endif
594 
595 #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:48
The QgsLayerTreeView class extends QTreeView and provides some additional functionality when working ...
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:113
Map canvas is a class for displaying all GIS data types on a canvas.
Definition: qgsmapcanvas.h:104
Widget to display the composer items.
QgisInterface Abstract base class defining interfaces exposed by QgisApp and made available to plugin...
Definition: qgisinterface.h:61
Represents a vector layer which manages a vector based data sets.