Skip to content
Permalink
Browse files

[layouts] Ensure time range set for map items have end exclusive

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 cbc18e17ecf425a7f56cade5ed68bb0be6294a53
@@ -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;
@@ -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
@@ -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();
@@ -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 );
@@ -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">
@@ -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>
@@ -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>
@@ -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>
@@ -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.