QGIS API Documentation  2.5.0-Master
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups 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;
392  virtual QMenu *settingsMenu() = 0;
393  virtual QMenu *pluginMenu() = 0;
394  virtual QMenu *rasterMenu() = 0;
397  virtual QMenu *databaseMenu() = 0;
400  virtual QMenu *vectorMenu() = 0;
403  virtual QMenu *webMenu() = 0;
404  virtual QMenu *firstRightStandardMenu() = 0;
405  virtual QMenu *windowMenu() = 0;
406  virtual QMenu *helpMenu() = 0;
407 
408  // ToolBars
409  virtual QToolBar *fileToolBar() = 0;
410  virtual QToolBar *layerToolBar() = 0;
411  virtual QToolBar *mapNavToolToolBar() = 0;
412  virtual QToolBar *digitizeToolBar() = 0;
413  virtual QToolBar *advancedDigitizeToolBar() = 0; // added in v1.5
414  virtual QToolBar *attributesToolBar() = 0;
415  virtual QToolBar *pluginToolBar() = 0;
416  virtual QToolBar *helpToolBar() = 0;
419  virtual QToolBar *rasterToolBar() = 0;
422  virtual QToolBar *vectorToolBar() = 0;
425  virtual QToolBar *databaseToolBar() = 0;
428  virtual QToolBar *webToolBar() = 0;
429 
430  // Project menu actions
431  virtual QAction *actionNewProject() = 0;
432  virtual QAction *actionOpenProject() = 0;
433  virtual QAction *actionSaveProject() = 0;
434  virtual QAction *actionSaveProjectAs() = 0;
435  virtual QAction *actionSaveMapAsImage() = 0;
436  virtual QAction *actionProjectProperties() = 0;
437  virtual QAction *actionPrintComposer() = 0;
438  virtual QAction *actionShowComposerManager() = 0;
439  virtual QAction *actionExit() = 0;
440 
441  // Edit menu actions
442  virtual QAction *actionCutFeatures() = 0;
443  virtual QAction *actionCopyFeatures() = 0;
444  virtual QAction *actionPasteFeatures() = 0;
445  virtual QAction *actionAddFeature() = 0;
446  virtual QAction *actionDeleteSelected() = 0;
447  virtual QAction *actionMoveFeature() = 0;
448  virtual QAction *actionSplitFeatures() = 0;
449  virtual QAction *actionSplitParts() = 0;
450  virtual QAction *actionAddRing() = 0;
451  virtual QAction *actionAddPart() = 0;
452  virtual QAction *actionSimplifyFeature() = 0;
453  virtual QAction *actionDeleteRing() = 0;
454  virtual QAction *actionDeletePart() = 0;
455  virtual QAction *actionNodeTool() = 0;
456 
457  // View menu actions
459  virtual QAction *actionPan() = 0;
461  virtual QAction *actionTouch() = 0;
463  virtual QAction *actionPanToSelected() = 0;
465  virtual QAction *actionZoomIn() = 0;
467  virtual QAction *actionZoomOut() = 0;
469  virtual QAction *actionSelect() = 0;
471  virtual QAction *actionSelectRectangle() = 0;
473  virtual QAction *actionSelectPolygon() = 0;
475  virtual QAction *actionSelectFreehand() = 0;
477  virtual QAction *actionSelectRadius() = 0;
479  virtual QAction *actionIdentify() = 0;
481  virtual QAction *actionFeatureAction() = 0;
483  virtual QAction *actionMeasure() = 0;
485  virtual QAction *actionMeasureArea() = 0;
487  virtual QAction *actionZoomFullExtent() = 0;
489  virtual QAction *actionZoomToLayer() = 0;
491  virtual QAction *actionZoomToSelected() = 0;
493  virtual QAction *actionZoomLast() = 0;
495  virtual QAction *actionZoomNext() = 0;
497  virtual QAction *actionZoomActualSize() = 0;
499  virtual QAction *actionMapTips() = 0;
501  virtual QAction *actionNewBookmark() = 0;
503  virtual QAction *actionShowBookmarks() = 0;
505  virtual QAction *actionDraw() = 0;
506 
507  // Layer menu actions
508  virtual QAction *actionNewVectorLayer() = 0;
509  virtual QAction *actionAddOgrLayer() = 0;
510  virtual QAction *actionAddRasterLayer() = 0;
511  virtual QAction *actionAddPgLayer() = 0;
512  virtual QAction *actionAddWmsLayer() = 0;
514  virtual QAction *actionCopyLayerStyle() = 0;
516  virtual QAction *actionPasteLayerStyle() = 0;
517  virtual QAction *actionOpenTable() = 0;
518  virtual QAction *actionOpenFieldCalculator() = 0;
519  virtual QAction *actionToggleEditing() = 0;
521  virtual QAction *actionSaveActiveLayerEdits() = 0;
523  virtual QAction *actionAllEdits() = 0;
525  virtual QAction *actionSaveEdits() = 0;
527  virtual QAction *actionSaveAllEdits() = 0;
529  virtual QAction *actionRollbackEdits() = 0;
531  virtual QAction *actionRollbackAllEdits() = 0;
533  virtual QAction *actionCancelEdits() = 0;
535  virtual QAction *actionCancelAllEdits() = 0;
536  virtual QAction *actionLayerSaveAs() = 0;
538 #ifndef Q_MOC_RUN
539  Q_DECL_DEPRECATED
540 #endif
541  virtual QAction *actionLayerSelectionSaveAs() = 0;
542  virtual QAction *actionRemoveLayer() = 0;
544  virtual QAction *actionDuplicateLayer() = 0;
545  virtual QAction *actionLayerProperties() = 0;
546  virtual QAction *actionAddToOverview() = 0;
547  virtual QAction *actionAddAllToOverview() = 0;
548  virtual QAction *actionRemoveAllFromOverview() = 0;
549  virtual QAction *actionHideAllLayers() = 0;
550  virtual QAction *actionShowAllLayers() = 0;
551 
552  // Plugin menu actions
553  virtual QAction *actionManagePlugins() = 0;
554  virtual QAction *actionPluginListSeparator() = 0;
555  virtual QAction *actionShowPythonDialog() = 0;
556 
557  // Settings menu actions
558  virtual QAction *actionToggleFullScreen() = 0;
559  virtual QAction *actionOptions() = 0;
560  virtual QAction *actionCustomProjection() = 0;
561 
562  // Help menu actions
563  virtual QAction *actionHelpContents() = 0;
564  virtual QAction *actionQgisHomePage() = 0;
565  virtual QAction *actionCheckQgisVersion() = 0;
566  virtual QAction *actionAbout() = 0;
567 
576  virtual bool openFeatureForm( QgsVectorLayer *l, QgsFeature &f, bool updateFeatureOnly = false, bool showModal = true ) = 0;
577 
586  virtual QgsAttributeDialog* getFeatureForm( QgsVectorLayer *l, QgsFeature &f ) = 0;
587 
595  virtual QgsVectorLayerTools* vectorLayerTools() = 0;
596 
608  virtual void preloadForm( QString uifile ) = 0;
609 
614  virtual QList<QgsMapLayer *> editableLayers( bool modified = false ) const = 0;
615 
618  virtual int messageTimeout() = 0;
619 
620  signals:
624  void currentLayerChanged( QgsMapLayer * layer );
625 
630  void composerAdded( QgsComposerView* v );
631 
636  void composerWillBeRemoved( QgsComposerView* v );
641  void initializationCompleted();
650  void projectRead();
661  void newProjectCreated();
662 };
663 
664 // FIXME: also in core/qgis.h
665 #ifndef QGISEXTERN
666 #ifdef WIN32
667 # define QGISEXTERN extern "C" __declspec( dllexport )
668 #else
669 # define QGISEXTERN extern "C"
670 #endif
671 #endif
672 
673 #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: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.
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.