Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #38601 from rduivenvoorde/temporalExtentsChanged_s…
…ignal

Add temporalExtentsChanged signal to QgsTemporalNavigationObject
  • Loading branch information
m-kuhn committed Sep 8, 2020
2 parents e31d4cd + 32b83a1 commit 5e9ac5b
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 2 deletions.
2 changes: 2 additions & 0 deletions python/core/auto_generated/qgsrange.sip.in
Expand Up @@ -258,6 +258,8 @@ If the range is empty and ``other`` is not, the range is changed and set to ``ot

bool operator==( const QgsTemporalRange<T> &other ) const;

bool operator!=( const QgsTemporalRange<T> &other ) const;

};


Expand Down
5 changes: 5 additions & 0 deletions python/core/auto_generated/qgstemporalnavigationobject.sip.in
Expand Up @@ -201,6 +201,11 @@ Emitted whenever the animation ``state`` changes.
void navigationModeChanged( NavigationMode mode );
%Docstring
Emitted whenever the navigation ``mode`` changes.
%End

void temporalExtentsChanged( const QgsDateTimeRange &extent );
%Docstring
Emitted whenever the temporalExtent ``extent`` changes.
%End

public slots:
Expand Down
5 changes: 5 additions & 0 deletions src/core/qgsrange.h
Expand Up @@ -458,6 +458,11 @@ class QgsTemporalRange
mIncludeUpper == other.includeEnd();
}

bool operator!=( const QgsTemporalRange<T> &other ) const
{
return ( ! operator==( other ) );
}

private:

T mLower;
Expand Down
10 changes: 8 additions & 2 deletions src/core/qgstemporalnavigationobject.cpp
Expand Up @@ -128,17 +128,22 @@ void QgsTemporalNavigationObject::setNavigationMode( const NavigationMode mode )

void QgsTemporalNavigationObject::setTemporalExtents( const QgsDateTimeRange &temporalExtents )
{
if ( mTemporalExtents == temporalExtents )
{
return;
}
mTemporalExtents = temporalExtents;
emit temporalExtentsChanged( mTemporalExtents );

switch ( mNavigationMode )
{
case Animated:
{
int currentFrameNmber = mCurrentFrameNumber;
int currentFrameNumber = mCurrentFrameNumber;
setCurrentFrameNumber( 0 );

//Force to emit signal if the current frame number doesn't change
if ( currentFrameNmber == mCurrentFrameNumber )
if ( currentFrameNumber == mCurrentFrameNumber )
emit updateTemporalRange( dateTimeRangeForFrameNumber( 0 ) );
break;
}
Expand All @@ -148,6 +153,7 @@ void QgsTemporalNavigationObject::setTemporalExtents( const QgsDateTimeRange &te
case NavigationOff:
break;
}

}

QgsDateTimeRange QgsTemporalNavigationObject::temporalExtents() const
Expand Down
5 changes: 5 additions & 0 deletions src/core/qgstemporalnavigationobject.h
Expand Up @@ -217,6 +217,11 @@ class CORE_EXPORT QgsTemporalNavigationObject : public QgsTemporalController, pu
*/
void navigationModeChanged( NavigationMode mode );

/**
* Emitted whenever the temporalExtent \a extent changes.
*/
void temporalExtentsChanged( const QgsDateTimeRange &extent );

public slots:

/**
Expand Down
1 change: 1 addition & 0 deletions src/gui/qgstemporalcontrollerwidget.cpp
Expand Up @@ -52,6 +52,7 @@ QgsTemporalControllerWidget::QgsTemporalControllerWidget( QWidget *parent )

setWidgetStateFromNavigationMode( mNavigationObject->navigationMode() );
connect( mNavigationObject, &QgsTemporalNavigationObject::navigationModeChanged, this, &QgsTemporalControllerWidget::setWidgetStateFromNavigationMode );
connect( mNavigationObject, &QgsTemporalNavigationObject::temporalExtentsChanged, this, &QgsTemporalControllerWidget::setDates );
connect( mNavigationOff, &QPushButton::clicked, this, &QgsTemporalControllerWidget::mNavigationOff_clicked );
connect( mNavigationFixedRange, &QPushButton::clicked, this, &QgsTemporalControllerWidget::mNavigationFixedRange_clicked );
connect( mNavigationAnimated, &QPushButton::clicked, this, &QgsTemporalControllerWidget::mNavigationAnimated_clicked );
Expand Down

0 comments on commit 5e9ac5b

Please sign in to comment.