Skip to content

Commit

Permalink
[layouts] Ensure time range set for map items have end exclusive
Browse files Browse the repository at this point in the history
if they are not set to show a time instant

And clearly reflect this in the UI
  • Loading branch information
nyalldawson committed Mar 30, 2021
1 parent 75975bb commit cbc18e1
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 29 deletions.
8 changes: 4 additions & 4 deletions src/core/layout/qgslayoutitemmap.cpp
Expand Up @@ -864,9 +864,9 @@ bool QgsLayoutItemMap::readPropertiesFromElement( const QDomElement &itemElem, c
setIsTemporal( itemElem.attribute( QStringLiteral( "isTemporal" ) ).toInt() );
if ( isTemporal() )
{
QDateTime begin = QDateTime::fromString( itemElem.attribute( QStringLiteral( "temporalRangeBegin" ) ), Qt::ISODate );
QDateTime end = QDateTime::fromString( itemElem.attribute( QStringLiteral( "temporalRangeEnd" ) ), Qt::ISODate );
setTemporalRange( QgsDateTimeRange( begin, end ) );
const QDateTime begin = QDateTime::fromString( itemElem.attribute( QStringLiteral( "temporalRangeBegin" ) ), Qt::ISODate );
const QDateTime end = QDateTime::fromString( itemElem.attribute( QStringLiteral( "temporalRangeEnd" ) ), Qt::ISODate );
setTemporalRange( QgsDateTimeRange( begin, end, true, begin == end ) );
}

mUpdatesEnabled = true;
Expand Down Expand Up @@ -1922,7 +1922,7 @@ void QgsLayoutItemMap::refreshDataDefinedProperty( const QgsLayoutObject::DataDe
if ( property == QgsLayoutObject::EndDateTime || property == QgsLayoutObject::AllProperties )
end = mDataDefinedProperties.valueAsDateTime( QgsLayoutObject::EndDateTime, context, temporalRange().end() );

setTemporalRange( QgsDateTimeRange( begin, end ) );
setTemporalRange( QgsDateTimeRange( begin, end, true, begin == end ) );
}

//force redraw
Expand Down
7 changes: 3 additions & 4 deletions src/gui/layout/qgslayoutmapwidget.cpp
Expand Up @@ -525,9 +525,6 @@ void QgsLayoutMapWidget::mTemporalCheckBox_toggled( bool checked )
return;
}

mStartDateTime->setEnabled( checked );
mEndDateTime->setEnabled( checked );

mMapItem->layout()->undoStack()->beginCommand( mMapItem, tr( "Toggle Temporal Range" ) );
mMapItem->setIsTemporal( checked );
mMapItem->layout()->undoStack()->endCommand();
Expand All @@ -548,7 +545,9 @@ void QgsLayoutMapWidget::updateTemporalExtent()
return;
}

QgsDateTimeRange range = QgsDateTimeRange( mStartDateTime->dateTime(), mEndDateTime->dateTime() );
const QDateTime begin = mStartDateTime->dateTime();
const QDateTime end = mEndDateTime->dateTime();
QgsDateTimeRange range = QgsDateTimeRange( begin, end, true, begin == end );

mMapItem->layout()->undoStack()->beginCommand( mMapItem, tr( "Set Temporal Range" ) );
mMapItem->setTemporalRange( range );
Expand Down
34 changes: 13 additions & 21 deletions src/ui/layout/qgslayoutmapwidgetbase.ui
Expand Up @@ -88,9 +88,9 @@
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<y>-376</y>
<width>548</width>
<height>1336</height>
<height>1398</height>
</rect>
</property>
<property name="sizePolicy">
Expand Down Expand Up @@ -445,11 +445,8 @@
<layout class="QGridLayout" name="gridLayout_5">
<item row="0" column="0">
<widget class="QLabel" name="mStartDateTimeLabel">
<property name="enabled">
<bool>true</bool>
</property>
<property name="text">
<string>Start</string>
<string>Start (inclusive)</string>
</property>
<property name="wordWrap">
<bool>false</bool>
Expand Down Expand Up @@ -484,11 +481,8 @@
</item>
<item row="1" column="0">
<widget class="QLabel" name="mEndDateTimeLabel">
<property name="enabled">
<bool>true</bool>
</property>
<property name="text">
<string>End</string>
<string>End (exclusive)</string>
</property>
<property name="wordWrap">
<bool>false</bool>
Expand Down Expand Up @@ -1010,27 +1004,27 @@
</widget>
<layoutdefault spacing="6" margin="11"/>
<customwidgets>
<customwidget>
<class>QgsSpinBox</class>
<extends>QSpinBox</extends>
<header>qgsspinbox.h</header>
</customwidget>
<customwidget>
<class>QgsDoubleSpinBox</class>
<extends>QDoubleSpinBox</extends>
<header>qgsdoublespinbox.h</header>
</customwidget>
<customwidget>
<class>QgsScrollArea</class>
<extends>QScrollArea</extends>
<header>qgsscrollarea.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>QgsProjectionSelectionWidget</class>
<extends>QWidget</extends>
<header>qgsprojectionselectionwidget.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>QgsScrollArea</class>
<extends>QScrollArea</extends>
<header>qgsscrollarea.h</header>
<container>1</container>
<class>QgsSpinBox</class>
<extends>QSpinBox</extends>
<header>qgsspinbox.h</header>
</customwidget>
<customwidget>
<class>QgsPropertyOverrideButton</class>
Expand Down Expand Up @@ -1126,8 +1120,6 @@
</tabstops>
<resources>
<include location="../../../images/images.qrc"/>
<include location="../../../images/images.qrc"/>
<include location="../../../images/images.qrc"/>
</resources>
<connections/>
</ui>

0 comments on commit cbc18e1

Please sign in to comment.