QGIS API Documentation  3.14.0-Pi (9f7028fd23)
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 <QMap>
24 #include <QString>
25 #include <QMetaType>
26 
27 class QDomElement;
28 class QDomDocument;
29 
56 class CORE_EXPORT QgsAbstractMetadataBase
57 {
58 
59 #ifdef SIP_RUN
61  if ( dynamic_cast< QgsLayerMetadata * >( sipCpp ) != NULL )
62  sipType = sipType_QgsLayerMetadata;
63  else if ( dynamic_cast< QgsProjectMetadata * >( sipCpp ) != NULL )
64  sipType = sipType_QgsProjectMetadata;
65  else
66  sipType = NULL;
67  SIP_END
68 #endif
69 
70  public:
71 
72  // NOTE - these really belong in a separate namespace, but SIP says no, I want to make you waste more time
73  // TODO: dump sip
74 
78  typedef QMap< QString, QStringList > KeywordMap;
79 
85  struct CORE_EXPORT Address
86  {
87 
91  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() )
92  : type( type )
93  , address( address )
94  , city( city )
95  , administrativeArea( administrativeArea )
96  , postalCode( postalCode )
97  , country( country )
98  {}
99 
103  QString type;
104 
108  QString address;
109 
113  QString city;
114 
119 
123  QString postalCode;
124 
128  QString country;
129 
130  bool operator==( const QgsAbstractMetadataBase::Address &other ) const;
131  };
132 
138  struct CORE_EXPORT Contact
139  {
140 
144  Contact( const QString &name = QString() )
145  : name( name )
146  {}
147 
151  QString name;
152 
156  QString organization;
157 
161  QString position;
162 
166  QList< QgsAbstractMetadataBase::Address > addresses;
167 
171  QString voice;
172 
176  QString fax;
177 
182  QString email;
183 
189  QString role;
190 
191  bool operator==( const QgsAbstractMetadataBase::Contact &other ) const;
192  };
193 
199  typedef QList< QgsAbstractMetadataBase::Contact > ContactList;
200 
201 
207  struct CORE_EXPORT Link
208  {
209 
213  Link( const QString &name = QString(), const QString &type = QString(), const QString &url = QString() )
214  : name( name )
215  , type( type )
216  , url( url )
217  {}
218 
222  QString name;
223 
228  QString type;
229 
233  QString description;
234 
238  QString url;
239 
243  QString format;
244 
248  QString mimeType;
249 
253  QString size;
254 
255  bool operator==( const QgsAbstractMetadataBase::Link &other ) const;
256  };
257 
263  typedef QList< QgsAbstractMetadataBase::Link > LinkList;
264 
265  virtual ~QgsAbstractMetadataBase() = default;
266 
271  virtual QgsAbstractMetadataBase *clone() const = 0 SIP_FACTORY;
272 
277  QString identifier() const;
278 
283  void setIdentifier( const QString &identifier );
284 
290  QString parentIdentifier() const;
291 
297  void setParentIdentifier( const QString &parentIdentifier );
298 
306  QString language() const;
307 
314  void setLanguage( const QString &language );
315 
321  QString type() const;
322 
328  void setType( const QString &type );
329 
334  QString title() const;
335 
340  void setTitle( const QString &title );
341 
346  QString abstract() const;
347 
352  void setAbstract( const QString &abstract );
353 
358  QStringList history() const;
359 
366  void setHistory( const QStringList &history );
367 
373  void addHistoryItem( const QString &text );
374 
386  QgsAbstractMetadataBase::KeywordMap keywords() const;
387 
400  void setKeywords( const QgsAbstractMetadataBase::KeywordMap &keywords );
401 
412  void addKeywords( const QString &vocabulary, const QStringList &keywords );
413 
420  bool removeKeywords( const QString &vocabulary );
421 
430  QStringList keywordVocabularies() const;
431 
442  QStringList keywords( const QString &vocabulary ) const;
443 
450  QStringList categories() const;
451 
458  void setCategories( const QStringList &categories );
459 
464  QgsAbstractMetadataBase::ContactList contacts() const;
465 
472  void setContacts( const QgsAbstractMetadataBase::ContactList &contacts );
473 
479  void addContact( const QgsAbstractMetadataBase::Contact &contact );
480 
485  QgsAbstractMetadataBase::LinkList links() const;
486 
493  void setLinks( const QgsAbstractMetadataBase::LinkList &links );
494 
500  void addLink( const QgsAbstractMetadataBase::Link &link );
501 
512  virtual bool readMetadataXml( const QDomElement &metadataElement );
513 
525  virtual bool writeMetadataXml( QDomElement &metadataElement, QDomDocument &document ) const;
526 
527  protected:
528 
534  QgsAbstractMetadataBase() = default;
535 
536  /*
537  * IMPORTANT!!!!!!
538  *
539  * Do NOT add anything to this class without also updating the schema
540  * definition located at resources/qgis-resource-metadata.xsd
541  *
542  */
543 
544  QString mIdentifier;
546  QString mLanguage;
547  QString mType;
548  QString mTitle;
549  QString mAbstract;
550  QStringList mHistory;
551 
552  // IMPORTANT - look up before adding anything here!!
553 
558 
560 
562 
563  /*
564  * IMPORTANT!!!!!!
565  *
566  * Do NOT add anything to this class without also updating the schema
567  * definition located at resources/qgis-resource-metadata.xsd
568  *
569  */
570 
571 
580  bool equals( const QgsAbstractMetadataBase &other ) const;
581 
582 };
583 
587 
588 #endif // QGSABSTRACTMETADATABASE_H
QgsAbstractMetadataBase::Contact::name
QString name
Name of contact.
Definition: qgsabstractmetadatabase.h:151
QgsProjectMetadata
A structured metadata store for a map layer.
Definition: qgsprojectmetadata.h:53
operator==
bool operator==(const QgsFeatureIterator &fi1, const QgsFeatureIterator &fi2)
Definition: qgsfeatureiterator.h:399
QgsAbstractMetadataBase::Contact::addresses
QList< QgsAbstractMetadataBase::Address > addresses
List of addresses associated with this contact.
Definition: qgsabstractmetadatabase.h:166
QgsAbstractMetadataBase::Contact::fax
QString fax
Facsimile telephone.
Definition: qgsabstractmetadatabase.h:176
QgsAbstractMetadataBase::mHistory
QStringList mHistory
Definition: qgsabstractmetadatabase.h:550
QgsAbstractMetadataBase::Address::city
QString city
City or locality name.
Definition: qgsabstractmetadatabase.h:113
QgsLayerMetadata
A structured metadata store for a map layer.
Definition: qgslayermetadata.h:56
QgsAbstractMetadataBase::mIdentifier
QString mIdentifier
Definition: qgsabstractmetadatabase.h:544
QgsAbstractMetadataBase::Address::country
QString country
Free-form country string.
Definition: qgsabstractmetadatabase.h:128
QgsAbstractMetadataBase::mLanguage
QString mLanguage
Definition: qgsabstractmetadatabase.h:546
QgsAbstractMetadataBase::mTitle
QString mTitle
Definition: qgsabstractmetadatabase.h:548
QgsAbstractMetadataBase::Contact::voice
QString voice
Voice telephone.
Definition: qgsabstractmetadatabase.h:171
QgsAbstractMetadataBase::mLinks
QgsAbstractMetadataBase::LinkList mLinks
Definition: qgsabstractmetadatabase.h:561
SIP_FACTORY
#define SIP_FACTORY
Definition: qgis_sip.h:76
Q_DECLARE_METATYPE
Q_DECLARE_METATYPE(QgsMeshTimeSettings)
SIP_CONVERT_TO_SUBCLASS_CODE
#define SIP_CONVERT_TO_SUBCLASS_CODE(code)
Definition: qgis_sip.h:172
QgsAbstractMetadataBase::Address::administrativeArea
QString administrativeArea
Administrative area (state, province/territory, etc.).
Definition: qgsabstractmetadatabase.h:118
qgis_sip.h
QgsAbstractMetadataBase::Address::postalCode
QString postalCode
Postal (or ZIP) code.
Definition: qgsabstractmetadatabase.h:123
QgsAbstractMetadataBase::Address
Metadata address structure.
Definition: qgsabstractmetadatabase.h:85
QgsAbstractMetadataBase::ContactList
QList< QgsAbstractMetadataBase::Contact > ContactList
A list of contacts.
Definition: qgsabstractmetadatabase.h:199
QgsAbstractMetadataBase::mKeywords
QgsAbstractMetadataBase::KeywordMap mKeywords
Keywords map.
Definition: qgsabstractmetadatabase.h:557
QgsAbstractMetadataBase::Contact::role
QString role
Role of contact.
Definition: qgsabstractmetadatabase.h:189
QgsAbstractMetadataBase::Address::type
QString type
Type of address, e.g.
Definition: qgsabstractmetadatabase.h:103
QgsAbstractMetadataBase::mAbstract
QString mAbstract
Definition: qgsabstractmetadatabase.h:549
QgsAbstractMetadataBase::Address::address
QString address
Free-form physical address component, e.g.
Definition: qgsabstractmetadatabase.h:108
QgsAbstractMetadataBase::Contact::position
QString position
Position/title of contact.
Definition: qgsabstractmetadatabase.h:161
QgsAbstractMetadataBase::Contact::organization
QString organization
Organization contact belongs to/represents.
Definition: qgsabstractmetadatabase.h:156
QgsAbstractMetadataBase::KeywordMap
QMap< QString, QStringList > KeywordMap
Map of vocabulary string to keyword list.
Definition: qgsabstractmetadatabase.h:78
QgsAbstractMetadataBase::Contact
Metadata contact structure.
Definition: qgsabstractmetadatabase.h:138
QgsAbstractMetadataBase::mType
QString mType
Definition: qgsabstractmetadatabase.h:547
QgsAbstractMetadataBase::mParentIdentifier
QString mParentIdentifier
Definition: qgsabstractmetadatabase.h:545
QgsAbstractMetadataBase::Contact::Contact
Contact(const QString &name=QString())
Constructor for Contact.
Definition: qgsabstractmetadatabase.h:144
QgsAbstractMetadataBase::Address::Address
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.
Definition: qgsabstractmetadatabase.h:91
QgsAbstractMetadataBase
An abstract base class for metadata stores.
Definition: qgsabstractmetadatabase.h:56
SIP_END
#define SIP_END
Definition: qgis_sip.h:189
QgsAbstractMetadataBase::LinkList
QList< QgsAbstractMetadataBase::Link > LinkList
A list of links.
Definition: qgsabstractmetadatabase.h:263
QgsAbstractMetadataBase::mContacts
QgsAbstractMetadataBase::ContactList mContacts
Definition: qgsabstractmetadatabase.h:559
QgsAbstractMetadataBase::Contact::email
QString email
Electronic mail address.
Definition: qgsabstractmetadatabase.h:182