QGIS API Documentation  2.8.2-Wien
 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 QgsSnappingUtils;
39 class QgsVectorLayer;
41 
42 #include <QObject>
43 #include <QFont>
44 #include <QPair>
45 #include <map>
46 
47 #include <qgis.h>
48 
49 
62 class GUI_EXPORT QgisInterface : public QObject
63 {
64  Q_OBJECT
65 
66  public:
67 
69  QgisInterface();
70 
72  virtual ~QgisInterface();
73 
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 
116  virtual bool setActiveLayer( QgsMapLayer * ) = 0;
117 
119  virtual int addToolBarIcon( QAction *qAction ) = 0;
120 
129  virtual QAction* addToolBarWidget( QWidget* widget ) = 0;
130 
132  virtual void removeToolBarIcon( QAction *qAction ) = 0;
133 
142  virtual QAction* addRasterToolBarWidget( QWidget* widget ) = 0;
143 
145  virtual int addRasterToolBarIcon( QAction *qAction ) = 0;
146 
148  virtual void removeRasterToolBarIcon( QAction *qAction ) = 0;
149 
151  virtual int addVectorToolBarIcon( QAction *qAction ) = 0;
152 
161  virtual QAction* addVectorToolBarWidget( QWidget* widget ) = 0;
162 
164  virtual void removeVectorToolBarIcon( QAction *qAction ) = 0;
165 
167  virtual int addDatabaseToolBarIcon( QAction *qAction ) = 0;
168 
177  virtual QAction* addDatabaseToolBarWidget( QWidget* widget ) = 0;
178 
180  virtual void removeDatabaseToolBarIcon( QAction *qAction ) = 0;
181 
183  virtual int addWebToolBarIcon( QAction *qAction ) = 0;
184 
193  virtual QAction* addWebToolBarWidget( QWidget* widget ) = 0;
194 
196  virtual void removeWebToolBarIcon( QAction *qAction ) = 0;
197 
199  virtual QToolBar *addToolBar( QString name ) = 0;
200 
203  virtual void addToolBar( QToolBar* toolbar, Qt::ToolBarArea area = Qt::TopToolBarArea ) = 0;
204 
206  virtual QgsMapCanvas * mapCanvas() = 0;
207 
209  virtual QWidget * mainWindow() = 0;
210 
212  virtual QgsMessageBar * messageBar() = 0;
213 
215  virtual QList<QgsComposerView*> activeComposers() = 0;
216 
222  virtual QgsComposerView* createNewComposer( QString title = QString( "" ) ) = 0;
223 
230  virtual QgsComposerView* duplicateComposer( QgsComposerView* composerView, QString title = QString( "" ) ) = 0;
231 
233  virtual void deleteComposer( QgsComposerView* composerView ) = 0;
234 
236  virtual QMap<QString, QVariant> defaultStyleSheetOptions() = 0;
237 
241  virtual void buildStyleSheet( const QMap<QString, QVariant>& opts ) = 0;
242 
244  virtual void saveStyleSheetOptions( const QMap<QString, QVariant>& opts ) = 0;
245 
247  virtual QFont defaultStyleSheetFont() = 0;
248 
250  virtual void addPluginToMenu( QString name, QAction* action ) = 0;
251 
253  virtual void removePluginMenu( QString name, QAction* action ) = 0;
254 
256  virtual void insertAddLayerAction( QAction *action ) = 0;
257 
259  virtual void removeAddLayerAction( QAction *action ) = 0;
260 
262  virtual void addPluginToDatabaseMenu( QString name, QAction* action ) = 0;
263 
265  virtual void removePluginDatabaseMenu( QString name, QAction* action ) = 0;
266 
268  virtual void addPluginToRasterMenu( QString name, QAction* action ) = 0;
269 
271  virtual void removePluginRasterMenu( QString name, QAction* action ) = 0;
272 
274  virtual void addPluginToVectorMenu( QString name, QAction* action ) = 0;
275 
277  virtual void removePluginVectorMenu( QString name, QAction* action ) = 0;
278 
280  virtual void addPluginToWebMenu( QString name, QAction* action ) = 0;
281 
283  virtual void removePluginWebMenu( QString name, QAction* action ) = 0;
284 
286  virtual void addDockWidget( Qt::DockWidgetArea area, QDockWidget * dockwidget ) = 0;
287 
289  virtual void removeDockWidget( QDockWidget * dockwidget ) = 0;
290 
292  virtual void showLayerProperties( QgsMapLayer *l ) = 0;
293 
295  virtual void showAttributeTable( QgsVectorLayer *l ) = 0;
296 
299  virtual void addWindow( QAction *action ) = 0;
300 
303  virtual void removeWindow( QAction *action ) = 0;
304 
306  virtual bool registerMainWindowAction( QAction* action, QString defaultShortcut ) = 0;
307 
309  virtual bool unregisterMainWindowAction( QAction* action ) = 0;
310 
311  // @todo is this deprecated in favour of QgsContextHelp?
320 #ifndef Q_MOC_RUN
321  Q_DECL_DEPRECATED
322 #endif
323  virtual void openURL( QString url, bool useQgisDocDirectory = true ) = 0;
324 
325 
330  // Menus
331 #ifndef Q_MOC_RUN
332  Q_DECL_DEPRECATED
333 #endif
334  virtual QMenu *fileMenu() = 0;
335  virtual QMenu *projectMenu() = 0;
336  virtual QMenu *editMenu() = 0;
337  virtual QMenu *viewMenu() = 0;
338  virtual QMenu *layerMenu() = 0;
339  virtual QMenu *newLayerMenu() = 0;
341  virtual QMenu *addLayerMenu() = 0;
342  virtual QMenu *settingsMenu() = 0;
343  virtual QMenu *pluginMenu() = 0;
344  virtual QMenu *rasterMenu() = 0;
345  virtual QMenu *databaseMenu() = 0;
346  virtual QMenu *vectorMenu() = 0;
347  virtual QMenu *webMenu() = 0;
348  virtual QMenu *firstRightStandardMenu() = 0;
349  virtual QMenu *windowMenu() = 0;
350  virtual QMenu *helpMenu() = 0;
351 
352  // ToolBars
353  virtual QToolBar *fileToolBar() = 0;
354  virtual QToolBar *layerToolBar() = 0;
355  virtual QToolBar *mapNavToolToolBar() = 0;
356  virtual QToolBar *digitizeToolBar() = 0;
357  virtual QToolBar *advancedDigitizeToolBar() = 0;
358  virtual QToolBar *attributesToolBar() = 0;
359  virtual QToolBar *pluginToolBar() = 0;
360  virtual QToolBar *helpToolBar() = 0;
361  virtual QToolBar *rasterToolBar() = 0;
362  virtual QToolBar *vectorToolBar() = 0;
363  virtual QToolBar *databaseToolBar() = 0;
364  virtual QToolBar *webToolBar() = 0;
365 
366  // Project menu actions
367  virtual QAction *actionNewProject() = 0;
368  virtual QAction *actionOpenProject() = 0;
369  virtual QAction *actionSaveProject() = 0;
370  virtual QAction *actionSaveProjectAs() = 0;
371  virtual QAction *actionSaveMapAsImage() = 0;
372  virtual QAction *actionProjectProperties() = 0;
373  virtual QAction *actionPrintComposer() = 0;
374  virtual QAction *actionShowComposerManager() = 0;
375  virtual QAction *actionExit() = 0;
376 
377  // Edit menu actions
378  virtual QAction *actionCutFeatures() = 0;
379  virtual QAction *actionCopyFeatures() = 0;
380  virtual QAction *actionPasteFeatures() = 0;
381  virtual QAction *actionAddFeature() = 0;
382  virtual QAction *actionDeleteSelected() = 0;
383  virtual QAction *actionMoveFeature() = 0;
384  virtual QAction *actionSplitFeatures() = 0;
385  virtual QAction *actionSplitParts() = 0;
386  virtual QAction *actionAddRing() = 0;
387  virtual QAction *actionAddPart() = 0;
388  virtual QAction *actionSimplifyFeature() = 0;
389  virtual QAction *actionDeleteRing() = 0;
390  virtual QAction *actionDeletePart() = 0;
391  virtual QAction *actionNodeTool() = 0;
392 
393  // View menu actions
395  virtual QAction *actionPan() = 0;
397  virtual QAction *actionTouch() = 0;
399  virtual QAction *actionPanToSelected() = 0;
401  virtual QAction *actionZoomIn() = 0;
403  virtual QAction *actionZoomOut() = 0;
405  virtual QAction *actionSelect() = 0;
407  virtual QAction *actionSelectRectangle() = 0;
409  virtual QAction *actionSelectPolygon() = 0;
411  virtual QAction *actionSelectFreehand() = 0;
413  virtual QAction *actionSelectRadius() = 0;
415  virtual QAction *actionIdentify() = 0;
417  virtual QAction *actionFeatureAction() = 0;
419  virtual QAction *actionMeasure() = 0;
421  virtual QAction *actionMeasureArea() = 0;
423  virtual QAction *actionZoomFullExtent() = 0;
425  virtual QAction *actionZoomToLayer() = 0;
427  virtual QAction *actionZoomToSelected() = 0;
429  virtual QAction *actionZoomLast() = 0;
431  virtual QAction *actionZoomNext() = 0;
433  virtual QAction *actionZoomActualSize() = 0;
435  virtual QAction *actionMapTips() = 0;
437  virtual QAction *actionNewBookmark() = 0;
439  virtual QAction *actionShowBookmarks() = 0;
441  virtual QAction *actionDraw() = 0;
442 
443  // Layer menu actions
444  virtual QAction *actionNewVectorLayer() = 0;
445  virtual QAction *actionAddOgrLayer() = 0;
446  virtual QAction *actionAddRasterLayer() = 0;
447  virtual QAction *actionAddPgLayer() = 0;
448  virtual QAction *actionAddWmsLayer() = 0;
449  virtual QAction *actionCopyLayerStyle() = 0;
450  virtual QAction *actionPasteLayerStyle() = 0;
451  virtual QAction *actionOpenTable() = 0;
452  virtual QAction *actionOpenFieldCalculator() = 0;
453  virtual QAction *actionToggleEditing() = 0;
454  virtual QAction *actionSaveActiveLayerEdits() = 0;
455  virtual QAction *actionAllEdits() = 0;
456  virtual QAction *actionSaveEdits() = 0;
457  virtual QAction *actionSaveAllEdits() = 0;
458  virtual QAction *actionRollbackEdits() = 0;
459  virtual QAction *actionRollbackAllEdits() = 0;
460  virtual QAction *actionCancelEdits() = 0;
461  virtual QAction *actionCancelAllEdits() = 0;
462  virtual QAction *actionLayerSaveAs() = 0;
464 #ifndef Q_MOC_RUN
465  Q_DECL_DEPRECATED
466 #endif
467  virtual QAction *actionLayerSelectionSaveAs() = 0;
468  virtual QAction *actionRemoveLayer() = 0;
469  virtual QAction *actionDuplicateLayer() = 0;
470  virtual QAction *actionLayerProperties() = 0;
471  virtual QAction *actionAddToOverview() = 0;
472  virtual QAction *actionAddAllToOverview() = 0;
473  virtual QAction *actionRemoveAllFromOverview() = 0;
474  virtual QAction *actionHideAllLayers() = 0;
475  virtual QAction *actionShowAllLayers() = 0;
476  virtual QAction *actionHideSelectedLayers() = 0;
477  virtual QAction *actionShowSelectedLayers() = 0;
478 
479  // Plugin menu actions
480  virtual QAction *actionManagePlugins() = 0;
481  virtual QAction *actionPluginListSeparator() = 0;
482  virtual QAction *actionShowPythonDialog() = 0;
483 
484  // Settings menu actions
485  virtual QAction *actionToggleFullScreen() = 0;
486  virtual QAction *actionOptions() = 0;
487  virtual QAction *actionCustomProjection() = 0;
488 
489  // Help menu actions
490  virtual QAction *actionHelpContents() = 0;
491  virtual QAction *actionQgisHomePage() = 0;
492  virtual QAction *actionCheckQgisVersion() = 0;
493  virtual QAction *actionAbout() = 0;
494 
502  virtual bool openFeatureForm( QgsVectorLayer *l, QgsFeature &f, bool updateFeatureOnly = false, bool showModal = true ) = 0;
503 
512  virtual QgsAttributeDialog* getFeatureForm( QgsVectorLayer *l, QgsFeature &f ) = 0;
513 
521  virtual QgsVectorLayerTools* vectorLayerTools() = 0;
522 
534  virtual void preloadForm( QString uifile ) = 0;
535 
539  virtual QList<QgsMapLayer *> editableLayers( bool modified = false ) const = 0;
540 
542  virtual int messageTimeout() = 0;
543 
544  signals:
548  void currentLayerChanged( QgsMapLayer * layer );
549 
553  void composerAdded( QgsComposerView* v );
554 
558  void composerWillBeRemoved( QgsComposerView* v );
562  void initializationCompleted();
569  void projectRead();
578  void newProjectCreated();
579 
584  void layerSavedAs( QgsMapLayer* l, QString path );
585 };
586 
587 // FIXME: also in core/qgis.h
588 #ifndef QGISEXTERN
589 #ifdef WIN32
590 # define QGISEXTERN extern "C" __declspec( dllexport )
591 #else
592 # define QGISEXTERN extern "C"
593 #endif
594 #endif
595 
596 #endif //#ifndef QGISINTERFACE_H