Skip to content
Permalink
Browse files

updates on temporal widgets ui

  • Loading branch information
Samweli authored and nyalldawson committed Mar 7, 2020
1 parent 3e06d0a commit 3e21500abddb33f4a7a16862cdcefb77370ccd85
@@ -241,7 +241,7 @@ QgsProjectProperties::QgsProjectProperties( QgsMapCanvas *mapCanvas, QWidget *pa
mEndDateTimeEdit->setDateTime( range.end() );
}

mCurrentRangeLabel->setText( tr( "Current range: %1 to %2" ).arg(
mCurrentRangeLabel->setText( tr( "Current selection range: %1 to %2" ).arg(
mStartDateTimeEdit->dateTime().toString( "yyyy-MM-dd hh:mm:ss" ),
mEndDateTimeEdit->dateTime().toString( "yyyy-MM-dd hh:mm:ss" ) ) );

@@ -64,6 +64,8 @@ void QgsRasterLayerTemporalProperties::setTemporalRange( const QgsDateTimeRange

if ( mFixedRange.contains( dateTimeRange ) )
mRange = dateTimeRange;
else
mRange = mFixedRange;
}

const QgsDateTimeRange &QgsRasterLayerTemporalProperties::temporalRange() const
@@ -45,6 +45,7 @@ QgsTemporalVcrDockWidget::QgsTemporalVcrDockWidget( const QString &name, QWidget
connect( mModeComboBox, qgis::overload<int>::of( &QComboBox::currentIndexChanged ), this, &QgsTemporalVcrDockWidget::modeComboBox_currentIndexChanged );
connect( mTimeSlider, &QSlider::valueChanged, this, &QgsTemporalVcrDockWidget::timeSlider_valueChanged );
connect( mSettings, &QPushButton::clicked, this, &QgsTemporalVcrDockWidget::settings_clicked );
connect( mSetToProjectTimeButton, &QPushButton::clicked, this, &QgsTemporalVcrDockWidget::setProjectTime );

connect( mStartDateTime, &QDateTimeEdit::dateTimeChanged, this, &QgsTemporalVcrDockWidget::startDateTime_changed );
connect( mEndDateTime, &QDateTimeEdit::dateTimeChanged, this, &QgsTemporalVcrDockWidget::endDateTime_changed );
@@ -77,6 +78,8 @@ void QgsTemporalVcrDockWidget::init()
mEndDateTime->setDateTime( range.end() );
}

mSetToProjectTimeButton->setToolTip( tr( "Set to project time" ) );

QStringList listSteps = ( QStringList() << tr( "Minutes" ) << tr( "Hours" ) << tr( "Days" ) <<
tr( "Months" ) << ( "Years" ) );

@@ -199,7 +202,12 @@ void QgsTemporalVcrDockWidget::endDateTime_changed( const QDateTime &datetime )
setSliderRange();
}

void QgsTemporalVcrDockWidget::updateDatesLabels( bool useProjectTime )
void QgsTemporalVcrDockWidget::setProjectTime()
{
updateDatesInputs( true );
}

void QgsTemporalVcrDockWidget::updateDatesInputs( bool useProjectTime )
{
if ( useProjectTime )
{
@@ -59,7 +59,7 @@ class GUI_EXPORT QgsTemporalVcrDockWidget : public QgsDockWidget, private Ui::Qg
* Updates the VCR dates time inputs.
* Checks if it should update the inputs using project time settings.
*/
void updateDatesLabels( bool useProjectTime );
void updateDatesInputs( bool useProjectTime );

/**
* Sets the VCR widget time slider.
@@ -162,10 +162,15 @@ class GUI_EXPORT QgsTemporalVcrDockWidget : public QgsDockWidget, private Ui::Qg
void endDateTime_changed( const QDateTime &datetime );

/**
* Loads a temporal map settings dialog
* Loads a temporal map settings dialog.
**/
void settings_clicked();

/**
* Updates on the widget temporal range from project time.
**/
void setProjectTime();

};

#endif // QGSTEMPORALVCRDOCKWIDGET_H
@@ -272,6 +272,7 @@ QgsRasterLayerProperties::QgsRasterLayerProperties( QgsMapLayer *lyr, QgsMapCanv
metadataFrame->setLayout( layout );

QVBoxLayout *temporalLayout = new QVBoxLayout( temporalFrame );
temporalLayout->setContentsMargins( -1, 0, -1, 0 );
mTemporalWidget = new QgsRasterLayerTemporalPropertiesWidget( this, mRasterLayer );
temporalLayout->addWidget( mTemporalWidget );

@@ -1037,6 +1038,9 @@ void QgsRasterLayerProperties::apply()
//set the blend mode for the layer
mRasterLayer->setBlendMode( mBlendModeComboBox->blendMode() );

// Update temporal properties
mTemporalWidget->saveTemporalProperties();

//get the thumbnail for the layer
QPixmap thumbnail = QPixmap::fromImage( mRasterLayer->previewAsImage( pixmapThumbnail->size() ) );
pixmapThumbnail->setPixmap( thumbnail );
@@ -81,7 +81,6 @@ void QgsRasterLayerTemporalPropertiesWidget::referenceCheckBox_clicked()

void QgsRasterLayerTemporalPropertiesWidget::init()
{
mLayerRadioButton->setChecked( true );
setInputWidgetState( TemporalDimension::BiTemporal, false );
setDateTimeInputsLimit();

@@ -93,6 +92,16 @@ void QgsRasterLayerTemporalPropertiesWidget::setDateTimeInputsLimit()
QgsRasterLayer *layer = qobject_cast<QgsRasterLayer *>( mLayer );
if ( layer && layer->temporalProperties() )
{
if ( layer->providerType() == QLatin1String( "wms" ) )
{
layer->temporalProperties()->setMode(
QgsRasterLayerTemporalProperties::ModeTemporalRangeFromDataProvider );
layer->temporalProperties()->setFixedTemporalRange(
layer->dataProvider()->temporalCapabilities()->fixedTemporalRange() );
layer->temporalProperties()->setFixedReferenceTemporalRange(
layer->dataProvider()->temporalCapabilities()->fixedReferenceTemporalRange() );
}

QgsDateTimeRange fixedRange = layer->temporalProperties()->fixedTemporalRange();
QgsDateTimeRange fixedReferenceRange = layer->temporalProperties()->fixedReferenceTemporalRange();

@@ -101,6 +110,12 @@ void QgsRasterLayerTemporalPropertiesWidget::setDateTimeInputsLimit()

// Set initial date time input values to the layers temporal range only if the
// ranges are valid

mStartTemporalDateTimeEdit->setDateTimeRange( fixedRange.begin(), fixedRange.end() );
mEndTemporalDateTimeEdit->setDateTimeRange( fixedRange.begin(), fixedRange.end() );
mStartReferenceDateTimeEdit->setDateTimeRange( fixedReferenceRange.begin(), fixedReferenceRange.end() );
mEndReferenceDateTimeEdit->setDateTimeRange( fixedReferenceRange.begin(), fixedReferenceRange.end() );

if ( range.begin().isValid() && range.end().isValid() )
{
mStartTemporalDateTimeEdit->setDateTime( range.begin() );
@@ -145,6 +160,9 @@ void QgsRasterLayerTemporalPropertiesWidget::setInputWidgetState( TemporalDimens
mEndReferenceDateTimeEdit->setEnabled( enabled );
mSetEndAsStartReferenceButton->setEnabled( enabled );
}

if ( mSource == TemporalRangeSource::Project )
mProjectRadioButton->setChecked( true );
}

void QgsRasterLayerTemporalPropertiesWidget::saveTemporalProperties()
@@ -162,6 +180,7 @@ void QgsRasterLayerTemporalPropertiesWidget::saveTemporalProperties()
rasterLayer->temporalProperties()->setTemporalRange( normalRange );
rasterLayer->temporalProperties()->setTemporalSource( QgsMapLayerTemporalProperties::TemporalSource::Layer );


if ( mReferenceCheckBox->isChecked() )
{
QgsDateTimeRange referenceRange = QgsDateTimeRange( mStartReferenceDateTimeEdit->dateTime(),
@@ -223,7 +242,7 @@ void QgsRasterLayerTemporalPropertiesWidget::updateRangeLabel( QLabel *label )
QgsDateTimeRange range = QgsProject::instance()->timeSettings()->temporalRange();

if ( range.begin().isValid() && range.end().isValid() )
label->setText( tr( "Current selection range: %1 to %2 from the project settings" ).arg(
label->setText( tr( "Project time range is from %1 to %2 " ).arg(
range.begin().toString(),
range.end().toString() ) );
else
@@ -2901,7 +2901,11 @@
</widget>
</item>
<item>
<widget class="QgsDateTimeEdit" name="mStartDateTimeEdit"/>
<widget class="QgsDateTimeEdit" name="mStartDateTimeEdit">
<property name="displayFormat">
<string>M/d/yyyy h:mm AP</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_36">
@@ -2911,7 +2915,11 @@
</widget>
</item>
<item>
<widget class="QgsDateTimeEdit" name="mEndDateTimeEdit"/>
<widget class="QgsDateTimeEdit" name="mEndDateTimeEdit">
<property name="displayFormat">
<string>M/d/yyyy h:mm AP</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="mCalculateFromLayerButton">
@@ -3005,11 +3013,6 @@
<header>qgscolorbutton.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>QgsDateTimeEdit</class>
<extends>QDateTimeEdit</extends>
<header>qgsdatetimeedit.h</header>
</customwidget>
<customwidget>
<class>QgsFilterLineEdit</class>
<extends>QLineEdit</extends>
@@ -3021,6 +3024,11 @@
<header>qgsopacitywidget.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>QgsDateTimeEdit</class>
<extends>QDateTimeEdit</extends>
<header>qgsdatetimeedit.h</header>
</customwidget>
<customwidget>
<class>QgsColorSchemeList</class>
<extends>QWidget</extends>

0 comments on commit 3e21500

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