QGIS API Documentation  2.0.1-Dufour
 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 QgsMapLayer;
30 class QgsMapCanvas;
31 class QgsRasterLayer;
32 class QgsVectorLayer;
33 class QgsLegendInterface;
35 class QgsFeature;
36 class QgsMessageBar;
37 
38 #include <QObject>
39 #include <QFont>
40 #include <QPair>
41 #include <map>
42 
43 #include <qgis.h>
44 
45 #ifdef _MSC_VER
46 # pragma warning( push )
47 # pragma warning( disable: 4996 ) // was declared deprecated
48 #endif
49 
62 class GUI_EXPORT QgisInterface : public QObject
63 {
64  Q_OBJECT
65 
66  public:
67 
69  QgisInterface();
70 
72  virtual ~QgisInterface();
73 
77  virtual QgsLegendInterface* legendInterface() = 0;
78 
79  virtual QgsPluginManagerInterface* pluginManagerInterface() = 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 
212  virtual QgsMapCanvas * mapCanvas() = 0;
213 
215  virtual QWidget * mainWindow() = 0;
216 
218  virtual QgsMessageBar * messageBar() = 0;
219 
221  virtual QList<QgsComposerView*> activeComposers() = 0;
222 
228  virtual QgsComposerView* createNewComposer( QString title = QString( "" ) ) = 0;
229 
236  virtual QgsComposerView* duplicateComposer( QgsComposerView* composerView, QString title = QString( "" ) ) = 0;
237 
241  virtual void deleteComposer( QgsComposerView* composerView ) = 0;
242 
246  virtual QMap<QString, QVariant> defaultStyleSheetOptions() = 0;
247 
252  virtual void buildStyleSheet( const QMap<QString, QVariant>& opts ) = 0;
253 
257  virtual void saveStyleSheetOptions( const QMap<QString, QVariant>& opts ) = 0;
258 
262  virtual QFont defaultStyleSheetFont() = 0;
263 
265  virtual void addPluginToMenu( QString name, QAction* action ) = 0;
266 
268  virtual void removePluginMenu( QString name, QAction* action ) = 0;
269 
273  virtual void insertAddLayerAction( QAction *action ) = 0;
274 
278  virtual void removeAddLayerAction( QAction *action ) = 0;
279 
283  virtual void addPluginToDatabaseMenu( QString name, QAction* action ) = 0;
284 
288  virtual void removePluginDatabaseMenu( QString name, QAction* action ) = 0;
289 
293  virtual void addPluginToRasterMenu( QString name, QAction* action ) = 0;
294 
298  virtual void removePluginRasterMenu( QString name, QAction* action ) = 0;
299 
303  virtual void addPluginToVectorMenu( QString name, QAction* action ) = 0;
304 
308  virtual void removePluginVectorMenu( QString name, QAction* action ) = 0;
309 
313  virtual void addPluginToWebMenu( QString name, QAction* action ) = 0;
314 
318  virtual void removePluginWebMenu( QString name, QAction* action ) = 0;
319 
321  virtual void addDockWidget( Qt::DockWidgetArea area, QDockWidget * dockwidget ) = 0;
322 
326  virtual void removeDockWidget( QDockWidget * dockwidget ) = 0;
327 
331  virtual void showLayerProperties( QgsMapLayer *l ) = 0;
332 
336  virtual void showAttributeTable( QgsVectorLayer *l ) = 0;
337 
340  virtual void addWindow( QAction *action ) = 0;
341 
344  virtual void removeWindow( QAction *action ) = 0;
345 
349  virtual bool registerMainWindowAction( QAction* action, QString defaultShortcut ) = 0;
350 
354  virtual bool unregisterMainWindowAction( QAction* action ) = 0;
355 
356  // @todo is this deprecated in favour of QgsContextHelp?
365 #ifndef Q_MOC_RUN
366  Q_DECL_DEPRECATED
367 #endif
368  virtual void openURL( QString url, bool useQgisDocDirectory = true ) = 0;
369 
370 
375 
376 #ifndef Q_MOC_RUN
377  Q_DECL_DEPRECATED
378 #endif
379  virtual QMenu *fileMenu() = 0;
380  virtual QMenu *projectMenu() = 0;
381  virtual QMenu *editMenu() = 0;
382  virtual QMenu *viewMenu() = 0;
383  virtual QMenu *layerMenu() = 0;
386  virtual QMenu *newLayerMenu() = 0;
387  virtual QMenu *settingsMenu() = 0;
388  virtual QMenu *pluginMenu() = 0;
389  virtual QMenu *rasterMenu() = 0;
392  virtual QMenu *databaseMenu() = 0;
395  virtual QMenu *vectorMenu() = 0;
398  virtual QMenu *webMenu() = 0;
399  virtual QMenu *firstRightStandardMenu() = 0;
400  virtual QMenu *windowMenu() = 0;
401  virtual QMenu *helpMenu() = 0;
402 
404  virtual QToolBar *fileToolBar() = 0;
405  virtual QToolBar *layerToolBar() = 0;
406  virtual QToolBar *mapNavToolToolBar() = 0;
407  virtual QToolBar *digitizeToolBar() = 0;
408  virtual QToolBar *advancedDigitizeToolBar() = 0; // added in v1.5
409  virtual QToolBar *attributesToolBar() = 0;
410  virtual QToolBar *pluginToolBar() = 0;
411  virtual QToolBar *helpToolBar() = 0;
414  virtual QToolBar *rasterToolBar() = 0;
417  virtual QToolBar *vectorToolBar() = 0;
420  virtual QToolBar *databaseToolBar() = 0;
423  virtual QToolBar *webToolBar() = 0;
424 
426  virtual QAction *actionNewProject() = 0;
427  virtual QAction *actionOpenProject() = 0;
428  virtual QAction *actionSaveProject() = 0;
429  virtual QAction *actionSaveProjectAs() = 0;
430  virtual QAction *actionSaveMapAsImage() = 0;
431  virtual QAction *actionProjectProperties() = 0;
432  virtual QAction *actionPrintComposer() = 0;
433  virtual QAction *actionShowComposerManager() = 0;
434  virtual QAction *actionExit() = 0;
435 
437  virtual QAction *actionCutFeatures() = 0;
438  virtual QAction *actionCopyFeatures() = 0;
439  virtual QAction *actionPasteFeatures() = 0;
440  virtual QAction *actionAddFeature() = 0;
441  virtual QAction *actionDeleteSelected() = 0;
442  virtual QAction *actionMoveFeature() = 0;
443  virtual QAction *actionSplitFeatures() = 0;
444  virtual QAction *actionAddRing() = 0;
445  virtual QAction *actionAddPart() = 0;
446  virtual QAction *actionSimplifyFeature() = 0;
447  virtual QAction *actionDeleteRing() = 0;
448  virtual QAction *actionDeletePart() = 0;
449  virtual QAction *actionNodeTool() = 0;
450 
452  virtual QAction *actionPan() = 0;
453  virtual QAction *actionTouch() = 0;
454  virtual QAction *actionPanToSelected() = 0;
455  virtual QAction *actionZoomIn() = 0;
456  virtual QAction *actionZoomOut() = 0;
457  virtual QAction *actionSelect() = 0;
458  virtual QAction *actionSelectRectangle() = 0;
459  virtual QAction *actionSelectPolygon() = 0;
460  virtual QAction *actionSelectFreehand() = 0;
461  virtual QAction *actionSelectRadius() = 0;
462  virtual QAction *actionIdentify() = 0;
463  virtual QAction *actionMeasure() = 0;
464  virtual QAction *actionMeasureArea() = 0;
465  virtual QAction *actionZoomFullExtent() = 0;
466  virtual QAction *actionZoomToLayer() = 0;
467  virtual QAction *actionZoomToSelected() = 0;
468  virtual QAction *actionZoomLast() = 0;
469  virtual QAction *actionZoomActualSize() = 0;
470  virtual QAction *actionMapTips() = 0;
471  virtual QAction *actionNewBookmark() = 0;
472  virtual QAction *actionShowBookmarks() = 0;
473  virtual QAction *actionDraw() = 0;
474 
476  virtual QAction *actionNewVectorLayer() = 0;
477  virtual QAction *actionAddOgrLayer() = 0;
478  virtual QAction *actionAddRasterLayer() = 0;
479  virtual QAction *actionAddPgLayer() = 0;
480  virtual QAction *actionAddWmsLayer() = 0;
482  virtual QAction *actionCopyLayerStyle() = 0;
484  virtual QAction *actionPasteLayerStyle() = 0;
485  virtual QAction *actionOpenTable() = 0;
486  virtual QAction *actionOpenFieldCalculator() = 0;
487  virtual QAction *actionToggleEditing() = 0;
489  virtual QAction *actionSaveActiveLayerEdits() = 0;
491  virtual QAction *actionAllEdits() = 0;
493  virtual QAction *actionSaveEdits() = 0;
495  virtual QAction *actionSaveAllEdits() = 0;
497  virtual QAction *actionRollbackEdits() = 0;
499  virtual QAction *actionRollbackAllEdits() = 0;
501  virtual QAction *actionCancelEdits() = 0;
503  virtual QAction *actionCancelAllEdits() = 0;
504  virtual QAction *actionLayerSaveAs() = 0;
505  virtual QAction *actionLayerSelectionSaveAs() = 0;
506  virtual QAction *actionRemoveLayer() = 0;
508  virtual QAction *actionDuplicateLayer() = 0;
509  virtual QAction *actionLayerProperties() = 0;
510  virtual QAction *actionAddToOverview() = 0;
511  virtual QAction *actionAddAllToOverview() = 0;
512  virtual QAction *actionRemoveAllFromOverview() = 0;
513  virtual QAction *actionHideAllLayers() = 0;
514  virtual QAction *actionShowAllLayers() = 0;
515 
517  virtual QAction *actionManagePlugins() = 0;
518  virtual QAction *actionPluginListSeparator() = 0;
519  virtual QAction *actionShowPythonDialog() = 0;
520 
522  virtual QAction *actionToggleFullScreen() = 0;
523  virtual QAction *actionOptions() = 0;
524  virtual QAction *actionCustomProjection() = 0;
525 
527  virtual QAction *actionHelpContents() = 0;
528  virtual QAction *actionQgisHomePage() = 0;
529  virtual QAction *actionCheckQgisVersion() = 0;
530  virtual QAction *actionAbout() = 0;
531 
533  // returns true when dialog was accepted
534  // @added in 1.6
535  virtual bool openFeatureForm( QgsVectorLayer *l, QgsFeature &f, bool updateFeatureOnly = false ) = 0;
536 
537  virtual QDialog* getFeatureForm( QgsVectorLayer *l, QgsFeature &f ) = 0;
538 
539  virtual void preloadForm( QString uifile ) = 0;
540 
545  virtual QList<QgsMapLayer *> editableLayers( bool modified = false ) const = 0;
546 
549  virtual int messageTimeout() = 0;
550 
551  signals:
555  void currentLayerChanged( QgsMapLayer * layer );
556 
560  void composerAdded( QgsComposerView* v );
561 
565  void composerWillBeRemoved( QgsComposerView* v );
569  void initializationCompleted();
578  void projectRead();
589  void newProjectCreated();
590 };
591 
592 #ifdef _MSC_VER
593 # pragma warning( pop )
594 # pragma warning( disable: 4190 )
595 #endif
596 
597 // FIXME: also in core/qgis.h
598 #ifndef QGISEXTERN
599 #ifdef WIN32
600 # define QGISEXTERN extern "C" __declspec( dllexport )
601 #else
602 # define QGISEXTERN extern "C"
603 #endif
604 #endif
605 
606 #endif //#ifndef QGISINTERFACE_H