QGIS API Documentation  2.5.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 
76  virtual QgsLegendInterface* legendInterface() = 0;
77 
78  virtual QgsPluginManagerInterface* pluginManagerInterface() = 0;
79 
80  virtual QgsLayerTreeView* layerTreeView() = 0;
81 
82  public slots: // TODO: do these functions really need to be slots?
83 
84  /* Exposed functions */
85 
87  virtual void zoomFull() = 0;
88 
90  virtual void zoomToPrevious() = 0;
91 
93  virtual void zoomToNext() = 0;
94 
96  virtual void zoomToActiveLayer() = 0;
97 
99  virtual QgsVectorLayer* addVectorLayer( QString vectorLayerPath, QString baseName, QString providerKey ) = 0;
100 
102  virtual QgsRasterLayer* addRasterLayer( QString rasterLayerPath, QString baseName = QString() ) = 0;
103 
105  virtual QgsRasterLayer* addRasterLayer( const QString& url, const QString& layerName, const QString& providerKey ) = 0;
106 
108  virtual bool addProject( QString theProject ) = 0;
110  virtual void newProject( bool thePromptToSaveFlag = false ) = 0;
111 
113  virtual QgsMapLayer *activeLayer() = 0;
114 
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 
148  virtual int addRasterToolBarIcon( QAction *qAction ) = 0;
149 
152  virtual void removeRasterToolBarIcon( QAction *qAction ) = 0;
153 
156 
157  virtual int addVectorToolBarIcon( QAction *qAction ) = 0;
158 
167  virtual QAction* addVectorToolBarWidget( QWidget* widget ) = 0;
168 
171  virtual void removeVectorToolBarIcon( QAction *qAction ) = 0;
172 
175  virtual int addDatabaseToolBarIcon( QAction *qAction ) = 0;
176 
185  virtual QAction* addDatabaseToolBarWidget( QWidget* widget ) = 0;
186 
189  virtual void removeDatabaseToolBarIcon( QAction *qAction ) = 0;
190 
193  virtual int addWebToolBarIcon( QAction *qAction ) = 0;
194 
203  virtual QAction* addWebToolBarWidget( QWidget* widget ) = 0;
204 
207  virtual void removeWebToolBarIcon( QAction *qAction ) = 0;
208 
210  virtual QToolBar *addToolBar( QString name ) = 0;
211 
214  virtual void addToolBar( QToolBar* toolbar, Qt::ToolBarArea area = Qt::TopToolBarArea ) = 0;
215 
217  virtual QgsMapCanvas * mapCanvas() = 0;
218 
220  virtual QWidget * mainWindow() = 0;
221 
223  virtual QgsMessageBar * messageBar() = 0;
224 
226  virtual QList<QgsComposerView*> activeComposers() = 0;
227 
233  virtual QgsComposerView* createNewComposer( QString title = QString( "" ) ) = 0;
234 
241  virtual QgsComposerView* duplicateComposer( QgsComposerView* composerView, QString title = QString( "" ) ) = 0;
242 
246  virtual void deleteComposer( QgsComposerView* composerView ) = 0;
247 
251  virtual QMap<QString, QVariant> defaultStyleSheetOptions() = 0;
252 
257  virtual void buildStyleSheet( const QMap<QString, QVariant>& opts ) = 0;
258 
262  virtual void saveStyleSheetOptions( const QMap<QString, QVariant>& opts ) = 0;
263 
267  virtual QFont defaultStyleSheetFont() = 0;
268 
270  virtual void addPluginToMenu( QString name, QAction* action ) = 0;
271 
273  virtual void removePluginMenu( QString name, QAction* action ) = 0;
274 
278  virtual void insertAddLayerAction( QAction *action ) = 0;
279 
283  virtual void removeAddLayerAction( QAction *action ) = 0;
284 
288  virtual void addPluginToDatabaseMenu( QString name, QAction* action ) = 0;
289 
293  virtual void removePluginDatabaseMenu( QString name, QAction* action ) = 0;
294 
298  virtual void addPluginToRasterMenu( QString name, QAction* action ) = 0;
299 
303  virtual void removePluginRasterMenu( QString name, QAction* action ) = 0;
304 
308  virtual void addPluginToVectorMenu( QString name, QAction* action ) = 0;
309 
313  virtual void removePluginVectorMenu( QString name, QAction* action ) = 0;
314 
318  virtual void addPluginToWebMenu( QString name, QAction* action ) = 0;
319 
323  virtual void removePluginWebMenu( QString name, QAction* action ) = 0;
324 
326  virtual void addDockWidget( Qt::DockWidgetArea area, QDockWidget * dockwidget ) = 0;
327 
331  virtual void removeDockWidget( QDockWidget * dockwidget ) = 0;
332 
336  virtual void showLayerProperties( QgsMapLayer *l ) = 0;
337 
341  virtual void showAttributeTable( QgsVectorLayer *l ) = 0;
342 
345  virtual void addWindow( QAction *action ) = 0;
346 
349  virtual void removeWindow( QAction *action ) = 0;
350 
354  virtual bool registerMainWindowAction( QAction* action, QString defaultShortcut ) = 0;
355 
359  virtual bool unregisterMainWindowAction( QAction* action ) = 0;
360 
361  // @todo is this deprecated in favour of QgsContextHelp?
370 #ifndef Q_MOC_RUN
371  Q_DECL_DEPRECATED
372 #endif
373  virtual void openURL( QString url, bool useQgisDocDirectory = true ) = 0;
374 
375 
380  // Menus
381 #ifndef Q_MOC_RUN
382  Q_DECL_DEPRECATED
383 #endif
384  virtual QMenu *fileMenu() = 0;
385  virtual QMenu *projectMenu() = 0;
386  virtual QMenu *editMenu() = 0;
387  virtual QMenu *viewMenu() = 0;
388  virtual QMenu *layerMenu() = 0;
391  virtual QMenu *newLayerMenu() = 0;
394  virtual QMenu *addLayerMenu() = 0;
395  virtual QMenu *settingsMenu() = 0;
396  virtual QMenu *pluginMenu() = 0;
397  virtual QMenu *rasterMenu() = 0;
400  virtual QMenu *databaseMenu() = 0;
403  virtual QMenu *vectorMenu() = 0;
406  virtual QMenu *webMenu() = 0;
407  virtual QMenu *firstRightStandardMenu() = 0;
408  virtual QMenu *windowMenu() = 0;
409  virtual QMenu *helpMenu() = 0;
410 
411  // ToolBars
412  virtual QToolBar *fileToolBar() = 0;
413  virtual QToolBar *layerToolBar() = 0;
414  virtual QToolBar *mapNavToolToolBar() = 0;
415  virtual QToolBar *digitizeToolBar() = 0;
416  virtual QToolBar *advancedDigitizeToolBar() = 0; // added in v1.5
417  virtual QToolBar *attributesToolBar() = 0;
418  virtual QToolBar *pluginToolBar() = 0;
419  virtual QToolBar *helpToolBar() = 0;
422  virtual QToolBar *rasterToolBar() = 0;
425  virtual QToolBar *vectorToolBar() = 0;
428  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 *actionCopyLayerStyle() = 0;
519  virtual QAction *actionPasteLayerStyle() = 0;
520  virtual QAction *actionOpenTable() = 0;
521  virtual QAction *actionOpenFieldCalculator() = 0;
522  virtual QAction *actionToggleEditing() = 0;
524  virtual QAction *actionSaveActiveLayerEdits() = 0;
526  virtual QAction *actionAllEdits() = 0;
528  virtual QAction *actionSaveEdits() = 0;
530  virtual QAction *actionSaveAllEdits() = 0;
532  virtual QAction *actionRollbackEdits() = 0;
534  virtual QAction *actionRollbackAllEdits() = 0;
536  virtual QAction *actionCancelEdits() = 0;
538  virtual QAction *actionCancelAllEdits() = 0;
539  virtual QAction *actionLayerSaveAs() = 0;
541 #ifndef Q_MOC_RUN
542  Q_DECL_DEPRECATED
543 #endif
544  virtual QAction *actionLayerSelectionSaveAs() = 0;
545  virtual QAction *actionRemoveLayer() = 0;
547  virtual QAction *actionDuplicateLayer() = 0;
548  virtual QAction *actionLayerProperties() = 0;
549  virtual QAction *actionAddToOverview() = 0;
550  virtual QAction *actionAddAllToOverview() = 0;
551  virtual QAction *actionRemoveAllFromOverview() = 0;
552  virtual QAction *actionHideAllLayers() = 0;
553  virtual QAction *actionShowAllLayers() = 0;
554 
555  // Plugin menu actions
556  virtual QAction *actionManagePlugins() = 0;
557  virtual QAction *actionPluginListSeparator() = 0;
558  virtual QAction *actionShowPythonDialog() = 0;
559 
560  // Settings menu actions
561  virtual QAction *actionToggleFullScreen() = 0;
562  virtual QAction *actionOptions() = 0;
563  virtual QAction *actionCustomProjection() = 0;
564 
565  // Help menu actions
566  virtual QAction *actionHelpContents() = 0;
567  virtual QAction *actionQgisHomePage() = 0;
568  virtual QAction *actionCheckQgisVersion() = 0;
569  virtual QAction *actionAbout() = 0;
570 
579  virtual bool openFeatureForm( QgsVectorLayer *l, QgsFeature &f, bool updateFeatureOnly = false, bool showModal = true ) = 0;
580 
589  virtual QgsAttributeDialog* getFeatureForm( QgsVectorLayer *l, QgsFeature &f ) = 0;
590 
598  virtual QgsVectorLayerTools* vectorLayerTools() = 0;
599 
611  virtual void preloadForm( QString uifile ) = 0;
612 
617  virtual QList<QgsMapLayer *> editableLayers( bool modified = false ) const = 0;
618 
621  virtual int messageTimeout() = 0;
622 
623  signals:
627  void currentLayerChanged( QgsMapLayer * layer );
628 
633  void composerAdded( QgsComposerView* v );
634 
639  void composerWillBeRemoved( QgsComposerView* v );
644  void initializationCompleted();
653  void projectRead();
664  void newProjectCreated();
665 };
666 
667 // FIXME: also in core/qgis.h
668 #ifndef QGISEXTERN
669 #ifdef WIN32
670 # define QGISEXTERN extern "C" __declspec( dllexport )
671 #else
672 # define QGISEXTERN extern "C"
673 #endif
674 #endif
675 
676 #endif //#ifndef QGISINTERFACE_H
Methods in this class are used to handle basic operations on vector layers.
Definition: qgsvectorlayertools.h:33
QgsLegendInterface Abstract base class to make QgsLegend available to plugins.
Definition: qgslegendinterface.h:42
Base class for all map layer types.
Definition: qgsmaplayer.h:48
The QgsLayerTreeView class extends QTreeView and provides some additional functionality when working ...
Definition: qgslayertreeview.h:44
This class provides qgis with the ability to render raster datasets onto the mapcanvas.
Definition: qgsrasterlayer.h:169
Definition: qgsattributedialog.h:35
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: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.
Definition: qgscomposerview.h:47
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.
Definition: qgsvectorlayer.h:470
Definition: qgspluginmanagerinterface.h:25