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 QgsComposerView;
29 class QgsFeature;
30 class QgsLayerTreeView;
31 class QgsLegendInterface;
32 class QgsMapCanvas;
33 class QgsMapLayer;
34 class QgsMessageBar;
36 class QgsRasterLayer;
37 class QgsVectorLayer;
39 
40 #include <QObject>
41 #include <QFont>
42 #include <QPair>
43 #include <map>
44 
45 #include <qgis.h>
46 
47 
60 class GUI_EXPORT QgisInterface : public QObject
61 {
62  Q_OBJECT
63 
64  public:
65 
67  QgisInterface();
68 
70  virtual ~QgisInterface();
71 
75  virtual QgsLegendInterface* legendInterface() = 0;
76 
77  virtual QgsPluginManagerInterface* pluginManagerInterface() = 0;
78 
79  virtual QgsLayerTreeView* layerTreeView() = 0;
80 
81  public slots: // TODO: do these functions really need to be slots?
82 
83  /* Exposed functions */
84 
86  virtual void zoomFull() = 0;
87 
89  virtual void zoomToPrevious() = 0;
90 
92  virtual void zoomToNext() = 0;
93 
95  virtual void zoomToActiveLayer() = 0;
96 
98  virtual QgsVectorLayer* addVectorLayer( QString vectorLayerPath, QString baseName, QString providerKey ) = 0;
99 
101  virtual QgsRasterLayer* addRasterLayer( QString rasterLayerPath, QString baseName = QString() ) = 0;
102 
104  virtual QgsRasterLayer* addRasterLayer( const QString& url, const QString& layerName, const QString& providerKey ) = 0;
105 
107  virtual bool addProject( QString theProject ) = 0;
109  virtual void newProject( bool thePromptToSaveFlag = false ) = 0;
110 
112  virtual QgsMapLayer *activeLayer() = 0;
113 
117  virtual bool setActiveLayer( QgsMapLayer * ) = 0;
118 
120  virtual int addToolBarIcon( QAction *qAction ) = 0;
121 
130  virtual QAction* addToolBarWidget( QWidget* widget ) = 0;
131 
133  virtual void removeToolBarIcon( QAction *qAction ) = 0;
134 
143  virtual QAction* addRasterToolBarWidget( QWidget* widget ) = 0;
144 
147  virtual int addRasterToolBarIcon( QAction *qAction ) = 0;
148 
151  virtual void removeRasterToolBarIcon( QAction *qAction ) = 0;
152 
155 
156  virtual int addVectorToolBarIcon( QAction *qAction ) = 0;
157 
166  virtual QAction* addVectorToolBarWidget( QWidget* widget ) = 0;
167 
170  virtual void removeVectorToolBarIcon( QAction *qAction ) = 0;
171 
174  virtual int addDatabaseToolBarIcon( QAction *qAction ) = 0;
175 
184  virtual QAction* addDatabaseToolBarWidget( QWidget* widget ) = 0;
185 
188  virtual void removeDatabaseToolBarIcon( QAction *qAction ) = 0;
189 
192  virtual int addWebToolBarIcon( QAction *qAction ) = 0;
193 
202  virtual QAction* addWebToolBarWidget( QWidget* widget ) = 0;
203 
206  virtual void removeWebToolBarIcon( QAction *qAction ) = 0;
207 
209  virtual QToolBar *addToolBar( QString name ) = 0;
210 
213  virtual void addToolBar( QToolBar* toolbar, Qt::ToolBarArea area = Qt::TopToolBarArea ) = 0;
214 
216  virtual QgsMapCanvas * mapCanvas() = 0;
217 
219  virtual QWidget * mainWindow() = 0;
220 
222  virtual QgsMessageBar * messageBar() = 0;
223 
225  virtual QList<QgsComposerView*> activeComposers() = 0;
226 
232  virtual QgsComposerView* createNewComposer( QString title = QString( "" ) ) = 0;
233 
240  virtual QgsComposerView* duplicateComposer( QgsComposerView* composerView, QString title = QString( "" ) ) = 0;
241 
245  virtual void deleteComposer( QgsComposerView* composerView ) = 0;
246 
250  virtual QMap<QString, QVariant> defaultStyleSheetOptions() = 0;
251 
256  virtual void buildStyleSheet( const QMap<QString, QVariant>& opts ) = 0;
257 
261  virtual void saveStyleSheetOptions( const QMap<QString, QVariant>& opts ) = 0;
262 
266  virtual QFont defaultStyleSheetFont() = 0;
267 
269  virtual void addPluginToMenu( QString name, QAction* action ) = 0;
270 
272  virtual void removePluginMenu( QString name, QAction* action ) = 0;
273 
277  virtual void insertAddLayerAction( QAction *action ) = 0;
278 
282  virtual void removeAddLayerAction( QAction *action ) = 0;
283 
287  virtual void addPluginToDatabaseMenu( QString name, QAction* action ) = 0;
288 
292  virtual void removePluginDatabaseMenu( QString name, QAction* action ) = 0;
293 
297  virtual void addPluginToRasterMenu( QString name, QAction* action ) = 0;
298 
302  virtual void removePluginRasterMenu( QString name, QAction* action ) = 0;
303 
307  virtual void addPluginToVectorMenu( QString name, QAction* action ) = 0;
308 
312  virtual void removePluginVectorMenu( QString name, QAction* action ) = 0;
313 
317  virtual void addPluginToWebMenu( QString name, QAction* action ) = 0;
318 
322  virtual void removePluginWebMenu( QString name, QAction* action ) = 0;
323 
325  virtual void addDockWidget( Qt::DockWidgetArea area, QDockWidget * dockwidget ) = 0;
326 
330  virtual void removeDockWidget( QDockWidget * dockwidget ) = 0;
331 
335  virtual void showLayerProperties( QgsMapLayer *l ) = 0;
336 
340  virtual void showAttributeTable( QgsVectorLayer *l ) = 0;
341 
344  virtual void addWindow( QAction *action ) = 0;
345 
348  virtual void removeWindow( QAction *action ) = 0;
349 
353  virtual bool registerMainWindowAction( QAction* action, QString defaultShortcut ) = 0;
354 
358  virtual bool unregisterMainWindowAction( QAction* action ) = 0;
359 
360  // @todo is this deprecated in favour of QgsContextHelp?
369 #ifndef Q_MOC_RUN
370  Q_DECL_DEPRECATED
371 #endif
372  virtual void openURL( QString url, bool useQgisDocDirectory = true ) = 0;
373 
374 
379  // Menus
380 #ifndef Q_MOC_RUN
381  Q_DECL_DEPRECATED
382 #endif
383  virtual QMenu *fileMenu() = 0;
384  virtual QMenu *projectMenu() = 0;
385  virtual QMenu *editMenu() = 0;
386  virtual QMenu *viewMenu() = 0;
387  virtual QMenu *layerMenu() = 0;
390  virtual QMenu *newLayerMenu() = 0;
391  virtual QMenu *settingsMenu() = 0;
392  virtual QMenu *pluginMenu() = 0;
393  virtual QMenu *rasterMenu() = 0;
396  virtual QMenu *databaseMenu() = 0;
399  virtual QMenu *vectorMenu() = 0;
402  virtual QMenu *webMenu() = 0;
403  virtual QMenu *firstRightStandardMenu() = 0;
404  virtual QMenu *windowMenu() = 0;
405  virtual QMenu *helpMenu() = 0;
406 
407  // ToolBars
408  virtual QToolBar *fileToolBar() = 0;
409  virtual QToolBar *layerToolBar() = 0;
410  virtual QToolBar *mapNavToolToolBar() = 0;
411  virtual QToolBar *digitizeToolBar() = 0;
412  virtual QToolBar *advancedDigitizeToolBar() = 0; // added in v1.5
413  virtual QToolBar *attributesToolBar() = 0;
414  virtual QToolBar *pluginToolBar() = 0;
415  virtual QToolBar *helpToolBar() = 0;
418  virtual QToolBar *rasterToolBar() = 0;
421  virtual QToolBar *vectorToolBar() = 0;
424  virtual QToolBar *databaseToolBar() = 0;
427  virtual QToolBar *webToolBar() = 0;
428 
429  // Project menu actions
430  virtual QAction *actionNewProject() = 0;
431  virtual QAction *actionOpenProject() = 0;
432  virtual QAction *actionSaveProject() = 0;
433  virtual QAction *actionSaveProjectAs() = 0;
434  virtual QAction *actionSaveMapAsImage() = 0;
435  virtual QAction *actionProjectProperties() = 0;
436  virtual QAction *actionPrintComposer() = 0;
437  virtual QAction *actionShowComposerManager() = 0;
438  virtual QAction *actionExit() = 0;
439 
440  // Edit menu actions
441  virtual QAction *actionCutFeatures() = 0;
442  virtual QAction *actionCopyFeatures() = 0;
443  virtual QAction *actionPasteFeatures() = 0;
444  virtual QAction *actionAddFeature() = 0;
445  virtual QAction *actionDeleteSelected() = 0;
446  virtual QAction *actionMoveFeature() = 0;
447  virtual QAction *actionSplitFeatures() = 0;
448  virtual QAction *actionSplitParts() = 0;
449  virtual QAction *actionAddRing() = 0;
450  virtual QAction *actionAddPart() = 0;
451  virtual QAction *actionSimplifyFeature() = 0;
452  virtual QAction *actionDeleteRing() = 0;
453  virtual QAction *actionDeletePart() = 0;
454  virtual QAction *actionNodeTool() = 0;
455 
456  // View menu actions
458  virtual QAction *actionPan() = 0;
460  virtual QAction *actionTouch() = 0;
462  virtual QAction *actionPanToSelected() = 0;
464  virtual QAction *actionZoomIn() = 0;
466  virtual QAction *actionZoomOut() = 0;
468  virtual QAction *actionSelect() = 0;
470  virtual QAction *actionSelectRectangle() = 0;
472  virtual QAction *actionSelectPolygon() = 0;
474  virtual QAction *actionSelectFreehand() = 0;
476  virtual QAction *actionSelectRadius() = 0;
478  virtual QAction *actionIdentify() = 0;
480  virtual QAction *actionFeatureAction() = 0;
482  virtual QAction *actionMeasure() = 0;
484  virtual QAction *actionMeasureArea() = 0;
486  virtual QAction *actionZoomFullExtent() = 0;
488  virtual QAction *actionZoomToLayer() = 0;
490  virtual QAction *actionZoomToSelected() = 0;
492  virtual QAction *actionZoomLast() = 0;
494  virtual QAction *actionZoomNext() = 0;
496  virtual QAction *actionZoomActualSize() = 0;
498  virtual QAction *actionMapTips() = 0;
500  virtual QAction *actionNewBookmark() = 0;
502  virtual QAction *actionShowBookmarks() = 0;
504  virtual QAction *actionDraw() = 0;
505 
506  // Layer menu actions
507  virtual QAction *actionNewVectorLayer() = 0;
508  virtual QAction *actionAddOgrLayer() = 0;
509  virtual QAction *actionAddRasterLayer() = 0;
510  virtual QAction *actionAddPgLayer() = 0;
511  virtual QAction *actionAddWmsLayer() = 0;
513  virtual QAction *actionCopyLayerStyle() = 0;
515  virtual QAction *actionPasteLayerStyle() = 0;
516  virtual QAction *actionOpenTable() = 0;
517  virtual QAction *actionOpenFieldCalculator() = 0;
518  virtual QAction *actionToggleEditing() = 0;
520  virtual QAction *actionSaveActiveLayerEdits() = 0;
522  virtual QAction *actionAllEdits() = 0;
524  virtual QAction *actionSaveEdits() = 0;
526  virtual QAction *actionSaveAllEdits() = 0;
528  virtual QAction *actionRollbackEdits() = 0;
530  virtual QAction *actionRollbackAllEdits() = 0;
532  virtual QAction *actionCancelEdits() = 0;
534  virtual QAction *actionCancelAllEdits() = 0;
535  virtual QAction *actionLayerSaveAs() = 0;
537 #ifndef Q_MOC_RUN
538  Q_DECL_DEPRECATED
539 #endif
540  virtual QAction *actionLayerSelectionSaveAs() = 0;
541  virtual QAction *actionRemoveLayer() = 0;
543  virtual QAction *actionDuplicateLayer() = 0;
544  virtual QAction *actionLayerProperties() = 0;
545  virtual QAction *actionAddToOverview() = 0;
546  virtual QAction *actionAddAllToOverview() = 0;
547  virtual QAction *actionRemoveAllFromOverview() = 0;
548  virtual QAction *actionHideAllLayers() = 0;
549  virtual QAction *actionShowAllLayers() = 0;
550 
551  // Plugin menu actions
552  virtual QAction *actionManagePlugins() = 0;
553  virtual QAction *actionPluginListSeparator() = 0;
554  virtual QAction *actionShowPythonDialog() = 0;
555 
556  // Settings menu actions
557  virtual QAction *actionToggleFullScreen() = 0;
558  virtual QAction *actionOptions() = 0;
559  virtual QAction *actionCustomProjection() = 0;
560 
561  // Help menu actions
562  virtual QAction *actionHelpContents() = 0;
563  virtual QAction *actionQgisHomePage() = 0;
564  virtual QAction *actionCheckQgisVersion() = 0;
565  virtual QAction *actionAbout() = 0;
566 
572  virtual bool openFeatureForm( QgsVectorLayer *l, QgsFeature &f, bool updateFeatureOnly = false ) = 0;
573 
574  virtual QDialog* getFeatureForm( QgsVectorLayer *l, QgsFeature &f ) = 0;
575 
576  virtual QgsVectorLayerTools* vectorLayerTools() = 0;
577 
578  virtual void preloadForm( QString uifile ) = 0;
579 
584  virtual QList<QgsMapLayer *> editableLayers( bool modified = false ) const = 0;
585 
588  virtual int messageTimeout() = 0;
589 
590  signals:
594  void currentLayerChanged( QgsMapLayer * layer );
595 
600  void composerAdded( QgsComposerView* v );
601 
606  void composerWillBeRemoved( QgsComposerView* v );
611  void initializationCompleted();
620  void projectRead();
631  void newProjectCreated();
632 };
633 
634 // FIXME: also in core/qgis.h
635 #ifndef QGISEXTERN
636 #ifdef WIN32
637 # define QGISEXTERN extern "C" __declspec( dllexport )
638 #else
639 # define QGISEXTERN extern "C"
640 #endif
641 #endif
642 
643 #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:60
Represents a vector layer which manages a vector based data sets.