Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix travis, broken due to some failure to convert struct QVariant pro…
…perty
  • Loading branch information
github-actions[bot] authored and nyalldawson committed Apr 14, 2020
1 parent 6d9fc8a commit e70eb13
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 33 deletions.
Expand Up @@ -24,19 +24,47 @@ Abstract base class for metadata validators.
%End
public:

struct ValidationResult
{
class ValidationResult
{
%Docstring
Contains the parameters describing a metadata validation failure.

.. versionadded:: 3.0
%End

%TypeHeaderCode
#include "qgslayermetadatavalidator.h"
%End
public:

ValidationResult( const QString &section, const QString &note, const QVariant &identifier = QVariant() );
ValidationResult( const QString &section, const QString &note, const QVariant &identifier = QVariant() );
%Docstring
Constructor for ValidationResult.
%End

QString section;
QString section;


%Property( name = identifier, get = _identifier, set = _setIdentifier )

QVariant _identifier() const;
%Docstring
Returns the optional identifier for the failed metadata item.
For instance, in list type metadata elements this
will be set to the list index of the failed metadata
item.
%End

void _setIdentifier( QVariant identifier );
%Docstring
Sets the optional ``identifier`` for the failed metadata item.
For instance, in list type metadata elements this
will be set to the list index of the failed metadata
item.
%End

QVariant identifier;
QString note;

QString note;
};

virtual ~QgsAbstractMetadataBaseValidator();
Expand Down
71 changes: 46 additions & 25 deletions src/core/metadata/qgslayermetadatavalidator.h
Expand Up @@ -39,34 +39,55 @@ class CORE_EXPORT QgsAbstractMetadataBaseValidator
public:

/**
* Contains the parameters describing a metadata validation
* failure.
* \ingroup core
* \brief Contains the parameters describing a metadata validation failure.
* \since QGIS 3.0
*/
struct ValidationResult
class ValidationResult
{

/**
* Constructor for ValidationResult.
*/
ValidationResult( const QString &section, const QString &note, const QVariant &identifier = QVariant() )
: section( section )
, identifier( identifier )
, note( note )
{}

//! Metadata section which failed the validation
QString section;

/**
* Optional identifier for the failed metadata item.
* For instance, in list type metadata elements this
* will be set to the list index of the failed metadata
* item.
*/
QVariant identifier;

//! The reason behind the validation failure.
QString note;
public:

/**
* Constructor for ValidationResult.
*/
ValidationResult( const QString &section, const QString &note, const QVariant &identifier = QVariant() )
: section( section )
, note( note )
, mIdentifier( identifier )
{}

//! Metadata section which failed the validation
QString section;

// TODO QGIS 4.0 - fix this

#ifdef SIP_RUN
SIP_PROPERTY( name = identifier, get = _identifier, set = _setIdentifier )
#endif

/**
* Returns the optional identifier for the failed metadata item.
* For instance, in list type metadata elements this
* will be set to the list index of the failed metadata
* item.
*/
QVariant _identifier() const { return mIdentifier; }

/**
* Sets the optional \a identifier for the failed metadata item.
* For instance, in list type metadata elements this
* will be set to the list index of the failed metadata
* item.
*/
void _setIdentifier( QVariant identifier ) { mIdentifier = identifier; }

//! The reason behind the validation failure.
QString note;

private:

QVariant mIdentifier;
};

virtual ~QgsAbstractMetadataBaseValidator() = default;
Expand Down
4 changes: 2 additions & 2 deletions src/gui/qgsmetadatawidget.cpp
Expand Up @@ -797,9 +797,9 @@ bool QgsMetadataWidget::checkMetadata()
for ( const QgsAbstractMetadataBaseValidator::ValidationResult &result : qgis::as_const( validationResults ) )
{
errors += QLatin1String( "<b>" ) % result.section;
if ( ! result.identifier.isNull() )
if ( ! result._identifier().isNull() )
{
errors += QLatin1String( " " ) % QVariant( result.identifier.toInt() + 1 ).toString();
errors += QLatin1String( " " ) % QVariant( result._identifier().toInt() + 1 ).toString();
}
errors += QLatin1String( "</b>: " ) % result.note % QLatin1String( "<br />" );
}
Expand Down

0 comments on commit e70eb13

Please sign in to comment.