QGIS API Documentation  3.14.0-Pi (9f7028fd23)
qgslayermetadatavalidator.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgslayermetadatavalidator.h
3  ---------------------------
4  begin : April 2017
5  copyright : (C) 2017 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 QGSLAYERMETADATAVALIDATOR_H
19 #define QGSLAYERMETADATAVALIDATOR_H
20 
21 #include "qgis_sip.h"
22 #include "qgis_core.h"
23 #include <QString>
24 #include <QVariant>
25 
27 class QgsLayerMetadata;
28 
37 {
38 
39  public:
40 
47  {
48 
49  public:
50 
54  ValidationResult( const QString &section, const QString &note, const QVariant &identifier = QVariant() )
55  : section( section )
56  , note( note )
57  , mIdentifier( identifier )
58  {}
59 
61  QString section;
62 
63  // TODO QGIS 4.0 - fix this
64 
65 #ifdef SIP_RUN
66  SIP_PROPERTY( name = identifier, get = _identifier, set = _setIdentifier )
67 #endif
68 
75  QVariant _identifier() const { return mIdentifier; }
76 
83  void _setIdentifier( QVariant identifier ) { mIdentifier = identifier; }
84 
86  QString note;
87 
88  private:
89 
90  QVariant mIdentifier;
91  };
92 
93  virtual ~QgsAbstractMetadataBaseValidator() = default;
94 
102  virtual bool validate( const QgsAbstractMetadataBase *metadata, QList< QgsAbstractMetadataBaseValidator::ValidationResult > &results SIP_OUT ) const = 0;
103 
104 };
105 
114 {
115 
116  public:
117 
121  QgsNativeMetadataBaseValidator() = default;
122 
123  bool validate( const QgsAbstractMetadataBase *metadata, QList< QgsAbstractMetadataBaseValidator::ValidationResult > &results SIP_OUT ) const override;
124 
125 };
126 
127 
136 {
137 
138  public:
139 
143  QgsNativeMetadataValidator() = default;
144 
145  bool validate( const QgsAbstractMetadataBase *metadata, QList< QgsAbstractMetadataBaseValidator::ValidationResult > &results SIP_OUT ) const override;
146 
147 };
148 
157 {
158 
159  public:
160 
165 
166  bool validate( const QgsAbstractMetadataBase *metadata, QList< QgsAbstractMetadataBaseValidator::ValidationResult > &results SIP_OUT ) const override;
167 
168 };
169 
170 #endif // QGSLAYERMETADATAVALIDATOR_H
QgsAbstractMetadataBaseValidator::ValidationResult::section
QString section
Metadata section which failed the validation.
Definition: qgslayermetadatavalidator.h:61
QgsAbstractMetadataBaseValidator::ValidationResult
Contains the parameters describing a metadata validation failure.
Definition: qgslayermetadatavalidator.h:46
QgsAbstractMetadataBaseValidator::ValidationResult::note
QString note
The reason behind the validation failure.
Definition: qgslayermetadatavalidator.h:86
SIP_OUT
#define SIP_OUT
Definition: qgis_sip.h:58
QgsLayerMetadata
A structured metadata store for a map layer.
Definition: qgslayermetadata.h:56
QgsNativeMetadataBaseValidator
A validator for the native base QGIS metadata schema definition.
Definition: qgslayermetadatavalidator.h:113
QgsNativeProjectMetadataValidator
A validator for the native QGIS project metadata schema definition.
Definition: qgslayermetadatavalidator.h:156
qgis_sip.h
QgsAbstractMetadataBaseValidator::ValidationResult::_setIdentifier
void _setIdentifier(QVariant identifier)
Sets the optional identifier for the failed metadata item.
Definition: qgslayermetadatavalidator.h:83
QgsAbstractMetadataBaseValidator::ValidationResult::ValidationResult
ValidationResult(const QString &section, const QString &note, const QVariant &identifier=QVariant())
Constructor for ValidationResult.
Definition: qgslayermetadatavalidator.h:54
QgsNativeMetadataValidator
A validator for the native QGIS layer metadata schema definition.
Definition: qgslayermetadatavalidator.h:135
QgsAbstractMetadataBaseValidator::ValidationResult::_identifier
QVariant _identifier() const
Returns the optional identifier for the failed metadata item.
Definition: qgslayermetadatavalidator.h:75
SIP_PROPERTY
#define SIP_PROPERTY(name, getter, setter)
Definition: qgis_sip.h:257
QgsAbstractMetadataBaseValidator
Abstract base class for metadata validators.
Definition: qgslayermetadatavalidator.h:36
QgsAbstractMetadataBase
An abstract base class for metadata stores.
Definition: qgsabstractmetadatabase.h:56
QgsAbstractMetadataBaseValidator::validate
virtual bool validate(const QgsAbstractMetadataBase *metadata, QList< QgsAbstractMetadataBaseValidator::ValidationResult > &results) const =0
Validates a metadata object, and returns true if the metadata is considered valid.
QgsNativeMetadataBaseValidator::validate
bool validate(const QgsAbstractMetadataBase *metadata, QList< QgsAbstractMetadataBaseValidator::ValidationResult > &results) const override
Validates a metadata object, and returns true if the metadata is considered valid.
Definition: qgslayermetadatavalidator.cpp:26