Skip to content
Permalink
Browse files

Add capabilities flags for QgsProviderMetadata

So that callers can determine which functionality in the metadata
is implemented for a particular object
  • Loading branch information
nyalldawson committed Nov 6, 2020
1 parent 9e72b69 commit 8254b7dd1f9bb911d7de1d7aad49b9e8701ba97d
@@ -107,6 +107,14 @@ library object.
%End
public:

enum ProviderMetadataCapability
{
PriorityForUri,
LayerTypesForUri,
};
typedef QFlags<QgsProviderMetadata::ProviderMetadataCapability> ProviderMetadataCapabilities;



QgsProviderMetadata( const QString &key, const QString &description, const QString &library = QString() );
%Docstring
@@ -132,6 +140,13 @@ This key string is used for the associative container in :py:class:`QgsProviderR
This returns descriptive text for the provider

This is used to provide a descriptive list of available data providers.
%End

virtual QgsProviderMetadata::ProviderMetadataCapabilities capabilities() const;
%Docstring
Returns the provider metadata capabilities.

.. versionadded:: 3.18
%End

QString library() const /Deprecated/;
@@ -526,6 +541,10 @@ relating to the connection have been updated.

};

QFlags<QgsProviderMetadata::ProviderMetadataCapability> operator|(QgsProviderMetadata::ProviderMetadataCapability f1, QFlags<QgsProviderMetadata::ProviderMetadataCapability> f2);



/************************************************************************
* This file has been generated automatically from *
* *
@@ -145,4 +145,10 @@ QString QgsEptProviderMetadata::encodeUri( const QVariantMap &parts ) const
return path;
}

QgsProviderMetadata::ProviderMetadataCapabilities QgsEptProviderMetadata::capabilities() const
{
return ProviderMetadataCapability::LayerTypesForUri
| ProviderMetadataCapability::PriorityForUri;
}
///@endcond

@@ -61,9 +61,11 @@ class QgsEptProviderMetadata : public QgsProviderMetadata
{
public:
QgsEptProviderMetadata();
QgsProviderMetadata::ProviderMetadataCapabilities capabilities() const override;
QgsEptProvider *createProvider( const QString &uri, const QgsDataProvider::ProviderOptions &options, QgsDataProvider::ReadFlags flags = QgsDataProvider::ReadFlags() ) override;
QList< QgsDataItemProvider * > dataItemProviders() const override;
int priorityForUri( const QString &uri ) const override;
QList< QgsMapLayerType > validLayerTypesForUri( const QString &uri ) const override;
bool uriIsBlocklisted( const QString &uri ) const override;
QString encodeUri( const QVariantMap &parts ) const override;
QVariantMap decodeUri( const QString &uri ) const override;
@@ -51,6 +51,11 @@ QString QgsProviderMetadata::description() const
return mDescription;
}

QgsProviderMetadata::ProviderMetadataCapabilities QgsProviderMetadata::capabilities() const
{
return QgsProviderMetadata::ProviderMetadataCapabilities();
}

QString QgsProviderMetadata::library() const
{
return mLibrary;
@@ -141,6 +141,18 @@ class CORE_EXPORT QgsProviderMetadata : public QObject

public:

/**
* Indicates capabilities of the provider metadata implementation.
*
* \since QGIS 3.18
*/
enum ProviderMetadataCapability
{
PriorityForUri = 1 << 0, //!< Indicates that the metadata can calculate a priority for a URI
LayerTypesForUri = 1 << 1, //!< Indicates that the metadata can determine valid layer types for a URI
};
Q_DECLARE_FLAGS( ProviderMetadataCapabilities, ProviderMetadataCapability )

/**
* Typedef for data provider creation function.
* \since QGIS 3.0
@@ -180,6 +192,13 @@ class CORE_EXPORT QgsProviderMetadata : public QObject
*/
QString description() const;

/**
* Returns the provider metadata capabilities.
*
* \since QGIS 3.18
*/
virtual QgsProviderMetadata::ProviderMetadataCapabilities capabilities() const;

/**
* This returns the library file name
*
@@ -604,4 +623,7 @@ class CORE_EXPORT QgsProviderMetadata : public QObject

};

Q_DECLARE_OPERATORS_FOR_FLAGS( QgsProviderMetadata::ProviderMetadataCapabilities )


#endif //QGSPROVIDERMETADATA_H
@@ -131,6 +131,12 @@ QgsPdalProvider *QgsPdalProviderMetadata::createProvider( const QString &uri, co
return new QgsPdalProvider( uri, options, flags );
}

QgsProviderMetadata::ProviderMetadataCapabilities QgsPdalProviderMetadata::capabilities() const
{
return ProviderMetadataCapability::LayerTypesForUri
| ProviderMetadataCapability::PriorityForUri;
}

QList<QgsDataItemProvider *> QgsPdalProviderMetadata::dataItemProviders() const
{
QList< QgsDataItemProvider * > providers;
@@ -57,6 +57,7 @@ class QgsPdalProviderMetadata : public QgsProviderMetadata
public:
QgsPdalProviderMetadata();
QgsPdalProvider *createProvider( const QString &uri, const QgsDataProvider::ProviderOptions &options, QgsDataProvider::ReadFlags flags = QgsDataProvider::ReadFlags() ) override;
QgsProviderMetadata::ProviderMetadataCapabilities capabilities() const override;
QList< QgsDataItemProvider * > dataItemProviders() const override;
QString encodeUri( const QVariantMap &parts ) const override;
QVariantMap decodeUri( const QString &uri ) const override;

0 comments on commit 8254b7d

Please sign in to comment.
You can’t perform that action at this time.