mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Filter: support imperial units
1) Choose the correct conversion function for comparison. 2) Add a unit suffix to the fields. 3) Update the suffixes on change of preferences. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
e8b0d165a7
commit
b28e0bf0b9
3 changed files with 23 additions and 4 deletions
|
@ -104,14 +104,13 @@ bool MultiFilterSortModel::showDive(const struct dive *d) const
|
|||
if (d->rating < filterData.minRating || d->rating > filterData.maxRating)
|
||||
return false;
|
||||
|
||||
// TODO: get the preferences for the imperial vs metric data.
|
||||
// ignore the check if it doesn't makes sense.
|
||||
auto temp_comp = prefs.units.temperature == units::CELSIUS ? C_to_mkelvin : F_to_mkelvin;
|
||||
if (d->watertemp.mkelvin &&
|
||||
(d->watertemp.mkelvin < C_to_mkelvin(filterData.minWaterTemp) || d->watertemp.mkelvin > C_to_mkelvin((filterData.maxWaterTemp))))
|
||||
(d->watertemp.mkelvin < (*temp_comp)(filterData.minWaterTemp) || d->watertemp.mkelvin > (*temp_comp)(filterData.maxWaterTemp)))
|
||||
return false;
|
||||
|
||||
if (d->airtemp.mkelvin &&
|
||||
(d->airtemp.mkelvin < C_to_mkelvin(filterData.minAirTemp) || d->airtemp.mkelvin > C_to_mkelvin(filterData.maxAirTemp)))
|
||||
(d->airtemp.mkelvin < (*temp_comp)(filterData.minAirTemp) || d->airtemp.mkelvin > (*temp_comp)(filterData.maxAirTemp)))
|
||||
return false;
|
||||
|
||||
QDateTime t = filterData.fromDate;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue