summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Jan Mulder <jlmulder@xs4all.nl>2019-01-20 17:00:56 +0100
committerGravatar Dirk Hohndel <dirk@hohndel.org>2019-01-21 17:22:24 +1200
commite8b0d165a78e802c09edc7dd0ea4ae5bed1d46d6 (patch)
tree2c2ee51bc48f074f69003a3d7897c310684e1813
parent5986225fcec159a9fa4d18cc89e54ae18d97e333 (diff)
downloadsubsurface-e8b0d165a78e802c09edc7dd0ea4ae5bed1d46d6.tar.gz
Desktop, Filter UI: make date/time consistent
On all (most?) places we use separate date/time fields for the time of a dive, and we follow the setting from the preferences to format those. Make the new filter widget consistent, with respect to the to and from interval. Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
-rw-r--r--desktop-widgets/filterwidget2.cpp24
-rw-r--r--desktop-widgets/filterwidget2.ui34
-rw-r--r--qt-models/filtermodels.cpp10
-rw-r--r--qt-models/filtermodels.h6
4 files changed, 57 insertions, 17 deletions
diff --git a/desktop-widgets/filterwidget2.cpp b/desktop-widgets/filterwidget2.cpp
index 4a1d2e807..d6a8acad5 100644
--- a/desktop-widgets/filterwidget2.cpp
+++ b/desktop-widgets/filterwidget2.cpp
@@ -24,7 +24,13 @@ FilterWidget2::FilterWidget2(QWidget* parent) : QWidget(parent)
ui.labelEquipment->hide();
ui.invertFilter->hide();
- ui.to->setDate(data.to.date());
+ ui.fromDate->setDisplayFormat(prefs.date_format);
+ ui.fromTime->setDisplayFormat(prefs.time_format);
+
+ ui.toDate->setDisplayFormat(prefs.date_format);
+ ui.toTime->setDisplayFormat(prefs.time_format);
+ ui.toDate->setDate(data.toDate.date());
+ ui.toTime->setTime(data.toTime);
connect(ui.maxRating, &StarWidget::valueChanged,
this, &FilterWidget2::updateFilter);
@@ -50,10 +56,16 @@ FilterWidget2::FilterWidget2(QWidget* parent) : QWidget(parent)
connect(ui.minWaterTemp, static_cast<void (QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged),
this, &FilterWidget2::updateFilter);
- connect(ui.from, &QDateTimeEdit::dateTimeChanged,
+ connect(ui.fromDate, &QDateTimeEdit::dateChanged,
+ this, &FilterWidget2::updateFilter);
+
+ connect(ui.fromTime, &QDateTimeEdit::timeChanged,
+ this, &FilterWidget2::updateFilter);
+
+ connect(ui.toDate, &QDateTimeEdit::dateChanged,
this, &FilterWidget2::updateFilter);
- connect(ui.to, &QDateTimeEdit::dateTimeChanged,
+ connect(ui.toTime, &QDateTimeEdit::timeChanged,
this, &FilterWidget2::updateFilter);
connect(ui.tags, &QLineEdit::textChanged,
@@ -81,8 +93,10 @@ void FilterWidget2::updateFilter()
filterData.maxWaterTemp = ui.maxWaterTemp->value();
filterData.minAirTemp = ui.minAirTemp->value();
filterData.maxWaterTemp = ui.maxWaterTemp->value();
- filterData.from = ui.from->dateTime();
- filterData.to = ui.to->dateTime();
+ filterData.fromDate = ui.fromDate->dateTime();
+ filterData.fromTime = ui.fromTime->time();
+ filterData.toDate = ui.toDate->dateTime();
+ filterData.toTime = ui.toTime->time();
filterData.tags = ui.tags->text().split(",", QString::SkipEmptyParts);
filterData.people = ui.people->text().split(",", QString::SkipEmptyParts);
filterData.location = ui.location->text().split(",", QString::SkipEmptyParts);
diff --git a/desktop-widgets/filterwidget2.ui b/desktop-widgets/filterwidget2.ui
index 8cee672e8..7ed52ef4e 100644
--- a/desktop-widgets/filterwidget2.ui
+++ b/desktop-widgets/filterwidget2.ui
@@ -160,9 +160,6 @@
</property>
</widget>
</item>
- <item row="5" column="1" colspan="4">
- <widget class="QDateTimeEdit" name="from"/>
- </item>
<item row="10" column="0">
<widget class="QLabel" name="label_9">
<property name="text">
@@ -170,9 +167,6 @@
</property>
</widget>
</item>
- <item row="6" column="1" colspan="4">
- <widget class="QDateTimeEdit" name="to"/>
- </item>
<item row="4" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
@@ -252,6 +246,26 @@
</property>
</widget>
</item>
+ <item row="5" column="3">
+ <widget class="QTimeEdit" name="fromTime"/>
+ </item>
+ <item row="5" column="1" colspan="2">
+ <widget class="QDateTimeEdit" name="fromDate">
+ <property name="calendarPopup">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="6" column="1" colspan="2">
+ <widget class="QDateTimeEdit" name="toDate">
+ <property name="calendarPopup">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="6" column="3">
+ <widget class="QTimeEdit" name="toTime"/>
+ </item>
</layout>
</widget>
<customwidgets>
@@ -267,8 +281,12 @@
<tabstop>maxRating</tabstop>
<tabstop>minVisibility</tabstop>
<tabstop>maxVisibility</tabstop>
- <tabstop>from</tabstop>
- <tabstop>to</tabstop>
+ <tabstop>fromDate</tabstop>
+ <tabstop>fromTime</tabstop>
+ <tabstop>toDate</tabstop>
+ <tabstop>toTime</tabstop>
+ <tabstop>logged</tabstop>
+ <tabstop>planned</tabstop>
<tabstop>tags</tabstop>
<tabstop>people</tabstop>
<tabstop>location</tabstop>
diff --git a/qt-models/filtermodels.cpp b/qt-models/filtermodels.cpp
index 2f3ce99a8..6efac8348 100644
--- a/qt-models/filtermodels.cpp
+++ b/qt-models/filtermodels.cpp
@@ -114,10 +114,16 @@ bool MultiFilterSortModel::showDive(const struct dive *d) const
(d->airtemp.mkelvin < C_to_mkelvin(filterData.minAirTemp) || d->airtemp.mkelvin > C_to_mkelvin(filterData.maxAirTemp)))
return false;
- if (filterData.from.isValid() && d->when < filterData.from.toTime_t())
+ QDateTime t = filterData.fromDate;
+ t.setTime(filterData.fromTime);
+ if (filterData.fromDate.isValid() && filterData.fromTime.isValid() &&
+ d->when < t.toMSecsSinceEpoch()/1000 + t.offsetFromUtc())
return false;
- if (filterData.to.isValid() && d->when > filterData.to.toTime_t())
+ t = filterData.toDate;
+ t.setTime(filterData.toTime);
+ if (filterData.toDate.isValid() && filterData.toTime.isValid() &&
+ d->when > t.toMSecsSinceEpoch()/1000 + t.offsetFromUtc())
return false;
// tags.
diff --git a/qt-models/filtermodels.h b/qt-models/filtermodels.h
index 5cb130522..f9be3a2ad 100644
--- a/qt-models/filtermodels.h
+++ b/qt-models/filtermodels.h
@@ -24,8 +24,10 @@ struct FilterData {
double maxWaterTemp = 100;
double minAirTemp = 0;
double maxAirTemp = 100;
- QDateTime from;
- QDateTime to = QDateTime::currentDateTime();
+ QDateTime fromDate;
+ QTime fromTime;
+ QDateTime toDate = QDateTime::currentDateTime();
+ QTime toTime = QTime::currentTime();
QStringList tags;
QStringList people;
QStringList location;