QGIS API Documentation 3.30.0-'s-Hertogenbosch (f186b8efe0)
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_sip.h"
22#include "qgis_core.h"
23#include "qgis.h"
24#include <QMap>
25#include <QString>
26#include <QMetaType>
27
28class QDomElement;
29class QDomDocument;
30
57class CORE_EXPORT QgsAbstractMetadataBase
58{
59
60#ifdef SIP_RUN
62 if ( dynamic_cast< QgsLayerMetadata * >( sipCpp ) != NULL )
63 sipType = sipType_QgsLayerMetadata;
64 else if ( dynamic_cast< QgsProjectMetadata * >( sipCpp ) != NULL )
65 sipType = sipType_QgsProjectMetadata;
66 else
67 sipType = NULL;
69#endif
70
71 public:
72
73 // NOTE - these really belong in a separate namespace, but SIP says no, I want to make you waste more time
74 // TODO: dump sip
75
79 typedef QMap< QString, QStringList > KeywordMap;
80
86 struct CORE_EXPORT Address
87 {
88
92 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() )
93 : type( type )
94 , address( address )
95 , city( city )
96 , administrativeArea( administrativeArea )
97 , postalCode( postalCode )
98 , country( country )
99 {}
100
104 QString type;
105
109 QString address;
110
114 QString city;
115
120
124 QString postalCode;
125
129 QString country;
130
131 // TODO c++20 - replace with = default
132 bool operator==( const QgsAbstractMetadataBase::Address &other ) const;
133 };
134
140 struct CORE_EXPORT Contact
141 {
142
146 Contact( const QString &name = QString() )
147 : name( name )
148 {}
149
153 QString name;
154
159
163 QString position;
164
168 QList< QgsAbstractMetadataBase::Address > addresses;
169
173 QString voice;
174
178 QString fax;
179
184 QString email;
185
191 QString role;
192
193 // TODO c++20 - replace with = default
194 bool operator==( const QgsAbstractMetadataBase::Contact &other ) const;
195 };
196
202 typedef QList< QgsAbstractMetadataBase::Contact > ContactList;
203
204
210 struct CORE_EXPORT Link
211 {
212
216 Link( const QString &name = QString(), const QString &type = QString(), const QString &url = QString() )
217 : name( name )
218 , type( type )
219 , url( url )
220 {}
221
225 QString name;
226
231 QString type;
232
236 QString description;
237
241 QString url;
242
246 QString format;
247
251 QString mimeType;
252
256 QString size;
257
258 // TODO c++20 - replace with = default
259 bool operator==( const QgsAbstractMetadataBase::Link &other ) const;
260 };
261
267 typedef QList< QgsAbstractMetadataBase::Link > LinkList;
268
269 virtual ~QgsAbstractMetadataBase() = default;
270
276
281 QString identifier() const;
282
287 void setIdentifier( const QString &identifier );
288
294 QString parentIdentifier() const;
295
301 void setParentIdentifier( const QString &parentIdentifier );
302
310 QString language() const;
311
318 void setLanguage( const QString &language );
319
325 QString type() const;
326
332 void setType( const QString &type );
333
338 QString title() const;
339
344 void setTitle( const QString &title );
345
350 QString abstract() const;
351
356 void setAbstract( const QString &abstract );
357
362 QStringList history() const;
363
370 void setHistory( const QStringList &history );
371
377 void addHistoryItem( const QString &text );
378
391
404 void setKeywords( const QgsAbstractMetadataBase::KeywordMap &keywords );
405
416 void addKeywords( const QString &vocabulary, const QStringList &keywords );
417
424 bool removeKeywords( const QString &vocabulary );
425
434 QStringList keywordVocabularies() const;
435
446 QStringList keywords( const QString &vocabulary ) const;
447
454 QStringList categories() const;
455
462 void setCategories( const QStringList &categories );
463
469
476 void setContacts( const QgsAbstractMetadataBase::ContactList &contacts );
477
483 void addContact( const QgsAbstractMetadataBase::Contact &contact );
484
490
497 void setLinks( const QgsAbstractMetadataBase::LinkList &links );
498
504 void addLink( const QgsAbstractMetadataBase::Link &link );
505
512 QDateTime dateTime( Qgis::MetadataDateType type ) const;
513
520 void setDateTime( Qgis::MetadataDateType type, QDateTime date );
521
532 virtual bool readMetadataXml( const QDomElement &metadataElement );
533
545 virtual bool writeMetadataXml( QDomElement &metadataElement, QDomDocument &document ) const;
546
554 virtual void combine( const QgsAbstractMetadataBase *other );
555
556 protected:
557
564
565 /*
566 * IMPORTANT!!!!!!
567 *
568 * Do NOT add anything to this class without also updating the schema
569 * definition located at resources/qgis-resource-metadata.xsd
570 *
571 */
572
573 QString mIdentifier;
575 QString mLanguage;
576 QString mType;
577 QString mTitle;
578 QString mAbstract;
579 QStringList mHistory;
580
581 // IMPORTANT - look up before adding anything here!!
582
587
589
591
593 QMap< Qgis::MetadataDateType, QDateTime > mDates;
594
595 /*
596 * IMPORTANT!!!!!!
597 *
598 * Do NOT add anything to this class without also updating the schema
599 * definition located at resources/qgis-resource-metadata.xsd
600 *
601 */
602
603
612 bool equals( const QgsAbstractMetadataBase &other ) const;
613
614};
615
619
620#endif // QGSABSTRACTMETADATABASE_H
MetadataDateType
Date types for metadata.
Definition: qgis.h:2831
An abstract base class for metadata stores.
QgsAbstractMetadataBase::ContactList mContacts
QMap< QString, QStringList > KeywordMap
Map of vocabulary string to keyword list.
QMap< Qgis::MetadataDateType, QDateTime > mDates
Metadata dates.
QgsAbstractMetadataBase::KeywordMap mKeywords
Keywords map.
virtual ~QgsAbstractMetadataBase()=default
QgsAbstractMetadataBase::LinkList mLinks
QgsAbstractMetadataBase()=default
Constructor for QgsAbstractMetadataBase.
virtual QgsAbstractMetadataBase * clone() const =0
Clones the metadata object.
A structured metadata store for a map layer.
A structured metadata store for a map layer.
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:186
#define SIP_FACTORY
Definition: qgis_sip.h:76
#define SIP_END
Definition: qgis_sip.h:203
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 type
Type of address, e.g.
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.