WMSOnlineResource can be defined by an expression. This means it's stored as a QgsProperty.

Functions to read and write QgsProperty.
This commit is contained in:
David Signer 2020-05-13 19:39:31 +02:00
parent 7bbfe5a5a4
commit 0e4b6b8cad
5 changed files with 283 additions and 219 deletions

View File

@ -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 );

View File

@ -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

View File

@ -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 )
{

View File

@ -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

View File

@ -245,7 +245,7 @@
</sizepolicy>
</property>
<property name="currentIndex">
<number>0</number>
<number>8</number>
</property>
<widget class="QWidget" name="mProjOptsGeneral">
<layout class="QVBoxLayout" name="verticalLayout_6">
@ -275,7 +275,7 @@
<x>0</x>
<y>0</y>
<width>671</width>
<height>865</height>
<height>828</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
@ -897,8 +897,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>587</width>
<height>167</height>
<width>685</width>
<height>681</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_7">
@ -972,8 +972,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>288</width>
<height>563</height>
<width>685</width>
<height>681</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_12">
@ -1548,8 +1548,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>177</width>
<height>56</height>
<width>178</width>
<height>54</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_17">
@ -1610,8 +1610,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>643</width>
<height>2818</height>
<width>671</width>
<height>2718</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_13">
@ -1642,185 +1642,7 @@
<bool>true</bool>
</property>
<layout class="QGridLayout" name="gridLayout_6">
<item row="1" column="0">
<widget class="QLabel" name="label_10">
<property name="text">
<string>Title</string>
</property>
<property name="buddy">
<cstring>mWMSTitle</cstring>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QLineEdit" name="mWMSOnlineResourceLineEdit">
<property name="toolTip">
<string>The web site URL of the service provider.</string>
</property>
<property name="placeholderText">
<string>The web site URL of the service provider.</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="mWMSOnlineResourceLabel">
<property name="text">
<string>Online resource</string>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_9">
<property name="text">
<string>&amp;Person</string>
</property>
<property name="buddy">
<cstring>mWMSContactPerson</cstring>
</property>
</widget>
</item>
<item row="6" column="1">
<widget class="QLineEdit" name="mWMSContactMail">
<property name="toolTip">
<string>The contact person e-mail for the service.</string>
</property>
<property name="placeholderText">
<string>The contact person e-mail for the service.</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QLineEdit" name="mWMSContactPerson">
<property name="toolTip">
<string>The contact person name for the service.</string>
</property>
<property name="placeholderText">
<string>The contact person name for the service.</string>
</property>
</widget>
</item>
<item row="6" column="0">
<widget class="QLabel" name="label_13">
<property name="text">
<string>E-Mail</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="mWMSContactOrganization">
<property name="toolTip">
<string>The name of the service provider.</string>
</property>
<property name="placeholderText">
<string>The name of the service provider.</string>
</property>
</widget>
</item>
<item row="7" column="0">
<widget class="QLabel" name="label_12">
<property name="text">
<string>Phone</string>
</property>
<property name="buddy">
<cstring>mWMSContactPhone</cstring>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="mWMSTitle">
<property name="toolTip">
<string>The title should be brief yet descriptive enough to identify this service.</string>
</property>
<property name="placeholderText">
<string>The title should be brief yet descriptive enough to identify this service.</string>
</property>
</widget>
</item>
<item row="8" column="0">
<widget class="QLabel" name="label_15">
<property name="text">
<string>Abstract</string>
</property>
<property name="buddy">
<cstring>mWMSAbstract</cstring>
</property>
</widget>
</item>
<item row="7" column="1">
<widget class="QLineEdit" name="mWMSContactPhone">
<property name="toolTip">
<string>The contact person phone for the service.</string>
</property>
<property name="placeholderText">
<string>The contact person phone for the service.</string>
</property>
</widget>
</item>
<item row="8" column="1">
<widget class="QTextEdit" name="mWMSAbstract">
<property name="toolTip">
<string>The abstract is a descriptive narrative providing more information about the service.</string>
</property>
<property name="whatsThis">
<string/>
</property>
<property name="documentTitle">
<string/>
</property>
</widget>
</item>
<item row="11" column="0">
<widget class="QLabel" name="mWMSKeywordListLabel">
<property name="text">
<string>Keyword list</string>
</property>
</widget>
</item>
<item row="11" column="1">
<widget class="QLineEdit" name="mWMSKeywordList">
<property name="toolTip">
<string>List of keywords separated by comma to help catalog searching.</string>
</property>
<property name="placeholderText">
<string>List of keywords separated by comma to help catalog searching.</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_11">
<property name="text">
<string>Or&amp;ganization</string>
</property>
<property name="buddy">
<cstring>mWMSContactOrganization</cstring>
</property>
</widget>
</item>
<item row="10" column="0">
<widget class="QLabel" name="mWMSAccessConstraintsLabel">
<property name="text">
<string>Access constraints</string>
</property>
</widget>
</item>
<item row="9" column="0">
<widget class="QLabel" name="mWMSFeesLabel">
<property name="text">
<string>Fees</string>
</property>
</widget>
</item>
<item row="9" column="1">
<widget class="QComboBox" name="mWMSFeesCb">
<property name="toolTip">
<string>Fees applied to the service.</string>
</property>
<property name="editable">
<bool>true</bool>
</property>
</widget>
</item>
<item row="10" column="1">
<item row="14" column="1">
<widget class="QComboBox" name="mWMSAccessConstraintsCb">
<property name="toolTip">
<string>Access constraints applied to the service.</string>
@ -1830,23 +1652,16 @@
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="label_20">
<property name="text">
<string>Position</string>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QComboBox" name="mWMSContactPositionCb">
<item row="12" column="1">
<widget class="QTextEdit" name="mWMSAbstract">
<property name="toolTip">
<string>The contact person position for the service.</string>
<string>The abstract is a descriptive narrative providing more information about the service.</string>
</property>
<property name="accessibleDescription">
<property name="whatsThis">
<string/>
</property>
<property name="editable">
<bool>true</bool>
<property name="documentTitle">
<string/>
</property>
</widget>
</item>
@ -1860,6 +1675,127 @@
</property>
</widget>
</item>
<item row="8" column="1">
<widget class="QLineEdit" name="mWMSContactPerson">
<property name="toolTip">
<string>The contact person name for the service.</string>
</property>
<property name="placeholderText">
<string>The contact person name for the service.</string>
</property>
</widget>
</item>
<item row="13" column="1">
<widget class="QComboBox" name="mWMSFeesCb">
<property name="toolTip">
<string>Fees applied to the service.</string>
</property>
<property name="editable">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="mWMSTitle">
<property name="toolTip">
<string>The title should be brief yet descriptive enough to identify this service.</string>
</property>
<property name="placeholderText">
<string>The title should be brief yet descriptive enough to identify this service.</string>
</property>
</widget>
</item>
<item row="15" column="0">
<widget class="QLabel" name="mWMSKeywordListLabel">
<property name="text">
<string>Keyword list</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_10">
<property name="text">
<string>Title</string>
</property>
<property name="buddy">
<cstring>mWMSTitle</cstring>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_11">
<property name="text">
<string>Or&amp;ganization</string>
</property>
<property name="buddy">
<cstring>mWMSContactOrganization</cstring>
</property>
</widget>
</item>
<item row="13" column="0">
<widget class="QLabel" name="mWMSFeesLabel">
<property name="text">
<string>Fees</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="mWMSContactOrganization">
<property name="toolTip">
<string>The name of the service provider.</string>
</property>
<property name="placeholderText">
<string>The name of the service provider.</string>
</property>
</widget>
</item>
<item row="9" column="0">
<widget class="QLabel" name="label_20">
<property name="text">
<string>Position</string>
</property>
</widget>
</item>
<item row="11" column="0">
<widget class="QLabel" name="label_12">
<property name="text">
<string>Phone</string>
</property>
<property name="buddy">
<cstring>mWMSContactPhone</cstring>
</property>
</widget>
</item>
<item row="10" column="0">
<widget class="QLabel" name="label_13">
<property name="text">
<string>E-Mail</string>
</property>
</widget>
</item>
<item row="9" column="1">
<widget class="QComboBox" name="mWMSContactPositionCb">
<property name="toolTip">
<string>The contact person position for the service.</string>
</property>
<property name="accessibleDescription">
<string/>
</property>
<property name="editable">
<bool>true</bool>
</property>
</widget>
</item>
<item row="15" column="1">
<widget class="QLineEdit" name="mWMSKeywordList">
<property name="toolTip">
<string>List of keywords separated by comma to help catalog searching.</string>
</property>
<property name="placeholderText">
<string>List of keywords separated by comma to help catalog searching.</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_6">
<property name="text">
@ -1867,6 +1803,81 @@
</property>
</widget>
</item>
<item row="12" column="0">
<widget class="QLabel" name="label_15">
<property name="text">
<string>Abstract</string>
</property>
<property name="buddy">
<cstring>mWMSAbstract</cstring>
</property>
</widget>
</item>
<item row="8" column="0">
<widget class="QLabel" name="label_9">
<property name="text">
<string>&amp;Person</string>
</property>
<property name="buddy">
<cstring>mWMSContactPerson</cstring>
</property>
</widget>
</item>
<item row="11" column="1">
<widget class="QLineEdit" name="mWMSContactPhone">
<property name="toolTip">
<string>The contact person phone for the service.</string>
</property>
<property name="placeholderText">
<string>The contact person phone for the service.</string>
</property>
</widget>
</item>
<item row="10" column="1">
<widget class="QLineEdit" name="mWMSContactMail">
<property name="toolTip">
<string>The contact person e-mail for the service.</string>
</property>
<property name="placeholderText">
<string>The contact person e-mail for the service.</string>
</property>
</widget>
</item>
<item row="14" column="0">
<widget class="QLabel" name="mWMSAccessConstraintsLabel">
<property name="text">
<string>Access constraints</string>
</property>
</widget>
</item>
<item row="4" column="1">
<layout class="QGridLayout" name="wmsOnlineResourceGrid">
<item row="0" column="0">
<widget class="QLineEdit" name="mWMSOnlineResourceLineEdit">
<property name="toolTip">
<string>The web site URL of the service provider.</string>
</property>
<property name="placeholderText">
<string>The web site URL of the service provider.</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QgsPropertyOverrideButton" name="mWMSOnlineResourceExpressionButton">
<property name="text">
<string>...</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="4" column="0">
<widget class="QLabel" name="mWMSOnlineResourceLabel">
<property name="text">
<string>Online resource</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
@ -2009,14 +2020,14 @@
<bool>true</bool>
</property>
<layout class="QGridLayout" name="gridLayout_5">
<item row="1" column="0">
<widget class="QToolButton" name="pbnWMSAddSRS">
<item row="1" column="1">
<widget class="QToolButton" name="pbnWMSRemoveSRS">
<property name="toolTip">
<string>Add new CRS</string>
<string>Remove selected CRS</string>
</property>
<property name="icon">
<iconset resource="../../images/images.qrc">
<normaloff>:/images/themes/default/symbologyAdd.svg</normaloff>:/images/themes/default/symbologyAdd.svg</iconset>
<normaloff>:/images/themes/default/symbologyRemove.svg</normaloff>:/images/themes/default/symbologyRemove.svg</iconset>
</property>
</widget>
</item>
@ -2033,14 +2044,14 @@
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QToolButton" name="pbnWMSRemoveSRS">
<item row="1" column="0">
<widget class="QToolButton" name="pbnWMSAddSRS">
<property name="toolTip">
<string>Remove selected CRS</string>
<string>Add new CRS</string>
</property>
<property name="icon">
<iconset resource="../../images/images.qrc">
<normaloff>:/images/themes/default/symbologyRemove.svg</normaloff>:/images/themes/default/symbologyRemove.svg</iconset>
<normaloff>:/images/themes/default/symbologyAdd.svg</normaloff>:/images/themes/default/symbologyAdd.svg</iconset>
</property>
</widget>
</item>
@ -2990,6 +3001,12 @@
</layout>
</widget>
<customwidgets>
<customwidget>
<class>QgsCollapsibleGroupBox</class>
<extends>QGroupBox</extends>
<header>qgscollapsiblegroupbox.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>QgsFilterLineEdit</class>
<extends>QLineEdit</extends>
@ -3007,12 +3024,6 @@
<header>qgsscrollarea.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>QgsCollapsibleGroupBox</class>
<extends>QGroupBox</extends>
<header>qgscollapsiblegroupbox.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>QgsDateTimeEdit</class>
<extends>QDateTimeEdit</extends>
@ -3112,7 +3123,6 @@
<tabstop>mWMSName</tabstop>
<tabstop>mWMSTitle</tabstop>
<tabstop>mWMSContactOrganization</tabstop>
<tabstop>mWMSOnlineResourceLineEdit</tabstop>
<tabstop>mWMSContactPerson</tabstop>
<tabstop>mWMSContactPositionCb</tabstop>
<tabstop>mWMSContactMail</tabstop>
@ -3172,8 +3182,6 @@
</tabstops>
<resources>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
</resources>
<connections>
<connection>