118 if (
mKeywords.contains( QStringLiteral(
"gmd:topicCategory" ) ) )
120 return mKeywords.value( QStringLiteral(
"gmd:topicCategory" ) );
124 return QStringList();
130 mKeywords.insert( QStringLiteral(
"gmd:topicCategory" ), category );
170 if ( !date.isValid() || date.isNull() )
192 mnl = metadataElement.namedItem( QStringLiteral(
"identifier" ) );
196 mnl = metadataElement.namedItem( QStringLiteral(
"parentidentifier" ) );
200 mnl = metadataElement.namedItem( QStringLiteral(
"language" ) );
204 mnl = metadataElement.namedItem( QStringLiteral(
"type" ) );
205 mType = mnl.toElement().text();
208 mnl = metadataElement.namedItem( QStringLiteral(
"title" ) );
209 mTitle = mnl.toElement().text();
212 mnl = metadataElement.namedItem( QStringLiteral(
"abstract" ) );
216 const QDomNodeList
keywords = metadataElement.elementsByTagName( QStringLiteral(
"keywords" ) );
218 for (
int i = 0; i <
keywords.size(); i++ )
220 QStringList keywordsList;
222 mne = mnl.toElement();
224 const QDomNodeList el = mne.elementsByTagName( QStringLiteral(
"keyword" ) );
225 for (
int j = 0; j < el.size(); j++ )
227 keywordsList.append( el.at( j ).toElement().text() );
229 addKeywords( mne.attribute( QStringLiteral(
"vocabulary" ) ), keywordsList );
233 const QDomNodeList contactsList = metadataElement.elementsByTagName( QStringLiteral(
"contact" ) );
235 for (
int i = 0; i < contactsList.size(); i++ )
237 mnl = contactsList.at( i );
238 mne = mnl.toElement();
241 oneContact.
name = mne.namedItem( QStringLiteral(
"name" ) ).toElement().text();
242 oneContact.
organization = mne.namedItem( QStringLiteral(
"organization" ) ).toElement().text();
243 oneContact.
position = mne.namedItem( QStringLiteral(
"position" ) ).toElement().text();
244 oneContact.
voice = mne.namedItem( QStringLiteral(
"voice" ) ).toElement().text();
245 oneContact.
fax = mne.namedItem( QStringLiteral(
"fax" ) ).toElement().text();
246 oneContact.
email = mne.namedItem( QStringLiteral(
"email" ) ).toElement().text();
247 oneContact.
role = mne.namedItem( QStringLiteral(
"role" ) ).toElement().text();
249 QList< QgsAbstractMetadataBase::Address > addresses;
250 const QDomNodeList addressList = mne.elementsByTagName( QStringLiteral(
"contactAddress" ) );
251 for (
int j = 0; j < addressList.size(); j++ )
253 const QDomElement addressElement = addressList.at( j ).toElement();
255 oneAddress.
address = addressElement.namedItem( QStringLiteral(
"address" ) ).toElement().text();
256 oneAddress.
administrativeArea = addressElement.namedItem( QStringLiteral(
"administrativearea" ) ).toElement().text();
257 oneAddress.
city = addressElement.namedItem( QStringLiteral(
"city" ) ).toElement().text();
258 oneAddress.
country = addressElement.namedItem( QStringLiteral(
"country" ) ).toElement().text();
259 oneAddress.
postalCode = addressElement.namedItem( QStringLiteral(
"postalcode" ) ).toElement().text();
260 oneAddress.
type = addressElement.namedItem( QStringLiteral(
"type" ) ).toElement().text();
261 addresses << oneAddress;
268 mnl = metadataElement.namedItem( QStringLiteral(
"links" ) );
269 mne = mnl.toElement();
271 const QDomNodeList el = mne.elementsByTagName( QStringLiteral(
"link" ) );
272 for (
int i = 0; i < el.size(); i++ )
274 mne = el.at( i ).toElement();
276 oneLink.
name = mne.attribute( QStringLiteral(
"name" ) );
277 oneLink.
type = mne.attribute( QStringLiteral(
"type" ) );
278 oneLink.
url = mne.attribute( QStringLiteral(
"url" ) );
279 oneLink.
description = mne.attribute( QStringLiteral(
"description" ) );
280 oneLink.
format = mne.attribute( QStringLiteral(
"format" ) );
281 oneLink.
mimeType = mne.attribute( QStringLiteral(
"mimeType" ) );
282 oneLink.
size = mne.attribute( QStringLiteral(
"size" ) );
287 const QDomNodeList historyNodeList = metadataElement.elementsByTagName( QStringLiteral(
"history" ) );
288 QStringList historyList;
289 for (
int i = 0; i < historyNodeList.size(); i++ )
291 mnl = historyNodeList.at( i );
292 mne = mnl.toElement();
293 historyList.append( mne.text() );
299 const QDomElement dateElement = metadataElement.firstChildElement( QStringLiteral(
"dates" ) );
300 if ( !dateElement.isNull() )
302 const QDomNodeList dateNodeList = dateElement.elementsByTagName( QStringLiteral(
"date" ) );
303 const QMetaEnum dateEnum = QMetaEnum::fromType<Qgis::MetadataDateType>();
304 for (
int i = 0; i < dateNodeList.size(); i++ )
306 const QDomElement dateElement = dateNodeList.at( i ).toElement();
308 const QDateTime value = QDateTime::fromString( dateElement.attribute( QStringLiteral(
"value" ) ), Qt::ISODate );
309 if ( value.isValid() && !value.isNull() )
321 QDomElement
identifier = document.createElement( QStringLiteral(
"identifier" ) );
322 const QDomText identifierText = document.createTextNode(
mIdentifier );
327 QDomElement
parentIdentifier = document.createElement( QStringLiteral(
"parentidentifier" ) );
328 const QDomText parentIdentifierText = document.createTextNode(
mParentIdentifier );
333 QDomElement
language = document.createElement( QStringLiteral(
"language" ) );
334 const QDomText languageText = document.createTextNode(
mLanguage );
335 language.appendChild( languageText );
336 metadataElement.appendChild(
language );
339 QDomElement
type = document.createElement( QStringLiteral(
"type" ) );
340 const QDomText typeText = document.createTextNode(
mType );
341 type.appendChild( typeText );
342 metadataElement.appendChild(
type );
345 QDomElement
title = document.createElement( QStringLiteral(
"title" ) );
346 const QDomText titleText = document.createTextNode(
mTitle );
347 title.appendChild( titleText );
348 metadataElement.appendChild(
title );
351 QDomElement
abstract = document.createElement( QStringLiteral(
"abstract" ) );
352 const QDomText abstractText = document.createTextNode(
mAbstract );
353 abstract.appendChild( abstractText );
354 metadataElement.appendChild(
abstract );
357 QMapIterator<QString, QStringList> i(
mKeywords );
358 while ( i.hasNext() )
361 QDomElement keywordsElement = document.createElement( QStringLiteral(
"keywords" ) );
362 keywordsElement.setAttribute( QStringLiteral(
"vocabulary" ), i.key() );
363 const QStringList values = i.value();
364 for (
const QString &kw : values )
366 QDomElement keyword = document.createElement( QStringLiteral(
"keyword" ) );
367 const QDomText keywordText = document.createTextNode( kw );
368 keyword.appendChild( keywordText );
369 keywordsElement.appendChild( keyword );
371 metadataElement.appendChild( keywordsElement );
377 QDomElement contactElement = document.createElement( QStringLiteral(
"contact" ) );
378 QDomElement nameElement = document.createElement( QStringLiteral(
"name" ) );
379 QDomElement organizationElement = document.createElement( QStringLiteral(
"organization" ) );
380 QDomElement positionElement = document.createElement( QStringLiteral(
"position" ) );
381 QDomElement voiceElement = document.createElement( QStringLiteral(
"voice" ) );
382 QDomElement faxElement = document.createElement( QStringLiteral(
"fax" ) );
383 QDomElement emailElement = document.createElement( QStringLiteral(
"email" ) );
384 QDomElement roleElement = document.createElement( QStringLiteral(
"role" ) );
386 const QDomText nameText = document.createTextNode( contact.name );
387 const QDomText orgaText = document.createTextNode( contact.organization );
388 const QDomText positionText = document.createTextNode( contact.position );
389 const QDomText voiceText = document.createTextNode( contact.voice );
390 const QDomText faxText = document.createTextNode( contact.fax );
391 const QDomText emailText = document.createTextNode( contact.email );
392 const QDomText roleText = document.createTextNode( contact.role );
396 QDomElement addressElement = document.createElement( QStringLiteral(
"contactAddress" ) );
397 QDomElement typeElement = document.createElement( QStringLiteral(
"type" ) );
398 QDomElement addressDetailedElement = document.createElement( QStringLiteral(
"address" ) );
399 QDomElement cityElement = document.createElement( QStringLiteral(
"city" ) );
400 QDomElement administrativeAreaElement = document.createElement( QStringLiteral(
"administrativearea" ) );
401 QDomElement postalCodeElement = document.createElement( QStringLiteral(
"postalcode" ) );
402 QDomElement countryElement = document.createElement( QStringLiteral(
"country" ) );
404 typeElement.appendChild( document.createTextNode( oneAddress.
type ) );
405 addressDetailedElement.appendChild( document.createTextNode( oneAddress.
address ) );
406 cityElement.appendChild( document.createTextNode( oneAddress.
city ) );
407 administrativeAreaElement.appendChild( document.createTextNode( oneAddress.
administrativeArea ) );
408 postalCodeElement.appendChild( document.createTextNode( oneAddress.
postalCode ) );
409 countryElement.appendChild( document.createTextNode( oneAddress.
country ) );
411 addressElement.appendChild( typeElement );
412 addressElement.appendChild( addressDetailedElement );
413 addressElement.appendChild( cityElement );
414 addressElement.appendChild( administrativeAreaElement );
415 addressElement.appendChild( postalCodeElement );
416 addressElement.appendChild( countryElement );
417 contactElement.appendChild( addressElement );
420 nameElement.appendChild( nameText );
421 organizationElement.appendChild( orgaText );
422 positionElement.appendChild( positionText );
423 voiceElement.appendChild( voiceText );
424 faxElement.appendChild( faxText );
425 emailElement.appendChild( emailText );
426 roleElement.appendChild( roleText );
428 contactElement.appendChild( nameElement );
429 contactElement.appendChild( organizationElement );
430 contactElement.appendChild( positionElement );
431 contactElement.appendChild( voiceElement );
432 contactElement.appendChild( faxElement );
433 contactElement.appendChild( emailElement );
434 contactElement.appendChild( roleElement );
435 metadataElement.appendChild( contactElement );
439 QDomElement
links = document.createElement( QStringLiteral(
"links" ) );
442 QDomElement linkElement = document.createElement( QStringLiteral(
"link" ) );
443 linkElement.setAttribute( QStringLiteral(
"name" ), link.name );
444 linkElement.setAttribute( QStringLiteral(
"type" ), link.type );
445 linkElement.setAttribute( QStringLiteral(
"url" ), link.url );
446 linkElement.setAttribute( QStringLiteral(
"description" ), link.description );
447 linkElement.setAttribute( QStringLiteral(
"format" ), link.format );
448 linkElement.setAttribute( QStringLiteral(
"mimeType" ), link.mimeType );
449 linkElement.setAttribute( QStringLiteral(
"size" ), link.size );
450 links.appendChild( linkElement );
452 metadataElement.appendChild(
links );
457 QDomElement historyElement = document.createElement( QStringLiteral(
"history" ) );
458 const QDomText historyText = document.createTextNode(
history );
459 historyElement.appendChild( historyText );
460 metadataElement.appendChild( historyElement );
465 const QMetaEnum dateEnum = QMetaEnum::fromType<Qgis::MetadataDateType>();
466 QDomElement datesElement = document.createElement( QStringLiteral(
"dates" ) );
467 for (
int k = 0; k < dateEnum.keyCount(); k++ )
472 QDomElement dateElement = document.createElement( QStringLiteral(
"date" ) );
473 dateElement.setAttribute( QStringLiteral(
"type" ), dateEnum.valueToKey(
static_cast< int >(
type ) ) );
474 dateElement.setAttribute( QStringLiteral(
"value" ),
mDates.value(
type ).toString( Qt::ISODate ) );
475 datesElement.appendChild( dateElement );
478 metadataElement.appendChild( datesElement );
498 if ( !other->
type().isEmpty() )
501 if ( !other->
title().isEmpty() )
507 if ( !other->
history().isEmpty() )
516 if ( !other->
links().isEmpty() )
519 const QMetaEnum dateEnum = QMetaEnum::fromType<Qgis::MetadataDateType>();
520 for (
int k = 0; k < dateEnum.keyCount(); k++ )
561 return name == other.
name &&
574 city == other.
city &&
MetadataDateType
Date types for metadata.