Skip to content
Permalink
Browse files

Fix project properties shows random dates for project temporal range

when temporal range has not been set
  • Loading branch information
nyalldawson committed Mar 13, 2020
1 parent 3b6c4db commit 64329ea16ee632e8c4fd24bea24f8d5ccb6e024e
Showing with 46 additions and 84 deletions.
  1. +5 −34 src/app/qgsprojectproperties.cpp
  2. +41 −50 src/ui/qgsprojectpropertiesbase.ui
@@ -238,24 +238,8 @@ QgsProjectProperties::QgsProjectProperties( QgsMapCanvas *mapCanvas, QWidget *pa
QgsDateTimeRange range = QgsProject::instance()->timeSettings()->temporalRange();
QLocale locale;

mStartDateTimeEdit->setDisplayFormat(
locale.dateTimeFormat( QLocale::ShortFormat ) );
mEndDateTimeEdit->setDisplayFormat(
locale.dateTimeFormat( QLocale::ShortFormat ) );

if ( range.begin().isValid() && range.end().isValid() )
{
mStartDateTimeEdit->setDateTime( range.begin() );
mEndDateTimeEdit->setDateTime( range.end() );

mCurrentRangeLabel->setText( tr( "Current selected range: %1 to %2" ).arg(
mStartDateTimeEdit->dateTime().toString( locale.dateTimeFormat() ),
mEndDateTimeEdit->dateTime().toString( locale.dateTimeFormat() ) ) );
}
else
{
mCurrentRangeLabel->setText( tr( "Project range is not set" ) );
}
mStartDateTimeEdit->setDateTime( range.begin() );
mEndDateTimeEdit->setDateTime( range.end() );

mAutoTransaction->setChecked( QgsProject::instance()->autoTransaction() );
title( QgsProject::instance()->title() );
@@ -1046,7 +1030,7 @@ void QgsProjectProperties::apply()
QgsProject::instance()->setTrustLayerMetadata( mTrustProjectCheckBox->isChecked() );

// Time settings
QDateTime start = mStartDateTimeEdit->dateTime();
QDateTime start = mStartDateTimeEdit->dateTime();
QDateTime end = mEndDateTimeEdit->dateTime();

QgsProject::instance()->timeSettings()->setTemporalRange( QgsDateTimeRange( start, end ) );
@@ -2512,21 +2496,8 @@ void QgsProjectProperties::mButtonAddColor_clicked()
void QgsProjectProperties::calculateFromLayersButton_clicked()
{
const QgsDateTimeRange range = QgsTemporalUtils::calculateTemporalRangeForProject( QgsProject::instance() );
const QDateTime minDate = range.begin();
const QDateTime maxDate = range.end();

if ( !minDate.isValid() || !maxDate.isValid() )
return;

mStartDateTimeEdit->setDateTime( minDate );
mEndDateTimeEdit->setDateTime( maxDate );

QLocale locale;
mCurrentRangeLabel->setText( tr( "Current selected range: %1 to %2" ).arg(
mStartDateTimeEdit->dateTime().toString(
locale.dateTimeFormat( QLocale::ShortFormat ) ),
mEndDateTimeEdit->dateTime().toString(
locale.dateTimeFormat( QLocale::ShortFormat ) ) ) );
mStartDateTimeEdit->setDateTime( range.begin() );
mEndDateTimeEdit->setDateTime( range.end() );
}

QListWidgetItem *QgsProjectProperties::addScaleToScaleList( const QString &newScale )
@@ -245,7 +245,7 @@
</sizepolicy>
</property>
<property name="currentIndex">
<number>9</number>
<number>0</number>
</property>
<widget class="QWidget" name="mProjOptsGeneral">
<layout class="QVBoxLayout" name="verticalLayout_6">
@@ -274,8 +274,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>652</width>
<height>846</height>
<width>671</width>
<height>865</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
@@ -897,8 +897,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>663</width>
<height>164</height>
<width>587</width>
<height>167</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_7">
@@ -972,8 +972,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>315</width>
<height>553</height>
<width>288</width>
<height>563</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_12">
@@ -1548,8 +1548,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>191</width>
<height>55</height>
<width>177</width>
<height>56</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_17">
@@ -1610,8 +1610,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>719</width>
<height>2767</height>
<width>643</width>
<height>2818</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_13">
@@ -2881,43 +2881,39 @@
<property name="title">
<string>Temporal Options</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_22">
<item>
<widget class="QLabel" name="mCurrentRangeLabel">
<property name="styleSheet">
<string notr="true">color:rgb(136, 138, 133);
</string>
<layout class="QGridLayout" name="gridLayout_22" columnstretch="0,1">
<item row="0" column="1">
<widget class="QgsDateTimeEdit" name="mStartDateTimeEdit">
<property name="displayFormat">
<string>M/d/yyyy h:mm AP</string>
</property>
<property name="text">
<string/>
<property name="timeSpec">
<enum>Qt::UTC</enum>
</property>
</widget>
</item>
<item>
<item row="0" column="0">
<widget class="QLabel" name="label_35">
<property name="text">
<string>Start date</string>
</property>
</widget>
</item>
<item>
<widget class="QgsDateTimeEdit" name="mStartDateTimeEdit">
<property name="displayFormat">
<string>M/d/yyyy h:mm AP</string>
</property>
<property name="timeSpec">
<enum>Qt::UTC</enum>
<item row="3" column="1">
<widget class="QPushButton" name="mCalculateFromLayerButton">
<property name="text">
<string>Calculate from Layers</string>
</property>
</widget>
</item>
<item>
<item row="2" column="0">
<widget class="QLabel" name="label_36">
<property name="text">
<string>End date</string>
</property>
</widget>
</item>
<item>
<item row="2" column="1">
<widget class="QgsDateTimeEdit" name="mEndDateTimeEdit">
<property name="displayFormat">
<string>M/d/yyyy h:mm AP</string>
@@ -2927,13 +2923,6 @@
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="mCalculateFromLayerButton">
<property name="text">
<string>Calculate from layers</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
@@ -3002,9 +2991,14 @@
</widget>
<customwidgets>
<customwidget>
<class>QgsCollapsibleGroupBox</class>
<extends>QGroupBox</extends>
<header>qgscollapsiblegroupbox.h</header>
<class>QgsFilterLineEdit</class>
<extends>QLineEdit</extends>
<header>qgsfilterlineedit.h</header>
</customwidget>
<customwidget>
<class>QgsVariableEditorWidget</class>
<extends>QWidget</extends>
<header>qgsvariableeditorwidget.h</header>
<container>1</container>
</customwidget>
<customwidget>
@@ -3013,6 +3007,12 @@
<header>qgsscrollarea.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>QgsCollapsibleGroupBox</class>
<extends>QGroupBox</extends>
<header>qgscollapsiblegroupbox.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>QgsDateTimeEdit</class>
<extends>QDateTimeEdit</extends>
@@ -3024,11 +3024,6 @@
<header>qgscolorbutton.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>QgsFilterLineEdit</class>
<extends>QLineEdit</extends>
<header>qgsfilterlineedit.h</header>
</customwidget>
<customwidget>
<class>QgsOpacityWidget</class>
<extends>QWidget</extends>
@@ -3041,12 +3036,6 @@
<header location="global">qgscolorschemelist.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>QgsVariableEditorWidget</class>
<extends>QWidget</extends>
<header location="global">qgsvariableeditorwidget.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>QgsDatumTransformTableWidget</class>
<extends>QWidget</extends>
@@ -3183,6 +3172,8 @@
</tabstops>
<resources>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
</resources>
<connections>
<connection>

0 comments on commit 64329ea

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