QGIS API Documentation 3.99.0-Master (2fe06baccd8)
Loading...
Searching...
No Matches
qgsabstractmetadatabase.h
Go to the documentation of this file.
1/***************************************************************************
2 QgsAbstractMetadataBase.h
3 -------------------
4 begin : March 2018
5 copyright : (C) 2018 by Nyall Dawson
6 email : nyall dot dawson at gmail dot com
7 ***************************************************************************/
8
9/***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17
18#ifndef QGSABSTRACTMETADATABASE_H
19#define QGSABSTRACTMETADATABASE_H
20
21#include "qgis.h"
22#include "qgis_core.h"
23#include "qgis_sip.h"
24#include "qgsreadwritecontext.h"
25
26#include <QMap>
27#include <QMetaType>
28#include <QString>
29
30class QDomElement;
31class QDomDocument;
33
60class CORE_EXPORT QgsAbstractMetadataBase
61{
62
63#ifdef SIP_RUN
65 if ( dynamic_cast< QgsLayerMetadata * >( sipCpp ) != NULL )
66 sipType = sipType_QgsLayerMetadata;
67 else if ( dynamic_cast< QgsProjectMetadata * >( sipCpp ) != NULL )
68 sipType = sipType_QgsProjectMetadata;
69 else
70 sipType = NULL;
72#endif
73
74 public:
75
76 // NOTE - these really belong in a separate namespace, but SIP says no, I want to make you waste more time
77 // TODO: dump sip
78
82 typedef QMap< QString, QStringList > KeywordMap;
83
89 struct CORE_EXPORT Address
90 {
91
95 Address( const QString &type = QString(), const QString &address = QString(), const QString &city = QString(), const QString &administrativeArea = QString(), const QString &postalCode = QString(), const QString &country = QString() )
96 : type( type )
97 , address( address )
98 , city( city )
101 , country( country )
102 {}
103
107 QString type;
108
112 QString address;
113
117 QString city;
118
123
127 QString postalCode;
128
132 QString country;
133
134 // TODO c++20 - replace with = default
135 bool operator==( const QgsAbstractMetadataBase::Address &other ) const;
136 };
137
143 struct CORE_EXPORT Contact
144 {
145
149 Contact( const QString &name = QString() )
150 : name( name )
151 {}
152
156 QString name;
157
162
166 QString position;
167
171 QList< QgsAbstractMetadataBase::Address > addresses;
172
176 QString voice;
177
181 QString fax;
182
187 QString email;
188
194 QString role;
195
196 // TODO c++20 - replace with = default
197 bool operator==( const QgsAbstractMetadataBase::Contact &other ) const;
198 };
199
205 typedef QList< QgsAbstractMetadataBase::Contact > ContactList;
206
207
213 struct CORE_EXPORT Link
214 {
215
219 Link( const QString &name = QString(), const QString &type = QString(), const QString &url = QString() )
220 : name( name )
221 , type( type )
222 , url( url )
223 {}
224
228 QString name;
229
234 QString type;
235
239 QString description;
240
244 QString url;
245
249 QString format;
250
254 QString mimeType;
255
259 QString size;
260
261 // TODO c++20 - replace with = default
262 bool operator==( const QgsAbstractMetadataBase::Link &other ) const;
263 };
264
270 typedef QList< QgsAbstractMetadataBase::Link > LinkList;
271
272 virtual ~QgsAbstractMetadataBase() = default;
273
279
284 QString identifier() const;
285
290 void setIdentifier( const QString &identifier );
291
297 QString parentIdentifier() const;
298
304 void setParentIdentifier( const QString &parentIdentifier );
305
313 QString language() const;
314
321 void setLanguage( const QString &language );
322
328 QString type() const;
329
335 void setType( const QString &type );
336
341 QString title() const;
342
347 void setTitle( const QString &title );
348
353 QString abstract() const;
354
359 void setAbstract( const QString &abstract );
360
365 QStringList history() const;
366
373 void setHistory( const QStringList &history );
374
380 void addHistoryItem( const QString &text );
381
394
408
419 void addKeywords( const QString &vocabulary, const QStringList &keywords );
420
427 bool removeKeywords( const QString &vocabulary );
428
437 QStringList keywordVocabularies() const;
438
449 QStringList keywords( const QString &vocabulary ) const;
450
457 QStringList categories() const;
458
465 void setCategories( const QStringList &categories );
466
472
480
486 void addContact( const QgsAbstractMetadataBase::Contact &contact );
487
493
501
507 void addLink( const QgsAbstractMetadataBase::Link &link );
508
515 QDateTime dateTime( Qgis::MetadataDateType type ) const;
516
523 void setDateTime( Qgis::MetadataDateType type, QDateTime date );
524
536 virtual bool readMetadataXml( const QDomElement &metadataElement, const QgsReadWriteContext &context = QgsReadWriteContext() );
537
550 virtual bool writeMetadataXml( QDomElement &metadataElement, QDomDocument &document, const QgsReadWriteContext &context = QgsReadWriteContext() ) const;
551
559 virtual void combine( const QgsAbstractMetadataBase *other );
560
566 virtual void registerTranslations( QgsTranslationContext *translationContext ) const;
567
568 protected:
569
576
577 /*
578 * IMPORTANT!!!!!!
579 *
580 * Do NOT add anything to this class without also updating the schema
581 * definition located at resources/qgis-resource-metadata.xsd
582 *
583 */
584
585 QString mIdentifier;
587 QString mLanguage;
588 QString mType;
589 QString mTitle;
590 QString mAbstract;
591 QStringList mHistory;
592
593 // IMPORTANT - look up before adding anything here!!
594
599
601
603
605 QMap< Qgis::MetadataDateType, QDateTime > mDates;
606
607 /*
608 * IMPORTANT!!!!!!
609 *
610 * Do NOT add anything to this class without also updating the schema
611 * definition located at resources/qgis-resource-metadata.xsd
612 *
613 */
614
615
624 bool equals( const QgsAbstractMetadataBase &other ) const;
625
626};
627
631
632#endif // QGSABSTRACTMETADATABASE_H
MetadataDateType
Date types for metadata.
Definition qgis.h:4693
QgsAbstractMetadataBase::ContactList mContacts
void setAbstract(const QString &abstract)
Sets a free-form abstract (description) of the resource.
void setType(const QString &type)
Sets the type (nature) of the resource.
void setParentIdentifier(const QString &parentIdentifier)
Sets a reference, URI, URL or some other mechanism to identify the parent resource that this resource...
QMap< QString, QStringList > KeywordMap
Map of vocabulary string to keyword list.
void addContact(const QgsAbstractMetadataBase::Contact &contact)
Adds an individual contact to the existing contacts.
void setTitle(const QString &title)
Sets the human readable title (name) of the resource, typically displayed in search results.
void setHistory(const QStringList &history)
Sets the freeform description of the history or lineage of the resource.
QgsAbstractMetadataBase::ContactList contacts() const
Returns a list of contact persons or entities associated with the resource.
virtual void combine(const QgsAbstractMetadataBase *other)
Combines the metadata from this object with the metadata from an other object.
void setLinks(const QgsAbstractMetadataBase::LinkList &links)
Sets the list of online resources associated with the resource.
void setIdentifier(const QString &identifier)
Sets the reference, URI, URL or some other mechanism to identify the resource.
QStringList categories() const
Returns categories of the resource.
QString abstract() const
Returns a free-form description of the resource.
QMap< Qgis::MetadataDateType, QDateTime > mDates
Metadata dates.
QStringList keywordVocabularies() const
Returns a list of keyword vocabularies contained in the metadata.
QString title() const
Returns the human readable name of the resource, typically displayed in search results.
virtual bool writeMetadataXml(QDomElement &metadataElement, QDomDocument &document, const QgsReadWriteContext &context=QgsReadWriteContext()) const
Stores state in a DOM node.
void setContacts(const QgsAbstractMetadataBase::ContactList &contacts)
Sets the list of contacts or entities associated with the resource.
void setKeywords(const QgsAbstractMetadataBase::KeywordMap &keywords)
Sets the keywords map, which is a set of descriptive keywords associated with the resource.
QStringList history() const
Returns a freeform description of the history or lineage of the resource.
void setDateTime(Qgis::MetadataDateType type, QDateTime date)
Sets a date value for the specified date type.
QDateTime dateTime(Qgis::MetadataDateType type) const
Returns the date for the specified date type.
QgsAbstractMetadataBase::KeywordMap mKeywords
Keywords map.
QgsAbstractMetadataBase::KeywordMap keywords() const
Returns the keywords map, which is a set of descriptive keywords associated with the resource.
bool equals(const QgsAbstractMetadataBase &other) const
Tests whether the common metadata fields in this object are equal to other.
QgsAbstractMetadataBase::LinkList links() const
Returns a list of online resources associated with the resource.
void setLanguage(const QString &language)
Sets the human language associated with the resource.
virtual void registerTranslations(QgsTranslationContext *translationContext) const
Registers metadata translation strings.
virtual ~QgsAbstractMetadataBase()=default
QString parentIdentifier() const
A reference, URI, URL or some other mechanism to identify the parent resource that this resource is a...
QString language() const
Returns the human language associated with the resource.
void addKeywords(const QString &vocabulary, const QStringList &keywords)
Adds a list of descriptive keywords for a specified vocabulary.
void addLink(const QgsAbstractMetadataBase::Link &link)
Adds an individual link to the existing links.
bool removeKeywords(const QString &vocabulary)
Remove a vocabulary from the list.
QgsAbstractMetadataBase::LinkList mLinks
QString type() const
Returns the nature of the resource.
QString identifier() const
A reference, URI, URL or some other mechanism to identify the resource.
QgsAbstractMetadataBase()=default
Constructor for QgsAbstractMetadataBase.
virtual QgsAbstractMetadataBase * clone() const =0
Clones the metadata object.
void setCategories(const QStringList &categories)
Sets categories of the resource.
virtual bool readMetadataXml(const QDomElement &metadataElement, const QgsReadWriteContext &context=QgsReadWriteContext())
Sets state from DOM document.
void addHistoryItem(const QString &text)
Adds a single history text to the end of the existing history list.
A structured metadata store for a map layer.
A structured metadata store for a project.
A container for the context for various read/write operations on objects.
Used for the collecting of strings from projects for translation and creation of ts files.
QList< QgsAbstractMetadataBase::Link > LinkList
A list of links.
QList< QgsAbstractMetadataBase::Contact > ContactList
A list of contacts.
#define SIP_CONVERT_TO_SUBCLASS_CODE(code)
Definition qgis_sip.h:199
#define SIP_FACTORY
Definition qgis_sip.h:84
#define SIP_END
Definition qgis_sip.h:216
Q_DECLARE_METATYPE(QgsDatabaseQueryLogEntry)
bool operator==(const QgsFeatureIterator &fi1, const QgsFeatureIterator &fi2)
QString administrativeArea
Administrative area (state, province/territory, etc.).
QString address
Free-form physical address component, e.g.
QString city
City or locality name.
QString country
Free-form country string.
QString postalCode
Postal (or ZIP) code.
Address(const QString &type=QString(), const QString &address=QString(), const QString &city=QString(), const QString &administrativeArea=QString(), const QString &postalCode=QString(), const QString &country=QString())
Constructor for Address.
QString position
Position/title of contact.
QList< QgsAbstractMetadataBase::Address > addresses
List of addresses associated with this contact.
QString email
Electronic mail address.
QString organization
Organization contact belongs to/represents.
Contact(const QString &name=QString())
Constructor for Contact.