Skip to content
Permalink
Browse files

Cleanup WMS-T settings widget (pt 1)

- Move settings which apply to both static WMS-T time and dynamic
temporal control out into their own "WMS-T Settings" group box,
so that it's clear that these settings apply regardless of the
selected mode

- Rename "Use dates" option to a clearer label which explicitly
states exactly what the option does, and add an even more
verbose explanatory tooltip

- Move WMS-T reference time setting out to its own group box, as
it applies regardless of the temporal mode selected. Rework the
UI for this group box to make it cleaner and clearer, and also
show the server's reported reference time extent in a
label so that users can see what reference times are likely
to be valid for the layer.
  • Loading branch information
nyalldawson committed Mar 24, 2021
1 parent 3c09c58 commit 331aad69e130c61967a633b3deff0af426d58c35
@@ -1116,7 +1116,7 @@ void QgsWmsProvider::addWmstParameters( QUrlQuery &query )
QString format { QStringLiteral( "yyyy-MM-ddThh:mm:ssZ" ) };
bool dateOnly = false;

QgsProviderMetadata *metadata = QgsProviderRegistry::instance()->providerMetadata( "wms" );
QgsProviderMetadata *metadata = QgsProviderRegistry::instance()->providerMetadata( QStringLiteral( "wms" ) );

QVariantMap uri = metadata->decodeUri( dataSourceUri() );

@@ -1141,7 +1141,7 @@ void QgsWmsProvider::addWmstParameters( QUrlQuery &query )

if ( !uri.value( QStringLiteral( "enableTime" ), true ).toBool() )
{
format = "yyyy-MM-dd";
format = QStringLiteral( "yyyy-MM-dd" );
dateOnly = true;
}

@@ -39,16 +39,8 @@ QgsWmstSettingsWidget::QgsWmstSettingsWidget( QgsMapLayer *layer, QgsMapCanvas *
mEndStaticDateTimeEdit->setDateTime( mStartStaticDateTimeEdit->dateTime() );
} );
connect( mProjectTemporalRange, &QRadioButton::toggled, this, &QgsWmstSettingsWidget::passProjectTemporalRange_toggled );
connect( mStaticTemporalRange, &QRadioButton::toggled, this, [ = ]( bool checked )
{
if ( checked )
{
mLabel->clear();
}
} );

connect( mStaticTemporalRange, &QRadioButton::toggled, mStaticWmstFrame, &QWidget::setEnabled );
connect( mReferenceTime, &QCheckBox::toggled, mWmstReferenceTimeFrame, &QWidget::setEnabled );

syncToLayer( mRasterLayer );

@@ -99,18 +91,20 @@ void QgsWmstSettingsWidget::syncToLayer( QgsMapLayer *layer )
}

const QString referenceTimeExtent = uri.value( QStringLiteral( "referenceTimeDimensionExtent" ) ).toString();

mReferenceTime->setEnabled( !referenceTimeExtent.isEmpty() );
mReferenceDateTimeEdit->setVisible( !referenceTimeExtent.isEmpty() );

QString referenceTimeLabelText = referenceTimeExtent.isEmpty() ?
tr( "There is no reference time in the layer's capabilities." ) : QString();
mReferenceTimeLabel->setText( referenceTimeLabelText );

const QString referenceTime = uri.value( QStringLiteral( "referenceTime" ) ).toString();

mReferenceTime->setChecked( !referenceTime.isEmpty() );

if ( referenceTimeExtent.isEmpty() )
{
mReferenceTimeExtentLabel->setText( tr( "No reference time is reported in the layer's capabilities." ) );
mReferenceTimeGroupBox->setChecked( false );
mReferenceTimeGroupBox->setEnabled( false );
}
else
{
mReferenceTimeExtentLabel->setText( tr( "Reported reference time extent: <i>%1</i>" ).arg( referenceTimeExtent ) );
mReferenceTimeGroupBox->setEnabled( true );
mReferenceTimeGroupBox->setChecked( !referenceTime.isEmpty() );
}
if ( !referenceTime.isEmpty() && !referenceTimeExtent.isEmpty() )
{
mReferenceDateTimeEdit->setDateTime( QDateTime::fromString( referenceTime, Qt::ISODateWithMs ) );
@@ -204,7 +198,7 @@ void QgsWmstSettingsWidget::apply()
}
}

if ( mReferenceTime->isChecked() )
if ( mReferenceTimeGroupBox->isChecked() )
{
QString referenceTime = mReferenceDateTimeEdit->dateTime().toString( Qt::ISODateWithMs );
uri[ QStringLiteral( "referenceTime" ) ] = referenceTime;
@@ -229,12 +223,14 @@ void QgsWmstSettingsWidget::passProjectTemporalRange_toggled( bool checked )
range = QgsProject::instance()->timeSettings()->temporalRange();

if ( range.begin().isValid() && range.end().isValid() )
mLabel->setText( tr( "Project temporal range is set from %1 to %2" ).arg(
range.begin().toString( QStringLiteral( "yyyy-MM-dd HH:mm:ss" ) ),
range.end().toString( QStringLiteral( "yyyy-MM-dd HH:mm:ss" ) )
) );
mProjectTemporalRangeLabel->setText( tr( "Project temporal range is set from %1 to %2" ).arg(
range.begin().toString( QStringLiteral( "yyyy-MM-dd HH:mm:ss" ) ),
range.end().toString( QStringLiteral( "yyyy-MM-dd HH:mm:ss" ) )
) );
else
mLabel->setText( tr( "Project temporal range is not valid, can't use it here" ) );
mProjectTemporalRangeLabel->setText( tr( "The option below is disabled because the project temporal range "
"is not valid, update the project temporal range in the project properties "
"with valid values in order to use it here." ) );
}
}

@@ -2,6 +2,14 @@
<ui version="4.0">
<class>QgsWmstSettingsWidgetBase</class>
<widget class="QWidget" name="QgsWmstSettingsWidgetBase">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>327</width>
<height>564</height>
</rect>
</property>
<property name="windowTitle">
<string>WMS-T Settings</string>
</property>
@@ -19,37 +27,21 @@
<number>0</number>
</property>
<item>
<widget class="QGroupBox" name="mWmstGroup">
<property name="enabled">
<bool>true</bool>
</property>
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Use static WMS-T capabilities</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>true</bool>
<string>WMS-T Settings</string>
</property>
<layout class="QGridLayout" name="gridLayout_15">
<item row="0" column="0" colspan="3">
<widget class="QLabel" name="mLabel">
<property name="text">
<string/>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="1" rowspan="2" colspan="2">
<layout class="QGridLayout" name="gridLayout" columnstretch="0,1">
<item row="1" column="1">
<widget class="QComboBox" name="mFetchModeComboBox"/>
</item>
<item row="3" column="0">
<item row="2" column="0" colspan="2">
<widget class="QCheckBox" name="mDisableTime">
<property name="toolTip">
<string>If checked the time component of temporal queries will be discarded and only the data component will be used in server requests</string>
</property>
<property name="text">
<string>Use dates only</string>
<string>Ignore time components (use dates only)</string>
</property>
</widget>
</item>
@@ -60,68 +52,83 @@
</property>
</widget>
</item>
<item row="8" column="0">
<widget class="QFrame" name="mWmstReferenceTimeFrame">
<property name="enabled">
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="mReferenceTimeGroupBox">
<property name="title">
<string>WMS-T Reference Time</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0" colspan="2">
<widget class="QLabel" name="mReferenceTimeExtentLabel">
<property name="text">
<string>No reference time is reported in the layer's capabilities.</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="0" colspan="2">
<widget class="QgsDateTimeEdit" name="mReferenceDateTimeEdit">
<property name="dateTime">
<datetime>
<hour>14</hour>
<minute>20</minute>
<second>36</second>
<year>2020</year>
<month>1</month>
<day>23</day>
</datetime>
</property>
<property name="date">
<date>
<year>2020</year>
<month>1</month>
<day>23</day>
</date>
</property>
<property name="currentSection">
<enum>QDateTimeEdit::MonthSection</enum>
</property>
<property name="displayFormat">
<string>M/d/yyyy H:mm:ss AP</string>
</property>
<property name="calendarPopup">
<bool>false</bool>
</property>
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
<property name="timeSpec">
<enum>Qt::UTC</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
<property name="allowNull" stdset="0">
<bool>false</bool>
</property>
<layout class="QGridLayout" name="gridLayout_17">
<property name="topMargin">
<number>0</number>
</property>
<item row="1" column="0">
<widget class="QLabel" name="mReferenceTimeLabel">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QgsDateTimeEdit" name="mReferenceDateTimeEdit">
<property name="dateTime">
<datetime>
<hour>0</hour>
<minute>20</minute>
<second>36</second>
<year>2020</year>
<month>1</month>
<day>24</day>
</datetime>
</property>
<property name="date">
<date>
<year>2020</year>
<month>1</month>
<day>24</day>
</date>
</property>
<property name="currentSection">
<enum>QDateTimeEdit::MonthSection</enum>
</property>
<property name="displayFormat">
<string>M/d/yyyy H:mm:ss AP</string>
</property>
<property name="calendarPopup">
<bool>false</bool>
</property>
<property name="timeSpec">
<enum>Qt::UTC</enum>
</property>
<property name="allowNull" stdset="0">
<bool>false</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="4" column="0" colspan="3">
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="mWmstGroup">
<property name="enabled">
<bool>true</bool>
</property>
<property name="title">
<string>Use static WMS-T capabilities</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>true</bool>
</property>
<layout class="QGridLayout" name="gridLayout_15">
<item row="1" column="0" colspan="2">
<widget class="QLabel" name="mWmstOptionsLabel">
<property name="text">
<string/>
@@ -131,14 +138,7 @@
</property>
</widget>
</item>
<item row="7" column="0">
<widget class="QCheckBox" name="mReferenceTime">
<property name="text">
<string>Reference time</string>
</property>
</widget>
</item>
<item row="5" column="0" colspan="3">
<item row="2" column="0" colspan="2">
<widget class="QFrame" name="mWmstOptions">
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
@@ -216,12 +216,12 @@
<widget class="QgsDateTimeEdit" name="mStartStaticDateTimeEdit">
<property name="dateTime">
<datetime>
<hour>3</hour>
<hour>17</hour>
<minute>3</minute>
<second>57</second>
<year>2020</year>
<month>4</month>
<day>28</day>
<day>27</day>
</datetime>
</property>
<property name="currentSection">
@@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>611</width>
<width>577</width>
<height>413</height>
</rect>
</property>
@@ -48,7 +48,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>611</width>
<width>577</width>
<height>413</height>
</rect>
</property>
@@ -124,7 +124,7 @@ background: white;QgsCollapsibleGroupBoxBasic::title, QgsCollapsibleGroupBox::ti
<property name="lineWidth">
<number>0</number>
</property>
<layout class="QGridLayout" name="gridLayout_2" columnstretch="0,0,0,0">
<layout class="QGridLayout" name="gridLayout_2" columnstretch="0,2,0,3">
<property name="topMargin">
<number>0</number>
</property>

0 comments on commit 331aad6

Please sign in to comment.