Skip to content
Permalink
Browse files

Merge pull request #3720 from sbrunner/WFS-provider-metadata

Add metadata for WFS provider in layer metadata informations
  • Loading branch information
sbrunner committed Nov 7, 2016
2 parents 8e7ae8f + bc1ad2c commit 59b10d65b7210f299445b9355d152e9de685896c
@@ -386,6 +386,12 @@ class QgsVectorDataProvider : QgsDataProvider
*/
virtual QList<QgsRelation> discoverRelations( const QgsVectorLayer* self, const QList<QgsVectorLayer*>& layers ) const;

/**
* Get some metadata that will be display in the metadata tab of the layer properties.
* @return The provider metadata
*/
virtual QMap<QString, QString> metadata() const;

signals:
/**
* Signals an error in this provider
@@ -390,7 +390,7 @@ class CORE_EXPORT QgsVectorDataProvider : public QgsDataProvider
* Returns true if the provider is strict about the type of inserted features
* (e.g. no multipolygon in a polygon layer)
*/
virtual bool doesStrictFeatureTypeCheck() const { return true;}
virtual bool doesStrictFeatureTypeCheck() const { return true; }

//! Returns a list of available encodings
static QStringList availableEncodings();
@@ -446,6 +446,12 @@ class CORE_EXPORT QgsVectorDataProvider : public QgsDataProvider
*/
virtual QList<QgsRelation> discoverRelations( const QgsVectorLayer* self, const QList<QgsVectorLayer*>& layers ) const;

/**
* Get some metadata that will be display in the metadata tab of the layer properties.
* @return The provider metadata
*/
virtual QMap<QString, QString> metadata() const { return QMap<QString, QString>(); };

signals:
/**
* Signals an error in this provider
@@ -3889,6 +3889,20 @@ QString QgsVectorLayer::metadata() const
myMetadata += QLatin1String( "<p>" );
myMetadata += dataProvider()->description().replace( '\n', QLatin1String( "<br>" ) );
myMetadata += QLatin1String( "</p>\n" );

QMap<QString, QString> dataProviderMetadata = mDataProvider->metadata();
if ( !dataProviderMetadata.isEmpty() )
{
myMetadata += "<p class=\"glossy\">" + tr( "Provider Metadata" ) + "</p>\n";
myMetadata += "<p><table><tr><th>" + tr( "Metadata name" ) + "</th><th>" + tr( "Metadata value" ) + "</th></tr>\n";
QMapIterator<QString, QString> i( dataProviderMetadata );
while ( i.hasNext() )
{
i.next();
myMetadata += "<tr><td>" + i.key() + ":</td><td>" + i.value() + "</td></tr>\n";
}
myMetadata += QLatin1String( "</table></p>\n" );
}
}

// data source
@@ -1100,6 +1100,16 @@ bool QgsWFSProvider::changeAttributeValues( const QgsChangedAttributesMap &attr_
}
}


QMap<QString, QString> QgsWFSProvider::metadata()
{
QMap<QString, QString> result;
result[tr( "Max Features" )] = mShared->mCaps.maxFeatures == 0 ? tr( "not provided" ) : QString( mShared->mCaps.maxFeatures );
result[tr( "Supports Paging" )] = mShared->mCaps.supportsPaging ? tr( "supported" ) : tr( "unsupported" );
result[tr( "Supports Joins" )] = mShared->mCaps.supportsJoins ? tr( "supported" ) : tr( "unsupported" );
return result;
}

bool QgsWFSProvider::describeFeatureType( QString& geometryAttribute, QgsFields& fields, QgsWkbTypes::Type& geomType )
{
fields.clear();
@@ -132,6 +132,12 @@ class QgsWFSProvider : public QgsVectorDataProvider
*/
virtual bool changeAttributeValues( const QgsChangedAttributesMap &attr_map ) override;

/**
* Get some metadata description of the provider.
* @return The provider metadata
*/
virtual QMap<QString, QString> metadata();

public slots:
/** Reloads the data from the source. Needs to be implemented by providers with data caches to
synchronize with changes in the data source*/

0 comments on commit 59b10d6

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