1 /*************************************************************************** 2 qgisapp.h - description 3 ------------------- 4 begin : Sat Jun 22 2002 5 copyright : (C) 2002 by Gary E.Sherman 6 email : sherman at mrcc.com 7 ***************************************************************************/ 8 9 /*************************************************************************** 10 * * 11 * This program is free software; you can redistribute it and/or modify * 12 * it under the terms of the GNU General Public License as published by * 13 * the Free Software Foundation; either version 2 of the License, or * 14 * (at your option) any later version. * 15 * * 16 ***************************************************************************/ 17 18 #ifndef QGISAPP_H 19 #define QGISAPP_H 20 21 class QActionGroup; 22 class QCheckBox; 23 class QCursor; 24 class QFileInfo; 25 class QKeyEvent; 26 class QLabel; 27 class QMenu; 28 class QPixmap; 29 class QProgressBar; 30 class QPushButton; 31 class QRect; 32 class QgsSettings; 33 class QSpinBox; 34 class QSplashScreen; 35 class QStringList; 36 class QToolButton; 37 class QTcpSocket; 38 class QValidator; 39 40 class QgisAppInterface; 41 class QgisAppStyleSheet; 42 class QgsAnnotation; 43 class QgsMapCanvasAnnotationItem; 44 class QgsAuthManager; 45 class QgsBookmarks; 46 class QgsClipboard; 47 class QgsComposer; 48 class QgsComposition; 49 class QgsComposerManager; 50 class QgsContrastEnhancement; 51 class QgsCoordinateReferenceSystem; 52 class QgsCustomDropHandler; 53 class QgsCustomProjectOpenHandler; 54 class QgsCustomLayerOrderWidget; 55 class QgsDockWidget; 56 class QgsDoubleSpinBox; 57 class QgsFeature; 58 class QgsFeatureStore; 59 class QgsGeometry; 60 class QgsLayerTreeMapCanvasBridge; 61 class QgsLayerTreeView; 62 class QgsLayout; 63 class QgsMasterLayoutInterface; 64 class QgsLayoutCustomDropHandler; 65 class QgsLayoutDesignerDialog; 66 class QgsLayoutDesignerInterface; 67 class QgsMapCanvas; 68 class QgsMapCanvasDockWidget; 69 class QgsMapLayer; 70 class QgsMapLayerConfigWidgetFactory; 71 class QgsMapOverviewCanvas; 72 class QgsMapTip; 73 class QgsMapTool; 74 class QgsOptions; 75 class QgsPluginLayer; 76 class QgsPluginLayer; 77 class QgsPluginManager; 78 class QgsPointCloudLayer; 79 class QgsPointXY; 80 class QgsPrintLayout; 81 class QgsProviderRegistry; 82 class QgsProviderSublayerDetails; 83 class QgsPythonUtils; 84 class QgsRasterLayer; 85 class QgsRectangle; 86 class QgsRuntimeProfiler; 87 class QgsSnappingUtils; 88 class QgsSnappingWidget; 89 class QgsStatusBarCoordinatesWidget; 90 class QgsStatusBarMagnifierWidget; 91 class QgsStatusBarScaleWidget; 92 class QgsTaskManagerStatusBarWidget; 93 class QgsTransactionGroup; 94 class QgsUndoWidget; 95 class QgsUserInputWidget; 96 class QgsVectorLayer; 97 class QgsVectorLayerTools; 98 class QgsVectorTileLayer; 99 class QgsWelcomePage; 100 class QgsOptionsWidgetFactory; 101 class QgsStatusBar; 102 class QgsGeometryValidationService; 103 class QgsGeometryValidationDock; 104 class QgsGeometryValidationModel; 105 class QgsUserProfileManager; 106 class QgsUserProfileManagerWidgetFactory; 107 class Qgs3DMapCanvasDockWidget; 108 class QgsHandleBadLayersHandler; 109 class QgsNetworkAccessManager; 110 class QgsGpsConnection; 111 class QgsApplicationExitBlockerInterface; 112 class QgsAbstractMapToolHandler; 113 class QgsAppMapTools; 114 class QgsMapToolIdentifyAction; 115 116 class QDomDocument; 117 class QNetworkReply; 118 class QNetworkProxy; 119 class QAuthenticator; 120 121 class QgsBrowserDockWidget; 122 class QgsAdvancedDigitizingDockWidget; 123 class QgsGpsInformationWidget; 124 class QgsStatisticalSummaryDockWidget; 125 class QgsMapCanvasTracer; 126 class QgsTemporalControllerDockWidget; 127 128 class QgsMapDecoration; 129 class QgsDecorationItem; 130 class QgsMessageLogViewer; 131 class QgsMessageBar; 132 class QgsMessageBarItem; 133 class QgsDataItem; 134 class QgsTileScaleWidget; 135 class QgsLabelingWidget; 136 class QgsLayerStylingWidget; 137 class QgsDiagramProperties; 138 class QgsLocatorWidget; 139 class QgsNominatimGeocoder; 140 class QgsDataSourceManagerDialog; 141 class QgsBrowserGuiModel; 142 class QgsBrowserModel; 143 class QgsGeoCmsProviderRegistry; 144 class QgsLayoutCustomDropHandler; 145 class QgsProxyProgressTask; 146 class QgsNetworkRequestParameters; 147 class QgsBearingNumericFormat; 148 class QgsDevToolsPanelWidget; 149 class QgsDevToolWidgetFactory; 150 class QgsNetworkLogger; 151 class QgsNetworkLoggerWidgetFactory; 152 class QgsMapToolCapture; 153 154 #include <QMainWindow> 155 #include <QToolBar> 156 #include <QAbstractSocket> 157 #include <QPointer> 158 #include <QSslError> 159 #include <QDateTime> 160 #include <QStackedWidget> 161 162 #include "qgsauthmanager.h" 163 #include "qgsconfig.h" 164 #include "qgspointxy.h" 165 #include "qgsmimedatautils.h" 166 #include "qgsrecentprojectsitemsmodel.h" 167 #include "qgsraster.h" 168 #include "qgsrasterminmaxorigin.h" 169 #include "qgslayertreeregistrybridge.h" 170 #include "qgsmaplayeractionregistry.h" 171 #include "qgsoptionswidgetfactory.h" 172 #include "qgsattributetablefiltermodel.h" 173 #include "qgsmasterlayoutinterface.h" 174 #include "qgsmaptoolselect.h" 175 #include "ogr/qgsvectorlayersaveasdialog.h" 176 #include "qgis.h" 177 #include "ui_qgisapp.h" 178 #include "qgis_app.h" 179 #include "qgsvectorlayerref.h" 180 #include "devtools/qgsappdevtoolutils.h" 181 #include "options/qgsoptionsutils.h" 182 183 #include <QGestureEvent> 184 #include <QTapAndHoldGesture> 185 186 #ifdef Q_OS_WIN 187 #include <windows.h> 188 #endif 189 190 class QgsLegendFilterButton; 191 192 #ifdef HAVE_GEOREFERENCER 193 class QgsGeoreferencerMainWindow; 194 #endif 195 196 /** 197 * \class QgisApp 198 * \brief Main window for the QGIS application 199 */ 200 class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow 201 { 202 Q_OBJECT 203 public: 204 //! Constructor 205 QgisApp( QSplashScreen *splash, bool restorePlugins = true, 206 bool skipVersionCheck = false, const QString &rootProfileLocation = QString(), 207 const QString &activeProfile = QString(), 208 QWidget *parent = nullptr, Qt::WindowFlags fl = Qt::Window ); 209 //! Constructor for unit tests 210 QgisApp(); 211 212 ~QgisApp() override; 213 214 QgisApp( QgisApp const & ) = delete; 215 QgisApp &operator=( QgisApp const & ) = delete; 216 217 /** 218 * Returns and adjusted uri for the layer based on current and available CRS as well as the last selected image format 219 * \since QGIS 2.8 220 */ 221 QString crsAndFormatAdjustedLayerUri( const QString &uri, const QStringList &supportedCrs, const QStringList &supportedFormats ) const; 222 223 //! Add a 'pre-made' map layer to the project 224 void addMapLayer( QgsMapLayer *mapLayer ); 225 226 //! Sets the extents of the map canvas 227 void setExtent( const QgsRectangle &rect ); 228 229 /** 230 * Open a raster or vector file; ignore other files. 231 * Used to process a commandline argument, FileOpen or Drop event. 232 * Set \a allowInteractive to TRUE if it is OK to ask the user for information (mostly for 233 * when a vector layer has sublayers and we want to ask which sublayers to use). 234 * \returns TRUE if the file is successfully opened 235 */ 236 bool openLayer( const QString &fileName, bool allowInteractive = false ); 237 238 /** 239 * Open the specified project file; prompt to save previous project if necessary. 240 * Used to process a commandline argument, FileOpen or Drop event. 241 */ 242 void openProject( const QString &fileName ); 243 244 void openLayerDefinition( const QString &filename ); 245 246 /** 247 * Opens a layout template file and creates a new layout designer window for it. 248 */ 249 void openTemplate( const QString &fileName ); 250 251 /** 252 * Attempts to run a Python script 253 * \param filePath full path to Python script 254 */ 255 void runScript( const QString &filePath ); 256 257 /** 258 * Opens a QGIS project file 259 * \returns FALSE if unable to open the project 260 */ 261 bool addProject( const QString &projectFile ); 262 263 //!Overloaded version of the private function with same name that takes the imagename as a parameter 264 void saveMapAsImage( const QString &, QPixmap * ); 265 266 //! Gets the mapcanvas object from the app 267 QgsMapCanvas *mapCanvas(); 268 269 /** 270 * Returns a list of all map canvases open in the app. 271 */ 272 QList< QgsMapCanvas * > mapCanvases(); 273 274 /** 275 * Create a new map canvas with the specified unique \a name. 276 */ 277 QgsMapCanvas *createNewMapCanvas( const QString &name ); 278 279 /** 280 * Create a new map canvas dock widget with the specified unique \a name. 281 * \note the mapCanvas() inside the dock widget will initially be frozen to avoid multiple 282 * unwanted map redraws. Callers must manually unfreeze the map canvas when they have finished 283 * setting the initial state of the canvas and are ready for it to begin rendering. 284 */ 285 QgsMapCanvasDockWidget *createNewMapCanvasDock( const QString &name ); 286 287 /** 288 * Closes the additional map canvas with matching \a name. 289 */ 290 void closeMapCanvas( const QString &name ); 291 292 /** 293 * Closes any additional map canvases. The main map canvas will not 294 * be affected. 295 */ 296 void closeAdditionalMapCanvases(); 297 298 /** 299 * Freezes all map canvases (or thaws them if the \a frozen argument is FALSE). 300 */ 301 void freezeCanvases( bool frozen = true ); 302 303 //! Returns the messageBar object which allows displaying unobtrusive messages to the user. 304 QgsMessageBar *messageBar(); 305 306 //! Open the message log dock widget 307 void openMessageLog(); 308 309 //! Adds a widget to the user input tool bar 310 void addUserInputWidget( QWidget *widget ); 311 312 //! Sets theme (icons) 313 void setTheme( const QString &themeName = "default" ); 314 315 void setIconSizes( int size ); 316 317 //! Gets stylesheet builder object for app and layout designers 318 QgisAppStyleSheet *styleSheetBuilder(); 319 320 //! Populates a menu with actions for opening layout designers 321 void populateLayoutsMenu( QMenu *menu ); 322 323 //! Setup the toolbar popup menus for a given theme 324 void setupToolbarPopups( QString themeName ); 325 //! Returns a pointer to the internal clipboard 326 QgsClipboard *clipboard(); 327 instance()328 static QgisApp *instance() { return sInstance; } 329 330 //! initialize network manager 331 void namSetup(); 332 333 //! update proxy settings 334 void namUpdate(); 335 336 //! Sets up master password 337 void masterPasswordSetup(); 338 339 /** 340 * Add a dock widget to the main window. Overloaded from QMainWindow. 341 * After adding the dock widget to the ui (by delegating to the QMainWindow 342 * parent class, it will also add it to the View menu list of docks. 343 */ 344 void addDockWidget( Qt::DockWidgetArea area, QDockWidget *dockwidget ); 345 void removeDockWidget( QDockWidget *dockwidget ); 346 347 /** 348 * Add a dock widget to the given area and tabify it (if other dock widgets 349 * exist in the same \a area). The new tab will be below other tabs unless 350 * \a raiseTab is passed as TRUE. 351 * 352 * \a tabifyWith is a list of dock widget object names, ordered by 353 * priority, with which the new dock widget should be tabified. Only the 354 * first matching object name will be picked. If none of the given object 355 * names is found in that \a area (or if \a tabifyWith is not given at 356 * all), the new dock widget will be created anyways, but its location 357 * within that \a area will be unpredictable. 358 * 359 * \since QGIS 3.14 360 */ 361 void addTabifiedDockWidget( Qt::DockWidgetArea area, QDockWidget *dockWidget, const QStringList &tabifyWith = QStringList(), bool raiseTab = false ); 362 363 /** 364 * Add a toolbar to the main window. Overloaded from QMainWindow. 365 * After adding the toolbar to the ui (by delegating to the QMainWindow 366 * parent class, it will also add it to the View menu list of toolbars. 367 */ 368 QToolBar *addToolBar( const QString &name ); 369 370 /** 371 * Add a toolbar to the main window. Overloaded from QMainWindow. 372 * After adding the toolbar to the ui (by delegating to the QMainWindow 373 * parent class, it will also add it to the View menu list of toolbars. 374 * \since QGIS 2.3 375 */ 376 void addToolBar( QToolBar *toolBar, Qt::ToolBarArea area = Qt::TopToolBarArea ); 377 378 379 /** 380 * Add window to Window menu. The action title is the window title 381 * and the action should raise, unminimize and activate the window. 382 */ 383 void addWindow( QAction *action ); 384 385 /** 386 * Remove window from Window menu. Calling this is necessary only for 387 * windows which are hidden rather than deleted when closed. 388 */ 389 void removeWindow( QAction *action ); 390 391 /** 392 * Returns the active layout designers. 393 */ layoutDesigners()394 QSet<QgsLayoutDesignerDialog *> layoutDesigners() const { return mLayoutDesignerDialogs; } 395 396 /** 397 * Gets a unique title from user for new and duplicate layouts. 398 * 399 * The \a title argument will be filled with the new layout title. 400 * 401 * If \a acceptEmpty is TRUE then empty titles will be acceptable (one will be generated). 402 * 403 * The \a currentTitle argument specifies a base name for initial title choice. 404 * 405 * \returns TRUE if user did not cancel the dialog. 406 */ 407 bool uniqueLayoutTitle( QWidget *parent, QString &title, bool acceptEmpty, QgsMasterLayoutInterface::Type type, const QString ¤tTitle = QString() ); 408 409 /** 410 * Creates a new print layout, opens a designer for it and returns a pointer to 411 * designer dialog. 412 * 413 * If \a title is specified it will be used as the name for the new print layout, 414 * otherwise the user will be prompted to enter a name for the layout. 415 */ 416 QgsLayoutDesignerDialog *createNewPrintLayout( const QString &title = QString() ); 417 418 //! Creates a new report and returns a pointer to it 419 QgsLayoutDesignerDialog *createNewReport( QString title = QString() ); 420 421 /** 422 * Opens a layout designer dialog for an existing \a layout. 423 * If a designer already exists for this layout then it will be activated. 424 */ 425 QgsLayoutDesignerDialog *openLayoutDesignerDialog( QgsMasterLayoutInterface *layout ); 426 427 /** 428 * Duplicates a \a layout and adds it to the current project. 429 * 430 * If \a title is set, it will be used as the title for the new layout. If it is not set, 431 * and auto-generated title will be used instead. 432 */ 433 QgsLayoutDesignerDialog *duplicateLayout( QgsMasterLayoutInterface *layout, const QString &title = QString() ); 434 435 //! Overloaded function used to sort menu entries alphabetically 436 QMenu *createPopupMenu() override; 437 438 /** 439 * Access the vector layer tools. This will be an instance of {\see QgsGuiVectorLayerTools} 440 * by default. 441 * \returns The vector layer tools 442 */ vectorLayerTools()443 QgsVectorLayerTools *vectorLayerTools() { return mVectorLayerTools; } 444 445 /** 446 * Notify the user by using the system tray notifications 447 * 448 * \note usage of the system tray notifications should be limited 449 * to long running tasks and to when the user needs to be notified 450 * about interaction with OS services, like the password manager. 451 * 452 * \param title 453 * \param message 454 * \param replaceExisting set to TRUE to replace any existing notifications, or FALSE to add a new notification 455 */ 456 void showSystemNotification( const QString &title, const QString &message, bool replaceExisting = true ); 457 458 459 //! Actions to be inserted in menus and toolbars actionNewProject()460 QAction *actionNewProject() { return mActionNewProject; } actionOpenProject()461 QAction *actionOpenProject() { return mActionOpenProject; } actionSaveProject()462 QAction *actionSaveProject() { return mActionSaveProject; } actionSaveProjectAs()463 QAction *actionSaveProjectAs() { return mActionSaveProjectAs; } actionSaveMapAsImage()464 QAction *actionSaveMapAsImage() { return mActionSaveMapAsImage; } actionSaveMapAsPdf()465 QAction *actionSaveMapAsPdf() { return mActionSaveMapAsPdf; } actionProjectProperties()466 QAction *actionProjectProperties() { return mActionProjectProperties; } actionShowLayoutManager()467 QAction *actionShowLayoutManager() { return mActionShowLayoutManager; } actionNewPrintLayout()468 QAction *actionNewPrintLayout() { return mActionNewPrintLayout; } actionExit()469 QAction *actionExit() { return mActionExit; } 470 actionCutFeatures()471 QAction *actionCutFeatures() { return mActionCutFeatures; } actionCopyFeatures()472 QAction *actionCopyFeatures() { return mActionCopyFeatures; } actionPasteFeatures()473 QAction *actionPasteFeatures() { return mActionPasteFeatures; } actionPasteAsNewVector()474 QAction *actionPasteAsNewVector() { return mActionPasteAsNewVector; } actionPasteAsNewMemoryVector()475 QAction *actionPasteAsNewMemoryVector() { return mActionPasteAsNewMemoryVector; } actionDeleteSelected()476 QAction *actionDeleteSelected() { return mActionDeleteSelected; } actionAddFeature()477 QAction *actionAddFeature() { return mActionAddFeature; } actionMoveFeature()478 QAction *actionMoveFeature() { return mActionMoveFeature; } actionMoveFeatureCopy()479 QAction *actionMoveFeatureCopy() { return mActionMoveFeatureCopy; } actionRotateFeature()480 QAction *actionRotateFeature() { return mActionRotateFeature;} actionScaleFeature()481 QAction *actionScaleFeature() { return mActionScaleFeature;} actionSplitFeatures()482 QAction *actionSplitFeatures() { return mActionSplitFeatures; } actionSplitParts()483 QAction *actionSplitParts() { return mActionSplitParts; } actionAddRing()484 QAction *actionAddRing() { return mActionAddRing; } actionFillRing()485 QAction *actionFillRing() { return mActionFillRing; } actionAddPart()486 QAction *actionAddPart() { return mActionAddPart; } actionSimplifyFeature()487 QAction *actionSimplifyFeature() { return mActionSimplifyFeature; } actionDeleteRing()488 QAction *actionDeleteRing() { return mActionDeleteRing; } actionDeletePart()489 QAction *actionDeletePart() { return mActionDeletePart; } actionVertexTool()490 QAction *actionVertexTool() { return mActionVertexTool; } actionVertexToolActiveLayer()491 QAction *actionVertexToolActiveLayer() { return mActionVertexToolActiveLayer; } actionSnappingOptions()492 QAction *actionSnappingOptions() { return mActionSnappingOptions; } actionOffsetCurve()493 QAction *actionOffsetCurve() { return mActionOffsetCurve; } actionPan()494 QAction *actionPan() { return mActionPan; } actionPanToSelected()495 QAction *actionPanToSelected() { return mActionPanToSelected; } actionZoomIn()496 QAction *actionZoomIn() { return mActionZoomIn; } actionZoomOut()497 QAction *actionZoomOut() { return mActionZoomOut; } actionSelect()498 QAction *actionSelect() { return mActionSelectFeatures; } actionSelectRectangle()499 QAction *actionSelectRectangle() { return mActionSelectFeatures; } actionSelectPolygon()500 QAction *actionSelectPolygon() { return mActionSelectPolygon; } actionSelectFreehand()501 QAction *actionSelectFreehand() { return mActionSelectFreehand; } actionSelectRadius()502 QAction *actionSelectRadius() { return mActionSelectRadius; } actionIdentify()503 QAction *actionIdentify() { return mActionIdentify; } actionFeatureAction()504 QAction *actionFeatureAction() { return mActionFeatureAction; } actionMeasure()505 QAction *actionMeasure() { return mActionMeasure; } actionMeasureArea()506 QAction *actionMeasureArea() { return mActionMeasureArea; } actionZoomFullExtent()507 QAction *actionZoomFullExtent() { return mActionZoomFullExtent; } actionZoomToLayer()508 QAction *actionZoomToLayer() { return mActionZoomToLayer; } actionZoomToLayers()509 QAction *actionZoomToLayers() { return mActionZoomToLayers; } actionZoomToSelected()510 QAction *actionZoomToSelected() { return mActionZoomToSelected; } actionZoomLast()511 QAction *actionZoomLast() { return mActionZoomLast; } actionZoomNext()512 QAction *actionZoomNext() { return mActionZoomNext; } actionZoomActualSize()513 QAction *actionZoomActualSize() { return mActionZoomActualSize; } actionMapTips()514 QAction *actionMapTips() { return mActionMapTips; } actionNewBookmark()515 QAction *actionNewBookmark() { return mActionNewBookmark; } actionShowBookmarks()516 QAction *actionShowBookmarks() { return mActionShowBookmarks; } actionShowBookmarkManager()517 QAction *actionShowBookmarkManager() { return mActionShowBookmarkManager; } actionDraw()518 QAction *actionDraw() { return mActionDraw; } actionCircle2Points()519 QAction *actionCircle2Points() { return mActionCircle2Points ; } actionCircle3Points()520 QAction *actionCircle3Points() { return mActionCircle3Points ; } actionCircle3Tangents()521 QAction *actionCircle3Tangents() { return mActionCircle3Tangents ; } actionCircle2TangentsPoint()522 QAction *actionCircle2TangentsPoint() { return mActionCircle2TangentsPoint ; } actionCircleCenterPoint()523 QAction *actionCircleCenterPoint() { return mActionCircleCenterPoint ; } actionEllipseCenter2Points()524 QAction *actionEllipseCenter2Points() { return mActionEllipseCenter2Points ; } actionEllipseCenterPoint()525 QAction *actionEllipseCenterPoint() { return mActionEllipseCenterPoint ; } actionEllipseExtent()526 QAction *actionEllipseExtent() { return mActionEllipseExtent ; } actionEllipseFoci()527 QAction *actionEllipseFoci() { return mActionEllipseFoci ; } actionRectangleCenterPoint()528 QAction *actionRectangleCenterPoint() { return mActionRectangleCenterPoint ; } actionRectangleExtent()529 QAction *actionRectangleExtent() { return mActionRectangleExtent ; } actionRectangle3PointsDistance()530 QAction *actionRectangle3PointsDistance() { return mActionRectangle3PointsDistance ; } actionRectangle3PointsProjected()531 QAction *actionRectangle3PointsProjected() { return mActionRectangle3PointsProjected ; } actionRegularPolygon2Points()532 QAction *actionRegularPolygon2Points() { return mActionRegularPolygon2Points ; } actionRegularPolygonCenterPoint()533 QAction *actionRegularPolygonCenterPoint() { return mActionRegularPolygonCenterPoint ; } actionRegularPolygonCenterCorner()534 QAction *actionRegularPolygonCenterCorner() { return mActionRegularPolygonCenterCorner ; } 535 536 actionDataSourceManager()537 QAction *actionDataSourceManager() { return mActionDataSourceManager; } actionNewVectorLayer()538 QAction *actionNewVectorLayer() { return mActionNewVectorLayer; } 539 #ifdef HAVE_SPATIALITE actionNewSpatialLiteLayer()540 QAction *actionNewSpatialLiteLayer() { return mActionNewSpatiaLiteLayer; } 541 #else actionNewSpatialLiteLayer()542 QAction *actionNewSpatialLiteLayer() { return nullptr; } 543 #endif actionEmbedLayers()544 QAction *actionEmbedLayers() { return mActionEmbedLayers; } actionAddOgrLayer()545 QAction *actionAddOgrLayer() { return mActionAddOgrLayer; } actionAddRasterLayer()546 QAction *actionAddRasterLayer() { return mActionAddRasterLayer; } actionAddPgLayer()547 QAction *actionAddPgLayer() { return mActionAddPgLayer; } 548 #ifdef HAVE_SPATIALITE actionAddSpatiaLiteLayer()549 QAction *actionAddSpatiaLiteLayer() { return mActionAddSpatiaLiteLayer; } 550 #else actionAddSpatiaLiteLayer()551 QAction *actionAddSpatiaLiteLayer() { return nullptr; } 552 #endif actionAddWmsLayer()553 QAction *actionAddWmsLayer() { return mActionAddWmsLayer; } actionAddXyzLayer()554 QAction *actionAddXyzLayer() { return mActionAddXyzLayer; } actionAddVectorTileLayer()555 QAction *actionAddVectorTileLayer() { return mActionAddVectorTileLayer; } actionAddPointCloudLayer()556 QAction *actionAddPointCloudLayer() { return mActionAddPointCloudLayer; } actionAddWcsLayer()557 QAction *actionAddWcsLayer() { return mActionAddWcsLayer; } 558 #ifdef HAVE_SPATIALITE actionAddWfsLayer()559 QAction *actionAddWfsLayer() { return mActionAddWfsLayer; } 560 #else actionAddWfsLayer()561 QAction *actionAddWfsLayer() { return nullptr; } 562 #endif actionAddAfsLayer()563 QAction *actionAddAfsLayer() { return mActionAddAfsLayer; } actionCopyLayerStyle()564 QAction *actionCopyLayerStyle() { return mActionCopyStyle; } actionPasteLayerStyle()565 QAction *actionPasteLayerStyle() { return mActionPasteStyle; } actionOpenTable()566 QAction *actionOpenTable() { return mActionOpenTable; } actionOpenFieldCalculator()567 QAction *actionOpenFieldCalculator() { return mActionOpenFieldCalc; } actionStatisticalSummary()568 QAction *actionStatisticalSummary() { return mActionStatisticalSummary; } actionToggleEditing()569 QAction *actionToggleEditing() { return mActionToggleEditing; } actionSaveActiveLayerEdits()570 QAction *actionSaveActiveLayerEdits() { return mActionSaveLayerEdits; } actionAllEdits()571 QAction *actionAllEdits() { return mActionAllEdits; } actionSaveEdits()572 QAction *actionSaveEdits() { return mActionSaveEdits; } actionSaveAllEdits()573 QAction *actionSaveAllEdits() { return mActionSaveAllEdits; } actionRollbackEdits()574 QAction *actionRollbackEdits() { return mActionRollbackEdits; } actionRollbackAllEdits()575 QAction *actionRollbackAllEdits() { return mActionRollbackAllEdits; } actionCancelEdits()576 QAction *actionCancelEdits() { return mActionCancelEdits; } actionCancelAllEdits()577 QAction *actionCancelAllEdits() { return mActionCancelAllEdits; } actionLayerSaveAs()578 QAction *actionLayerSaveAs() { return mActionLayerSaveAs; } actionRemoveLayer()579 QAction *actionRemoveLayer() { return mActionRemoveLayer; } actionDuplicateLayer()580 QAction *actionDuplicateLayer() { return mActionDuplicateLayer; } 581 //! \since QGIS 2.4 actionSetLayerScaleVisibility()582 QAction *actionSetLayerScaleVisibility() { return mActionSetLayerScaleVisibility; } actionSetLayerCrs()583 QAction *actionSetLayerCrs() { return mActionSetLayerCRS; } actionSetProjectCrsFromLayer()584 QAction *actionSetProjectCrsFromLayer() { return mActionSetProjectCRSFromLayer; } actionLayerProperties()585 QAction *actionLayerProperties() { return mActionLayerProperties; } actionLayerSubsetString()586 QAction *actionLayerSubsetString() { return mActionLayerSubsetString; } actionAddToOverview()587 QAction *actionAddToOverview() { return mActionAddToOverview; } actionAddAllToOverview()588 QAction *actionAddAllToOverview() { return mActionAddAllToOverview; } actionRemoveAllFromOverview()589 QAction *actionRemoveAllFromOverview() { return mActionRemoveAllFromOverview; } actionHideAllLayers()590 QAction *actionHideAllLayers() { return mActionHideAllLayers; } actionShowAllLayers()591 QAction *actionShowAllLayers() { return mActionShowAllLayers; } actionHideSelectedLayers()592 QAction *actionHideSelectedLayers() { return mActionHideSelectedLayers; } actionToggleSelectedLayers()593 QAction *actionToggleSelectedLayers() { return mActionToggleSelectedLayers; } actionToggleSelectedLayersIndependently()594 QAction *actionToggleSelectedLayersIndependently() { return mActionToggleSelectedLayersIndependently; } actionHideDeselectedLayers()595 QAction *actionHideDeselectedLayers() { return mActionHideDeselectedLayers; } actionShowSelectedLayers()596 QAction *actionShowSelectedLayers() { return mActionShowSelectedLayers; } 597 actionManagePlugins()598 QAction *actionManagePlugins() { return mActionManagePlugins; } actionPluginListSeparator()599 QAction *actionPluginListSeparator() { return mActionPluginSeparator1; } actionPluginPythonSeparator()600 QAction *actionPluginPythonSeparator() { return mActionPluginSeparator2; } actionShowPythonDialog()601 QAction *actionShowPythonDialog() { return mActionShowPythonDialog; } 602 actionToggleFullScreen()603 QAction *actionToggleFullScreen() { return mActionToggleFullScreen; } actionTogglePanelsVisibility()604 QAction *actionTogglePanelsVisibility() { return mActionTogglePanelsVisibility; } actionToggleMapOnly()605 QAction *actionToggleMapOnly() { return mActionToggleMapOnly; } actionOptions()606 QAction *actionOptions() { return mActionOptions; } actionCustomProjection()607 QAction *actionCustomProjection() { return mActionCustomProjection; } actionConfigureShortcuts()608 QAction *actionConfigureShortcuts() { return mActionConfigureShortcuts; } 609 610 #ifdef Q_OS_MAC actionWindowMinimize()611 QAction *actionWindowMinimize() { return mActionWindowMinimize; } actionWindowZoom()612 QAction *actionWindowZoom() { return mActionWindowZoom; } actionWindowAllToFront()613 QAction *actionWindowAllToFront() { return mActionWindowAllToFront; } 614 #endif 615 actionHelpContents()616 QAction *actionHelpContents() { return mActionHelpContents; } actionHelpAPI()617 QAction *actionHelpAPI() { return mActionHelpAPI; } actionReportaBug()618 QAction *actionReportaBug() { return mActionReportaBug; } actionQgisHomePage()619 QAction *actionQgisHomePage() { return mActionQgisHomePage; } actionCheckQgisVersion()620 QAction *actionCheckQgisVersion() { return mActionCheckQgisVersion; } actionAbout()621 QAction *actionAbout() { return mActionAbout; } actionSponsors()622 QAction *actionSponsors() { return mActionSponsors; } 623 actionShowPinnedLabels()624 QAction *actionShowPinnedLabels() { return mActionShowPinnedLabels; } 625 626 //! Menus projectMenu()627 QMenu *projectMenu() { return mProjectMenu; } editMenu()628 QMenu *editMenu() { return mEditMenu; } viewMenu()629 QMenu *viewMenu() { return mViewMenu; } layerMenu()630 QMenu *layerMenu() { return mLayerMenu; } newLayerMenu()631 QMenu *newLayerMenu() { return mNewLayerMenu; } 632 //! \since QGIS 2.5 addLayerMenu()633 QMenu *addLayerMenu() { return mAddLayerMenu; } settingsMenu()634 QMenu *settingsMenu() { return mSettingsMenu; } pluginMenu()635 QMenu *pluginMenu() { return mPluginMenu; } pluginHelpMenu()636 QMenu *pluginHelpMenu() { return mMenuPluginHelp; } databaseMenu()637 QMenu *databaseMenu() { return mDatabaseMenu; } rasterMenu()638 QMenu *rasterMenu() { return mRasterMenu; } vectorMenu()639 QMenu *vectorMenu() { return mVectorMenu; } webMenu()640 QMenu *webMenu() { return mWebMenu; } 641 #ifdef Q_OS_MAC firstRightStandardMenu()642 QMenu *firstRightStandardMenu() { return mWindowMenu; } windowMenu()643 QMenu *windowMenu() { return mWindowMenu; } 644 #else firstRightStandardMenu()645 QMenu *firstRightStandardMenu() { return mHelpMenu; } windowMenu()646 QMenu *windowMenu() { return nullptr; } 647 #endif helpMenu()648 QMenu *helpMenu() { return mHelpMenu; } 649 650 //! Toolbars 651 652 /** 653 * Gets a reference to a toolbar. Mainly intended 654 * to be used by plugins that want to specifically add 655 * an icon into the file toolbar for consistency e.g. 656 * addWFS and GPS plugins. 657 */ fileToolBar()658 QToolBar *fileToolBar() { return mFileToolBar; } layerToolBar()659 QToolBar *layerToolBar() { return mLayerToolBar; } dataSourceManagerToolBar()660 QToolBar *dataSourceManagerToolBar() { return mDataSourceManagerToolBar; } mapNavToolToolBar()661 QToolBar *mapNavToolToolBar() { return mMapNavToolBar; } digitizeToolBar()662 QToolBar *digitizeToolBar() { return mDigitizeToolBar; } advancedDigitizeToolBar()663 QToolBar *advancedDigitizeToolBar() { return mAdvancedDigitizeToolBar; } shapeDigitizeToolBar()664 QToolBar *shapeDigitizeToolBar() { return mShapeDigitizeToolBar; } attributesToolBar()665 QToolBar *attributesToolBar() { return mAttributesToolBar; } 666 667 /** 668 * Returns selection toolbar 669 * \since QGIS 3.14 670 */ selectionToolBar()671 QToolBar *selectionToolBar() { return mSelectionToolBar; } pluginToolBar()672 QToolBar *pluginToolBar() { return mPluginToolBar; } helpToolBar()673 QToolBar *helpToolBar() { return mHelpToolBar; } rasterToolBar()674 QToolBar *rasterToolBar() { return mRasterToolBar; } vectorToolBar()675 QToolBar *vectorToolBar() { return mVectorToolBar; } meshToolBar()676 QToolBar *meshToolBar() {return mMeshToolBar;} databaseToolBar()677 QToolBar *databaseToolBar() { return mDatabaseToolBar; } webToolBar()678 QToolBar *webToolBar() { return mWebToolBar; } 679 statusBarIface()680 QgsStatusBar *statusBarIface() { return mStatusBar; } 681 682 //! Returns the CAD dock widget cadDockWidget()683 QgsAdvancedDigitizingDockWidget *cadDockWidget() { return mAdvancedDigitizingDockWidget; } 684 685 //! Returns map overview canvas mapOverviewCanvas()686 QgsMapOverviewCanvas *mapOverviewCanvas() { return mOverviewCanvas; } 687 locatorWidget()688 QgsLocatorWidget *locatorWidget() { return mLocatorWidget; } 689 690 //! show layer properties 691 void showLayerProperties( QgsMapLayer *mapLayer, const QString &page = QString() ); 692 693 //! returns pointer to map legend 694 QgsLayerTreeView *layerTreeView(); 695 layerTreeCanvasBridge()696 QgsLayerTreeMapCanvasBridge *layerTreeCanvasBridge() { return mLayerTreeCanvasBridge; } 697 698 //! returns pointer to plugin manager 699 QgsPluginManager *pluginManager(); 700 701 /** 702 * The applications user profile manager. 703 */ 704 QgsUserProfileManager *userProfileManager(); 705 706 /** 707 * Returns the vector layers in edit mode 708 * \param modified whether to return only layers that have been modified 709 * \returns list of layers in legend order, or empty list 710 */ 711 QList<QgsMapLayer *> editableLayers( bool modified = false, bool ignoreLayersWhichCannotBeToggled = false ) const; 712 713 //! emit initializationCompleted signal 714 void completeInitialization(); 715 716 void emitCustomCrsValidation( QgsCoordinateReferenceSystem &crs ); 717 718 /** 719 * Returns a list of active map decorations 720 * \since QGIS 3.14 721 */ 722 QList<QgsMapDecoration *> activeDecorations(); 723 724 //! Returns a list of registered map decoration items decorationItems()725 QList<QgsDecorationItem *> decorationItems() { return mDecorationItems; } 726 727 //! A a map decoration \a item addDecorationItem(QgsDecorationItem * item)728 void addDecorationItem( QgsDecorationItem *item ) { mDecorationItems.append( item ); } 729 730 //! \since QGIS 2.1 normalizedMenuName(const QString & name)731 static QString normalizedMenuName( const QString &name ) { return name.normalized( QString::NormalizationForm_KD ).remove( QRegExp( "[^a-zA-Z]" ) ); } 732 733 void parseVersionInfo( QNetworkReply *reply, int &latestVersion, QStringList &versionInfo ); 734 735 //! Register a new tab in the layer properties dialog 736 void registerMapLayerPropertiesFactory( QgsMapLayerConfigWidgetFactory *factory ); 737 738 //! Unregister a previously registered tab in the layer properties dialog 739 void unregisterMapLayerPropertiesFactory( QgsMapLayerConfigWidgetFactory *factory ); 740 741 //! Register a new tab in the options dialog 742 void registerOptionsWidgetFactory( QgsOptionsWidgetFactory *factory ); 743 744 //! Unregister a previously registered tab in the options dialog 745 void unregisterOptionsWidgetFactory( QgsOptionsWidgetFactory *factory ); 746 747 //! Register a new tab in the project properties dialog 748 void registerProjectPropertiesWidgetFactory( QgsOptionsWidgetFactory *factory ); 749 750 //! Unregister a previously registered tab in the project properties dialog 751 void unregisterProjectPropertiesWidgetFactory( QgsOptionsWidgetFactory *factory ); 752 753 //! Register a dev tool factory 754 void registerDevToolFactory( QgsDevToolWidgetFactory *factory ); 755 756 //! Unregister a previously registered dev tool factory 757 void unregisterDevToolFactory( QgsDevToolWidgetFactory *factory ); 758 759 /** 760 * Register a new application exit blocker, which can be used to prevent the QGIS application 761 * from exiting while a plugin or script has unsaved changes. 762 * 763 * \note Ownership of \a blocker is not transferred, and the blocker must 764 * be unregistered when plugin is unloaded. 765 * 766 * \see unregisterApplicationExitBlocker() 767 */ 768 void registerApplicationExitBlocker( QgsApplicationExitBlockerInterface *blocker ); 769 770 /** 771 * Unregister a previously registered application exit \a blocker. 772 * \see registerApplicationExitBlocker() 773 */ 774 void unregisterApplicationExitBlocker( QgsApplicationExitBlockerInterface *blocker ); 775 776 /** 777 * Register a new application map tool \a handler, which can be used to automatically setup all connections 778 * and logic required to switch to a custom map tool whenever the state of the QGIS application 779 * permits. 780 * 781 * \note Ownership of \a handler is not transferred, and the handler must 782 * be unregistered when plugin is unloaded. 783 * 784 * \see QgsAbstractMapToolHandler 785 * \see unregisterMapToolHandler() 786 */ 787 void registerMapToolHandler( QgsAbstractMapToolHandler *handler ); 788 789 /** 790 * Unregister a previously registered map tool \a handler. 791 * \see registerMapToolHandler() 792 */ 793 void unregisterMapToolHandler( QgsAbstractMapToolHandler *handler ); 794 795 //! Register a new custom drop handler. 796 void registerCustomDropHandler( QgsCustomDropHandler *handler ); 797 798 //! Unregister a previously registered custom drop handler. 799 void unregisterCustomDropHandler( QgsCustomDropHandler *handler ); 800 801 /** 802 * Register a new custom project open \a handler. 803 * \note Ownership of \a handler is not transferred, and the handler must 804 * be unregistered when plugin is unloaded. 805 * \see QgsCustomProjectOpenHandler 806 * \see unregisterCustomProjectOpenHandler() 807 */ 808 void registerCustomProjectOpenHandler( QgsCustomProjectOpenHandler *handler ); 809 810 /** 811 * Unregister a previously registered custom project open \a handler. 812 * \see QgsCustomDropHandler 813 * \see registerCustomProjectOpenHandler() 814 */ 815 void unregisterCustomProjectOpenHandler( QgsCustomProjectOpenHandler *handler ); 816 817 //! Returns a list of registered custom drop handlers. 818 QVector<QPointer<QgsCustomDropHandler >> customDropHandlers() const; 819 820 //! Register a new custom layout drop handler. 821 void registerCustomLayoutDropHandler( QgsLayoutCustomDropHandler *handler ); 822 823 //! Unregister a previously registered custom layout drop handler. 824 void unregisterCustomLayoutDropHandler( QgsLayoutCustomDropHandler *handler ); 825 826 //! Returns a list of registered custom layout drop handlers. 827 QVector<QPointer<QgsLayoutCustomDropHandler >> customLayoutDropHandlers() const; 828 829 //! Returns the active map layer. 830 QgsMapLayer *activeLayer(); 831 832 /** 833 * Returns the toolbar icon size. If \a dockedToolbar is TRUE, the icon size 834 * for toolbars contained within docks is returned. 835 */ 836 QSize iconSize( bool dockedToolbar = false ) const; 837 838 /** 839 * Checks available datum transforms and ask user if several are available and none 840 * is chosen. Dialog is shown only if global option is set accordingly. 841 * \returns TRUE if a datum transform has been specifically chosen by user or only one is available. 842 * \since 3.0 843 */ 844 bool askUserForDatumTransform( const QgsCoordinateReferenceSystem &sourceCrs, const QgsCoordinateReferenceSystem &destinationCrs, const QgsMapLayer *layer = nullptr ); 845 846 //! Gets map of bookmarks 847 QMap<QString, QModelIndex> getBookmarkIndexMap(); 848 //! Zoom to a bookmark 849 void zoomToBookmarkIndex( const QModelIndex & ); 850 851 //! Returns pointer to the identify map tool - used by identify tool in 3D view 852 QgsMapToolIdentifyAction *identifyMapTool() const; 853 854 /** 855 * Take screenshots for user documentation 856 * @param saveDirectory path were the screenshots will be saved 857 * @param categories an int as a flag value of QgsAppScreenShots::Categories 858 */ 859 void takeAppScreenShots( const QString &saveDirectory, const int categories = 0 ); 860 861 QgsLayerTreeRegistryBridge::InsertionPoint layerTreeInsertionPoint() const; 862 863 /** 864 * Sets a GPS \a connection to use within the GPS Panel widget. 865 * 866 * Any existing GPS connection used by the widget will be disconnect and replaced with this connection. The connection 867 * is automatically registered within the QgsApplication::gpsConnectionRegistry(). 868 */ 869 void setGpsPanelConnection( QgsGpsConnection *connection ); 870 871 public slots: 872 //! save current vector layer 873 QString saveAsFile( QgsMapLayer *layer = nullptr, bool onlySelected = false, bool defaultToAddToMap = true ); 874 875 /** 876 * Makes a memory layer permanent, by prompting users to save the layer to a disk-based (OGR) 877 * format, and then replacing the layer's data source in place. 878 */ 879 void makeMemoryLayerPermanent( QgsVectorLayer *layer ); 880 881 //! save qml style for the current layer 882 void saveStyleFile( QgsMapLayer *layer = nullptr ); 883 //! save qrl definition for the current layer 884 void saveAsLayerDefinition(); 885 //! save current raster layer 886 QString saveAsRasterFile( QgsRasterLayer *layer = nullptr, bool defaultAddToCanvas = true ); 887 //! Process the list of URIs that have been dropped in QGIS 888 void handleDropUriList( const QgsMimeDataUtils::UriList &lst ); 889 //! Convenience function to open either a project or a layer file. 890 void openFile( const QString &fileName, const QString &fileTypeHint = QString() ); 891 void layerTreeViewDoubleClicked( const QModelIndex &index ); 892 //! Make sure the insertion point for new layers is up-to-date with the current item in layer tree view 893 void updateNewLayerInsertionPoint(); 894 //! connected to layer tree registry bridge, selects first of the newly added map layers 895 void autoSelectAddedLayer( QList<QgsMapLayer *> layers ); 896 897 //! Zoom to full extent 898 void zoomFull(); 899 //! Zoom to the previous extent 900 void zoomToPrevious(); 901 //! Zoom to the forward extent 902 void zoomToNext(); 903 //! Zoom to selected features 904 void zoomToSelected(); 905 //! Pan map to selected features 906 void panToSelected(); 907 908 //! open the properties dialog for the currently selected layer 909 void layerProperties(); 910 911 //! show the attribute table for the currently selected layer 912 void attributeTable( QgsAttributeTableFilterModel::FilterMode filter = QgsAttributeTableFilterModel::ShowAll ); 913 914 void fieldCalculator(); 915 916 //! mark project dirty 917 void markDirty(); 918 919 /** 920 * \brief layersWereAdded is triggered when layers were added 921 * This method loops through the list of \a layers and connect all 922 * application signals that need to listen to layer events. 923 * \param layers list of map layers that have been added 924 */ 925 void layersWereAdded( const QList<QgsMapLayer *> &layers ); 926 927 /* layer will be removed - changed from removingLayer to removingLayers 928 in 1.8. 929 */ 930 void removingLayers( const QStringList & ); 931 932 //! starts/stops editing mode of the current layer 933 void toggleEditing(); 934 935 //! starts/stops editing mode of a layer 936 bool toggleEditing( QgsMapLayer *layer, bool allowCancel = true ); 937 938 //! Save edits for active vector layer and start new transactions 939 void saveActiveLayerEdits(); 940 941 /** 942 * Save edits of a layer 943 * \param leaveEditable leave the layer in editing mode when done 944 * \param triggerRepaint send layer signal to repaint canvas when done 945 */ 946 void saveEdits( QgsMapLayer *layer, bool leaveEditable = true, bool triggerRepaint = true ); 947 948 /** 949 * Cancel edits for a layer 950 * \param leaveEditable leave the layer in editing mode when done 951 * \param triggerRepaint send layer signal to repaint canvas when done 952 */ 953 void cancelEdits( QgsMapLayer *layer, bool leaveEditable = true, bool triggerRepaint = true ); 954 955 //! Save current edits for selected layer(s) and start new transaction(s) 956 void saveEdits(); 957 958 //! Save edits for all layers and start new transactions 959 void saveAllEdits( bool verifyAction = true ); 960 961 //! Rollback current edits for selected layer(s) and start new transaction(s) 962 void rollbackEdits(); 963 964 //! Rollback edits for all layers and start new transactions 965 void rollbackAllEdits( bool verifyAction = true ); 966 967 //! Cancel edits for selected layer(s) and toggle off editing 968 void cancelEdits(); 969 970 //! Cancel all edits for all layers and toggle off editing 971 void cancelAllEdits( bool verifyAction = true ); 972 973 void updateUndoActions(); 974 975 //! cuts selected features on the active layer to the clipboard 976 977 /** 978 * \param layerContainingSelection The layer that the selection will be taken from 979 * (defaults to the active layer on the legend) 980 */ 981 void cutSelectionToClipboard( QgsMapLayer *layerContainingSelection = nullptr ); 982 //! copies selected features on the active layer to the clipboard 983 984 /** 985 * \param layerContainingSelection The layer that the selection will be taken from 986 * (defaults to the active layer on the legend) 987 */ 988 void copySelectionToClipboard( QgsMapLayer *layerContainingSelection = nullptr ); 989 //! copies features on the clipboard to the active layer 990 991 /** 992 * \param destinationLayer The layer that the clipboard will be pasted to 993 * (defaults to the active layer on the legend) 994 */ 995 void pasteFromClipboard( QgsMapLayer *destinationLayer = nullptr ); 996 997 //! copies features on the clipboard to a new vector layer 998 void pasteAsNewVector(); 999 //! copies features on the clipboard to a new memory vector layer 1000 QgsVectorLayer *pasteAsNewMemoryVector( const QString &layerName = QString() ); 1001 //! copies style of the active layer to the clipboard 1002 1003 /** 1004 * Copy the style of a map layer 1005 * \param sourceLayer The layer where the style will be taken from (defaults to the active layer on the legend) 1006 * \param categories The style categories to copy 1007 */ 1008 void copyStyle( QgsMapLayer *sourceLayer = nullptr, QgsMapLayer::StyleCategories categories = QgsMapLayer::AllStyleCategories ); 1009 //! pastes style on the clipboard to the active layer 1010 1011 /** 1012 * \param destinationLayer The layer that the clipboard will be pasted to (defaults to the active layer on the legend) 1013 * \param categories The style categories to copy 1014 */ 1015 void pasteStyle( QgsMapLayer *destinationLayer = nullptr, 1016 QgsMapLayer::StyleCategories categories = QgsMapLayer::AllStyleCategories ); 1017 //! copies group or layer on the clipboard 1018 void copyLayer(); 1019 //! pastes group or layer from the clipboard to layer tree 1020 void pasteLayer(); 1021 1022 //! Apply the same style to selected layers or to current legend group 1023 void applyStyleToGroup(); 1024 1025 //! Sets CRS of a layer 1026 void setLayerCrs(); 1027 //! Assign layer CRS to project 1028 void setProjectCrsFromLayer(); 1029 1030 //! copies features to internal clipboard 1031 void copyFeatures( QgsFeatureStore &featureStore ); 1032 1033 //! Deletes the selected attributes for the currently selected vector layer 1034 void deleteSelected( QgsMapLayer *layer = nullptr, QWidget *parent = nullptr, bool checkFeaturesVisible = false ); 1035 1036 //! project was written 1037 void writeProject( QDomDocument & ); 1038 1039 //! project was read 1040 void readProject( const QDomDocument & ); 1041 1042 //! Sets app stylesheet from settings 1043 void setAppStyleSheet( const QString &stylesheet ); 1044 1045 //! request credentials for network manager 1046 void namProxyAuthenticationRequired( const QNetworkProxy &proxy, QAuthenticator *auth ); 1047 void namRequestTimedOut( const QgsNetworkRequestParameters &request ); 1048 1049 //! Schedule and erase of the authentication database upon confirmation 1050 void eraseAuthenticationDatabase(); 1051 1052 //! Push authentication manager output to messagebar 1053 void authMessageOut( const QString &message, const QString &authtag, QgsAuthManager::MessageLevel level ); 1054 1055 //! update default action of toolbutton 1056 void toolButtonActionTriggered( QAction * ); 1057 1058 //! layer selection changed 1059 void legendLayerSelectionChanged(); 1060 1061 /** 1062 * Zooms so that the pixels of the raster layer occupies exactly one screen pixel. 1063 * Only works on raster layers. 1064 */ 1065 void legendLayerZoomNative(); 1066 1067 /** 1068 * Stretches the raster layer, if stretching is active, based on the min and max of the current extent. 1069 * Only works on raster layers. 1070 */ 1071 void legendLayerStretchUsingCurrentExtent(); 1072 1073 //! Watch for QFileOpenEvent. 1074 bool event( QEvent *event ) override; 1075 1076 //! Sets the CRS of the current legend group 1077 void legendGroupSetCrs(); 1078 //! Sets the WMS data of the current legend group 1079 void legendGroupSetWmsData(); 1080 1081 /** 1082 * \brief dataSourceManager Open the DataSourceManager dialog 1083 * \param pageName the page name, usually the provider name or "browser" (for the browser panel) 1084 * or "ogr" (vector layers) or "raster" (raster layers) 1085 */ 1086 void dataSourceManager( const QString &pageName = QString() ); 1087 1088 //! Add a virtual layer 1089 void addVirtualLayer(); 1090 1091 //! Remove a layer from the map and legend 1092 void removeLayer(); 1093 1094 //! Duplicate map layer(s) in legend 1095 void duplicateLayers( const QList<QgsMapLayer *> &lyrList = QList<QgsMapLayer *>() ); 1096 1097 /** 1098 * Changes layer subset of \a mapLayer 1099 * \since QGIS 3.12 1100 */ 1101 void layerSubsetString( QgsMapLayer *mapLayer ); 1102 1103 //! change layer subset of the active layer 1104 void layerSubsetString( ); 1105 1106 //! Sets scale visibility of selected layers 1107 void setLayerScaleVisibility(); 1108 1109 //! Zoom to nearest scale such that current layer is visible 1110 void zoomToLayerScale(); 1111 1112 /** 1113 * Returns the shared application browser model. 1114 */ 1115 QgsBrowserGuiModel *browserModel(); 1116 1117 /** 1118 * Change data source for \a layer, a data source selection dialog 1119 * will be opened and if accepted the data selected source will be 1120 * applied. 1121 * 1122 * In case the layer was originally invalid and it had the original 1123 * XML layer properties, the properties will be applied. 1124 */ 1125 void changeDataSource( QgsMapLayer *layer ); 1126 1127 /** 1128 * Add a raster layer directly without prompting user for location 1129 * The caller must provide information compatible with the provider plugin 1130 * using the \a uri and \a baseName. The provider can use these 1131 * parameters in any way necessary to initialize the layer. The \a baseName 1132 * parameter is used in the Map Legend so it should be formed in a meaningful 1133 * way. 1134 */ 1135 QgsRasterLayer *addRasterLayer( QString const &uri, QString const &baseName, QString const &providerKey = QLatin1String( "gdal" ) ); 1136 1137 /** 1138 * Add a vector layer directly without prompting user for location 1139 * The caller must provide information compatible with the provider plugin 1140 * using the \a vectorLayerPath and \a baseName. The provider can use these 1141 * parameters in any way necessary to initialize the layer. The \a baseName 1142 * parameter is used in the Map Legend so it should be formed in a meaningful 1143 * way. 1144 */ 1145 QgsVectorLayer *addVectorLayer( const QString &vectorLayerPath, const QString &baseName, const QString &providerKey = QLatin1String( "ogr" ) ); 1146 1147 /** 1148 * Adds a mesh layer directly without prompting user for location 1149 * The caller must provide information compatible with the provider plugin 1150 * using the \a url and \a baseName. The provider can use these 1151 * parameters in any way necessary to initialize the layer. The \a baseName 1152 * parameter is used in the Map Legend so it should be formed in a meaningful 1153 * way. 1154 */ 1155 QgsMeshLayer *addMeshLayer( const QString &url, const QString &baseName, const QString &providerKey ); 1156 1157 /** 1158 * Adds a vector tile layer directly without prompting user for location 1159 * The caller must provide information needed for layer construction 1160 * using the \a url and \a baseName. The \a baseName parameter is used 1161 * in the Map Legend so it should be formed in a meaningful way. 1162 * \since QGIS 3.14 1163 */ 1164 QgsVectorTileLayer *addVectorTileLayer( const QString &url, const QString &baseName ); 1165 1166 /** 1167 * Adds a vector tile layer directly without prompting user for location 1168 * The caller must provide information needed for layer construction 1169 * using the \a url and \a baseName. The \a baseName parameter is used 1170 * in the Map Legend so it should be formed in a meaningful way. 1171 * \since QGIS 3.18 1172 */ 1173 QgsPointCloudLayer *addPointCloudLayer( const QString &url, const QString &baseName, const QString &providerKey ); 1174 1175 /** 1176 * \brief overloaded version of the private addLayer method that takes a list of 1177 * file names instead of prompting user with a dialog. 1178 * \param enc encoding type for the layer 1179 * \param dataSourceType type of ogr datasource 1180 * \returns TRUE if successfully added layer 1181 */ 1182 bool addVectorLayers( const QStringList &layerQStringList, const QString &enc, const QString &dataSourceType ); 1183 1184 /** 1185 * Overloaded version of the private addRasterLayer() 1186 * Method that takes a list of file names instead of prompting 1187 * user with a dialog. 1188 * \returns TRUE if successfully added layer(s) 1189 */ 1190 bool addRasterLayers( const QStringList &files, bool guiWarning = true ); 1191 1192 //! Open a plugin layer using its provider 1193 QgsPluginLayer *addPluginLayer( const QString &uri, const QString &baseName, const QString &providerKey ); 1194 1195 void versionReplyFinished(); 1196 logViewer()1197 QgsMessageLogViewer *logViewer() { return mLogViewer; } 1198 1199 //! Update project menu with the project templates 1200 void updateProjectFromTemplates(); 1201 1202 /** 1203 * 1204 * Settings pages section 1205 */ 1206 //! Gets map of option pages 1207 QMap<QString, QString> optionsPagesMap(); 1208 //! Gets map of project property pages 1209 QMap< QString, QString > projectPropertiesPagesMap(); 1210 //! Gets map of setting pages 1211 QMap< QString, QString > settingPagesMap(); 1212 1213 void showProjectProperties( const QString &page = QString() ); 1214 void showSettings( const QString &page ); 1215 // End Settings pages section 1216 1217 //! Opens the options dialog 1218 void showOptionsDialog( QWidget *parent = nullptr, const QString ¤tPage = QString(), int pageNumber = -1 ); 1219 1220 /** 1221 * Refreshes the state of the layer actions toolbar action 1222 * \since QGIS 2.1 1223 */ 1224 void refreshActionFeatureAction(); 1225 panelMenu()1226 QMenu *panelMenu() { return mPanelMenu; } 1227 1228 void renameView(); 1229 1230 void showStatusMessage( const QString &message ); 1231 1232 void loadingLayerMessages( const QString &layerName, const QList<QgsReadWriteContext::ReadWriteMessage> &messages ); 1233 1234 //! Sets the active layer 1235 bool setActiveLayer( QgsMapLayer * ); 1236 1237 /** 1238 * Reload connections emitting the connectionsChanged signal 1239 * \since QGIS 3.0 1240 */ 1241 void reloadConnections(); 1242 1243 /** 1244 * Shows the layout manager dialog. 1245 * \since QGIS 3.0 1246 */ 1247 void showLayoutManager(); 1248 1249 //! shows the snapping Options 1250 void snappingOptions(); 1251 1252 void setMapTipsDelay( int timerInterval ); 1253 1254 /** 1255 * Abort application triggering the crash handler 1256 * \since QGIS 3.4 1257 */ 1258 void triggerCrashHandler(); 1259 1260 //! Create a new file from a template project 1261 bool fileNewFromTemplate( const QString &fileName ); 1262 1263 //! Show the spatial bookmark manager panel 1264 void showBookmarkManager( bool show ); 1265 1266 //! Show and focus the browser panel to spatial bookmarks 1267 void showBookmarks(); 1268 1269 //! Create a new spatial bookmark 1270 void newBookmark( bool inProject = false ); 1271 1272 /** 1273 * Creates a default attribute editor context using the main map canvas and the main edit tools and message bar 1274 * \since QGIS 3.12 1275 */ 1276 QgsAttributeEditorContext createAttributeEditorContext(); 1277 1278 protected: 1279 void showEvent( QShowEvent *event ) override; 1280 1281 //! Handle state changes (WindowTitleChange) 1282 void changeEvent( QEvent *event ) override; 1283 //! Have some control over closing of the application 1284 void closeEvent( QCloseEvent *event ) override; 1285 1286 void dragEnterEvent( QDragEnterEvent *event ) override; 1287 void dropEvent( QDropEvent *event ) override; 1288 1289 //! reimplements widget keyPress event so we can check if cancel was pressed 1290 void keyPressEvent( QKeyEvent *event ) override; 1291 1292 #ifdef ANDROID 1293 //! reimplements widget keyReleaseEvent event so we can check if back was pressed 1294 virtual void keyReleaseEvent( QKeyEvent *event ); 1295 #endif 1296 1297 private slots: 1298 void newProfile(); 1299 1300 void onTaskCompleteShowNotify( long taskId, int status ); 1301 1302 void onTransactionGroupsChanged(); 1303 1304 void transactionGroupCommitError( const QString &error ); 1305 1306 void onSnappingConfigChanged(); 1307 1308 /** 1309 * Triggers validation of the specified \a crs. 1310 */ 1311 void validateCrs( QgsCoordinateReferenceSystem &crs ); 1312 1313 //! QGIS Sponsors 1314 void sponsors(); 1315 //! About QGIS 1316 void about(); 1317 1318 //! Add a list of database layers to the map 1319 void addDatabaseLayers( QStringList const &layerPathList, QString const &providerKey ); 1320 //! Add a vector layer defined by uri, layer name, data source uri 1321 void addSelectedVectorLayer( const QString &uri, const QString &layerName, const QString &provider ); 1322 //! Replace the selected layer by a vector layer defined by uri, layer name, data source uri 1323 void replaceSelectedVectorLayer( const QString &oldId, const QString &uri, const QString &layerName, const QString &provider ); 1324 1325 //! toggles whether the current selected layer is in overview or not 1326 void isInOverview(); 1327 //! Store the position for map tool tip 1328 void saveLastMousePosition( const QgsPointXY & ); 1329 //! Slot to show current map scale; 1330 void showScale( double scale ); 1331 1332 /** 1333 * Slot to handle user rotation input; 1334 * \since QGIS 2.8 1335 */ 1336 void userRotation(); 1337 1338 //! zoom to extent of layer 1339 void zoomToLayerExtent(); 1340 //! zoom to actual size of raster layer 1341 void zoomActualSize(); 1342 1343 /** 1344 * Perform a local histogram stretch on the active raster layer 1345 * (stretch based on pixel values in view extent). 1346 * Valid for non wms raster layers only. 1347 */ 1348 void localHistogramStretch(); 1349 1350 /** 1351 * Perform a full histogram stretch on the active raster layer 1352 * (stretch based on pixels values in full dataset) 1353 * Valid for non wms raster layers only. 1354 */ 1355 void fullHistogramStretch(); 1356 //! Perform a local cumulative cut stretch 1357 void localCumulativeCutStretch(); 1358 //! Perform a full extent cumulative cut stretch 1359 void fullCumulativeCutStretch(); 1360 1361 /** 1362 * Increase raster brightness 1363 * Valid for non wms raster layers only. 1364 */ 1365 void increaseBrightness(); 1366 1367 /** 1368 * Decrease raster brightness 1369 * Valid for non wms raster layers only. 1370 */ 1371 void decreaseBrightness(); 1372 1373 /** 1374 * Increase raster contrast 1375 * Valid for non wms raster layers only. 1376 */ 1377 void increaseContrast(); 1378 1379 /** 1380 * Decrease raster contrast 1381 * Valid for non wms raster layers only. 1382 */ 1383 void decreaseContrast(); 1384 1385 /** 1386 * Increase raster gamma 1387 * Valid for non wms raster layers only. 1388 * \since QGIS 3.16 1389 */ 1390 void increaseGamma(); 1391 1392 /** 1393 * Decrease raster gamma 1394 * Valid for non wms raster layers only. 1395 * \since QGIS 3.16 1396 */ 1397 void decreaseGamma(); 1398 1399 1400 //! plugin manager 1401 void showPluginManager(); 1402 //! load Python support if possible 1403 void loadPythonSupport(); 1404 1405 //! Find the QMenu with the given name within plugin menu (ie the user visible text on the menu item) 1406 QMenu *getPluginMenu( const QString &menuName ); 1407 //! Add the action to the submenu with the given name under the plugin menu 1408 void addPluginToMenu( const QString &name, QAction *action ); 1409 //! Remove the action to the submenu with the given name under the plugin menu 1410 void removePluginMenu( const QString &name, QAction *action ); 1411 //! Find the QMenu with the given name within the Database menu (ie the user visible text on the menu item) 1412 QMenu *getDatabaseMenu( const QString &menuName ); 1413 //! Add the action to the submenu with the given name under the Database menu 1414 void addPluginToDatabaseMenu( const QString &name, QAction *action ); 1415 //! Remove the action to the submenu with the given name under the Database menu 1416 void removePluginDatabaseMenu( const QString &name, QAction *action ); 1417 //! Find the QMenu with the given name within the Raster menu (ie the user visible text on the menu item) 1418 QMenu *getRasterMenu( const QString &menuName ); 1419 //! Add the action to the submenu with the given name under the Raster menu 1420 void addPluginToRasterMenu( const QString &name, QAction *action ); 1421 //! Remove the action to the submenu with the given name under the Raster menu 1422 void removePluginRasterMenu( const QString &name, QAction *action ); 1423 //! Find the QMenu with the given name within the Vector menu (ie the user visible text on the menu item) 1424 QMenu *getVectorMenu( const QString &menuName ); 1425 //! Add the action to the submenu with the given name under the Vector menu 1426 void addPluginToVectorMenu( const QString &name, QAction *action ); 1427 //! Remove the action to the submenu with the given name under the Vector menu 1428 void removePluginVectorMenu( const QString &name, QAction *action ); 1429 //! Find the QMenu with the given name within the Web menu (ie the user visible text on the menu item) 1430 QMenu *getWebMenu( const QString &menuName ); 1431 //! Add the action to the submenu with the given name under the Web menu 1432 void addPluginToWebMenu( const QString &name, QAction *action ); 1433 //! Remove the action to the submenu with the given name under the Web menu 1434 void removePluginWebMenu( const QString &name, QAction *action ); 1435 //! Add "add layer" action to layer menu 1436 void insertAddLayerAction( QAction *action ); 1437 //! Remove "add layer" action to layer menu 1438 void removeAddLayerAction( QAction *action ); 1439 //! Add an icon to the plugin toolbar 1440 int addPluginToolBarIcon( QAction *qAction ); 1441 1442 /** 1443 * Add a widget to the plugins toolbar. 1444 * To remove this widget again, call removeToolBarIcon() 1445 * with the returned QAction. 1446 * 1447 * \param widget widget to add. The toolbar will take ownership of this widget 1448 * \returns the QAction you can use to remove this widget from the toolbar 1449 */ 1450 QAction *addPluginToolBarWidget( QWidget *widget ); 1451 //! Remove an icon from the plugin toolbar 1452 void removePluginToolBarIcon( QAction *qAction ); 1453 //! Add an icon to the Raster toolbar 1454 int addRasterToolBarIcon( QAction *qAction ); 1455 1456 /** 1457 * Add a widget to the raster toolbar. 1458 * To remove this widget again, call removeRasterToolBarIcon() 1459 * with the returned QAction. 1460 * 1461 * \param widget widget to add. The toolbar will take ownership of this widget 1462 * \returns the QAction you can use to remove this widget from the toolbar 1463 */ 1464 QAction *addRasterToolBarWidget( QWidget *widget ); 1465 //! Remove an icon from the Raster toolbar 1466 void removeRasterToolBarIcon( QAction *qAction ); 1467 //! Add an icon to the Vector toolbar 1468 int addVectorToolBarIcon( QAction *qAction ); 1469 1470 /** 1471 * Add a widget to the vector toolbar. 1472 * To remove this widget again, call removeVectorToolBarIcon() 1473 * with the returned QAction. 1474 * 1475 * \param widget widget to add. The toolbar will take ownership of this widget 1476 * \returns the QAction you can use to remove this widget from the toolbar 1477 */ 1478 QAction *addVectorToolBarWidget( QWidget *widget ); 1479 //! Remove an icon from the Vector toolbar 1480 void removeVectorToolBarIcon( QAction *qAction ); 1481 //! Add an icon to the Database toolbar 1482 int addDatabaseToolBarIcon( QAction *qAction ); 1483 1484 void onVirtualLayerAdded( const QString &uri, const QString &layerName ); 1485 1486 /** 1487 * Add a widget to the database toolbar. 1488 * To remove this widget again, call removeDatabaseToolBarIcon() 1489 * with the returned QAction. 1490 * 1491 * \param widget widget to add. The toolbar will take ownership of this widget 1492 * \returns the QAction you can use to remove this widget from the toolbar 1493 */ 1494 QAction *addDatabaseToolBarWidget( QWidget *widget ); 1495 //! Remove an icon from the Database toolbar 1496 void removeDatabaseToolBarIcon( QAction *qAction ); 1497 //! Add an icon to the Web toolbar 1498 int addWebToolBarIcon( QAction *qAction ); 1499 1500 /** 1501 * Add a widget to the web toolbar. 1502 * To remove this widget again, call removeWebToolBarIcon() 1503 * with the returned QAction. 1504 * 1505 * \param widget widget to add. The toolbar will take ownership of this widget 1506 * \returns the QAction you can use to remove this widget from the toolbar 1507 */ 1508 QAction *addWebToolBarWidget( QWidget *widget ); 1509 //! Remove an icon from the Web toolbar 1510 void removeWebToolBarIcon( QAction *qAction ); 1511 //! Save window state 1512 void saveWindowState(); 1513 //! Restore the window and toolbar state 1514 void restoreWindowState(); 1515 //! Save project. Returns true if the user selected a file to save to, false if not. 1516 bool fileSave(); 1517 //! Save project as 1518 void fileSaveAs(); 1519 //! Export project in dxf format 1520 void dxfExport(); 1521 //! Import layers in dwg format 1522 void dwgImport(); 1523 1524 /** 1525 * Open the project file corresponding to the 1526 * text)= of the given action. 1527 */ 1528 void openProject( QAction *action ); 1529 //! Save the map view as an image - user is prompted for image name using a dialog 1530 void saveMapAsImage(); 1531 //! Save the map view as a pdf - user is prompted for image name using a dialog 1532 void saveMapAsPdf(); 1533 //! Open a project 1534 void fileOpen(); 1535 //! Revert unsaved changes to a project 1536 void fileRevert(); 1537 //! Create a new project 1538 bool fileNew(); 1539 //! Create a new blank project (no template) 1540 bool fileNewBlank(); 1541 1542 /** 1543 * Close the current open project and show the welcome screen again. 1544 */ 1545 void fileClose(); 1546 1547 //! As above but allows forcing without prompt and forcing blank project 1548 bool fileNew( bool promptToSaveFlag, bool forceBlank = false ); 1549 //! What type of project to open after launch 1550 void fileOpenAfterLaunch(); 1551 //! After project read, set any auto-opened project as successful 1552 void fileOpenedOKAfterLaunch(); 1553 void fileNewFromTemplateAction( QAction *qAction ); 1554 void fileNewFromDefaultTemplate(); 1555 //! Calculate new rasters from existing ones 1556 void showRasterCalculator(); 1557 //! Calculate new meshes from existing ones 1558 void showMeshCalculator(); 1559 //! Open dialog to align raster layers 1560 void showAlignRasterTool(); 1561 1562 /** 1563 * Called whenever user wants to embed layers 1564 */ 1565 void embedLayers(); 1566 1567 /** 1568 * Embed \a groups and \a layerIds items from \a projectFile 1569 */ 1570 void addEmbeddedItems( const QString &projectFile, const QStringList &groups, const QStringList &layerIds ); 1571 1572 //! Creates a new map canvas view 1573 void newMapCanvas(); 1574 //! Creates a new 3D map canvas view 1575 void new3DMapCanvas(); 1576 1577 //! Create a new empty vector layer 1578 void newVectorLayer(); 1579 //! Create a new memory layer 1580 void newMemoryLayer(); 1581 #ifdef HAVE_SPATIALITE 1582 //! Create a new empty SpatiaLite layer 1583 void newSpatialiteLayer(); 1584 #endif 1585 //! Create a new empty GeoPackage layer 1586 void newGeoPackageLayer(); 1587 1588 //! Create a new empty mesh layer 1589 void newMeshLayer(); 1590 1591 //! Create a new empty GPX layer 1592 void newGpxLayer(); 1593 1594 //! Create a new print layout 1595 void newPrintLayout(); 1596 1597 //! Create a new report 1598 void newReport(); 1599 1600 //! Slot to handle display of layouts menu, e.g. sorting 1601 void layoutsMenuAboutToShow(); 1602 1603 //! Add all loaded layers into the overview - overrides qgisappbase method 1604 void addAllToOverview(); 1605 //! Remove all loaded layers from the overview - overrides qgisappbase method 1606 void removeAllFromOverview(); 1607 //reimplements method from base (gui) class 1608 void hideAllLayers(); 1609 //reimplements method from base (gui) class 1610 void showAllLayers(); 1611 //reimplements method from base (gui) class 1612 void hideSelectedLayers(); 1613 //! Toggles the visibility of the selected layers depending on the state of the first layer in selection (first clicked) 1614 void toggleSelectedLayers(); 1615 //! Toggles the visibility of the selected layers independently 1616 void toggleSelectedLayersIndependently(); 1617 //! Hides any layers which are not selected 1618 void hideDeselectedLayers(); 1619 //reimplements method from base (gui) class 1620 void showSelectedLayers(); 1621 1622 //! Open the help contents in a browser 1623 void helpContents(); 1624 //! Open the API documentation in a browser 1625 void apiDocumentation(); 1626 //! Open the Bugtracker page in a browser 1627 void reportaBug(); 1628 //! Open the QGIS support page 1629 void supportProviders(); 1630 //! Open the QGIS homepage in users browser 1631 void helpQgisHomePage(); 1632 //! Open a url in the users configured browser 1633 void openURL( QString url, bool useQgisDocDirectory = true ); 1634 //! Check qgis version against the qgis version server 1635 void checkQgisVersion(); 1636 //!Invoke the custom projection dialog 1637 void customProjection(); 1638 //! configure shortcuts 1639 void configureShortcuts(); 1640 //! show customization dialog 1641 void customize(); 1642 //! options dialog slot 1643 void options(); 1644 //! Open project properties dialog and show the projections tab 1645 void projectPropertiesProjections(); 1646 /* void urlData(); */ 1647 //! activates the add feature tool 1648 void addFeature(); 1649 //! activates the move feature tool 1650 void moveFeature(); 1651 //! activates the copy and move feature tool 1652 void moveFeatureCopy(); 1653 //! activates the offset curve tool 1654 void offsetCurve(); 1655 //! activates the reshape features tool 1656 void reshapeFeatures(); 1657 //! activates the split features tool 1658 void splitFeatures(); 1659 //! activates the split parts tool 1660 void splitParts(); 1661 //! activates the add ring tool 1662 void addRing(); 1663 //! activates the fill ring tool 1664 void fillRing(); 1665 //! activates the add part tool 1666 void addPart(); 1667 //! simplifies feature 1668 void simplifyFeature(); 1669 //! deletes ring in polygon 1670 void deleteRing(); 1671 //! deletes part of polygon 1672 void deletePart(); 1673 //! merges the selected features together 1674 void mergeSelectedFeatures(); 1675 //! merges the attributes of selected features 1676 void mergeAttributesOfSelectedFeatures(); 1677 //! Modifies the attributes of selected features via feature form 1678 void modifyAttributesOfSelectedFeatures(); 1679 //! provides operations with nodes on all layers 1680 void vertexTool(); 1681 //! provides operations with nodes on active layer only 1682 void vertexToolActiveLayer(); 1683 //! activates the rotate points tool 1684 void rotatePointSymbols(); 1685 //! activates the offset point symbol tool 1686 void offsetPointSymbol(); 1687 //! activates the reverse line tool 1688 void reverseLine(); 1689 //! activates the tool 1690 void setMapTool( QgsMapTool *tool, bool clean = false ); 1691 1692 1693 //! activates the rectangle selection tool 1694 void selectFeatures(); 1695 1696 //! activates the polygon selection tool 1697 void selectByPolygon(); 1698 1699 //! activates the freehand selection tool 1700 void selectByFreehand(); 1701 1702 //! activates the radius selection tool 1703 void selectByRadius(); 1704 1705 //! deselect features from all layers 1706 void deselectAll(); 1707 1708 //! deselect features from the current active layer 1709 void deselectActiveLayer(); 1710 1711 //! select all features 1712 void selectAll(); 1713 1714 //! invert the selection 1715 void invertSelection(); 1716 1717 //! select features by expression 1718 void selectByExpression(); 1719 1720 //! select features by form 1721 void selectByForm(); 1722 1723 //! refresh map canvas 1724 void refreshMapCanvas( bool redrawAllLayers = false ); 1725 1726 //! start "busy" progress bar 1727 void canvasRefreshStarted(); 1728 //! stop "busy" progress bar 1729 void canvasRefreshFinished(); 1730 1731 //! Dialog for verification of action on many edits 1732 bool verifyEditsActionDialog( const QString &act, const QString &upon ); 1733 1734 //! Update gui actions/menus when layers are modified 1735 void updateLayerModifiedActions(); 1736 1737 //! map tool changed 1738 void mapToolChanged( QgsMapTool *newTool, QgsMapTool *oldTool ); 1739 1740 //! map layers changed 1741 void showMapCanvas(); 1742 1743 //! change log message icon in statusbar 1744 void toggleLogMessageIcon( bool hasLogMessage ); 1745 1746 //! Called when some layer's editing mode was toggled on/off 1747 void layerEditStateChanged(); 1748 1749 //! Update the label toolbar buttons 1750 void updateLabelToolButtons(); 1751 1752 //! Returns true if at least one selected layer in layer panel has a selection (returns false if none). 1753 bool selectedLayersHaveSelection(); 1754 1755 //! Returns true if at least one selected layer in layer panel is spatial (returns false if none). 1756 bool selectedLayersHaveSpatial(); 1757 1758 //! Activates or deactivates actions depending on the selected layers in the layer panel. 1759 void activateDeactivateMultipleLayersRelatedActions(); 1760 1761 /** 1762 * Activates or deactivates actions depending on the current maplayer type. 1763 * Is called from the legend when the current legend item has changed. 1764 */ 1765 void activateDeactivateLayerRelatedActions( QgsMapLayer *layer ); 1766 1767 void selectionChanged( QgsMapLayer *layer ); 1768 1769 void extentChanged(); 1770 void showRotation(); 1771 1772 void showPanMessage( double distance, QgsUnitTypes::DistanceUnit unit, double bearing ); 1773 1774 void selectionModeChanged( QgsMapToolSelect::Mode mode ); 1775 1776 void displayMapToolMessage( const QString &message, Qgis::MessageLevel level = Qgis::MessageLevel::Info ); 1777 void displayMessage( const QString &title, const QString &message, Qgis::MessageLevel level ); 1778 void removeMapToolMessage(); 1779 void updateMouseCoordinatePrecision(); 1780 // void debugHook(); 1781 //! Add a Layer Definition file 1782 void addLayerDefinition(); 1783 //! Exit Qgis 1784 void fileExit(); 1785 //! Sets map tool to Zoom out 1786 void zoomOut(); 1787 //! Sets map tool to Zoom in 1788 void zoomIn(); 1789 //! Sets map tool to pan 1790 void pan(); 1791 //! Identify feature(s) on the currently selected layer 1792 void identify(); 1793 //! Measure distance 1794 void measure(); 1795 //! Measure area 1796 void measureArea(); 1797 //! Measure angle 1798 void measureAngle(); 1799 1800 //! Run the default feature action on the current layer 1801 void doFeatureAction(); 1802 //! Sets the default feature action for the current layer 1803 void updateDefaultFeatureAction( QAction *action ); 1804 //! Refresh the list of feature actions of the current layer 1805 void refreshFeatureActions(); 1806 1807 //annotations 1808 void addFormAnnotation(); 1809 void addTextAnnotation(); 1810 void addHtmlAnnotation(); 1811 void addSvgAnnotation(); 1812 void modifyAnnotation(); 1813 void reprojectAnnotations(); 1814 1815 //! Alerts user when labeling font for layer has not been found on system 1816 void labelingFontNotFound( QgsVectorLayer *vlayer, const QString &fontfamily ); 1817 1818 //! Alerts user when commit errors occurred 1819 void commitError( QgsVectorLayer *vlayer ); 1820 1821 //! Opens the labeling dialog for a layer when called from labelingFontNotFound alert 1822 void labelingDialogFontNotFound( QAction *act ); 1823 1824 //! shows label settings dialog (for labeling-ng) 1825 void labeling(); 1826 1827 //! shows the map styling dock 1828 void mapStyleDock( bool enabled ); 1829 1830 //! diagrams properties 1831 void diagramProperties(); 1832 1833 //! Creates a new annotation layer 1834 void createAnnotationLayer(); 1835 1836 //! Sets the CAD dock widget visible 1837 void setCadDockVisible( bool visible ); 1838 1839 //! show Python console 1840 void showPythonDialog(); 1841 1842 //! add Python cnosole at start up 1843 void initPythonConsoleOptions(); 1844 1845 //! Shows a warning when an old project file is read. 1846 void oldProjectVersionWarning( const QString & ); 1847 1848 //! Toggle map tips on/off 1849 void toggleMapTips( bool enabled ); 1850 1851 //! Show the map tip 1852 void showMapTip(); 1853 1854 //! Toggle full screen mode 1855 void toggleFullScreen(); 1856 1857 //! Toggle visibility of opened panels 1858 void togglePanelsVisibility(); 1859 1860 //! Toggle visibility of main map only 1861 void toggleMapOnly(); 1862 1863 //! Toggle between full QGIS view and reduced view (being either Map only or only hiding panels) 1864 void toggleReducedView( bool viewMapOnly ); 1865 1866 //! Sets minimized mode of active window 1867 void showActiveWindowMinimized(); 1868 1869 //! Toggle maximized mode of active window 1870 void toggleActiveWindowMaximized(); 1871 1872 //! Raise, unminimize and activate this window 1873 void activate(); 1874 1875 //! Bring forward all open windows 1876 void bringAllToFront(); 1877 1878 //! Stops rendering of the main map 1879 void stopRendering(); 1880 1881 void showStyleManager(); 1882 1883 //! Toggles whether to show pinned labels 1884 void showPinnedLabels( bool show ); 1885 //! Activates pin labels tool 1886 void pinLabels(); 1887 //! Activates show/hide labels tool 1888 void showHideLabels(); 1889 //! Activates the move label tool 1890 void moveLabel(); 1891 //! Activates rotate feature tool 1892 void rotateFeature(); 1893 //! Activates scale feature tool 1894 void scaleFeature(); 1895 //! Activates rotate label tool 1896 void rotateLabel(); 1897 //! Activates label property tool 1898 void changeLabelProperties(); 1899 1900 void renderDecorationItems( QPainter *p ); 1901 void projectReadDecorationItems(); 1902 1903 //! clear out any stuff from project 1904 void closeProject(); 1905 1906 //! trust and load project macros 1907 void enableProjectMacros(); 1908 1909 void clipboardChanged(); 1910 1911 //! catch MapCanvas keyPress event so we can check if selected feature collection must be deleted 1912 void mapCanvas_keyPressed( QKeyEvent *e ); 1913 1914 /** 1915 * Disable any preview modes shown on the map canvas 1916 * \since QGIS 2.3 1917 */ 1918 void disablePreviewMode(); 1919 1920 /** 1921 * Enable a monochrome preview mode on the map canvas 1922 * \since QGIS 2.3 1923 */ 1924 void activateMonoPreview(); 1925 1926 /** 1927 * Enable a grayscale preview mode on the map canvas 1928 * \since QGIS 2.3 1929 */ 1930 void activateGrayscalePreview(); 1931 1932 /** 1933 * Enable a color blindness (protanopia) preview mode on the map canvas 1934 * \since QGIS 2.3 1935 */ 1936 void activateProtanopePreview(); 1937 1938 /** 1939 * Enable a color blindness (deuteranopia) preview mode on the map canvas 1940 * \since QGIS 2.3 1941 */ 1942 void activateDeuteranopePreview(); 1943 1944 /** 1945 * Enable a color blindness (tritanopia) preview mode on the map canvas 1946 * \since QGIS 3.18 1947 */ 1948 void activateTritanopePreview(); 1949 1950 void toggleFilterLegendByExpression( bool ); 1951 void updateFilterLegend(); 1952 1953 //! Pushes a layer error to the message bar 1954 void onLayerError( const QString &msg ); 1955 1956 //! Sets the layer for the map style dock. Doesn't show the style dock 1957 void setMapStyleDockLayer( QgsMapLayer *layer ); 1958 1959 void annotationCreated( QgsAnnotation *annotation ); 1960 1961 void updateCrsStatusBar(); 1962 1963 //! handle project crs changes 1964 void projectCrsChanged(); 1965 1966 //! Updates the temporal range in layers that are using project temporal range. 1967 void projectTemporalRangeChanged(); 1968 1969 void onActiveLayerChanged( QgsMapLayer *layer ); 1970 1971 /** 1972 * Triggered when a vector layer style has changed, checks for widget config layer dependencies 1973 * \param categories style categories 1974 * \since QGIS 3.12 1975 */ 1976 void vectorLayerStyleLoaded( QgsVectorLayer *vl, const QgsMapLayer::StyleCategories categories ); 1977 1978 //! Enable or disable event tracing (for debugging) 1979 void toggleEventTracing(); 1980 1981 /** 1982 * Enables or disables digitizing with curve for map tool that support this capabilities 1983 * \since QGIS 3.16 1984 */ 1985 void enableDigitizeWithCurve( bool enable ); 1986 1987 /** 1988 * Enables or disables stream digitizing 1989 * \since QGIS 3.20 1990 */ 1991 void enableStreamDigitizing( bool enable ); 1992 1993 /** 1994 * Enables the action that toggles digitizing with curve 1995 */ 1996 void enableDigitizeTechniqueActions( bool enable, QAction *triggeredFromToolAction = nullptr ); 1997 1998 #ifdef HAVE_GEOREFERENCER 1999 void showGeoreferencer(); 2000 #endif 2001 2002 void annotationItemTypeAdded( int id ); 2003 2004 signals: 2005 2006 /** 2007 * Emitted when a connection has been added/removed or changed by the provider 2008 * selection dialogs 2009 */ 2010 void connectionsChanged(); 2011 2012 /** 2013 * Emitted when a key is pressed and we want non widget subclasses to be able 2014 * to pick up on this (e.g. maplayer). 2015 */ 2016 void keyPressed( QKeyEvent *e ); 2017 2018 /** 2019 * Emitted when a project file is successfully read 2020 * \note This is useful for plug-ins that store properties with project files. A 2021 * plug-in can connect to this signal. When it is emitted, the plug-in 2022 * knows to then check the project properties for any relevant state. 2023 */ 2024 void projectRead(); 2025 2026 /** 2027 * Emitted when starting an entirely new project 2028 * \note 2029 * This is similar to projectRead(); plug-ins might want to be notified 2030 * that they're in a new project. Yes, projectRead() could have been 2031 * overloaded to be used in the case of new projects instead. However, 2032 * it's probably more semantically correct to have an entirely separate 2033 * signal for when this happens. 2034 */ 2035 void newProject(); 2036 2037 /** 2038 * Signal emitted when the current theme is changed so plugins 2039 * can change there tool button icons. 2040 */ 2041 void currentThemeChanged( const QString & ); 2042 2043 /** 2044 * Emitted when a new layout \a designer has been opened. 2045 * \see layoutDesignerWillBeClosed() 2046 * \since QGIS 3.0 2047 */ 2048 void layoutDesignerOpened( QgsLayoutDesignerInterface *designer ); 2049 2050 /** 2051 * Emitted before a layout \a designer is going to be closed 2052 * and deleted. 2053 * \see layoutDesignerClosed() 2054 * \see layoutDesignerOpened() 2055 * \since QGIS 3.0 2056 */ 2057 void layoutDesignerWillBeClosed( QgsLayoutDesignerInterface *designer ); 2058 2059 /** 2060 * Emitted after a layout designer window is closed. 2061 * \see layoutDesignerWillBeClosed() 2062 * \see layoutDesignerOpened() 2063 * \since QGIS 3.0 2064 */ 2065 void layoutDesignerClosed(); 2066 2067 //! Emitted when QGIS' initialization is complete 2068 void initializationCompleted(); 2069 2070 void customCrsValidation( QgsCoordinateReferenceSystem &crs ); 2071 2072 /** 2073 * Emitted when a layer has been saved using save as 2074 * \since QGIS 2.7 2075 */ 2076 void layerSavedAs( QgsMapLayer *l, const QString &path ); 2077 2078 /** 2079 * Emitted when the active layer is changed. 2080 */ 2081 void activeLayerChanged( QgsMapLayer *layer ); 2082 2083 private: 2084 void createPreviewImage( const QString &path, const QIcon &overlayIcon = QIcon() ); 2085 void startProfile( const QString &name ); 2086 void endProfile(); 2087 void functionProfile( void ( QgisApp::*fnc )(), QgisApp *instance, const QString &name ); 2088 2089 void showProgress( int progress, int totalSteps ); 2090 2091 /** 2092 * This method will open a dialog so the user can select GDAL sublayers to load 2093 * \returns TRUE if any items were loaded 2094 */ 2095 bool askUserForZipItemLayers( const QString &path, const QList< QgsMapLayerType > &acceptableTypes ); 2096 2097 enum class SublayerHandling 2098 { 2099 AskUser, 2100 LoadAll, 2101 AbortLoading 2102 }; 2103 SublayerHandling shouldAskUserForSublayers( const QList< QgsProviderSublayerDetails > &layers, bool hasNonLayerItems = false ) const; 2104 2105 QList< QgsMapLayer * > addSublayers( const QList< QgsProviderSublayerDetails> &layers, const QString &baseName, const QString &groupName ); 2106 2107 void postProcessAddedLayer( QgsMapLayer *layer ); 2108 2109 //! Open a vector tile layer - this is the generic function which takes all parameters 2110 QgsVectorTileLayer *addVectorTileLayerPrivate( const QString &uri, const QString &baseName, bool guiWarning = true ); 2111 2112 //! Open a point cloud layer - this is the generic function which takes all parameters 2113 QgsPointCloudLayer *addPointCloudLayerPrivate( const QString &uri, 2114 const QString &baseName, 2115 const QString &providerKey, 2116 bool guiWarning = true ); 2117 2118 bool addVectorLayersPrivate( const QStringList &layers, const QString &enc, const QString &dataSourceType, bool guiWarning = true ); 2119 2120 template<typename T> T *addLayerPrivate( QgsMapLayerType type, const QString &uri, const QString &baseName, const QString &providerKey, bool guiWarnings = true ); 2121 2122 /** 2123 * Add the current project to the recently opened/saved projects list 2124 * pass settings by reference since creating more than one 2125 * instance simultaneously results in data loss. 2126 * 2127 * \param savePreviewImage Set to FALSE when the preview image should not be saved. E.g. project load. 2128 * \param iconOverlay optional icon to overlay when saving a preview image 2129 */ 2130 void saveRecentProjectPath( bool savePreviewImage = true, const QIcon &iconOverlay = QIcon() ); 2131 //! Save recent projects list to settings 2132 void saveRecentProjects(); 2133 //! Update project menu with the current list of recently accessed projects 2134 void updateRecentProjectPaths(); 2135 //! Read Well Known Binary stream from PostGIS 2136 //void readWKB(const char *, QStringList tables); 2137 //! shows the paste-transformations dialog 2138 // void pasteTransformations(); 2139 2140 /** 2141 * Check to see if the current project file is dirty and if so, prompt the user to save it. 2142 * \returns TRUE if saved or discarded, FALSE if canceled 2143 */ 2144 bool saveDirty(); 2145 2146 /** 2147 * Checks for unsaved changes in open layers and prompts the user to save 2148 * or discard these changes for each layer. 2149 * 2150 * Returns TRUE if there are no unsaved layer edits remaining, or the user 2151 * opted to discard them all. Returns FALSE if the user opted to cancel 2152 * on any layer. 2153 */ 2154 bool checkUnsavedLayerEdits(); 2155 2156 /** 2157 * Checks whether memory layers (with features) exist in the project, and if so 2158 * shows a warning to users that their contents will be lost on 2159 * project unload. 2160 * 2161 * Returns TRUE if there are no memory layers present, or if the 2162 * user opted to discard their contents. Returns FALSE if there 2163 * are memory layers present and the user clicked 'Cancel' on 2164 * the warning dialog. 2165 */ 2166 bool checkMemoryLayers(); 2167 2168 /** 2169 * Checks whether any registered application exit blockers should prevent 2170 * the application from exiting. 2171 */ 2172 bool checkExitBlockers(); 2173 2174 //! Checks for running tasks dependent on the open project 2175 bool checkTasksDependOnProject(); 2176 2177 /** 2178 * Helper function to union several geometries together (used in function mergeSelectedFeatures) 2179 * \returns empty geometry in case of error or if canceled 2180 */ 2181 QgsGeometry unionGeometries( const QgsVectorLayer *vl, QgsFeatureList &featureList, bool &canceled ); 2182 2183 //! Deletes all the layout designer windows 2184 void deleteLayoutDesigners(); 2185 2186 void setupLayoutManagerConnections(); 2187 2188 void setupAtlasMapLayerAction( QgsPrintLayout *layout, bool enableAction ); 2189 2190 void setLayoutAtlasFeature( QgsPrintLayout *layout, const QgsFeature &feat ); 2191 2192 QString saveAsVectorFileGeneral( QgsVectorLayer *vlayer = nullptr, bool symbologyOption = true, bool onlySelected = false, bool defaultToAddToMap = true ); 2193 2194 QString saveAsVectorFileGeneral( QgsVectorLayer *vlayer, bool symbologyOption, bool onlySelected, bool defaultToAddToMap, 2195 const std::function< void ( const QString &newFilename, 2196 bool addToCanvas, 2197 const QString &layerName, 2198 const QString &encoding, 2199 const QString &vectorFileName )> &onSuccess, const std::function< void ( int error, const QString &errorMessage ) > &onFailure, 2200 QgsVectorLayerSaveAsDialog::Options dialogOptions = QgsVectorLayerSaveAsDialog::AllOptions, 2201 const QString &dialogTitle = QString() ); 2202 2203 //! Sets project properties, including map untis 2204 void projectProperties( const QString ¤tPage = QString() ); 2205 2206 /** 2207 * Paste features from clipboard into a new memory layer. 2208 * If no features are in clipboard an empty layer is returned. 2209 * Returns a new memory layer or NULLPTR if the operation failed. 2210 */ 2211 std::unique_ptr< QgsVectorLayer > pasteToNewMemoryVector(); 2212 2213 //! Returns all annotation items in the canvas 2214 QList<QgsMapCanvasAnnotationItem *> annotationItems(); 2215 2216 //! Removes annotation items in the canvas 2217 void removeAnnotationItems(); 2218 2219 //! Configure layer tree view according to the user options from QgsSettings 2220 void setupLayerTreeViewFromSettings(); 2221 2222 void switchToMapToolViaHandler(); 2223 2224 void readSettings(); 2225 void writeSettings(); 2226 void createActions(); 2227 void createActionGroups(); 2228 void createMenus(); 2229 void createProfileMenu(); 2230 void createToolBars(); 2231 void createStatusBar(); 2232 void setupConnections(); 2233 void initLayerTreeView(); 2234 void createOverview(); 2235 void setupCanvasTools(); 2236 void createMapTips(); 2237 void createDecorations(); 2238 void init3D(); 2239 void initNativeProcessing(); 2240 void initLayouts(); 2241 2242 //! Creates a new 3D map dock without initializing its position or contents 2243 Qgs3DMapCanvasDockWidget *createNew3DMapCanvasDock( const QString &name ); 2244 2245 //! Closes any existing 3D map docks 2246 void closeAdditional3DMapCanvases(); 2247 2248 /** 2249 * Refresh the user profile menu. 2250 */ 2251 void refreshProfileMenu(); 2252 2253 //! Do histogram stretch for singleband gray / multiband color rasters 2254 void histogramStretch( bool visibleAreaOnly = false, QgsRasterMinMaxOrigin::Limits limits = QgsRasterMinMaxOrigin::MinMax ); 2255 2256 //! Apply raster brightness/contrast 2257 void adjustBrightnessContrast( int delta, bool updateBrightness = true ); 2258 2259 /** 2260 * Apply raster gamma 2261 * \since QGIS 3.16 2262 */ 2263 void adjustGamma( double delta ); 2264 2265 //! Copy a vector style from a layer to another one, if they have the same geometry type 2266 void duplicateVectorStyle( QgsVectorLayer *srcLayer, QgsVectorLayer *destLayer ); 2267 2268 //! Loads the list of recent projects from settings 2269 void readRecentProjects(); 2270 2271 /** 2272 * Applies project map canvas settings to the specified canvas 2273 */ 2274 void applyProjectSettingsToCanvas( QgsMapCanvas *canvas ); 2275 2276 /** 2277 * Applies global qgis settings to the specified canvas 2278 */ 2279 void applyDefaultSettingsToCanvas( QgsMapCanvas *canvas ); 2280 2281 /** 2282 * Configures positioning of a newly created dock widget. 2283 * The \a isFloating and \a dockGeometry arguments can be used to specify an initial floating state 2284 * and widget geometry rect for the dock. 2285 */ 2286 void setupDockWidget( QDockWidget *dockWidget, bool isFloating = false, QRect dockGeometry = QRect(), 2287 Qt::DockWidgetArea area = Qt::RightDockWidgetArea ); 2288 2289 /** 2290 * Reads dock widget's position settings from a DOM element and calls setupDockWidget() 2291 * \sa writeDockWidgetSettings() 2292 */ 2293 void readDockWidgetSettings( QDockWidget *dockWidget, const QDomElement &elem ); 2294 2295 /** 2296 * Writes dock widget's position settings to a DOM element 2297 * \sa readDockWidgetSettings() 2298 */ 2299 void writeDockWidgetSettings( QDockWidget *dockWidget, QDomElement &elem ); 2300 2301 QgsCoordinateReferenceSystem defaultCrsForNewLayers() const; 2302 2303 //! Attempts to choose a reasonable default icon size based on the window's screen DPI 2304 int chooseReasonableDefaultIconSize() const; 2305 2306 //! Populates project "load from" / "save to" menu based on project storages (when the menu is about to be shown) 2307 void populateProjectStorageMenu( QMenu *menu, bool saving ); 2308 2309 //! Tries to save the current project to project storage at given URI 2310 void saveProjectToProjectStorage( const QString &uri ); 2311 2312 //! Create the option dialog 2313 QgsOptions *createOptionsDialog( QWidget *parent = nullptr ); 2314 2315 //! Returns the message bar of the datasource manager dialog if it is visible, the canvas's message bar otherwise. 2316 QgsMessageBar *visibleMessageBar(); 2317 2318 /** 2319 * Searches for layer dependencies by querying the form widgets and the 2320 * \a vectorLayer itself for broken relations. Style \a categories can be 2321 * used to limit the search to one or more of the currently implemented search 2322 * categories ("Forms" for the form widgets and "Relations" for layer weak relations). 2323 * \return a list of weak references to broken layer dependencies 2324 */ 2325 const QList< QgsVectorLayerRef > findBrokenLayerDependencies( QgsVectorLayer *vectorLayer, 2326 QgsMapLayer::StyleCategories categories = QgsMapLayer::StyleCategory::AllStyleCategories ) const; 2327 2328 /** 2329 * Scans the \a vectorLayer for broken dependencies and automatically 2330 * try to load the missing layers, users are notified about the operation 2331 * result. Style \a categories can be 2332 * used to exclude one of the currently implemented search categories 2333 * ("Forms" for the form widgets and "Relations" for layer weak relations). 2334 */ 2335 void resolveVectorLayerDependencies( QgsVectorLayer *vectorLayer, 2336 QgsMapLayer::StyleCategories categories = QgsMapLayer::AllStyleCategories ); 2337 2338 /** 2339 * Scans the \a vectorLayer for weak relations and automatically 2340 * try to resolve and create the broken relations. 2341 */ 2342 void resolveVectorLayerWeakRelations( QgsVectorLayer *vectorLayer ); 2343 2344 /** 2345 * Pastes the \a features to the \a pasteVectorLayer and gives feedback to the user 2346 * according to \a invalidGeometryCount and \a nTotalFeatures 2347 */ 2348 void pasteFeatures( QgsVectorLayer *pasteVectorLayer, int invalidGeometriesCount, int nTotalFeatures, QgsFeatureList &features ); 2349 2350 /** 2351 * starts/stops for a vector layer \a vlayer 2352 */ 2353 bool toggleEditingVectorLayer( QgsVectorLayer *vlayer, bool allowCancel = true ); 2354 2355 /** 2356 * Starts/stops for a mesh layer \a mlayer 2357 */ 2358 bool toggleEditingMeshLayer( QgsMeshLayer *vlayer, bool allowCancel = true ); 2359 2360 /** 2361 * Saves edits of a vector layer 2362 * \param leaveEditable leave the layer in editing mode when done 2363 * \param triggerRepaint send layer signal to repaint canvas when done 2364 */ 2365 void saveVectorLayerEdits( QgsMapLayer *layer, bool leaveEditable = true, bool triggerRepaint = true ); 2366 2367 /** 2368 * Saves edits of a mesh layer 2369 * \param leaveEditable leave the layer in editing mode when done 2370 * \param triggerRepaint send layer signal to repaint canvas when done 2371 */ 2372 void saveMeshLayerEdits( QgsMapLayer *layer, bool leaveEditable = true, bool triggerRepaint = true ); 2373 2374 /** 2375 * Cancels edits of a vector layer 2376 * \param leaveEditable leave the layer in editing mode when done 2377 * \param triggerRepaint send layer signal to repaint canvas when done 2378 */ 2379 void cancelVectorLayerEdits( QgsMapLayer *layer, bool leaveEditable = true, bool triggerRepaint = true ); 2380 2381 /** 2382 * Cancels edits of a mesh layer 2383 * \param leaveEditable leave the layer in editing mode when done 2384 * \param triggerRepaint send layer signal to repaint canvas when done 2385 */ 2386 void cancelMeshLayerEdits( QgsMapLayer *layer, bool leaveEditable = true, bool triggerRepaint = true ); 2387 2388 /** 2389 * Enables/Disables mesh frame editing tools 2390 */ 2391 void enableMeshEditingTools( bool enable ); 2392 2393 /** 2394 * Returns a list of all capture map tools. 2395 */ 2396 QList< QgsMapToolCapture * > captureTools(); 2397 2398 QgisAppStyleSheet *mStyleSheetBuilder = nullptr; 2399 2400 // actions for menus and toolbars ----------------- 2401 2402 #ifdef Q_OS_MAC 2403 QAction *mActionWindowMinimize = nullptr; 2404 QAction *mActionWindowZoom = nullptr; 2405 QAction *mActionWindowSeparator1 = nullptr; 2406 QAction *mActionWindowAllToFront = nullptr; 2407 QAction *mActionWindowSeparator2 = nullptr; 2408 QActionGroup *mWindowActions = nullptr; 2409 #endif 2410 2411 QAction *mActionPluginSeparator1 = nullptr; 2412 QAction *mActionPluginSeparator2 = nullptr; 2413 QAction *mActionRasterSeparator = nullptr; 2414 2415 // action groups ---------------------------------- 2416 QActionGroup *mMapToolGroup = nullptr; 2417 QActionGroup *mPreviewGroup = nullptr; 2418 2419 // menus ------------------------------------------ 2420 2421 #ifdef Q_OS_MAC 2422 QMenu *mWindowMenu = nullptr; 2423 #endif 2424 QMenu *mPanelMenu = nullptr; 2425 QMenu *mToolbarMenu = nullptr; 2426 2427 // docks ------------------------------------------ 2428 QgsDockWidget *mLayerTreeDock = nullptr; 2429 QgsDockWidget *mLayerOrderDock = nullptr; 2430 QgsDockWidget *mOverviewDock = nullptr; 2431 QgsDockWidget *mpGpsDock = nullptr; 2432 QgsDockWidget *mLogDock = nullptr; 2433 2434 #ifdef Q_OS_MAC 2435 //! Window menu action to select this window 2436 QAction *mWindowAction = nullptr; 2437 #endif 2438 2439 std::unique_ptr< QgsAppMapTools > mMapTools; 2440 2441 QgsMapTool *mNonEditMapTool = nullptr; 2442 2443 QgsTaskManagerStatusBarWidget *mTaskManagerWidget = nullptr; 2444 2445 QgsStatusBarScaleWidget *mScaleWidget = nullptr; 2446 2447 //! zoom widget 2448 QgsStatusBarMagnifierWidget *mMagnifierWidget = nullptr; 2449 2450 //! Widget that will live in the statusbar to display and edit coords 2451 QgsStatusBarCoordinatesWidget *mCoordsEdit = nullptr; 2452 2453 //! Widget that will live on the statusbar to display "Rotation" 2454 QLabel *mRotationLabel = nullptr; 2455 //! Widget that will live in the statusbar to display and edit rotation 2456 QgsDoubleSpinBox *mRotationEdit = nullptr; 2457 //! The validator for the mCoordsEdit 2458 QValidator *mRotationEditValidator = nullptr; 2459 //! Widget that will live in the statusbar to show progress of operations 2460 QProgressBar *mProgressBar = nullptr; 2461 //! Widget used to suppress rendering 2462 QCheckBox *mRenderSuppressionCBox = nullptr; 2463 //! Widget in status bar used to show current project CRS 2464 QLabel *mOnTheFlyProjectionStatusLabel = nullptr; 2465 //! Widget in status bar used to show status of on the fly projection 2466 QToolButton *mOnTheFlyProjectionStatusButton = nullptr; 2467 QToolButton *mMessageButton = nullptr; 2468 //! Menu that contains the list of actions of the selected vector layer 2469 QMenu *mFeatureActionMenu = nullptr; 2470 //! Popup menu 2471 QMenu *mPopupMenu = nullptr; 2472 //! Top level database menu 2473 QMenu *mDatabaseMenu = nullptr; 2474 //! Top level web menu 2475 QMenu *mWebMenu = nullptr; 2476 2477 QMenu *mConfigMenu = nullptr; 2478 2479 //! Popup menu for the map overview tools 2480 QMenu *mToolPopupOverviews = nullptr; 2481 //! Popup menu for the display tools 2482 QMenu *mToolPopupDisplay = nullptr; 2483 //! Map canvas 2484 QgsMapCanvas *mMapCanvas = nullptr; 2485 //! Overview map canvas 2486 QgsMapOverviewCanvas *mOverviewCanvas = nullptr; 2487 //! Table of contents (legend) for the map 2488 QgsLayerTreeView *mLayerTreeView = nullptr; 2489 //! Helper class that connects layer tree with map canvas 2490 QgsLayerTreeMapCanvasBridge *mLayerTreeCanvasBridge = nullptr; 2491 //! Table of contents (legend) to order layers of the map 2492 QgsCustomLayerOrderWidget *mMapLayerOrder = nullptr; 2493 //! Cursor for the overview map 2494 QCursor *mOverviewMapCursor = nullptr; 2495 //! Current map window extent in real-world coordinates 2496 QRect *mMapWindow = nullptr; 2497 QString mStartupPath; 2498 //! full path name of the current map file (if it has been saved or loaded) 2499 QString mFullPathName; 2500 2501 //! interface to QgisApp for plugins 2502 QgisAppInterface *mQgisInterface = nullptr; 2503 2504 QSplashScreen *mSplash = nullptr; 2505 //! list of recently opened/saved project files 2506 QList<QgsRecentProjectItemsModel::RecentProjectData> mRecentProjects; 2507 2508 //! Currently open layout designer dialogs 2509 QSet<QgsLayoutDesignerDialog *> mLayoutDesignerDialogs; 2510 2511 //! QGIS-internal vector feature clipboard 2512 QgsClipboard *mInternalClipboard = nullptr; 2513 2514 /** 2515 * String containing supporting vector file formats 2516 * Suitable for a QFileDialog file filter. Build in ctor. 2517 */ 2518 QString mVectorFileFilter; 2519 2520 /** 2521 * String containing supporting raster file formats 2522 * Suitable for a QFileDialog file filter. Build in ctor. 2523 */ 2524 QString mRasterFileFilter; 2525 2526 //! Timer for map tips 2527 QTimer *mpMapTipsTimer = nullptr; 2528 2529 //! Point of last mouse position in map coordinates (used with MapTips) 2530 QgsPointXY mLastMapPosition; 2531 2532 //! Maptip object 2533 QgsMapTip *mpMaptip = nullptr; 2534 2535 //! Flag to indicate if maptips are on or off 2536 bool mMapTipsVisible = false; 2537 2538 //! Flag to indicate whether we are in fullscreen mode or not 2539 bool mFullScreenMode = false; 2540 2541 //! Flag to indicate that the previous screen mode was 'maximised' 2542 bool mPrevScreenModeMaximized = false; 2543 2544 //! Flag to indicate an edits save/rollback for active layer is in progress 2545 bool mSaveRollbackInProgress = false; 2546 2547 QgsPythonUtils *mPythonUtils = nullptr; 2548 2549 static QgisApp *sInstance; 2550 2551 QgsUndoWidget *mUndoWidget = nullptr; 2552 QgsDockWidget *mUndoDock = nullptr; 2553 2554 QgsBrowserDockWidget *mBrowserWidget = nullptr; 2555 QgsBrowserDockWidget *mBrowserWidget2 = nullptr; 2556 2557 QgsTemporalControllerDockWidget *mTemporalControllerWidget = nullptr; 2558 2559 QgsAdvancedDigitizingDockWidget *mAdvancedDigitizingDockWidget = nullptr; 2560 QgsStatisticalSummaryDockWidget *mStatisticalSummaryDockWidget = nullptr; 2561 QgsBookmarks *mBookMarksDockWidget = nullptr; 2562 2563 //! Data Source Manager 2564 QgsDataSourceManagerDialog *mDataSourceManagerDialog = nullptr; 2565 2566 //! snapping widget 2567 QgsSnappingWidget *mSnappingWidget = nullptr; 2568 QWidget *mSnappingDialogContainer = nullptr; 2569 QgsSnappingWidget *mSnappingDialog = nullptr; 2570 2571 QgsPluginManager *mPluginManager = nullptr; 2572 QgsUserProfileManager *mUserProfileManager = nullptr; 2573 QgsDockWidget *mMapStylingDock = nullptr; 2574 QgsLayerStylingWidget *mMapStyleWidget = nullptr; 2575 QgsDockWidget *mDevToolsDock = nullptr; 2576 QgsDevToolsPanelWidget *mDevToolsWidget = nullptr; 2577 2578 QToolButton *mDigitizeModeToolButton = nullptr; 2579 2580 //! Persistent tile scale slider 2581 QgsTileScaleWidget *mpTileScaleWidget = nullptr; 2582 2583 QList<QgsDecorationItem *> mDecorationItems; 2584 2585 //! Persistent GPS toolbox 2586 QgsGpsInformationWidget *mpGpsWidget = nullptr; 2587 2588 QgsMessageBarItem *mLastMapToolMessage = nullptr; 2589 2590 QgsMessageLogViewer *mLogViewer = nullptr; 2591 2592 //! project changed 2593 void projectChanged( const QDomDocument & ); 2594 2595 bool cmpByText( QAction *a, QAction *b ); 2596 2597 //! the user has trusted the project macros 2598 bool mPythonMacrosEnabled = false; 2599 2600 //! a bar to display warnings in a non-blocker manner 2601 QgsMessageBar *mInfoBar = nullptr; 2602 QWidget *mMacrosWarn = nullptr; 2603 2604 //! A tool bar for user input 2605 QgsUserInputWidget *mUserInputDockWidget = nullptr; 2606 2607 QgsVectorLayerTools *mVectorLayerTools = nullptr; 2608 2609 //! A class that facilitates tracing of features 2610 QgsMapCanvasTracer *mTracer = nullptr; 2611 2612 QToolButton *mFilterLegendToolButton = nullptr; 2613 QAction *mFilterLegendByMapContentAction = nullptr; 2614 QAction *mFilterLegendToggleShowPrivateLayersAction = nullptr; 2615 QAction *mActionStyleDock = nullptr; 2616 2617 QgsLegendFilterButton *mLegendExpressionFilterButton = nullptr; 2618 2619 QgsSnappingUtils *mSnappingUtils = nullptr; 2620 2621 #ifdef HAVE_GEOREFERENCER 2622 QgsGeoreferencerMainWindow *mGeoreferencer = nullptr; 2623 #endif 2624 2625 QList<const QgsMapLayerConfigWidgetFactory *> mMapLayerPanelFactories; 2626 QList<QPointer<QgsOptionsWidgetFactory>> mOptionsWidgetFactories; 2627 QList<QPointer<QgsOptionsWidgetFactory>> mProjectPropertiesWidgetFactories; 2628 2629 QList<QgsDevToolWidgetFactory * > mDevToolFactories; 2630 2631 QList<QgsApplicationExitBlockerInterface * > mApplicationExitBlockers; 2632 QList<QgsAbstractMapToolHandler * > mMapToolHandlers; 2633 2634 QVector<QPointer<QgsCustomDropHandler>> mCustomDropHandlers; 2635 QVector<QPointer<QgsCustomProjectOpenHandler>> mCustomProjectOpenHandlers; 2636 QVector<QPointer<QgsLayoutCustomDropHandler>> mCustomLayoutDropHandlers; 2637 2638 QgsLayoutCustomDropHandler *mLayoutQptDropHandler = nullptr; 2639 QgsLayoutCustomDropHandler *mLayoutImageDropHandler = nullptr; 2640 2641 QDateTime mProjectLastModified; 2642 2643 QgsWelcomePage *mWelcomePage = nullptr; 2644 2645 QStackedWidget *mCentralContainer = nullptr; 2646 2647 QHash< QgsPrintLayout *, QgsMapLayerAction * > mAtlasFeatureActions; 2648 2649 2650 std::unique_ptr<QgsMapLayerAction> mDuplicateFeatureAction; 2651 std::unique_ptr<QgsMapLayerAction> mDuplicateFeatureDigitizeAction; 2652 2653 int mProjOpen = 0; 2654 2655 bool gestureEvent( QGestureEvent *event ); 2656 void tapAndHoldTriggered( QTapAndHoldGesture *gesture ); 2657 2658 QgsLocatorWidget *mLocatorWidget = nullptr; 2659 std::unique_ptr<QgsNominatimGeocoder> mNominatimGeocoder; 2660 2661 QgsStatusBar *mStatusBar = nullptr; 2662 2663 QElapsedTimer mLastRenderTime; 2664 double mLastRenderTimeSeconds = 0; 2665 QTimer mRenderProgressBarTimer; 2666 QMetaObject::Connection mRenderProgressBarTimerConnection; 2667 2668 QgsBrowserGuiModel *mBrowserModel = nullptr; 2669 2670 void setupDuplicateFeaturesAction(); 2671 2672 QgsFeature duplicateFeatures( QgsMapLayer *mlayer, const QgsFeature &feature ); 2673 QgsFeature duplicateFeatureDigitized( QgsMapLayer *mlayer, const QgsFeature &feature ); 2674 2675 QgsProxyProgressTask *mProjectLoadingProxyTask = nullptr; 2676 2677 //! True if we are blocking the activeLayerChanged signal from being emitted 2678 bool mBlockActiveLayerChanged = false; 2679 2680 int mBlockBrowser1Refresh = 0; 2681 int mBlockBrowser2Refresh = 0; 2682 int mDataSourceManagerRefresh = 0; 2683 2684 std::unique_ptr<QgsGeometryValidationService> mGeometryValidationService; 2685 QgsGeometryValidationModel *mGeometryValidationModel = nullptr; 2686 QgsGeometryValidationDock *mGeometryValidationDock = nullptr; 2687 QgsHandleBadLayersHandler *mAppBadLayersHandler = nullptr; 2688 2689 std::unique_ptr< QgsBearingNumericFormat > mBearingNumericFormat; 2690 2691 QgsNetworkLogger *mNetworkLogger = nullptr; 2692 QgsScopedDevToolWidgetFactory mNetworkLoggerWidgetFactory; 2693 QgsScopedDevToolWidgetFactory mStartupProfilerWidgetFactory; 2694 2695 QgsScopedOptionsWidgetFactory mCodeEditorWidgetFactory; 2696 QgsScopedOptionsWidgetFactory mBabelGpsDevicesWidgetFactory; 2697 QgsScopedOptionsWidgetFactory m3DOptionsWidgetFactory; 2698 2699 QMap< QString, QToolButton * > mAnnotationItemGroupToolButtons; 2700 QAction *mAnnotationsItemInsertBefore = nullptr; // Used to insert annotation items at the appropriate location in the annotations toolbar 2701 2702 class QgsCanvasRefreshBlocker 2703 { 2704 public: 2705 QgsCanvasRefreshBlocker()2706 QgsCanvasRefreshBlocker() 2707 { 2708 if ( QgisApp::instance()->mFreezeCount++ == 0 ) 2709 { 2710 // going from unfrozen to frozen, so freeze canvases 2711 QgisApp::instance()->freezeCanvases( true ); 2712 } 2713 } 2714 QgsCanvasRefreshBlocker( const QgsCanvasRefreshBlocker &other ) = delete; 2715 QgsCanvasRefreshBlocker &operator=( const QgsCanvasRefreshBlocker &other ) = delete; 2716 release()2717 void release() 2718 { 2719 if ( mReleased ) 2720 return; 2721 2722 mReleased = true; 2723 if ( --QgisApp::instance()->mFreezeCount == 0 ) 2724 { 2725 // going from frozen to unfrozen, so unfreeze canvases 2726 QgisApp::instance()->freezeCanvases( false ); 2727 QgisApp::instance()->refreshMapCanvas(); 2728 } 2729 } 2730 ~QgsCanvasRefreshBlocker()2731 ~QgsCanvasRefreshBlocker() 2732 { 2733 if ( !mReleased ) 2734 release(); 2735 } 2736 2737 private: 2738 2739 bool mReleased = false; 2740 }; 2741 int mFreezeCount = 0; 2742 friend class QgsCanvasRefreshBlocker; 2743 2744 friend class TestQgisAppPython; 2745 friend class TestQgisApp; 2746 friend class QgisAppInterface; 2747 friend class QgsAppScreenShots; 2748 }; 2749 2750 #ifdef ANDROID 2751 #define QGIS_ICON_SIZE 32 2752 #else 2753 #define QGIS_ICON_SIZE 24 2754 #endif 2755 2756 // clazy:excludeall=qstring-allocations 2757 2758 #endif 2759