enabled passing a map canvas to a provider source widget

This commit is contained in:
Samweli 2021-11-23 01:43:55 +03:00 committed by Nyall Dawson
parent b44a62863e
commit 4a1f27428d
3 changed files with 40 additions and 0 deletions

View File

@ -8,6 +8,7 @@
class QgsProviderSourceWidget : QWidget class QgsProviderSourceWidget : QWidget
{ {
%Docstring(signature="appended") %Docstring(signature="appended")
@ -38,6 +39,18 @@ Sets the source ``uri`` to show in the widget.
Returns the source URI as currently defined by the widget. Returns the source URI as currently defined by the widget.
.. seealso:: :py:func:`setSourceUri` .. seealso:: :py:func:`setSourceUri`
%End
void setMapCanvas( QgsMapCanvas *canvas );
%Docstring
Sets a map ``canvas`` associated with the widget.
.. versionadded:: 3.24
%End
QgsMapCanvas *mapCanvas();
%Docstring
Returns a map canvas associated with the widget.
%End %End
signals: signals:

View File

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

View File

@ -21,6 +21,8 @@
#include "qgis_gui.h" #include "qgis_gui.h"
#include "qgis_sip.h" #include "qgis_sip.h"
class QgsMapCanvas;
/** /**
* Base class for widgets which allow customization of a provider's source URI. * Base class for widgets which allow customization of a provider's source URI.
* *
@ -52,6 +54,18 @@ class GUI_EXPORT QgsProviderSourceWidget : public QWidget
*/ */
virtual QString sourceUri() const = 0; virtual QString sourceUri() const = 0;
/**
* Sets a map \a canvas associated with the widget.
*
* \since QGIS 3.24
*/
void setMapCanvas( QgsMapCanvas *canvas );
/**
* Returns a map canvas associated with the widget.
*/
QgsMapCanvas *mapCanvas();
signals: signals:
/** /**
@ -62,5 +76,8 @@ class GUI_EXPORT QgsProviderSourceWidget : public QWidget
*/ */
void validChanged( bool isValid ); void validChanged( bool isValid );
private:
QgsMapCanvas *mMapCanvas = nullptr;
}; };
#endif //QGSPROVIDERSOURCEWIDGET_H #endif //QGSPROVIDERSOURCEWIDGET_H