QGIS API Documentation  3.22.4-Białowieża (ce8e65e95e)
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  // TODO c++20 - replace with = default
131  bool operator==( const QgsAbstractMetadataBase::Address &other ) const;
132  };
133 
139  struct CORE_EXPORT Contact
140  {
141 
145  Contact( const QString &name = QString() )
146  : name( name )
147  {}
148 
152  QString name;
153 
157  QString organization;
158 
162  QString position;
163 
167  QList< QgsAbstractMetadataBase::Address > addresses;
168 
172  QString voice;
173 
177  QString fax;
178 
183  QString email;
184 
190  QString role;
191 
192  // TODO c++20 - replace with = default
193  bool operator==( const QgsAbstractMetadataBase::Contact &other ) const;
194  };
195 
201  typedef QList< QgsAbstractMetadataBase::Contact > ContactList;
202 
203 
209  struct CORE_EXPORT Link
210  {
211 
215  Link( const QString &name = QString(), const QString &type = QString(), const QString &url = QString() )
216  : name( name )
217  , type( type )
218  , url( url )
219  {}
220 
224  QString name;
225 
230  QString type;
231 
235  QString description;
236 
240  QString url;
241 
245  QString format;
246 
250  QString mimeType;
251 
255  QString size;
256 
257  // TODO c++20 - replace with = default
258  bool operator==( const QgsAbstractMetadataBase::Link &other ) const;
259  };
260 
266  typedef QList< QgsAbstractMetadataBase::Link > LinkList;
267 
268  virtual ~QgsAbstractMetadataBase() = default;
269 
275 
280  QString identifier() const;
281 
286  void setIdentifier( const QString &identifier );
287 
293  QString parentIdentifier() const;
294 
300  void setParentIdentifier( const QString &parentIdentifier );
301 
309  QString language() const;
310 
317  void setLanguage( const QString &language );
318 
324  QString type() const;
325 
331  void setType( const QString &type );
332 
337  QString title() const;
338 
343  void setTitle( const QString &title );
344 
349  QString abstract() const;
350 
355  void setAbstract( const QString &abstract );
356 
361  QStringList history() const;
362 
369  void setHistory( const QStringList &history );
370 
376  void addHistoryItem( const QString &text );
377 
389  QgsAbstractMetadataBase::KeywordMap keywords() const;
390 
403  void setKeywords( const QgsAbstractMetadataBase::KeywordMap &keywords );
404 
415  void addKeywords( const QString &vocabulary, const QStringList &keywords );
416 
423  bool removeKeywords( const QString &vocabulary );
424 
433  QStringList keywordVocabularies() const;
434 
445  QStringList keywords( const QString &vocabulary ) const;
446 
453  QStringList categories() const;
454 
461  void setCategories( const QStringList &categories );
462 
467  QgsAbstractMetadataBase::ContactList contacts() const;
468 
475  void setContacts( const QgsAbstractMetadataBase::ContactList &contacts );
476 
482  void addContact( const QgsAbstractMetadataBase::Contact &contact );
483 
488  QgsAbstractMetadataBase::LinkList links() const;
489 
496  void setLinks( const QgsAbstractMetadataBase::LinkList &links );
497 
503  void addLink( const QgsAbstractMetadataBase::Link &link );
504 
515  virtual bool readMetadataXml( const QDomElement &metadataElement );
516 
528  virtual bool writeMetadataXml( QDomElement &metadataElement, QDomDocument &document ) const;
529 
537  virtual void combine( const QgsAbstractMetadataBase *other );
538 
539  protected:
540 
547 
548  /*
549  * IMPORTANT!!!!!!
550  *
551  * Do NOT add anything to this class without also updating the schema
552  * definition located at resources/qgis-resource-metadata.xsd
553  *
554  */
555 
556  QString mIdentifier;
558  QString mLanguage;
559  QString mType;
560  QString mTitle;
561  QString mAbstract;
562  QStringList mHistory;
563 
564  // IMPORTANT - look up before adding anything here!!
565 
570 
572 
574 
575  /*
576  * IMPORTANT!!!!!!
577  *
578  * Do NOT add anything to this class without also updating the schema
579  * definition located at resources/qgis-resource-metadata.xsd
580  *
581  */
582 
583 
592  bool equals( const QgsAbstractMetadataBase &other ) const;
593 
594 };
595 
599 
600 #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.