Source select widget: configure from layer URI

This commit is contained in:
Alessandro Pasotti 2023-09-30 09:59:51 +02:00 committed by Nyall Dawson
parent 153a34e2dc
commit fa9fc3ee34
5 changed files with 33 additions and 0 deletions

View File

@ -55,6 +55,7 @@ of feature and attribute information from a spatial datasource.
CreateLabeling,
ReloadData,
FeatureSymbology,
ConfigureSourceSelectFromUri,
};
typedef QFlags<QgsVectorDataProvider::Capability> Capabilities;

View File

@ -78,6 +78,21 @@ this method on every reopening.
This should clear any selection that has previously been done.
.. versionadded:: 3.10
%End
virtual bool configureFromUri( const QString &uri );
%Docstring
Configure the widget from a layer ``uri`` by selecting the layer path or connection options.
The base implementation does nothing and returns ``False``: providers with ConfigureSourceSelectFromUri capability
must override to implement this functionality.
.. note::
Not all data providers may be able to configure the widget from the provided uri, in that case this method returns ``False``.
:return: ``True`` on success.
.. versionadded:: 3.38
%End
signals:

View File

@ -96,6 +96,7 @@ class CORE_EXPORT QgsVectorDataProvider : public QgsDataProvider, public QgsFeat
CreateLabeling = 1 << 25, //!< Provider can set labeling settings using backend-specific formatting information. Since QGIS 3.6. See QgsVectorDataProvider::createLabeling().
ReloadData = 1 << 26, //!< Provider is able to force reload data
FeatureSymbology = 1 << 27, //!< Provider is able retrieve embedded symbology associated with individual features. Since QGIS 3.20.
ConfigureSourceSelectFromUri = 1 << 28, //!< Provider is able to configure the source select widget from a layer URI. Since QGIS 3.38.
};
Q_DECLARE_FLAGS( Capabilities, Capability )

View File

@ -65,3 +65,9 @@ void QgsAbstractDataSourceWidget::addButtonClicked()
void QgsAbstractDataSourceWidget::reset()
{
}
bool QgsAbstractDataSourceWidget::configureFromUri( const QString &uri )
{
Q_UNUSED( uri );
return false;
}

View File

@ -96,6 +96,16 @@ class GUI_EXPORT QgsAbstractDataSourceWidget : public QDialog
*/
virtual void reset();
/**
* Configure the widget from a layer \a uri by selecting the layer path or connection options.
* The base implementation does nothing and returns FALSE: providers with ConfigureSourceSelectFromUri capability
* must override to implement this functionality.
* \note Not all data providers may be able to configure the widget from the provided uri, in that case this method returns FALSE.
* \return TRUE on success.
* \since 3.38
*/
virtual bool configureFromUri( const QString &uri );
signals:
/**