made canvas methods in source provider widget virtual

This commit is contained in:
Samweli 2022-05-02 13:38:54 +03:00 committed by Nyall Dawson
parent 0118403ed7
commit 998c58dff1
9 changed files with 19 additions and 47 deletions

View File

@ -42,8 +42,6 @@ Sets a browser ``model`` to use with the widget.
Returns the dialog map canvas Returns the dialog map canvas
.. seealso:: :py:func:`setMapCanvas` .. seealso:: :py:func:`setMapCanvas`
.. versionadded:: 3.26
%End %End
virtual void setMapCanvas( QgsMapCanvas *mapCanvas ); virtual void setMapCanvas( QgsMapCanvas *mapCanvas );
@ -51,8 +49,6 @@ Returns the dialog map canvas
Sets the dialog map canvas Sets the dialog map canvas
.. seealso:: :py:func:`mapCanvas` .. seealso:: :py:func:`mapCanvas`
.. versionadded:: 3.26
%End %End
public slots: public slots:

View File

@ -41,14 +41,14 @@ Returns the source URI as currently defined by the widget.
.. seealso:: :py:func:`setSourceUri` .. seealso:: :py:func:`setSourceUri`
%End %End
void setMapCanvas( QgsMapCanvas *canvas ); virtual void setMapCanvas( QgsMapCanvas *mapCanvas );
%Docstring %Docstring
Sets a map ``canvas`` associated with the widget. Sets a map ``canvas`` associated with the widget.
.. versionadded:: 3.26 .. versionadded:: 3.26
%End %End
QgsMapCanvas *mapCanvas(); virtual QgsMapCanvas *mapCanvas();
%Docstring %Docstring
Returns the map canvas associated with the widget. Returns the map canvas associated with the widget.

View File

@ -58,14 +58,12 @@ class GUI_EXPORT QgsAbstractDataSourceWidget : public QDialog
* Returns the dialog map canvas * Returns the dialog map canvas
* \see setMapCanvas() * \see setMapCanvas()
* *
* \since QGIS 3.26
*/ */
virtual QgsMapCanvas *mapCanvas() {return mMapCanvas; } virtual QgsMapCanvas *mapCanvas() {return mMapCanvas; }
/** /**
* Sets the dialog map canvas * Sets the dialog map canvas
* \see mapCanvas() * \see mapCanvas()
* \since QGIS 3.26
*/ */
virtual void setMapCanvas( QgsMapCanvas *mapCanvas ) { mMapCanvas = mapCanvas; } virtual void setMapCanvas( QgsMapCanvas *mapCanvas ) { mMapCanvas = mapCanvas; }

View File

@ -31,14 +31,26 @@ QgsOWSSourceWidget::QgsOWSSourceWidget( const QString &providerKey, QWidget *par
QgsCoordinateReferenceSystem destinationCrs; QgsCoordinateReferenceSystem destinationCrs;
QgsCoordinateReferenceSystem crs = QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:4326" ) ); QgsCoordinateReferenceSystem crs = QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:4326" ) );
mSpatialExtentBox->setOutputCrs( crs ); mSpatialExtentBox->setOutputCrs( crs );
}
void QgsOWSSourceWidget::setMapCanvas( QgsMapCanvas *canvas )
{
QgsProviderSourceWidget::setMapCanvas( canvas );
QgsCoordinateReferenceSystem destinationCrs;
QgsCoordinateReferenceSystem crs = QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:4326" ) );
if ( mapCanvas() && mapCanvas()->mapSettings().destinationCrs().isValid() ) if ( mapCanvas() && mapCanvas()->mapSettings().destinationCrs().isValid() )
destinationCrs = mapCanvas()->mapSettings().destinationCrs(); destinationCrs = mapCanvas()->mapSettings().destinationCrs();
else else
destinationCrs = crs; destinationCrs = crs;
mSpatialExtentBox->setOutputCrs( destinationCrs );
mSpatialExtentBox->setMapCanvas( mapCanvas() ); mSpatialExtentBox->setMapCanvas( mapCanvas() );
} }
void QgsOWSSourceWidget::setExtent( const QgsRectangle &extent ) void QgsOWSSourceWidget::setExtent( const QgsRectangle &extent )
{ {
QgsCoordinateReferenceSystem destinationCrs; QgsCoordinateReferenceSystem destinationCrs;

View File

@ -60,6 +60,9 @@ class GUI_EXPORT QgsOWSSourceWidget : public QgsProviderSourceWidget, private Ui
QgsRectangle extent() const; QgsRectangle extent() const;
void setMapCanvas( QgsMapCanvas *canvas ) override;
private: private:
QVariantMap mSourceParts; QVariantMap mSourceParts;

View File

@ -23,13 +23,3 @@ QgsProviderSourceWidget::QgsProviderSourceWidget( QWidget *parent )
{ {
} }
void QgsProviderSourceWidget::setMapCanvas( QgsMapCanvas *canvas )
{
mMapCanvas = canvas;
}
QgsMapCanvas *QgsProviderSourceWidget::mapCanvas()
{
return mMapCanvas;
}

View File

@ -59,14 +59,14 @@ class GUI_EXPORT QgsProviderSourceWidget : public QWidget
* *
* \since QGIS 3.26 * \since QGIS 3.26
*/ */
void setMapCanvas( QgsMapCanvas *canvas ); virtual void setMapCanvas( QgsMapCanvas *mapCanvas ) { mMapCanvas = mapCanvas; }
/** /**
* Returns the map canvas associated with the widget. * Returns the map canvas associated with the widget.
* *
* \since QGIS 3.26 * \since QGIS 3.26
*/ */
QgsMapCanvas *mapCanvas(); virtual QgsMapCanvas *mapCanvas() {return mMapCanvas; }
signals: signals:

View File

@ -43,16 +43,6 @@ QgsWCSSourceSelect::QgsWCSSourceSelect( QWidget *parent, Qt::WindowFlags fl, Qgs
connect( buttonBox, &QDialogButtonBox::helpRequested, this, &QgsWCSSourceSelect::showHelp ); connect( buttonBox, &QDialogButtonBox::helpRequested, this, &QgsWCSSourceSelect::showHelp );
} }
void QgsWCSSourceSelect::setMapCanvas( QgsMapCanvas *mapCanvas )
{
mMapCanvas = mapCanvas;
}
QgsMapCanvas *QgsWCSSourceSelect::mapCanvas()
{
return mMapCanvas;
}
void QgsWCSSourceSelect::populateLayerList() void QgsWCSSourceSelect::populateLayerList()
{ {

View File

@ -56,25 +56,8 @@ class QgsWCSSourceSelect : public QgsOWSSourceSelect
//! Constructor //! Constructor
QgsWCSSourceSelect( QWidget *parent = nullptr, Qt::WindowFlags fl = QgsGuiUtils::ModalDialogFlags, QgsProviderRegistry::WidgetMode widgetMode = QgsProviderRegistry::WidgetMode::None ); QgsWCSSourceSelect( QWidget *parent = nullptr, Qt::WindowFlags fl = QgsGuiUtils::ModalDialogFlags, QgsProviderRegistry::WidgetMode widgetMode = QgsProviderRegistry::WidgetMode::None );
/**
* Sets the dialog map canvas
* \see mapCanvas()
*
* \since QGIS 3.24
*/
void setMapCanvas( QgsMapCanvas *mapCanvas ) override;
/**
* Returns the dialog map canvas
* \see setMapCanvas()
*
* \since QGIS 3.24
*/
QgsMapCanvas *mapCanvas() override;
private: private:
QgsWcsCapabilities mCapabilities; QgsWcsCapabilities mCapabilities;
QgsMapCanvas *mMapCanvas = nullptr;
QString selectedIdentifier(); QString selectedIdentifier();