QGIS API Documentation  3.2.0-Bonn (bc43194)
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.h"
22 #include "qgis_core.h"
23 
24 class QDomElement;
25 class QDomDocument;
26 
53 class CORE_EXPORT QgsAbstractMetadataBase
54 {
55 
56 #ifdef SIP_RUN
58  if ( dynamic_cast< QgsLayerMetadata * >( sipCpp ) != NULL )
59  sipType = sipType_QgsLayerMetadata;
60  else if ( dynamic_cast< QgsProjectMetadata * >( sipCpp ) != NULL )
61  sipType = sipType_QgsProjectMetadata;
62  else
63  sipType = NULL;
64  SIP_END
65 #endif
66 
67  public:
68 
69  // NOTE - these really belong in a separate namespace, but SIP says no, I want to make you waste more time
70  // TODO: dump sip
71 
75  typedef QMap< QString, QStringList > KeywordMap;
76 
82  struct CORE_EXPORT Address
83  {
84 
88  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() )
89  : type( type )
90  , address( address )
91  , city( city )
92  , administrativeArea( administrativeArea )
93  , postalCode( postalCode )
94  , country( country )
95  {}
96 
100  QString type;
101 
105  QString address;
106 
110  QString city;
111 
116 
120  QString postalCode;
121 
125  QString country;
126 
127  bool operator==( const QgsAbstractMetadataBase::Address &other ) const;
128  };
129 
135  struct CORE_EXPORT Contact
136  {
137 
141  Contact( const QString &name = QString() )
142  : name( name )
143  {}
144 
148  QString name;
149 
153  QString organization;
154 
158  QString position;
159 
163  QList< QgsAbstractMetadataBase::Address > addresses;
164 
168  QString voice;
169 
173  QString fax;
174 
179  QString email;
180 
186  QString role;
187 
188  bool operator==( const QgsAbstractMetadataBase::Contact &other ) const;
189  };
190 
196  typedef QList< QgsAbstractMetadataBase::Contact > ContactList;
197 
198 
204  struct CORE_EXPORT Link
205  {
206 
210  Link( const QString &name = QString(), const QString &type = QString(), const QString &url = QString() )
211  : name( name )
212  , type( type )
213  , url( url )
214  {}
215 
219  QString name;
220 
225  QString type;
226 
230  QString description;
231 
235  QString url;
236 
240  QString format;
241 
245  QString mimeType;
246 
250  QString size;
251 
252  bool operator==( const QgsAbstractMetadataBase::Link &other ) const;
253  };
254 
260  typedef QList< QgsAbstractMetadataBase::Link > LinkList;
261 
262  virtual ~QgsAbstractMetadataBase() = default;
263 
268  virtual QgsAbstractMetadataBase *clone() const = 0 SIP_FACTORY;
269 
274  QString identifier() const;
275 
280  void setIdentifier( const QString &identifier );
281 
287  QString parentIdentifier() const;
288 
294  void setParentIdentifier( const QString &parentIdentifier );
295 
303  QString language() const;
304 
311  void setLanguage( const QString &language );
312 
318  QString type() const;
319 
325  void setType( const QString &type );
326 
331  QString title() const;
332 
337  void setTitle( const QString &title );
338 
343  QString abstract() const;
344 
349  void setAbstract( const QString &abstract );
350 
355  QStringList history() const;
356 
363  void setHistory( const QStringList &history );
364 
370  void addHistoryItem( const QString &text );
371 
383  QgsAbstractMetadataBase::KeywordMap keywords() const;
384 
397  void setKeywords( const QgsAbstractMetadataBase::KeywordMap &keywords );
398 
409  void addKeywords( const QString &vocabulary, const QStringList &keywords );
410 
417  bool removeKeywords( const QString &vocabulary );
418 
427  QStringList keywordVocabularies() const;
428 
439  QStringList keywords( const QString &vocabulary ) const;
440 
447  QStringList categories() const;
448 
455  void setCategories( const QStringList &categories );
456 
461  QgsAbstractMetadataBase::ContactList contacts() const;
462 
469  void setContacts( const QgsAbstractMetadataBase::ContactList &contacts );
470 
476  void addContact( const QgsAbstractMetadataBase::Contact &contact );
477 
482  QgsAbstractMetadataBase::LinkList links() const;
483 
490  void setLinks( const QgsAbstractMetadataBase::LinkList &links );
491 
497  void addLink( const QgsAbstractMetadataBase::Link &link );
498 
509  virtual bool readMetadataXml( const QDomElement &metadataElement );
510 
522  virtual bool writeMetadataXml( QDomElement &metadataElement, QDomDocument &document ) const;
523 
524  protected:
525 
531  QgsAbstractMetadataBase() = default;
532 
533  /*
534  * IMPORTANT!!!!!!
535  *
536  * Do NOT add anything to this class without also updating the schema
537  * definition located at resources/qgis-resource-metadata.xsd
538  *
539  */
540 
541  QString mIdentifier;
543  QString mLanguage;
544  QString mType;
545  QString mTitle;
546  QString mAbstract;
547  QStringList mHistory;
548 
549  // IMPORTANT - look up before adding anything here!!
550 
555 
557 
559 
560  /*
561  * IMPORTANT!!!!!!
562  *
563  * Do NOT add anything to this class without also updating the schema
564  * definition located at resources/qgis-resource-metadata.xsd
565  *
566  */
567 
568 
577  bool equals( const QgsAbstractMetadataBase &other ) const;
578 
579 };
580 
584 
585 #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.
Q_DECLARE_METATYPE(QModelIndex)
QString administrativeArea
Administrative area (state, province/territory, etc.).
#define SIP_END
Definition: qgis_sip.h:182
#define SIP_FACTORY
Definition: qgis_sip.h:69
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:165
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.