diff options
author | Berthold Stoeger <bstoeger@mail.tuwien.ac.at> | 2019-10-13 12:44:39 +0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2019-10-26 11:36:23 -0700 |
commit | 8dea2ada3bc9d0fcfbe1bb101ea079480dfdbe57 (patch) | |
tree | 12611a44e6f9efef1fa3ed8ce510d78b6841e63c /desktop-widgets/tab-widgets/TabDiveInformation.cpp | |
parent | 5c4d163a41c69538c8a658db82dde1a7486b6759 (diff) | |
download | subsurface-8dea2ada3bc9d0fcfbe1bb101ea079480dfdbe57.tar.gz |
Undo: turn dive- and trip-fields into flags
The divesEdited signal sends the changed field as a parameter.
Since some undo-commands change multiple fields, this led to
numerous signals for a single command. This in turn would lead
to multiple profile-reloads and statistic recalculations.
Therefore, turn the enum into a bitfield. For simplicity,
provide a constructor that takes classical flags and turns
them into the bitfield. This is necessary because C-style
named initialization is only supported on C++20 onward!
Is this somewhat overengineered? Yes, maybe.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'desktop-widgets/tab-widgets/TabDiveInformation.cpp')
-rw-r--r-- | desktop-widgets/tab-widgets/TabDiveInformation.cpp | 24 |
1 files changed, 6 insertions, 18 deletions
diff --git a/desktop-widgets/tab-widgets/TabDiveInformation.cpp b/desktop-widgets/tab-widgets/TabDiveInformation.cpp index 66c1f7401..273bf4525 100644 --- a/desktop-widgets/tab-widgets/TabDiveInformation.cpp +++ b/desktop-widgets/tab-widgets/TabDiveInformation.cpp @@ -141,30 +141,18 @@ void TabDiveInformation::divesChanged(const QVector<dive *> &dives, DiveField fi if (!current_dive || !dives.contains(current_dive)) return; - switch(field) { - case DiveField::DURATION: - case DiveField::DEPTH: - case DiveField::MODE: + if (field.duration || field.depth || field.mode) updateProfile(); - break; - case DiveField::AIR_TEMP: + if (field.air_temp) ui->airTemperatureText->setText(get_temperature_string(current_dive->airtemp, true)); - break; - case DiveField::WATER_TEMP: + if (field.water_temp) ui->waterTemperatureText->setText(get_temperature_string(current_dive->watertemp, true)); - break; - case DiveField::ATM_PRESS: + if (field.atm_press) ui->atmPressVal->setText(ui->atmPressVal->text().sprintf("%d",current_dive->surface_pressure.mbar)); - break; - case DiveField::DATETIME: + if (field.datetime) updateWhen(); - break; - case DiveField::SALINITY: + if (field.salinity) updateSalinity(); - break; - default: - break; - } } void TabDiveInformation::on_atmPressType_currentIndexChanged(int index) { updateTextBox(COMBO_CHANGED); } |