QGIS API Documentation 4.1.0-Master (60fea48833c)
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#ifdef SIP_RUN
64 if ( dynamic_cast< QgsLayerMetadata * >( sipCpp ) != NULL )
65 sipType = sipType_QgsLayerMetadata;
66 else if ( dynamic_cast< QgsProjectMetadata * >( sipCpp ) != NULL )
67 sipType = sipType_QgsProjectMetadata;
68 else
69 sipType = NULL;
71#endif
72
73 public:
74
75 // NOTE - these really belong in a separate namespace, but SIP says no, I want to make you waste more time
76 // TODO: dump sip
77
81 typedef QMap< QString, QStringList > KeywordMap;
82
88 struct CORE_EXPORT Address
89 {
94 const QString &type = QString(),
95 const QString &address = QString(),
96 const QString &city = QString(),
97 const QString &administrativeArea = QString(),
98 const QString &postalCode = QString(),
99 const QString &country = QString()
100 )
101 : type( type )
102 , address( address )
103 , city( city )
106 , country( country )
107 {}
108
112 QString type;
113
117 QString address;
118
122 QString city;
123
128
132 QString postalCode;
133
137 QString country;
138
139 // TODO c++20 - replace with = default
140 bool operator==( const QgsAbstractMetadataBase::Address &other ) const;
141 };
142
148 struct CORE_EXPORT Contact
149 {
153 Contact( const QString &name = QString() )
154 : name( name )
155 {}
156
160 QString name;
161
166
170 QString position;
171
175 QList< QgsAbstractMetadataBase::Address > addresses;
176
180 QString voice;
181
185 QString fax;
186
191 QString email;
192
198 QString role;
199
200 // TODO c++20 - replace with = default
201 bool operator==( const QgsAbstractMetadataBase::Contact &other ) const;
202 };
203
209 typedef QList< QgsAbstractMetadataBase::Contact > ContactList;
210
211
217 struct CORE_EXPORT Link
218 {
222 Link( const QString &name = QString(), const QString &type = QString(), const QString &url = QString() )
223 : name( name )
224 , type( type )
225 , url( url )
226 {}
227
231 QString name;
232
237 QString type;
238
242 QString description;
243
247 QString url;
248
252 QString format;
253
257 QString mimeType;
258
262 QString size;
263
264 // TODO c++20 - replace with = default
265 bool operator==( const QgsAbstractMetadataBase::Link &other ) const;
266 };
267
273 typedef QList< QgsAbstractMetadataBase::Link > LinkList;
274
275 virtual ~QgsAbstractMetadataBase() = default;
276
282
287 QString identifier() const;
288
293 void setIdentifier( const QString &identifier );
294
300 QString parentIdentifier() const;
301
307 void setParentIdentifier( const QString &parentIdentifier );
308
316 QString language() const;
317
324 void setLanguage( const QString &language );
325
331 QString type() const;
332
338 void setType( const QString &type );
339
344 QString title() const;
345
350 void setTitle( const QString &title );
351
356 QString abstract() const;
357
362 void setAbstract( const QString &abstract );
363
368 QStringList history() const;
369
376 void setHistory( const QStringList &history );
377
383 void addHistoryItem( const QString &text );
384
397
411
422 void addKeywords( const QString &vocabulary, const QStringList &keywords );
423
430 bool removeKeywords( const QString &vocabulary );
431
440 QStringList keywordVocabularies() const;
441
452 QStringList keywords( const QString &vocabulary ) const;
453
460 QStringList categories() const;
461
468 void setCategories( const QStringList &categories );
469
475
483
489 void addContact( const QgsAbstractMetadataBase::Contact &contact );
490
496
504
510 void addLink( const QgsAbstractMetadataBase::Link &link );
511
518 QDateTime dateTime( Qgis::MetadataDateType type ) const;
519
526 void setDateTime( Qgis::MetadataDateType type, QDateTime date );
527
539 virtual bool readMetadataXml( const QDomElement &metadataElement, const QgsReadWriteContext &context = QgsReadWriteContext() );
540
553 virtual bool writeMetadataXml( QDomElement &metadataElement, QDomDocument &document, const QgsReadWriteContext &context = QgsReadWriteContext() ) const;
554
562 virtual void combine( const QgsAbstractMetadataBase *other );
563
569 virtual void registerTranslations( QgsTranslationContext *translationContext ) const;
570
571 protected:
578
579 /*
580 * IMPORTANT!!!!!!
581 *
582 * Do NOT add anything to this class without also updating the schema
583 * definition located at resources/qgis-resource-metadata.xsd
584 *
585 */
586
587 QString mIdentifier;
589 QString mLanguage;
590 QString mType;
591 QString mTitle;
592 QString mAbstract;
593 QStringList mHistory;
594
595 // IMPORTANT - look up before adding anything here!!
596
601
603
605
607 QMap< Qgis::MetadataDateType, QDateTime > mDates;
608
609 /*
610 * IMPORTANT!!!!!!
611 *
612 * Do NOT add anything to this class without also updating the schema
613 * definition located at resources/qgis-resource-metadata.xsd
614 *
615 */
616
617
626 bool equals( const QgsAbstractMetadataBase &other ) const;
627};
628
632
633#endif // QGSABSTRACTMETADATABASE_H
MetadataDateType
Date types for metadata.
Definition qgis.h:4850
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:198
#define SIP_FACTORY
Definition qgis_sip.h:83
#define SIP_END
Definition qgis_sip.h:215
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.