QGIS API Documentation  3.17.0-Master (7a14973234)
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
QList< QgsAbstractMetadataBase::Address > addresses
List of addresses associated with this contact.
QString fax
Facsimile telephone.
QList< QgsAbstractMetadataBase::Link > LinkList
A list of links.
QString city
City or locality name.
QgsAbstractMetadataBase::ContactList mContacts
bool operator==(const QgsFeatureIterator &fi1, const QgsFeatureIterator &fi2)
QString country
Free-form country string.
QgsAbstractMetadataBase::LinkList mLinks
QList< QgsAbstractMetadataBase::Contact > ContactList
A list of contacts.
Metadata address structure.
QString administrativeArea
Administrative area (state, province/territory, etc.).
#define SIP_END
Definition: qgis_sip.h:194
Q_DECLARE_METATYPE(QgsMeshTimeSettings)
#define SIP_FACTORY
Definition: qgis_sip.h:76
QString postalCode
Postal (or ZIP) code.
QgsAbstractMetadataBase::KeywordMap mKeywords
Keywords map.
QString type
Type of address, e.g.
QString position
Position/title of contact.
QString address
Free-form physical address component, e.g.
QMap< QString, QStringList > KeywordMap
Map of vocabulary string to keyword list.
#define SIP_CONVERT_TO_SUBCLASS_CODE(code)
Definition: qgis_sip.h:177
An abstract base class for metadata stores.
QString organization
Organization contact belongs to/represents.
Contact(const QString &name=QString())
Constructor for Contact.
QString email
Electronic mail 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.