Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
update on state handling between temporal properties and static wmst …
…capabilities ui
  • Loading branch information
Samweli authored and nyalldawson committed Jun 15, 2020
1 parent 4fc4007 commit 9dcc699
Show file tree
Hide file tree
Showing 3 changed files with 205 additions and 146 deletions.
90 changes: 59 additions & 31 deletions src/gui/raster/qgsrasterlayerproperties.cpp
Expand Up @@ -128,6 +128,9 @@ QgsRasterLayerProperties::QgsRasterLayerProperties( QgsMapLayer *lyr, QgsMapCanv
connect( mStaticTemporalRange, &QRadioButton::toggled, mStaticWmstFrame, &QWidget::setEnabled );
connect( mReferenceTime, &QCheckBox::toggled, mWmstReferenceTimeFrame, &QWidget::setEnabled );

if ( mRasterLayer && mRasterLayer->temporalProperties() )
connect( mRasterLayer->temporalProperties(), &QgsRasterLayerTemporalProperties::changed, this, &QgsRasterLayerProperties::temporalPropertiesChange );

mBtnStyle = new QPushButton( tr( "Style" ) );
QMenu *menuStyle = new QMenu( this );
menuStyle->addAction( tr( "Load Style…" ), this, &QgsRasterLayerProperties::loadStyle_clicked );
Expand Down Expand Up @@ -1234,49 +1237,55 @@ void QgsRasterLayerProperties::updateSourceStaticTime()
if ( mWmstGroup->isVisibleTo( this ) )
uri[ QStringLiteral( "allowTemporalUpdates" ) ] = mWmstGroup->isChecked();


if ( mWmstGroup->isEnabled() &&
mRasterLayer->dataProvider() &&
mRasterLayer->dataProvider()->temporalCapabilities()->hasTemporalCapabilities() )
{
if ( mStaticTemporalRange->isChecked() )
{
QString time = mStartStaticDateTimeEdit->dateTime().toString( Qt::ISODateWithMs ) + '/' +
mEndStaticDateTimeEdit->dateTime().toString( Qt::ISODateWithMs );
uri[ QStringLiteral( "time" ) ] = time;
uri[ QStringLiteral( "temporalSource" ) ] = QLatin1String( "provider" );
}
bool enableTime = !mDisableTime->isChecked();

if ( mProjectTemporalRange->isChecked() )
uri[ QStringLiteral( "enableTime" ) ] = enableTime;
qobject_cast< QgsRasterLayerTemporalProperties * >( mRasterLayer->temporalProperties() )->setIntervalHandlingMethod( static_cast< QgsRasterDataProviderTemporalCapabilities::IntervalHandlingMethod >(
mFetchModeComboBox->currentData().toInt() ) );

// Don't do static temporal updates if temporal properties are active
if ( !mRasterLayer->temporalProperties()->isActive() )
{
QgsDateTimeRange range;
if ( mStaticTemporalRange->isChecked() )
{
QString time = mStartStaticDateTimeEdit->dateTime().toString( Qt::ISODateWithMs ) + '/' +
mEndStaticDateTimeEdit->dateTime().toString( Qt::ISODateWithMs );
uri[ QStringLiteral( "time" ) ] = time;
uri[ QStringLiteral( "temporalSource" ) ] = QLatin1String( "provider" );
}

if ( QgsProject::instance()->timeSettings() )
range = QgsProject::instance()->timeSettings()->temporalRange();
if ( range.begin().isValid() && range.end().isValid() )
if ( mProjectTemporalRange->isChecked() )
{
QString time = range.begin().toString( Qt::ISODateWithMs ) + '/' +
range.end().toString( Qt::ISODateWithMs );
QgsDateTimeRange range;

uri[ QStringLiteral( "time" ) ] = time;
uri[ QStringLiteral( "temporalSource" ) ] = QLatin1String( "project" );
if ( QgsProject::instance()->timeSettings() )
range = QgsProject::instance()->timeSettings()->temporalRange();
if ( range.begin().isValid() && range.end().isValid() )
{
QString time = range.begin().toString( Qt::ISODateWithMs ) + '/' +
range.end().toString( Qt::ISODateWithMs );

uri[ QStringLiteral( "time" ) ] = time;
uri[ QStringLiteral( "temporalSource" ) ] = QLatin1String( "project" );
}
}
}

if ( mReferenceTime->isChecked() )
{
QString referenceTime = mReferenceDateTimeEdit->dateTime().toString( Qt::ISODateWithMs );
uri[ QStringLiteral( "referenceTime" ) ] = referenceTime;
}
else
{
if ( uri.contains( QStringLiteral( "referenceTime" ) ) )
uri.remove( QStringLiteral( "referenceTime" ) );
if ( mReferenceTime->isChecked() )
{
QString referenceTime = mReferenceDateTimeEdit->dateTime().toString( Qt::ISODateWithMs );
uri[ QStringLiteral( "referenceTime" ) ] = referenceTime;
}
else
{
if ( uri.contains( QStringLiteral( "referenceTime" ) ) )
uri.remove( QStringLiteral( "referenceTime" ) );
}
}
bool enableTime = !mDisableTime->isChecked();

uri[ QStringLiteral( "enableTime" ) ] = enableTime;
qobject_cast< QgsRasterLayerTemporalProperties * >( mRasterLayer->temporalProperties() )->setIntervalHandlingMethod( static_cast< QgsRasterDataProviderTemporalCapabilities::IntervalHandlingMethod >(
mFetchModeComboBox->currentData().toInt() ) );
}

if ( currentUri != uri )
Expand Down Expand Up @@ -1359,6 +1368,13 @@ void QgsRasterLayerProperties::setSourceStaticTimeState()

mDisableTime->setChecked( !enableTime );

mWmstOptions->setEnabled( !mRasterLayer->temporalProperties()->isActive() );

if ( mRasterLayer->temporalProperties()->isActive() )
mWmstOptionsLabel->setText( "The static temporal options below are disabled because the layer "
"temporal properties are active, to enable them disable temporal properties "
"in the temporal tab. " );

mWmstGroup->setChecked( uri.contains( QStringLiteral( "allowTemporalUpdates" ) ) &&
uri.value( QStringLiteral( "allowTemporalUpdates" ), true ).toBool() );
}
Expand Down Expand Up @@ -1390,6 +1406,18 @@ void QgsRasterLayerProperties::passProjectTemporalRange_toggled( bool checked )
}
}

void QgsRasterLayerProperties::temporalPropertiesChange()
{
mWmstOptions->setEnabled( !mRasterLayer->temporalProperties()->isActive() );

if ( mRasterLayer->temporalProperties()->isActive() )
mWmstOptionsLabel->setText( "The static temporal options below are disabled because the layer "
"temporal properties are active, to enable them disable temporal properties "
"in the temporal tab. " );
else
mWmstOptionsLabel->clear();
}

void QgsRasterLayerProperties::mLayerOrigNameLineEd_textEdited( const QString &text )
{
leDisplayName->setText( mRasterLayer->formatLayerName( text ) );
Expand Down
3 changes: 3 additions & 0 deletions src/gui/raster/qgsrasterlayerproperties.h
Expand Up @@ -113,6 +113,9 @@ class GUI_EXPORT QgsRasterLayerProperties : public QgsOptionsDialogBase, private
//! \brief slot executed when user "Static time range" radio button on time options in source page.
void staticTemporalRange_toggled( bool checked );

//! \brief slot executed when temporal properties status change.
void temporalPropertiesChange();

/**
* \brief slot executed when the single band radio button is pressed.
* \brief slot executed when the reset null value to file default icon is selected
Expand Down

0 comments on commit 9dcc699

Please sign in to comment.