Skip to content

Commit

Permalink
When clicking the "time range from project" button in the temporal dock,
Browse files Browse the repository at this point in the history
if NO explicit time range is set for a project then automatically calculate
the range from the map's layers
  • Loading branch information
nyalldawson committed Mar 13, 2020
1 parent ade535b commit 3b6c4db
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/gui/qgstemporalcontrollerwidget.cpp
Expand Up @@ -21,6 +21,7 @@
#include "qgsprojecttimesettings.h"
#include "qgstemporalnavigationobject.h"
#include "qgstemporalmapsettingswidget.h"
#include "qgstemporalutils.h"

QgsTemporalControllerWidget::QgsTemporalControllerWidget( QWidget *parent )
: QgsPanelWidget( parent )
Expand Down Expand Up @@ -187,9 +188,17 @@ void QgsTemporalControllerWidget::timeSlider_valueChanged( int value )
void QgsTemporalControllerWidget::setDatesToProjectTime()
{
QgsDateTimeRange range;

// by default try taking the project's fixed temporal extent
if ( QgsProject::instance()->timeSettings() )
range = QgsProject::instance()->timeSettings()->temporalRange();

// if that's not set, calculate the extent from the project's layers
if ( !range.begin().isValid() || !range.end().isValid() )
{
range = QgsTemporalUtils::calculateTemporalRangeForProject( QgsProject::instance() );
}

if ( range.begin().isValid() && range.end().isValid() )
{
mStartDateTime->setDateTime( range.begin() );
Expand Down

0 comments on commit 3b6c4db

Please sign in to comment.