QGIS API Documentation  3.26.3-Buenos Aires (65e4edfdad)
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 
274  virtual QgsAbstractMetadataBase *clone() const = 0 SIP_FACTORY;
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 
546  QgsAbstractMetadataBase() = default;
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
QgsAbstractMetadataBase::Contact::name
QString name
Name of contact.
Definition: qgsabstractmetadatabase.h:152
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:425
QgsAbstractMetadataBase::Contact::addresses
QList< QgsAbstractMetadataBase::Address > addresses
List of addresses associated with this contact.
Definition: qgsabstractmetadatabase.h:167
QgsAbstractMetadataBase::Contact::fax
QString fax
Facsimile telephone.
Definition: qgsabstractmetadatabase.h:177
QgsAbstractMetadataBase::mHistory
QStringList mHistory
Definition: qgsabstractmetadatabase.h:562
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:556
QgsAbstractMetadataBase::Address::country
QString country
Free-form country string.
Definition: qgsabstractmetadatabase.h:128
QgsAbstractMetadataBase::mLanguage
QString mLanguage
Definition: qgsabstractmetadatabase.h:558
QgsAbstractMetadataBase::mTitle
QString mTitle
Definition: qgsabstractmetadatabase.h:560
QgsAbstractMetadataBase::Contact::voice
QString voice
Voice telephone.
Definition: qgsabstractmetadatabase.h:172
QgsAbstractMetadataBase::mLinks
QgsAbstractMetadataBase::LinkList mLinks
Definition: qgsabstractmetadatabase.h:573
SIP_FACTORY
#define SIP_FACTORY
Definition: qgis_sip.h:76
SIP_CONVERT_TO_SUBCLASS_CODE
#define SIP_CONVERT_TO_SUBCLASS_CODE(code)
Definition: qgis_sip.h:186
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:201
QgsAbstractMetadataBase::mKeywords
QgsAbstractMetadataBase::KeywordMap mKeywords
Keywords map.
Definition: qgsabstractmetadatabase.h:569
QgsAbstractMetadataBase::Contact::role
QString role
Role of contact.
Definition: qgsabstractmetadatabase.h:190
QgsAbstractMetadataBase::Address::type
QString type
Type of address, e.g.
Definition: qgsabstractmetadatabase.h:103
QgsAbstractMetadataBase::mAbstract
QString mAbstract
Definition: qgsabstractmetadatabase.h:561
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:162
QgsAbstractMetadataBase::Contact::organization
QString organization
Organization contact belongs to/represents.
Definition: qgsabstractmetadatabase.h:157
Q_DECLARE_METATYPE
Q_DECLARE_METATYPE(QgsDatabaseQueryLogEntry)
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:139
QgsAbstractMetadataBase::mType
QString mType
Definition: qgsabstractmetadatabase.h:559
QgsAbstractMetadataBase::mParentIdentifier
QString mParentIdentifier
Definition: qgsabstractmetadatabase.h:557
QgsAbstractMetadataBase::Contact::Contact
Contact(const QString &name=QString())
Constructor for Contact.
Definition: qgsabstractmetadatabase.h:145
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:203
QgsAbstractMetadataBase::LinkList
QList< QgsAbstractMetadataBase::Link > LinkList
A list of links.
Definition: qgsabstractmetadatabase.h:266
QgsAbstractMetadataBase::mContacts
QgsAbstractMetadataBase::ContactList mContacts
Definition: qgsabstractmetadatabase.h:571
QgsAbstractMetadataBase::Contact::email
QString email
Electronic mail address.
Definition: qgsabstractmetadatabase.h:183