Skip to content
Permalink
Browse files

WMSOnlineResource can be defined by an expression. This means it's st…

…ored as a QgsProperty.

Functions to read and write QgsProperty.
  • Loading branch information
signedav committed May 13, 2020
1 parent 7bbfe5a commit 0e4b6b8cadbd91b9a0e20a9e55a6b29ced611b22
@@ -401,6 +401,18 @@ Write a string list entry to the project file.
Keys are '/'-delimited entries, implying
a hierarchy of keys and corresponding values

.. note::

The key string must be valid xml tag names in order to be saved to the file.
%End

bool writeEntry( const QString &scope, const QString &key, const QgsProperty &value );
%Docstring
Write a QgsProperty entry to the project file.

Keys are '/'-delimited entries, implying
a hierarchy of keys and corresponding values

.. note::

The key string must be valid xml tag names in order to be saved to the file.
@@ -418,6 +430,7 @@ implying a hierarchy of keys and corresponding values
int readNumEntry( const QString &scope, const QString &key, int def = 0, bool *ok = 0 ) const;
double readDoubleEntry( const QString &scope, const QString &key, double def = 0, bool *ok = 0 ) const;
bool readBoolEntry( const QString &scope, const QString &key, bool def = false, bool *ok = 0 ) const;
QgsProperty readPropertyEntry( const QString &scope, const QString &key, QgsProperty def = QgsProperty(), bool *ok = 0 ) const;


bool removeEntry( const QString &scope, const QString &key );
@@ -442,6 +442,7 @@ QgsProjectProperties::QgsProjectProperties( QgsMapCanvas *mapCanvas, QWidget *pa
mWMSContactPhone->setText( QgsProject::instance()->readEntry( QStringLiteral( "WMSContactPhone" ), QStringLiteral( "/" ), QString() ) );
mWMSAbstract->setPlainText( QgsProject::instance()->readEntry( QStringLiteral( "WMSServiceAbstract" ), QStringLiteral( "/" ), QString() ) );
mWMSOnlineResourceLineEdit->setText( QgsProject::instance()->readEntry( QStringLiteral( "WMSOnlineResource" ), QStringLiteral( "/" ), QString() ) );
mWMSOnlineResourceExpressionButton->setToProperty( QgsProject::instance()->readPropertyEntry( "WMSOnlineResourceExpression", "/" ) );
mWMSUrlLineEdit->setText( QgsProject::instance()->readEntry( QStringLiteral( "WMSUrl" ), QStringLiteral( "/" ), QString() ) );
mWMSKeywordList->setText( QgsProject::instance()->readListEntry( QStringLiteral( "WMSKeywordList" ), QStringLiteral( "/" ) ).join( QStringLiteral( ", " ) ) );

@@ -1170,6 +1171,7 @@ void QgsProjectProperties::apply()
QgsProject::instance()->writeEntry( QStringLiteral( "WMSContactPhone" ), QStringLiteral( "/" ), mWMSContactPhone->text() );
QgsProject::instance()->writeEntry( QStringLiteral( "WMSServiceAbstract" ), QStringLiteral( "/" ), mWMSAbstract->toPlainText() );
QgsProject::instance()->writeEntry( QStringLiteral( "WMSOnlineResource" ), QStringLiteral( "/" ), mWMSOnlineResourceLineEdit->text() );
QgsProject::instance()->writeEntry( QStringLiteral( "WMSOnlineResourceExpression" ), QStringLiteral( "/" ), mWMSOnlineResourceExpressionButton->toProperty() );
QgsProject::instance()->writeEntry( QStringLiteral( "WMSUrl" ), QStringLiteral( "/" ), mWMSUrlLineEdit->text() );

// WMS Contact Position
@@ -2359,6 +2359,17 @@ bool QgsProject::writeEntry( const QString &scope, const QString &key, const QSt
return success;
}

bool QgsProject::writeEntry( const QString &scope, const QString &key, const QgsProperty &value )
{
bool propertiesModified;
bool success = addKey_( scope, key, &mProperties, value.toVariant(), propertiesModified );

if ( propertiesModified )
setDirty( true );

return success;
}

QStringList QgsProject::readListEntry( const QString &scope,
const QString &key,
const QStringList &def,
@@ -2477,6 +2488,25 @@ bool QgsProject::readBoolEntry( const QString &scope, const QString &key, bool d
return def;
}

QgsProperty QgsProject::readPropertyEntry( const QString &scope, const QString &key, QgsProperty def, bool *ok ) const
{
QgsProjectProperty *property = findKey_( scope, key, mProperties );

if ( property )
{
QgsProperty qgsproperty;
QVariant value = property->value();
bool loaded = qgsproperty.loadVariant( value );
if ( ok )
*ok = loaded;

if ( loaded )
return qgsproperty;
}

return def;
}


bool QgsProject::removeEntry( const QString &scope, const QString &key )
{
@@ -423,6 +423,16 @@ class CORE_EXPORT QgsProject : public QObject, public QgsExpressionContextGenera
*/
bool writeEntry( const QString &scope, const QString &key, const QStringList &value );

/**
* Write a QgsProperty entry to the project file.
*
* Keys are '/'-delimited entries, implying
* a hierarchy of keys and corresponding values
*
* \note The key string must be valid xml tag names in order to be saved to the file.
*/
bool writeEntry( const QString &scope, const QString &key, const QgsProperty &value );

/**
* Key value accessors
*
@@ -435,6 +445,7 @@ class CORE_EXPORT QgsProject : public QObject, public QgsExpressionContextGenera
int readNumEntry( const QString &scope, const QString &key, int def = 0, bool *ok = nullptr ) const;
double readDoubleEntry( const QString &scope, const QString &key, double def = 0, bool *ok = nullptr ) const;
bool readBoolEntry( const QString &scope, const QString &key, bool def = false, bool *ok = nullptr ) const;
QgsProperty readPropertyEntry( const QString &scope, const QString &key, QgsProperty def = QgsProperty(), bool *ok = nullptr ) const;


//! Remove the given key

0 comments on commit 0e4b6b8

Please sign in to comment.
You can’t perform that action at this time.