Skip to content

Commit

Permalink
Merge pull request #3720 from sbrunner/WFS-provider-metadata
Browse files Browse the repository at this point in the history
Add metadata for WFS provider in layer metadata informations
  • Loading branch information
sbrunner authored Nov 7, 2016
2 parents 8e7ae8f + bc1ad2c commit 59b10d6
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 1 deletion.
6 changes: 6 additions & 0 deletions python/core/qgsvectordataprovider.sip
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 7 additions & 1 deletion src/core/qgsvectordataprovider.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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
Expand Down
14 changes: 14 additions & 0 deletions src/core/qgsvectorlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 10 additions & 0 deletions src/providers/wfs/qgswfsprovider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
6 changes: 6 additions & 0 deletions src/providers/wfs/qgswfsprovider.h
Original file line number Diff line number Diff line change
Expand Up @@ -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*/
Expand Down

0 comments on commit 59b10d6

Please sign in to comment.