15#include <QStringBuilder>
23 : mMetadata( metadata )
29 QString myMetadata = QStringLiteral(
"<table class=\"list-view\">\n" );
30 myMetadata += QStringLiteral(
"<tr><td class=\"highlight\">" ) + tr(
"Fees" ) + QStringLiteral(
"</td><td>" ) +
QgsStringUtils::insertLinks( mMetadata.
fees() ) + QStringLiteral(
"</td></tr>\n" );
31 myMetadata += QStringLiteral(
"<tr><td class=\"highlight\">" ) + tr(
"Licenses" ) + QStringLiteral(
"</td><td>" ) +
QgsStringUtils::insertLinks( mMetadata.
licenses().join( QLatin1String(
"<br />" ) ) ) + QStringLiteral(
"</td></tr>\n" );
32 myMetadata += QStringLiteral(
"<tr><td class=\"highlight\">" ) + tr(
"Rights" ) + QStringLiteral(
"</td><td>" ) +
QgsStringUtils::insertLinks( mMetadata.
rights().join( QLatin1String(
"<br />" ) ) ) + QStringLiteral(
"</td></tr>\n" );
33 myMetadata += QStringLiteral(
"<tr><td class=\"highlight\">" ) + tr(
"Constraints" ) + QStringLiteral(
"</td><td>" );
34 const QList<QgsLayerMetadata::Constraint> &constraints = mMetadata.
constraints();
35 bool notFirstRow =
false;
40 myMetadata += QLatin1String(
"<br />" );
42 myMetadata += QStringLiteral(
"<strong>" ) + constraint.type + QStringLiteral(
": </strong>" ) +
QgsStringUtils::insertLinks( constraint.constraint );
45 myMetadata += QLatin1String(
"</td></tr>\n" );
46 myMetadata += QLatin1String(
"</table>\n" );
52 const QList<QgsAbstractMetadataBase::Contact> &contacts = mMetadata.
contacts();
54 if ( contacts.isEmpty() )
56 myMetadata += QStringLiteral(
"<p>" ) + tr(
"No contact yet." ) + QStringLiteral(
"</p>" );
60 myMetadata += QLatin1String(
"<table width=\"100%\" class=\"tabular-view\">\n" );
61 myMetadata += QLatin1String(
"<tr><th>" ) + tr(
"ID" ) + QLatin1String(
"</th><th>" ) + tr(
"Name" ) + QLatin1String(
"</th><th>" ) + tr(
"Position" ) + QLatin1String(
"</th><th>" ) + tr(
"Organization" ) + QLatin1String(
"</th><th>" ) + tr(
"Role" ) + QLatin1String(
"</th><th>" ) + tr(
"Email" ) + QLatin1String(
"</th><th>" ) + tr(
"Voice" ) + QLatin1String(
"</th><th>" ) + tr(
"Fax" ) + QLatin1String(
"</th><th>" ) + tr(
"Addresses" ) + QLatin1String(
"</th></tr>\n" );
67 rowClass = QStringLiteral(
"class=\"odd-row\"" );
68 myMetadata += QLatin1String(
"<tr " ) + rowClass + QLatin1String(
"><td>" ) + QString::number( i ) + QLatin1String(
"</td><td>" ) + contact.name + QLatin1String(
"</td><td>" ) + contact.position + QLatin1String(
"</td><td>" ) + contact.organization + QLatin1String(
"</td><td>" ) + contact.role + QStringLiteral(
"</td><td><a href=\"mailto:%1\">%1</a></td><td>" ).arg( contact.email ) + contact.voice + QLatin1String(
"</td><td>" ) + contact.fax + QLatin1String(
"</td><td>" );
69 bool notFirstRow =
false;
74 myMetadata += QLatin1String(
"<br />\n" );
76 if ( ! oneAddress.type.isEmpty() )
78 myMetadata += oneAddress.type + QStringLiteral(
"<br />" );
80 if ( ! oneAddress.address.isEmpty() )
82 myMetadata += oneAddress.address + QStringLiteral(
"<br />" );
84 if ( ! oneAddress.postalCode.isEmpty() )
86 myMetadata += oneAddress.postalCode + QStringLiteral(
"<br />" );
88 if ( ! oneAddress.city.isEmpty() )
90 myMetadata += oneAddress.city + QStringLiteral(
"<br />" );
92 if ( ! oneAddress.administrativeArea.isEmpty() )
94 myMetadata += oneAddress.administrativeArea + QStringLiteral(
"<br />" );
96 if ( ! oneAddress.country.isEmpty() )
98 myMetadata += oneAddress.country;
102 myMetadata += QLatin1String(
"</td></tr>\n" );
105 myMetadata += QLatin1String(
"</table>\n" );
113 bool notFirstRow =
false;
114 QString myMetadata = QStringLiteral(
"<table class=\"list-view\">\n" );
115 if ( showSpatialExtent )
117 myMetadata += QStringLiteral(
"<tr><td class=\"highlight\">" ) + tr(
"CRS" ) + QStringLiteral(
"</td><td>" );
122 myMetadata += tr(
"Geographic" );
124 myMetadata += tr(
"Projected" );
126 myMetadata += QLatin1String(
"</td></tr>\n" );
128 myMetadata += QStringLiteral(
"<tr><td class=\"highlight\">" ) + tr(
"Spatial Extent" ) + QStringLiteral(
"</td><td>" );
129 const QList< QgsLayerMetadata::SpatialExtent > spatialExtents = extent.
spatialExtents();
132 if ( spatialExtent.bounds.isNull() || spatialExtent.bounds.toRectangle().isNull() )
137 myMetadata += QLatin1String(
"<br />\n" );
139 myMetadata += QStringLiteral(
"<strong>" ) + tr(
"CRS" ) + QStringLiteral(
": </strong>" ) + spatialExtent.extentCrs.userFriendlyIdentifier() + QStringLiteral(
" - " );
140 if ( spatialExtent.extentCrs.isGeographic() )
141 myMetadata += tr(
"Geographic" );
143 myMetadata += tr(
"Projected" );
144 myMetadata += QLatin1String(
"<br />" );
145 myMetadata += QStringLiteral(
"<strong>" ) + tr(
"X Minimum:" ) + QStringLiteral(
" </strong>" ) +
qgsDoubleToString( spatialExtent.bounds.xMinimum() ) + QStringLiteral(
"<br />" );
146 myMetadata += QStringLiteral(
"<strong>" ) + tr(
"Y Minimum:" ) + QStringLiteral(
" </strong>" ) +
qgsDoubleToString( spatialExtent.bounds.yMinimum() ) + QStringLiteral(
"<br />" );
147 myMetadata += QStringLiteral(
"<strong>" ) + tr(
"X Maximum:" ) + QStringLiteral(
" </strong>" ) +
qgsDoubleToString( spatialExtent.bounds.xMaximum() ) + QStringLiteral(
"<br />" );
148 myMetadata += QStringLiteral(
"<strong>" ) + tr(
"Y Maximum:" ) + QStringLiteral(
" </strong>" ) +
qgsDoubleToString( spatialExtent.bounds.yMaximum() ) + QStringLiteral(
"<br />" );
149 if ( spatialExtent.bounds.zMinimum() || spatialExtent.bounds.zMaximum() )
151 myMetadata += QStringLiteral(
"<strong>" ) + tr(
"Z Minimum:" ) + QStringLiteral(
" </strong>" ) +
qgsDoubleToString( spatialExtent.bounds.zMinimum() ) + QStringLiteral(
"<br />" );
152 myMetadata += QStringLiteral(
"<strong>" ) + tr(
"Z Maximum:" ) + QStringLiteral(
" </strong>" ) +
qgsDoubleToString( spatialExtent.bounds.zMaximum() );
156 myMetadata += QLatin1String(
"</td></tr>\n" );
158 myMetadata += QStringLiteral(
"<tr><td class=\"highlight\">" ) + tr(
"Temporal Extent" ) + QStringLiteral(
"</td><td>" );
159 const QList< QgsDateTimeRange > temporalExtents = extent.
temporalExtents();
165 myMetadata += QLatin1String(
"<br />\n" );
167 if ( temporalExtent.isInstant() )
169 myMetadata += QStringLiteral(
"<strong>" ) + tr(
"Instant:" ) + QStringLiteral(
" </strong>" ) + temporalExtent.begin().toTimeSpec( Qt::OffsetFromUTC ).toString( Qt::ISODate );
173 myMetadata += QStringLiteral(
"<strong>" ) + tr(
"Start:" ) + QStringLiteral(
" </strong>" ) + temporalExtent.begin().toTimeSpec( Qt::OffsetFromUTC ).toString( Qt::ISODate ) + QStringLiteral(
"<br />\n" );
174 myMetadata += QStringLiteral(
"<strong>" ) + tr(
"End:" ) + QStringLiteral(
" </strong>" ) + temporalExtent.end().toTimeSpec( Qt::OffsetFromUTC ).toString( Qt::ISODate );
178 myMetadata += QLatin1String(
"</td></tr>\n" );
179 myMetadata += QLatin1String(
"</table>\n" );
185 QString myMetadata = QStringLiteral(
"<table class=\"list-view\">\n" );
188 myMetadata += QStringLiteral(
"<tr><td class=\"highlight\">" ) + tr(
"Identifier" ) + QStringLiteral(
"</td><td>" ) + mMetadata.
identifier() + QStringLiteral(
"</td></tr>\n" );
191 myMetadata += QStringLiteral(
"<tr><td class=\"highlight\">" ) + tr(
"Parent Identifier" ) + QStringLiteral(
"</td><td>" ) + mMetadata.
parentIdentifier() + QStringLiteral(
"</td></tr>\n" );
194 myMetadata += QStringLiteral(
"<tr><td class=\"highlight\">" ) + tr(
"Title" ) + QStringLiteral(
"</td><td>" ) + mMetadata.
title() + QStringLiteral(
"</td></tr>\n" );
197 myMetadata += QStringLiteral(
"<tr><td class=\"highlight\">" ) + tr(
"Type" ) + QStringLiteral(
"</td><td>" ) + mMetadata.
type() + QStringLiteral(
"</td></tr>\n" );
200 myMetadata += QStringLiteral(
"<tr><td class=\"highlight\">" ) + tr(
"Language" ) + QStringLiteral(
"</td><td>" ) + mMetadata.
language() + QStringLiteral(
"</td></tr>\n" );
203 myMetadata += QStringLiteral(
"<tr><td class=\"highlight\">" ) + tr(
"Abstract" ) + QStringLiteral(
"</td><td>" ) +
QgsStringUtils::insertLinks( mMetadata.
abstract() ).replace(
'\n', QLatin1String(
"<br>" ) ) + QStringLiteral(
"</td></tr>\n" );
206 myMetadata += QStringLiteral(
"<tr><td class=\"highlight\">" ) + tr(
"Categories" ) + QStringLiteral(
"</td><td>" ) + mMetadata.
categories().join( QLatin1String(
", " ) ) + QStringLiteral(
"</td></tr>\n" );
209 myMetadata += QStringLiteral(
"<tr><td class=\"highlight\">" ) + tr(
"Keywords" ) + QStringLiteral(
"</td><td>\n" );
210 QMapIterator<QString, QStringList> i( mMetadata.
keywords() );
213 myMetadata += QLatin1String(
"<table width=\"100%\" class=\"tabular-view\">\n" );
214 myMetadata += QLatin1String(
"<tr><th>" ) + tr(
"Vocabulary" ) + QLatin1String(
"</th><th>" ) + tr(
"Items" ) + QLatin1String(
"</th></tr>\n" );
216 while ( i.hasNext() )
221 rowClass = QStringLiteral(
"class=\"odd-row\"" );
222 myMetadata += QLatin1String(
"<tr " ) + rowClass + QLatin1String(
"><td>" ) + i.key() + QLatin1String(
"</td><td>" ) + i.value().join( QLatin1String(
", " ) ) + QLatin1String(
"</td></tr>\n" );
225 myMetadata += QLatin1String(
"</table>\n" );
227 myMetadata += QLatin1String(
"</td></tr>\n" );
228 myMetadata += QLatin1String(
"</table>\n" );
235 const QStringList historyItems = mMetadata.
history();
236 if ( historyItems.isEmpty() )
238 myMetadata += QStringLiteral(
"<p>" ) + tr(
"No history yet." ) + QStringLiteral(
"</p>\n" );
242 myMetadata += QLatin1String(
"<table width=\"100%\" class=\"tabular-view\">\n" );
243 myMetadata += QLatin1String(
"<tr><th>" ) + tr(
"ID" ) + QLatin1String(
"</th><th>" ) + tr(
"Action" ) + QLatin1String(
"</th></tr>\n" );
245 for (
const QString &history : historyItems )
249 rowClass = QStringLiteral(
"class=\"odd-row\"" );
250 myMetadata += QLatin1String(
"<tr " ) + rowClass + QLatin1String(
"><td width=\"5%\">" ) + QString::number( i ) + QLatin1String(
"</td><td>" ) +
QgsStringUtils::insertLinks( history ) + QLatin1String(
"</td></tr>\n" );
253 myMetadata += QLatin1String(
"</table>\n" );
261 const QList<QgsAbstractMetadataBase::Link> &links = mMetadata.
links();
262 if ( links.isEmpty() )
264 myMetadata += QStringLiteral(
"<p>" ) + tr(
"No links yet." ) + QStringLiteral(
"</p>\n" );
268 myMetadata += QLatin1String(
"<table width=\"100%\" class=\"tabular-view\">\n" );
269 myMetadata += QLatin1String(
"<tr><th>" ) + tr(
"ID" ) + QLatin1String(
"</th><th>" ) + tr(
"Name" ) + QLatin1String(
"</th><th>" ) + tr(
"Type" ) + QLatin1String(
"</th><th>" ) + tr(
"URL" ) + QLatin1String(
"</th><th>" ) + tr(
"Description" ) + QLatin1String(
"</th><th>" ) + tr(
"Format" ) + QLatin1String(
"</th><th>" ) + tr(
"MIME Type" ) + QLatin1String(
"</th><th>" ) + tr(
"Size" ) + QLatin1String(
"</th></tr>\n" );
275 rowClass = QStringLiteral(
"class=\"odd-row\"" );
276 myMetadata += QLatin1String(
"<tr " ) + rowClass + QLatin1String(
"><td>" ) + QString::number( i ) + QLatin1String(
"</td><td>" ) + link.name + QLatin1String(
"</td><td>" ) + link.type + QStringLiteral(
"</td><td><a href=\"%1\">%1</a></td><td>" ).arg( link.url ) + link.description + QLatin1String(
"</td><td>" ) + link.format + QLatin1String(
"</td><td>" ) + link.mimeType + QLatin1String(
"</td><td>" ) + link.size + QLatin1String(
"</td></tr>\n" );
279 myMetadata += QLatin1String(
"</table>\n" );
bool isValid() const
Returns whether this CRS is correctly initialized and usable.
QString userFriendlyIdentifier(Qgis::CrsIdentifierType type=Qgis::CrsIdentifierType::MediumString) const
Returns a user friendly identifier for the CRS.
static QString insertLinks(const QString &string, bool *foundLinks=nullptr)
Returns a string with any URL (e.g., http(s)/ftp) and mailto: text converted to valid HTML <a ....
QString qgsDoubleToString(double a, int precision=17)
Returns a string representation of a double.