QGIS API Documentation  3.17.0-Master (8af46bc54f)
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
#define SIP_PROPERTY(name, getter, setter)
Definition: qgis_sip.h:262
A validator for the native QGIS layer metadata schema definition.
void _setIdentifier(QVariant identifier)
Sets the optional identifier for the failed metadata item.
ValidationResult(const QString &section, const QString &note, const QVariant &identifier=QVariant())
Constructor for ValidationResult.
A validator for the native base QGIS metadata schema definition.
QVariant _identifier() const
Returns the optional identifier for the failed metadata item.
Abstract base class for metadata validators.
A validator for the native QGIS project metadata schema definition.
Contains the parameters describing a metadata validation failure.
QString section
Metadata section which failed the validation.
A structured metadata store for a map layer.
#define SIP_OUT
Definition: qgis_sip.h:58
QString note
The reason behind the validation failure.
An abstract base class for metadata stores.