Skip to content
Permalink
Browse files
Implement html metadata for annotation layers
  • Loading branch information
nyalldawson committed Sep 10, 2021
1 parent 985b989 commit fbce5ad8643904a11fc3b75b719d99a21f3f83da
@@ -153,6 +153,8 @@ Returns ``True`` if the operation was successfully applied.

virtual QgsDataProvider *dataProvider();

virtual QString htmlMetadata() const;


};

@@ -461,6 +461,32 @@ const QgsDataProvider *QgsAnnotationLayer::dataProvider() const
return mDataProvider;
}

QString QgsAnnotationLayer::htmlMetadata() const
{
QString metadata = QStringLiteral( "<html>\n<body>\n<h1>" ) + tr( "General" ) + QStringLiteral( "</h1>\n<hr>\n" ) + QStringLiteral( "<table class=\"list-view\">\n" );

metadata += QStringLiteral( "<tr><td class=\"highlight\">" ) + tr( "Name" ) + QStringLiteral( "</td><td>" ) + name() + QStringLiteral( "</td></tr>\n" );

// Extent
metadata += QStringLiteral( "<tr><td class=\"highlight\">" ) + tr( "Extent" ) + QStringLiteral( "</td><td>" ) + extent().toString() + QStringLiteral( "</td></tr>\n" );

// item count
QLocale locale = QLocale();
locale.setNumberOptions( locale.numberOptions() &= ~QLocale::NumberOption::OmitGroupSeparator );
const int itemCount = mItems.size();
metadata += QStringLiteral( "<tr><td class=\"highlight\">" )
+ tr( "Item count" ) + QStringLiteral( "</td><td>" )
+ locale.toString( static_cast<qlonglong>( itemCount ) )
+ QStringLiteral( "</td></tr>\n" );
metadata += QLatin1String( "</table>\n<br><br>" );

// CRS
metadata += crsHtmlMetadata();

metadata += QLatin1String( "\n</body>\n</html>\n" );
return metadata;
}


//
// QgsAnnotationLayerDataProvider
@@ -170,6 +170,7 @@ class CORE_EXPORT QgsAnnotationLayer : public QgsMapLayer
bool supportsEditing() const override;
QgsDataProvider *dataProvider() override;
const QgsDataProvider *dataProvider() const override SIP_SKIP;
QString htmlMetadata() const override;

private:

0 comments on commit fbce5ad

Please sign in to comment.