QGIS API Documentation  3.20.0-Odense (decaadbb31)
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 
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 
534  virtual void combine( const QgsAbstractMetadataBase *other );
535 
536  protected:
537 
544 
545  /*
546  * IMPORTANT!!!!!!
547  *
548  * Do NOT add anything to this class without also updating the schema
549  * definition located at resources/qgis-resource-metadata.xsd
550  *
551  */
552 
553  QString mIdentifier;
555  QString mLanguage;
556  QString mType;
557  QString mTitle;
558  QString mAbstract;
559  QStringList mHistory;
560 
561  // IMPORTANT - look up before adding anything here!!
562 
567 
569 
571 
572  /*
573  * IMPORTANT!!!!!!
574  *
575  * Do NOT add anything to this class without also updating the schema
576  * definition located at resources/qgis-resource-metadata.xsd
577  *
578  */
579 
580 
589  bool equals( const QgsAbstractMetadataBase &other ) const;
590 
591 };
592 
596 
597 #endif // QGSABSTRACTMETADATABASE_H
An abstract base class for metadata stores.
QgsAbstractMetadataBase::ContactList mContacts
QMap< QString, QStringList > KeywordMap
Map of vocabulary string to keyword list.
virtual QgsAbstractMetadataBase * clone() const =0
Clones the metadata object.
QgsAbstractMetadataBase::KeywordMap mKeywords
Keywords map.
virtual ~QgsAbstractMetadataBase()=default
QgsAbstractMetadataBase::LinkList mLinks
QgsAbstractMetadataBase()=default
Constructor for QgsAbstractMetadataBase.
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:177
#define SIP_FACTORY
Definition: qgis_sip.h:76
#define SIP_END
Definition: qgis_sip.h:194
bool operator==(const QgsFeatureIterator &fi1, const QgsFeatureIterator &fi2)
Q_DECLARE_METATYPE(QgsMeshTimeSettings)
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.