Further updates from review

This commit is contained in:
Martin Dobias 2019-06-25 15:38:07 +02:00
parent aead182b21
commit d155b1c877
11 changed files with 134 additions and 72 deletions

View File

@ -138,17 +138,29 @@ Returns pyramid resampling methods available for provider
virtual QVariantMap decodeUri( const QString &uri ); virtual QVariantMap decodeUri( const QString &uri );
%Docstring %Docstring
Decodes URI Breaks a provider data source URI into its component paths (e.g. file path, layer name).
:param uri: uri string
:return: map containing components. Standard components include "path", "layerName", "url".
.. note::
this function may not be supported by all providers, an empty map will be returned in such case
.. versionadded:: 3.10 .. versionadded:: 3.10
%End %End
virtual QList< QgsDataItemProvider * > dataItemProviders() const; virtual QList< QgsDataItemProvider * > dataItemProviders() const /Factory/;
%Docstring %Docstring
Returns data item providers. Caller is responsible for ownership of the item providers Returns data item providers. Caller is responsible for ownership of the item providers
.. seealso:: :py:func:`QgsProviderGuiMetadata.dataItemGuiProviders` .. seealso:: :py:func:`QgsProviderGuiMetadata.dataItemGuiProviders`
.. note::
Ownership of created data item providers is passed to the caller.
.. versionadded:: 3.10 .. versionadded:: 3.10
%End %End

View File

@ -152,10 +152,14 @@ responsible for deleting the returned widget.
.. deprecated:: QGIS 3.10 - use QgsGui.providerGuiRegistry()->createDataSourceWidget() instead .. deprecated:: QGIS 3.10 - use QgsGui.providerGuiRegistry()->createDataSourceWidget() instead
%End %End
QList< QgsDataItemProvider * > dataItemProviders( const QString &providerKey ) const; QList< QgsDataItemProvider * > dataItemProviders( const QString &providerKey ) const /Factory/;
%Docstring %Docstring
Returns list of data item providers of the provider Returns list of data item providers of the provider
.. note::
Ownership of created data item providers is passed to the caller.
.. versionadded:: 3.10 .. versionadded:: 3.10
%End %End

View File

@ -31,24 +31,37 @@ Constructor for provider gui metadata
virtual ~QgsProviderGuiMetadata(); virtual ~QgsProviderGuiMetadata();
virtual QList<QgsDataItemGuiProvider *> dataItemGuiProviders();
%Docstring
Returns data item gui providers
%End
virtual void registerGui( QMainWindow *widget ); virtual void registerGui( QMainWindow *widget );
%Docstring %Docstring
Assigns parent to widget Called during GUI initialization - allows provider to do its internal initialization
of GUI components, possibly making use of the passed pointer to the QGIS main window.
%End %End
virtual QList<QgsProjectStorageGuiProvider *> projectStorageGuiProviders(); virtual QList<QgsDataItemGuiProvider *> dataItemGuiProviders() /Factory/;
%Docstring
Returns data item gui providers
.. note::
Ownership of created data item gui providers is passed to the caller.
%End
virtual QList<QgsProjectStorageGuiProvider *> projectStorageGuiProviders() /Factory/;
%Docstring %Docstring
Returns project storage gui providers Returns project storage gui providers
.. note::
Ownership of created project storage gui providers is passed to the caller.
%End %End
virtual QList<QgsSourceSelectProvider *> sourceSelectProviders(); virtual QList<QgsSourceSelectProvider *> sourceSelectProviders() /Factory/;
%Docstring %Docstring
Returns source select providers Returns source select providers
.. note::
Ownership of created source select providers is passed to the caller.
%End %End
QString key() const; QString key() const;

View File

@ -21,7 +21,7 @@ QgsProviderGuiRegistry is not usually directly created, but rather accessed thro
:py:func:`QgsGui.providerGuiRegistry()` :py:func:`QgsGui.providerGuiRegistry()`
setPluginPath() should be called (once) to load dynamic providers. Static providers are setPluginPath() should be called (once) to load dynamic providers. Static providers are
loaded in constructopr loaded in constructor.
.. versionadded:: 3.10 .. versionadded:: 3.10
%End %End
@ -50,25 +50,35 @@ Returns metadata of the provider or ``None`` if not found
void registerGuis( QMainWindow *widget ); void registerGuis( QMainWindow *widget );
%Docstring %Docstring
Calls registerGui function of all providers Called during GUI initialization - allows providers to do its internal initialization
of GUI components, possibly making use of the passed pointer to the QGIS main window.
%End %End
virtual const QList<QgsDataItemGuiProvider *> dataItemGuiProviders( const QString &providerKey ); virtual const QList<QgsDataItemGuiProvider *> dataItemGuiProviders( const QString &providerKey ) /Factory/;
%Docstring %Docstring
Returns all data item gui providers registered in provider with ``providerKey`` Returns all data item gui providers registered in provider with ``providerKey``
Caller receiver ownership of created data item providers
.. note::
Ownership of created data item providers is passed to the caller.
%End %End
virtual QList<QgsSourceSelectProvider *> sourceSelectProviders( const QString &providerKey ); virtual QList<QgsSourceSelectProvider *> sourceSelectProviders( const QString &providerKey ) /Factory/;
%Docstring %Docstring
Returns all source select providers registered in provider with ``providerKey`` Returns all source select providers registered in provider with ``providerKey``
Caller receiver ownership of created data item providers
.. note::
Ownership of created source select providers is passed to the caller.
%End %End
virtual QList<QgsProjectStorageGuiProvider *> projectStorageGuiProviders( const QString &providerKey ); virtual QList<QgsProjectStorageGuiProvider *> projectStorageGuiProviders( const QString &providerKey ) /Factory/;
%Docstring %Docstring
Returns all project storage gui providers registered in provider with ``providerKey`` Returns all project storage gui providers registered in provider with ``providerKey``
Caller receiver ownership of created data item providers
.. note::
Ownership of created project storage gui providers is passed to the caller.
%End %End

View File

@ -3015,17 +3015,18 @@ bool QgsGdalProvider::remove()
*/ */
QString QgsGdalProviderMetadata::filters( FilterType type ) QString QgsGdalProviderMetadata::filters( FilterType type )
{ {
if ( type == QgsProviderMetadata::FilterType::FilterRaster ) switch ( type )
{ {
QString fileFiltersString; case QgsProviderMetadata::FilterType::FilterRaster:
QStringList exts; {
QStringList wildcards; QString fileFiltersString;
buildSupportedRasterFileFilterAndExtensions( fileFiltersString, exts, wildcards ); QStringList exts;
return fileFiltersString; QStringList wildcards;
} buildSupportedRasterFileFilterAndExtensions( fileFiltersString, exts, wildcards );
else return fileFiltersString;
{ }
return QString(); default:
return QString();
} }
} }
@ -3190,7 +3191,7 @@ GDALRasterBandH QgsGdalProvider::getBand( int bandNo ) const
// see ticket #284 // see ticket #284
QList<QPair<QString, QString> > QgsGdalProviderMetadata::pyramidResamplingMethods() QList<QPair<QString, QString> > QgsGdalProviderMetadata::pyramidResamplingMethods()
{ {
QList<QPair<QString, QString> > methods; static QList<QPair<QString, QString> > methods;
if ( methods.isEmpty() ) if ( methods.isEmpty() )
{ {

View File

@ -6608,13 +6608,12 @@ QgsOgrProviderMetadata::QgsOgrProviderMetadata()
QString QgsOgrProviderMetadata::filters( FilterType type ) QString QgsOgrProviderMetadata::filters( FilterType type )
{ {
if ( type == QgsProviderMetadata::FilterType::FilterVector ) switch ( type )
{ {
return QgsOgrProviderUtils::fileVectorFilters(); case QgsProviderMetadata::FilterType::FilterVector:
} return QgsOgrProviderUtils::fileVectorFilters();
else default:
{ return QString();
return QString();
} }
} }

View File

@ -187,7 +187,10 @@ class CORE_EXPORT QgsProviderMetadata
virtual QList<QPair<QString, QString> > pyramidResamplingMethods(); virtual QList<QPair<QString, QString> > pyramidResamplingMethods();
/** /**
* Decodes URI * Breaks a provider data source URI into its component paths (e.g. file path, layer name).
* \param uri uri string
* \returns map containing components. Standard components include "path", "layerName", "url".
* \note this function may not be supported by all providers, an empty map will be returned in such case
* \since QGIS 3.10 * \since QGIS 3.10
*/ */
virtual QVariantMap decodeUri( const QString &uri ); virtual QVariantMap decodeUri( const QString &uri );
@ -195,9 +198,10 @@ class CORE_EXPORT QgsProviderMetadata
/** /**
* Returns data item providers. Caller is responsible for ownership of the item providers * Returns data item providers. Caller is responsible for ownership of the item providers
* \see QgsProviderGuiMetadata::dataItemGuiProviders() * \see QgsProviderGuiMetadata::dataItemGuiProviders()
* \note Ownership of created data item providers is passed to the caller.
* \since QGIS 3.10 * \since QGIS 3.10
*/ */
virtual QList< QgsDataItemProvider * > dataItemProviders() const; virtual QList< QgsDataItemProvider * > dataItemProviders() const SIP_FACTORY;
/** /**
* Lists stored layer styles in the provider defined by \a uri * Lists stored layer styles in the provider defined by \a uri

View File

@ -181,10 +181,11 @@ class CORE_EXPORT QgsProviderRegistry
Q_DECL_DEPRECATED QWidget *createSelectionWidget( const QString &providerKey, QWidget *parent = nullptr, Qt::WindowFlags fl = Qt::WindowFlags(), QgsProviderRegistry::WidgetMode widgetMode = QgsProviderRegistry::WidgetMode::None ) SIP_DEPRECATED; Q_DECL_DEPRECATED QWidget *createSelectionWidget( const QString &providerKey, QWidget *parent = nullptr, Qt::WindowFlags fl = Qt::WindowFlags(), QgsProviderRegistry::WidgetMode widgetMode = QgsProviderRegistry::WidgetMode::None ) SIP_DEPRECATED;
/** /**
* Returns list of data item providers of the provider * Returns list of data item providers of the provider
* \since QGIS 3.10 * \note Ownership of created data item providers is passed to the caller.
*/ * \since QGIS 3.10
QList< QgsDataItemProvider * > dataItemProviders( const QString &providerKey ) const; */
QList< QgsDataItemProvider * > dataItemProviders( const QString &providerKey ) const SIP_FACTORY;
/** /**
* Lists stored layer styles in the provider defined by \a providerKey and \a uri * Lists stored layer styles in the provider defined by \a providerKey and \a uri

View File

@ -45,17 +45,29 @@ class GUI_EXPORT QgsProviderGuiMetadata
virtual ~QgsProviderGuiMetadata(); virtual ~QgsProviderGuiMetadata();
//! Returns data item gui providers /**
virtual QList<QgsDataItemGuiProvider *> dataItemGuiProviders(); * Called during GUI initialization - allows provider to do its internal initialization
* of GUI components, possibly making use of the passed pointer to the QGIS main window.
//! Assigns parent to widget */
virtual void registerGui( QMainWindow *widget ); virtual void registerGui( QMainWindow *widget );
//! Returns project storage gui providers /**
virtual QList<QgsProjectStorageGuiProvider *> projectStorageGuiProviders(); * Returns data item gui providers
* \note Ownership of created data item gui providers is passed to the caller.
*/
virtual QList<QgsDataItemGuiProvider *> dataItemGuiProviders() SIP_FACTORY;
//! Returns source select providers /**
virtual QList<QgsSourceSelectProvider *> sourceSelectProviders(); * Returns project storage gui providers
* \note Ownership of created project storage gui providers is passed to the caller.
*/
virtual QList<QgsProjectStorageGuiProvider *> projectStorageGuiProviders() SIP_FACTORY;
/**
* Returns source select providers
* \note Ownership of created source select providers is passed to the caller.
*/
virtual QList<QgsSourceSelectProvider *> sourceSelectProviders() SIP_FACTORY;
//! Returns unique provider key //! Returns unique provider key
QString key() const; QString key() const;

View File

@ -42,7 +42,7 @@ class QgsProjectStorageGuiProvider;
* QgsGui::providerGuiRegistry(). * QgsGui::providerGuiRegistry().
* *
* setPluginPath() should be called (once) to load dynamic providers. Static providers are * setPluginPath() should be called (once) to load dynamic providers. Static providers are
* loaded in constructopr * loaded in constructor.
* *
* \since QGIS 3.10 * \since QGIS 3.10
*/ */
@ -62,26 +62,29 @@ class GUI_EXPORT QgsProviderGuiRegistry
//! Returns metadata of the provider or NULLPTR if not found //! Returns metadata of the provider or NULLPTR if not found
const QgsProviderGuiMetadata *providerMetadata( const QString &providerKey ) const; const QgsProviderGuiMetadata *providerMetadata( const QString &providerKey ) const;
//! Calls registerGui function of all providers /**
* Called during GUI initialization - allows providers to do its internal initialization
* of GUI components, possibly making use of the passed pointer to the QGIS main window.
*/
void registerGuis( QMainWindow *widget ); void registerGuis( QMainWindow *widget );
/** /**
* Returns all data item gui providers registered in provider with \a providerKey * Returns all data item gui providers registered in provider with \a providerKey
* Caller receiver ownership of created data item providers * \note Ownership of created data item providers is passed to the caller.
*/ */
virtual const QList<QgsDataItemGuiProvider *> dataItemGuiProviders( const QString &providerKey ); virtual const QList<QgsDataItemGuiProvider *> dataItemGuiProviders( const QString &providerKey ) SIP_FACTORY;
/** /**
* Returns all source select providers registered in provider with \a providerKey * Returns all source select providers registered in provider with \a providerKey
* Caller receiver ownership of created data item providers * \note Ownership of created source select providers is passed to the caller.
*/ */
virtual QList<QgsSourceSelectProvider *> sourceSelectProviders( const QString &providerKey ); virtual QList<QgsSourceSelectProvider *> sourceSelectProviders( const QString &providerKey ) SIP_FACTORY;
/** /**
* Returns all project storage gui providers registered in provider with \a providerKey * Returns all project storage gui providers registered in provider with \a providerKey
* Caller receiver ownership of created data item providers * \note Ownership of created project storage gui providers is passed to the caller.
*/ */
virtual QList<QgsProjectStorageGuiProvider *> projectStorageGuiProviders( const QString &providerKey ); virtual QList<QgsProjectStorageGuiProvider *> projectStorageGuiProviders( const QString &providerKey ) SIP_FACTORY;
//! Type for data provider metadata associative container //! Type for data provider metadata associative container
SIP_SKIP typedef std::map<QString, QgsProviderGuiMetadata *> GuiProviders; SIP_SKIP typedef std::map<QString, QgsProviderGuiMetadata *> GuiProviders;

View File

@ -587,22 +587,25 @@ QList<QgsSourceSelectProvider *> QgsMdalProviderGuiMetadata::sourceSelectProvide
QString QgsMdalProviderMetadata::filters( FilterType type ) QString QgsMdalProviderMetadata::filters( FilterType type )
{ {
if ( type == QgsProviderMetadata::FilterType::FilterMesh ) switch ( type )
{ {
QString fileMeshFiltersString; case QgsProviderMetadata::FilterType::FilterMesh:
QString fileMeshDatasetFiltersString; {
QgsMdalProvider::fileMeshFilters( fileMeshFiltersString, fileMeshDatasetFiltersString ); QString fileMeshFiltersString;
return fileMeshFiltersString; QString fileMeshDatasetFiltersString;
QgsMdalProvider::fileMeshFilters( fileMeshFiltersString, fileMeshDatasetFiltersString );
return fileMeshFiltersString;
}
case QgsProviderMetadata::FilterType::FilterMeshDataset:
{
QString fileMeshFiltersString;
QString fileMeshDatasetFiltersString;
QgsMdalProvider::fileMeshFilters( fileMeshFiltersString, fileMeshDatasetFiltersString );
return fileMeshDatasetFiltersString;
}
default:
return QString();
} }
else if ( type == QgsProviderMetadata::FilterType::FilterMeshDataset )
{
QString fileMeshFiltersString;
QString fileMeshDatasetFiltersString;
QgsMdalProvider::fileMeshFilters( fileMeshFiltersString, fileMeshDatasetFiltersString );
return fileMeshDatasetFiltersString;
}
else
return QString();
} }
#endif #endif