change state of the map canvas to non-const so it can be used in provider dialogs spatial extent input widgets

This commit is contained in:
Samweli 2021-10-25 10:47:34 +03:00 committed by Nyall Dawson
parent 462e276e2c
commit 4104a62f85
3 changed files with 14 additions and 7 deletions

View File

@ -28,7 +28,7 @@ and add layers.
%End
public:
void setMapCanvas( const QgsMapCanvas *mapCanvas );
void setMapCanvas( QgsMapCanvas *mapCanvas );
%Docstring
Store a pointer to the map canvas to retrieve extent and CRS
Used to select an appropriate CRS and possibly to retrieve data only in the current extent
@ -169,6 +169,10 @@ Emitted when a ``message`` with ``title`` and ``level`` must be shown to the use
.. versionadded:: 3.14
%End
void mapCanvasChanged();
%Docstring
Emitted when map canvas is updated
%End
protected:
@ -182,7 +186,7 @@ Constructor
Returns the widget mode
%End
const QgsMapCanvas *mapCanvas() const;
QgsMapCanvas *mapCanvas();
%Docstring
Returns the map canvas (can be ``None``)
%End

View File

@ -30,7 +30,7 @@ QgsProviderRegistry::WidgetMode QgsAbstractDataSourceWidget::widgetMode() const
return mWidgetMode;
}
const QgsMapCanvas *QgsAbstractDataSourceWidget::mapCanvas() const
QgsMapCanvas *QgsAbstractDataSourceWidget::mapCanvas()
{
return mMapCanvas;
}
@ -58,9 +58,10 @@ void QgsAbstractDataSourceWidget::setupButtons( QDialogButtonBox *buttonBox )
connect( closeButton, &QPushButton::clicked, this, &QgsAbstractDataSourceWidget::reject );
}
void QgsAbstractDataSourceWidget::setMapCanvas( const QgsMapCanvas *mapCanvas )
void QgsAbstractDataSourceWidget::setMapCanvas( QgsMapCanvas *mapCanvas )
{
mMapCanvas = mapCanvas;
emit mapCanvasChanged();
}
void QgsAbstractDataSourceWidget::setBrowserModel( QgsBrowserModel *model )

View File

@ -50,7 +50,7 @@ class GUI_EXPORT QgsAbstractDataSourceWidget : public QDialog
* Store a pointer to the map canvas to retrieve extent and CRS
* Used to select an appropriate CRS and possibly to retrieve data only in the current extent
*/
void setMapCanvas( const QgsMapCanvas *mapCanvas );
void setMapCanvas( QgsMapCanvas *mapCanvas );
/**
* Sets a browser \a model to use with the widget.
@ -169,6 +169,8 @@ class GUI_EXPORT QgsAbstractDataSourceWidget : public QDialog
*/
void pushMessage( const QString &title, const QString &message, const Qgis::MessageLevel level = Qgis::MessageLevel::Info );
//! Emitted when map canvas is updated
void mapCanvasChanged();
protected:
@ -179,7 +181,7 @@ class GUI_EXPORT QgsAbstractDataSourceWidget : public QDialog
QgsProviderRegistry::WidgetMode widgetMode() const;
//! Returns the map canvas (can be NULLPTR)
const QgsMapCanvas *mapCanvas() const;
QgsMapCanvas *mapCanvas();
/**
* Returns the associated browser model (may be NULLPTR).
@ -197,7 +199,7 @@ class GUI_EXPORT QgsAbstractDataSourceWidget : public QDialog
private:
QPushButton *mAddButton = nullptr;
QgsProviderRegistry::WidgetMode mWidgetMode;
QgsMapCanvas const *mMapCanvas = nullptr;
QgsMapCanvas *mMapCanvas = nullptr;
QgsBrowserModel *mBrowserModel = nullptr;
};