QGIS API Documentation  2.2.0-Valmiera
 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;
38 
39 #include <QObject>
40 #include <QFont>
41 #include <QPair>
42 #include <map>
43 
44 #include <qgis.h>
45 
46 #ifdef _MSC_VER
47 # pragma warning( push )
48 # pragma warning( disable: 4996 ) // was declared deprecated
49 #endif
50 
63 class GUI_EXPORT QgisInterface : public QObject
64 {
65  Q_OBJECT
66 
67  public:
68 
70  QgisInterface();
71 
73  virtual ~QgisInterface();
74 
78  virtual QgsLegendInterface* legendInterface() = 0;
79 
80  virtual QgsPluginManagerInterface* pluginManagerInterface() = 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 
213  virtual QgsMapCanvas * mapCanvas() = 0;
214 
216  virtual QWidget * mainWindow() = 0;
217 
219  virtual QgsMessageBar * messageBar() = 0;
220 
222  virtual QList<QgsComposerView*> activeComposers() = 0;
223 
229  virtual QgsComposerView* createNewComposer( QString title = QString( "" ) ) = 0;
230 
237  virtual QgsComposerView* duplicateComposer( QgsComposerView* composerView, QString title = QString( "" ) ) = 0;
238 
242  virtual void deleteComposer( QgsComposerView* composerView ) = 0;
243 
247  virtual QMap<QString, QVariant> defaultStyleSheetOptions() = 0;
248 
253  virtual void buildStyleSheet( const QMap<QString, QVariant>& opts ) = 0;
254 
258  virtual void saveStyleSheetOptions( const QMap<QString, QVariant>& opts ) = 0;
259 
263  virtual QFont defaultStyleSheetFont() = 0;
264 
266  virtual void addPluginToMenu( QString name, QAction* action ) = 0;
267 
269  virtual void removePluginMenu( QString name, QAction* action ) = 0;
270 
274  virtual void insertAddLayerAction( QAction *action ) = 0;
275 
279  virtual void removeAddLayerAction( QAction *action ) = 0;
280 
284  virtual void addPluginToDatabaseMenu( QString name, QAction* action ) = 0;
285 
289  virtual void removePluginDatabaseMenu( QString name, QAction* action ) = 0;
290 
294  virtual void addPluginToRasterMenu( QString name, QAction* action ) = 0;
295 
299  virtual void removePluginRasterMenu( QString name, QAction* action ) = 0;
300 
304  virtual void addPluginToVectorMenu( QString name, QAction* action ) = 0;
305 
309  virtual void removePluginVectorMenu( QString name, QAction* action ) = 0;
310 
314  virtual void addPluginToWebMenu( QString name, QAction* action ) = 0;
315 
319  virtual void removePluginWebMenu( QString name, QAction* action ) = 0;
320 
322  virtual void addDockWidget( Qt::DockWidgetArea area, QDockWidget * dockwidget ) = 0;
323 
327  virtual void removeDockWidget( QDockWidget * dockwidget ) = 0;
328 
332  virtual void showLayerProperties( QgsMapLayer *l ) = 0;
333 
337  virtual void showAttributeTable( QgsVectorLayer *l ) = 0;
338 
341  virtual void addWindow( QAction *action ) = 0;
342 
345  virtual void removeWindow( QAction *action ) = 0;
346 
350  virtual bool registerMainWindowAction( QAction* action, QString defaultShortcut ) = 0;
351 
355  virtual bool unregisterMainWindowAction( QAction* action ) = 0;
356 
357  // @todo is this deprecated in favour of QgsContextHelp?
366 #ifndef Q_MOC_RUN
367  Q_DECL_DEPRECATED
368 #endif
369  virtual void openURL( QString url, bool useQgisDocDirectory = true ) = 0;
370 
371 
376  // Menus
377 #ifndef Q_MOC_RUN
378  Q_DECL_DEPRECATED
379 #endif
380  virtual QMenu *fileMenu() = 0;
381  virtual QMenu *projectMenu() = 0;
382  virtual QMenu *editMenu() = 0;
383  virtual QMenu *viewMenu() = 0;
384  virtual QMenu *layerMenu() = 0;
387  virtual QMenu *newLayerMenu() = 0;
388  virtual QMenu *settingsMenu() = 0;
389  virtual QMenu *pluginMenu() = 0;
390  virtual QMenu *rasterMenu() = 0;
393  virtual QMenu *databaseMenu() = 0;
396  virtual QMenu *vectorMenu() = 0;
399  virtual QMenu *webMenu() = 0;
400  virtual QMenu *firstRightStandardMenu() = 0;
401  virtual QMenu *windowMenu() = 0;
402  virtual QMenu *helpMenu() = 0;
403 
404  // ToolBars
405  virtual QToolBar *fileToolBar() = 0;
406  virtual QToolBar *layerToolBar() = 0;
407  virtual QToolBar *mapNavToolToolBar() = 0;
408  virtual QToolBar *digitizeToolBar() = 0;
409  virtual QToolBar *advancedDigitizeToolBar() = 0; // added in v1.5
410  virtual QToolBar *attributesToolBar() = 0;
411  virtual QToolBar *pluginToolBar() = 0;
412  virtual QToolBar *helpToolBar() = 0;
415  virtual QToolBar *rasterToolBar() = 0;
418  virtual QToolBar *vectorToolBar() = 0;
421  virtual QToolBar *databaseToolBar() = 0;
424  virtual QToolBar *webToolBar() = 0;
425 
426  // Project menu actions
427  virtual QAction *actionNewProject() = 0;
428  virtual QAction *actionOpenProject() = 0;
429  virtual QAction *actionSaveProject() = 0;
430  virtual QAction *actionSaveProjectAs() = 0;
431  virtual QAction *actionSaveMapAsImage() = 0;
432  virtual QAction *actionProjectProperties() = 0;
433  virtual QAction *actionPrintComposer() = 0;
434  virtual QAction *actionShowComposerManager() = 0;
435  virtual QAction *actionExit() = 0;
436 
437  // Edit menu actions
438  virtual QAction *actionCutFeatures() = 0;
439  virtual QAction *actionCopyFeatures() = 0;
440  virtual QAction *actionPasteFeatures() = 0;
441  virtual QAction *actionAddFeature() = 0;
442  virtual QAction *actionDeleteSelected() = 0;
443  virtual QAction *actionMoveFeature() = 0;
444  virtual QAction *actionSplitFeatures() = 0;
445  virtual QAction *actionSplitParts() = 0;
446  virtual QAction *actionAddRing() = 0;
447  virtual QAction *actionAddPart() = 0;
448  virtual QAction *actionSimplifyFeature() = 0;
449  virtual QAction *actionDeleteRing() = 0;
450  virtual QAction *actionDeletePart() = 0;
451  virtual QAction *actionNodeTool() = 0;
452 
453  // View menu actions
455  virtual QAction *actionPan() = 0;
457  virtual QAction *actionTouch() = 0;
459  virtual QAction *actionPanToSelected() = 0;
461  virtual QAction *actionZoomIn() = 0;
463  virtual QAction *actionZoomOut() = 0;
465  virtual QAction *actionSelect() = 0;
467  virtual QAction *actionSelectRectangle() = 0;
469  virtual QAction *actionSelectPolygon() = 0;
471  virtual QAction *actionSelectFreehand() = 0;
473  virtual QAction *actionSelectRadius() = 0;
475  virtual QAction *actionIdentify() = 0;
477  virtual QAction *actionFeatureAction() = 0;
479  virtual QAction *actionMeasure() = 0;
481  virtual QAction *actionMeasureArea() = 0;
483  virtual QAction *actionZoomFullExtent() = 0;
485  virtual QAction *actionZoomToLayer() = 0;
487  virtual QAction *actionZoomToSelected() = 0;
489  virtual QAction *actionZoomLast() = 0;
491  virtual QAction *actionZoomNext() = 0;
493  virtual QAction *actionZoomActualSize() = 0;
495  virtual QAction *actionMapTips() = 0;
497  virtual QAction *actionNewBookmark() = 0;
499  virtual QAction *actionShowBookmarks() = 0;
501  virtual QAction *actionDraw() = 0;
502 
503  // Layer menu actions
504  virtual QAction *actionNewVectorLayer() = 0;
505  virtual QAction *actionAddOgrLayer() = 0;
506  virtual QAction *actionAddRasterLayer() = 0;
507  virtual QAction *actionAddPgLayer() = 0;
508  virtual QAction *actionAddWmsLayer() = 0;
510  virtual QAction *actionCopyLayerStyle() = 0;
512  virtual QAction *actionPasteLayerStyle() = 0;
513  virtual QAction *actionOpenTable() = 0;
514  virtual QAction *actionOpenFieldCalculator() = 0;
515  virtual QAction *actionToggleEditing() = 0;
517  virtual QAction *actionSaveActiveLayerEdits() = 0;
519  virtual QAction *actionAllEdits() = 0;
521  virtual QAction *actionSaveEdits() = 0;
523  virtual QAction *actionSaveAllEdits() = 0;
525  virtual QAction *actionRollbackEdits() = 0;
527  virtual QAction *actionRollbackAllEdits() = 0;
529  virtual QAction *actionCancelEdits() = 0;
531  virtual QAction *actionCancelAllEdits() = 0;
532  virtual QAction *actionLayerSaveAs() = 0;
533  virtual QAction *actionLayerSelectionSaveAs() = 0;
534  virtual QAction *actionRemoveLayer() = 0;
536  virtual QAction *actionDuplicateLayer() = 0;
537  virtual QAction *actionLayerProperties() = 0;
538  virtual QAction *actionAddToOverview() = 0;
539  virtual QAction *actionAddAllToOverview() = 0;
540  virtual QAction *actionRemoveAllFromOverview() = 0;
541  virtual QAction *actionHideAllLayers() = 0;
542  virtual QAction *actionShowAllLayers() = 0;
543 
544  // Plugin menu actions
545  virtual QAction *actionManagePlugins() = 0;
546  virtual QAction *actionPluginListSeparator() = 0;
547  virtual QAction *actionShowPythonDialog() = 0;
548 
549  // Settings menu actions
550  virtual QAction *actionToggleFullScreen() = 0;
551  virtual QAction *actionOptions() = 0;
552  virtual QAction *actionCustomProjection() = 0;
553 
554  // Help menu actions
555  virtual QAction *actionHelpContents() = 0;
556  virtual QAction *actionQgisHomePage() = 0;
557  virtual QAction *actionCheckQgisVersion() = 0;
558  virtual QAction *actionAbout() = 0;
559 
565  virtual bool openFeatureForm( QgsVectorLayer *l, QgsFeature &f, bool updateFeatureOnly = false ) = 0;
566 
567  virtual QDialog* getFeatureForm( QgsVectorLayer *l, QgsFeature &f ) = 0;
568 
569  virtual QgsVectorLayerTools* vectorLayerTools() = 0;
570 
571  virtual void preloadForm( QString uifile ) = 0;
572 
577  virtual QList<QgsMapLayer *> editableLayers( bool modified = false ) const = 0;
578 
581  virtual int messageTimeout() = 0;
582 
583  signals:
587  void currentLayerChanged( QgsMapLayer * layer );
588 
593  void composerAdded( QgsComposerView* v );
594 
599  void composerWillBeRemoved( QgsComposerView* v );
604  void initializationCompleted();
613  void projectRead();
624  void newProjectCreated();
625 };
626 
627 #ifdef _MSC_VER
628 # pragma warning( pop )
629 # pragma warning( disable: 4190 )
630 #endif
631 
632 // FIXME: also in core/qgis.h
633 #ifndef QGISEXTERN
634 #ifdef WIN32
635 # define QGISEXTERN extern "C" __declspec( dllexport )
636 #else
637 # define QGISEXTERN extern "C"
638 #endif
639 #endif
640 
641 #endif //#ifndef QGISINTERFACE_H