-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathqgisappinterface.h
531 lines (444 loc) · 22.1 KB
/
qgisappinterface.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
/***************************************************************************
qgisappinterface.h
Interface class for exposing functions in QgisApp for use by plugins
-------------------
begin : 2004-02-11
copyright : (C) 2004 by Gary E.Sherman
email : sherman at mrcc.com
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef QGISIFACE_H
#define QGISIFACE_H
#include "qgisinterface.h"
#include "qgsapppluginmanagerinterface.h"
#include "qgis_app.h"
class QgisApp;
/** \class QgisAppInterface
* \brief Interface class to provide access to private methods in QgisApp
* for use by plugins.
*
* Only those functions "exposed" by QgisInterface can be called from within a
* plugin.
*/
class APP_EXPORT QgisAppInterface : public QgisInterface
{
Q_OBJECT
public:
/**
* Constructor.
* @param qgis Pointer to the QgisApp object
*/
QgisAppInterface( QgisApp *qgisapp );
QgisAppInterface( QgisAppInterface const & ) = delete;
QgisAppInterface &operator=( QgisAppInterface const & ) = delete;
QgsPluginManagerInterface *pluginManagerInterface() override;
QgsLayerTreeView *layerTreeView() override;
virtual void addCustomActionForLayerType( QAction *action, QString menu,
QgsMapLayer::LayerType type, bool allLayers ) override;
virtual void addCustomActionForLayer( QAction *action, QgsMapLayer *layer ) override;
virtual bool removeCustomActionForLayerType( QAction *action ) override;
/* Exposed functions */
//! Zoom map to full extent
void zoomFull() override;
//! Zoom map to previous extent
void zoomToPrevious() override;
//! Zoom map to next extent
void zoomToNext() override;
//! Zoom to active layer
void zoomToActiveLayer() override;
//! Add a vector layer
QgsVectorLayer *addVectorLayer( const QString &vectorLayerPath, const QString &baseName, const QString &providerKey ) override;
//! Add a raster layer given its file name
QgsRasterLayer *addRasterLayer( const QString &rasterLayerPath, const QString &baseName ) override;
//! Add a WMS layer
QgsRasterLayer *addRasterLayer( const QString &url, const QString &baseName, const QString &providerKey ) override;
//! Add a project
bool addProject( const QString &projectName ) override;
//! Start a new blank project
void newProject( bool promptToSaveFlag = false ) override;
//! Get pointer to the active layer (layer selected in the legend)
QgsMapLayer *activeLayer() override;
//! set the active layer (layer selected in the legend)
bool setActiveLayer( QgsMapLayer *layer ) override;
//! Add an icon to the plugins toolbar
int addToolBarIcon( QAction *qAction ) override;
/**
* Add a widget to the plugins toolbar.
* To remove this widget again, call {@link removeToolBarIcon}
* with the returned QAction.
*
* @param widget widget to add. The toolbar will take ownership of this widget
* @return the QAction you can use to remove this widget from the toolbar
*/
QAction *addToolBarWidget( QWidget *widget ) override;
//! Remove an icon (action) from the plugin toolbar
void removeToolBarIcon( QAction *qAction ) override;
//! Add an icon to the Raster toolbar
int addRasterToolBarIcon( QAction *qAction ) override;
/**
* Add a widget to the raster toolbar.
* To remove this widget again, call {@link removeRasterToolBarIcon}
* with the returned QAction.
*
* @param widget widget to add. The toolbar will take ownership of this widget
* @return the QAction you can use to remove this widget from the toolbar
*/
QAction *addRasterToolBarWidget( QWidget *widget ) override;
//! Remove an icon (action) from the Raster toolbar
void removeRasterToolBarIcon( QAction *qAction ) override;
//! Add an icon to the Vector toolbar
int addVectorToolBarIcon( QAction *qAction ) override;
/**
* Add a widget to the vector toolbar.
* To remove this widget again, call {@link removeVectorToolBarIcon}
* with the returned QAction.
*
* @param widget widget to add. The toolbar will take ownership of this widget
* @return the QAction you can use to remove this widget from the toolbar
*/
QAction *addVectorToolBarWidget( QWidget *widget ) override;
//! Remove an icon (action) from the Vector toolbar
void removeVectorToolBarIcon( QAction *qAction ) override;
//! Add an icon to the Database toolbar
int addDatabaseToolBarIcon( QAction *qAction ) override;
/**
* Add a widget to the database toolbar.
* To remove this widget again, call {@link removeDatabaseToolBarIcon}
* with the returned QAction.
*
* @param widget widget to add. The toolbar will take ownership of this widget
* @return the QAction you can use to remove this widget from the toolbar
*/
QAction *addDatabaseToolBarWidget( QWidget *widget ) override;
//! Remove an icon (action) from the Database toolbar
void removeDatabaseToolBarIcon( QAction *qAction ) override;
//! Add an icon to the Web toolbar
int addWebToolBarIcon( QAction *qAction ) override;
/**
* Add a widget to the web toolbar.
* To remove this widget again, call {@link removeWebToolBarIcon}
* with the returned QAction.
*
* @param widget widget to add. The toolbar will take ownership of this widget
* @return the QAction you can use to remove this widget from the toolbar
*/
QAction *addWebToolBarWidget( QWidget *widget ) override;
//! Remove an icon (action) from the Web toolbar
void removeWebToolBarIcon( QAction *qAction ) override;
//! Add toolbar with specified name
QToolBar *addToolBar( const QString &name ) override;
//! Add a toolbar
//! @note added in 2.3
void addToolBar( QToolBar *toolbar, Qt::ToolBarArea area = Qt::TopToolBarArea ) override;
/** Open a url in the users browser. By default the QGIS doc directory is used
* as the base for the URL. To open a URL that is not relative to the installed
* QGIS documentation, set useQgisDocDirectory to false.
* @param url URL to open
* @param useQgisDocDirectory If true, the URL will be formed by concatenating
* url to the QGIS documentation directory path (<prefix>/share/doc)
*/
#ifndef Q_MOC_RUN
Q_DECL_DEPRECATED
#endif
void openURL( const QString &url, bool useQgisDocDirectory = true ) override;
//! Return a pointer to the map canvas used by qgisapp
QgsMapCanvas *mapCanvas() override;
/**
* Returns a pointer to the layer tree canvas bridge
*
* @note added in 2.12
*/
QgsLayerTreeMapCanvasBridge *layerTreeCanvasBridge() override;
/** Gives access to main QgisApp object
Plugins don't need to know about QgisApp, as we pass it as QWidget,
it can be used for connecting slots and using as widget's parent
*/
QWidget *mainWindow() override;
QgsMessageBar *messageBar() override;
//! Open the message log dock widget *
void openMessageLog() override;
//! Adds a widget to the user input tool bar.
void addUserInputWidget( QWidget *widget ) override;
// ### QGIS 3: return QgsComposer*, not QgsComposerView*
QList<QgsComposerView *> activeComposers() override;
// ### QGIS 3: return QgsComposer*, not QgsComposerView*
/** Create a new composer
* @param title window title for new composer (one will be generated if empty)
* @return pointer to composer's view
* @note new composer window will be shown and activated
*/
QgsComposerView *createNewComposer( const QString &title = QString() ) override;
// ### QGIS 3: return QgsComposer*, not QgsComposerView*
/** Duplicate an existing parent composer from composer view
* @param composerView pointer to existing composer view
* @param title window title for duplicated composer (one will be generated if empty)
* @return pointer to duplicate composer's view
* @note duplicate composer window will be hidden until loaded, then shown and activated
*/
QgsComposerView *duplicateComposer( QgsComposerView *composerView, const QString &title = QString() ) override;
//! Deletes parent composer of composer view, after closing composer window
void deleteComposer( QgsComposerView *composerView ) override;
//! Return changeable options built from settings and/or defaults
QMap<QString, QVariant> defaultStyleSheetOptions() override;
/** Generate stylesheet
* @param opts generated default option values, or a changed copy of them */
void buildStyleSheet( const QMap<QString, QVariant> &opts ) override;
//! Save changed default option keys/values to user settings
void saveStyleSheetOptions( const QMap<QString, QVariant> &opts ) override;
//! Get reference font for initial qApp (may not be same as QgisApp)
QFont defaultStyleSheetFont() override;
//! Add action to the plugins menu
void addPluginToMenu( const QString &name, QAction *action ) override;
//! Remove action from the plugins menu
void removePluginMenu( const QString &name, QAction *action ) override;
//! Add action to the Database menu
void addPluginToDatabaseMenu( const QString &name, QAction *action ) override;
//! Remove action from the Database menu
void removePluginDatabaseMenu( const QString &name, QAction *action ) override;
//! Add action to the Raster menu
void addPluginToRasterMenu( const QString &name, QAction *action ) override;
//! Remove action from the Raster menu
void removePluginRasterMenu( const QString &name, QAction *action ) override;
//! Add action to the Vector menu
void addPluginToVectorMenu( const QString &name, QAction *action ) override;
//! Remove action from the Raster menu
void removePluginVectorMenu( const QString &name, QAction *action ) override;
//! Add action to the Web menu
void addPluginToWebMenu( const QString &name, QAction *action ) override;
//! Remove action from the Web menu
void removePluginWebMenu( const QString &name, QAction *action ) override;
//! Add "add layer" action to the layer menu
void insertAddLayerAction( QAction *action ) override;
//! Remove "add layer" action from the layer menu
void removeAddLayerAction( QAction *action ) override;
//! Add a dock widget to the main window
void addDockWidget( Qt::DockWidgetArea area, QDockWidget *dockwidget ) override;
//! Remove specified dock widget from main window (doesn't delete it).
void removeDockWidget( QDockWidget *dockwidget ) override;
//! return CAD dock widget
QgsAdvancedDigitizingDockWidget *cadDockWidget() override;
/** Show layer properties dialog for layer
* @param l layer to show properties table for
*/
virtual void showLayerProperties( QgsMapLayer *l ) override;
/** Show layer attribute dialog for layer
* @param l layer to show attribute table for
*/
virtual QDialog *showAttributeTable( QgsVectorLayer *l, const QString &filterExpression = QString() ) override;
/** Add window to Window menu. The action title is the window title
* and the action should raise, unminimize and activate the window. */
virtual void addWindow( QAction *action ) override;
/** Remove window from Window menu. Calling this is necessary only for
* windows which are hidden rather than deleted when closed. */
virtual void removeWindow( QAction *action ) override;
//! Register action to the shortcuts manager so its shortcut can be changed in GUI.
virtual bool registerMainWindowAction( QAction *action, const QString &defaultShortcut ) override;
//! Unregister a previously registered action. (e.g. when plugin is going to be unloaded.
virtual bool unregisterMainWindowAction( QAction *action ) override;
virtual void registerMapLayerConfigWidgetFactory( QgsMapLayerConfigWidgetFactory *factory ) override;
virtual void unregisterMapLayerConfigWidgetFactory( QgsMapLayerConfigWidgetFactory *factory ) override;
virtual void registerOptionsWidgetFactory( QgsOptionsWidgetFactory *factory ) override;
virtual void unregisterOptionsWidgetFactory( QgsOptionsWidgetFactory *factory ) override;
/** Register a new custom drop handler.
* @note added in QGIS 3.0
* @note Ownership of the factory is not transferred, and the factory must
* be unregistered when plugin is unloaded.
* @see unregisterCustomDropHandler() */
virtual void registerCustomDropHandler( QgsCustomDropHandler *handler ) override;
/** Unregister a previously registered custom drop handler.
* @note added in QGIS 3.0
* @see registerCustomDropHandler() */
virtual void unregisterCustomDropHandler( QgsCustomDropHandler *handler ) override;
/** Accessors for inserting items into menus and toolbars.
* An item can be inserted before any existing action.
*/
//! Menus
virtual QMenu *projectMenu() override;
virtual QMenu *editMenu() override;
virtual QMenu *viewMenu() override;
virtual QMenu *layerMenu() override;
virtual QMenu *newLayerMenu() override;
//! @note added in 2.5
virtual QMenu *addLayerMenu() override;
virtual QMenu *settingsMenu() override;
virtual QMenu *pluginMenu() override;
virtual QMenu *rasterMenu() override;
virtual QMenu *vectorMenu() override;
virtual QMenu *databaseMenu() override;
virtual QMenu *webMenu() override;
virtual QMenu *firstRightStandardMenu() override;
virtual QMenu *windowMenu() override;
virtual QMenu *helpMenu() override;
//! ToolBars
virtual QToolBar *fileToolBar() override;
virtual QToolBar *layerToolBar() override;
virtual QToolBar *mapNavToolToolBar() override;
virtual QToolBar *digitizeToolBar() override;
virtual QToolBar *advancedDigitizeToolBar() override;
virtual QToolBar *attributesToolBar() override;
virtual QToolBar *pluginToolBar() override;
virtual QToolBar *helpToolBar() override;
virtual QToolBar *rasterToolBar() override;
virtual QToolBar *vectorToolBar() override;
virtual QToolBar *databaseToolBar() override;
virtual QToolBar *webToolBar() override;
//! Project menu actions
virtual QAction *actionNewProject() override;
virtual QAction *actionOpenProject() override;
virtual QAction *actionSaveProject() override;
virtual QAction *actionSaveProjectAs() override;
virtual QAction *actionSaveMapAsImage() override;
virtual QAction *actionProjectProperties() override;
virtual QAction *actionPrintComposer() override;
virtual QAction *actionShowComposerManager() override;
virtual QAction *actionExit() override;
//! Edit menu actions
virtual QAction *actionCutFeatures() override;
virtual QAction *actionCopyFeatures() override;
virtual QAction *actionPasteFeatures() override;
virtual QAction *actionAddFeature() override;
virtual QAction *actionDeleteSelected() override;
virtual QAction *actionMoveFeature() override;
virtual QAction *actionSplitFeatures() override;
virtual QAction *actionSplitParts() override;
virtual QAction *actionAddRing() override;
virtual QAction *actionAddPart() override;
virtual QAction *actionSimplifyFeature() override;
virtual QAction *actionDeleteRing() override;
virtual QAction *actionDeletePart() override;
virtual QAction *actionNodeTool() override;
//! View menu actions
virtual QAction *actionPan() override;
virtual QAction *actionPanToSelected() override;
virtual QAction *actionZoomIn() override;
virtual QAction *actionZoomOut() override;
virtual QAction *actionSelect() override;
virtual QAction *actionSelectRectangle() override;
virtual QAction *actionSelectPolygon() override;
virtual QAction *actionSelectFreehand() override;
virtual QAction *actionSelectRadius() override;
virtual QAction *actionIdentify() override;
virtual QAction *actionFeatureAction() override;
virtual QAction *actionMeasure() override;
virtual QAction *actionMeasureArea() override;
virtual QAction *actionZoomFullExtent() override;
virtual QAction *actionZoomToLayer() override;
virtual QAction *actionZoomToSelected() override;
virtual QAction *actionZoomLast() override;
virtual QAction *actionZoomNext() override;
virtual QAction *actionZoomActualSize() override;
virtual QAction *actionMapTips() override;
virtual QAction *actionNewBookmark() override;
virtual QAction *actionShowBookmarks() override;
virtual QAction *actionDraw() override;
//! Layer menu actions
virtual QAction *actionNewVectorLayer() override;
virtual QAction *actionAddOgrLayer() override;
virtual QAction *actionAddRasterLayer() override;
virtual QAction *actionAddPgLayer() override;
virtual QAction *actionAddWmsLayer() override;
//! Get access to the native Add ArcGIS FeatureServer action.
virtual QAction *actionAddAfsLayer() override;
//! Get access to the native Add ArcGIS MapServer action.
virtual QAction *actionAddAmsLayer() override;
virtual QAction *actionCopyLayerStyle() override;
virtual QAction *actionPasteLayerStyle() override;
virtual QAction *actionOpenTable() override;
virtual QAction *actionOpenFieldCalculator() override;
virtual QAction *actionToggleEditing() override;
virtual QAction *actionSaveActiveLayerEdits() override;
virtual QAction *actionAllEdits() override;
virtual QAction *actionSaveEdits() override;
virtual QAction *actionSaveAllEdits() override;
virtual QAction *actionRollbackEdits() override;
virtual QAction *actionRollbackAllEdits() override;
virtual QAction *actionCancelEdits() override;
virtual QAction *actionCancelAllEdits() override;
virtual QAction *actionLayerSaveAs() override;
virtual QAction *actionDuplicateLayer() override;
virtual QAction *actionLayerProperties() override;
virtual QAction *actionAddToOverview() override;
virtual QAction *actionAddAllToOverview() override;
virtual QAction *actionRemoveAllFromOverview() override;
virtual QAction *actionHideAllLayers() override;
virtual QAction *actionShowAllLayers() override;
virtual QAction *actionHideSelectedLayers() override;
virtual QAction *actionHideDeselectedLayers() override;
virtual QAction *actionShowSelectedLayers() override;
//! Plugin menu actions
virtual QAction *actionManagePlugins() override;
virtual QAction *actionPluginListSeparator() override;
virtual QAction *actionShowPythonDialog() override;
//! Settings menu actions
virtual QAction *actionToggleFullScreen() override;
virtual QAction *actionOptions() override;
virtual QAction *actionCustomProjection() override;
//! Help menu actions
virtual QAction *actionHelpContents() override;
virtual QAction *actionQgisHomePage() override;
virtual QAction *actionCheckQgisVersion() override;
virtual QAction *actionAbout() override;
/**
* Open feature form
* returns true when dialog was accepted (if shown modal, true otherwise)
* @param l vector layer
* @param f feature to show/modify
* @param updateFeatureOnly only update the feature update (don't change any attributes of the layer) [UNUSED]
* @param showModal if true, will wait for the dialog to be executed (only shown otherwise)
*/
virtual bool openFeatureForm( QgsVectorLayer *l, QgsFeature &f, bool updateFeatureOnly = false, bool showModal = true ) override;
/**
* Returns a feature form for a given feature
*
* @param layer The layer for which the dialog will be created
* @param feature The feature for which the dialog will be created
*
* @return A feature form
*/
virtual QgsAttributeDialog *getFeatureForm( QgsVectorLayer *layer, QgsFeature &feature ) override;
/**
* Access the vector layer tools instance.
* With the help of this you can access methods like addFeature, startEditing
* or stopEditing while giving the user the appropriate dialogs.
*
* @return An instance of the vector layer tools
*/
virtual QgsVectorLayerTools *vectorLayerTools() override;
/** This method is only needed when using a UI form with a custom widget plugin and calling
* openFeatureForm or getFeatureForm from Python (PyQt4) and you haven't used the info tool first.
* Python will crash bringing QGIS with it
* if the custom form is not loaded from a C++ method call.
*
* This method uses a QTimer to call QUiLoader in order to load the form via C++
* you only need to call this once after that you can call openFeatureForm/getFeatureForm
* like normal
*
* More information here: http://qt-project.org/forums/viewthread/27098/
*/
virtual void preloadForm( const QString &uifile ) override;
/** Return vector layers in edit mode
* @param modified whether to return only layers that have been modified
* @returns list of layers in legend order, or empty list
*/
virtual QList<QgsMapLayer *> editableLayers( bool modified = false ) const override;
//! Get timeout for timed messages: default of 5 seconds
virtual int messageTimeout() override;
signals:
void currentThemeChanged( const QString & );
private slots:
void cacheloadForm( const QString &uifile );
private:
//! Pointer to the QgisApp object
QgisApp *qgis = nullptr;
QTimer *mTimer = nullptr;
//! Pointer to the PluginManagerInterface object
QgsAppPluginManagerInterface pluginManagerIface;
};
#endif //#define QGISAPPINTERFACE_H