mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-30 22:20:21 +00:00
Undo: don't create spurious undo commands for temperature fields
When tabbing through the dive-info fields we get *EditingFinished signals. This would create undo commands. The undo commands should recognize if nothing changed. But for the temperature fields, owing to rounding, an unchanged text could actually represent a different value. This would lead to very confusing situations: 1) Edit air temperature 2) Press tab to finish editing 3) Focus goes to water temperature 4) Try to undo change in menu 5) When opening the menu water temperature loses focus 6) Water temperature is edited 7) Undo undos the water temperature, not the air temperature 8) Goto 4 Fortunately, QLineEdit fields have the isModified() member function that returns true if the field was changed by the user. Use this to prevent this case. This is not a general method, i.e. it has to applied to every field with that problem. But it is less intrusive than subclassing the QLineEdit class. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
cdb3bcb1a6
commit
1641147e7b
1 changed files with 8 additions and 2 deletions
|
@ -753,7 +753,10 @@ void MainTab::on_depth_editingFinished()
|
|||
|
||||
void MainTab::on_airtemp_editingFinished()
|
||||
{
|
||||
if (editMode == IGNORE || !current_dive)
|
||||
// If the field wasn't modified by the user, don't post a new undo command.
|
||||
// Owing to rounding errors, this might lead to undo commands that have
|
||||
// no user visible effects. These can be very confusing.
|
||||
if (editMode == IGNORE || !ui.airtemp->isModified() || !current_dive)
|
||||
return;
|
||||
Command::editAirTemp(parseTemperatureToMkelvin(ui.airtemp->text()), false);
|
||||
}
|
||||
|
@ -767,7 +770,10 @@ void MainTab::divetype_Changed(int index)
|
|||
|
||||
void MainTab::on_watertemp_editingFinished()
|
||||
{
|
||||
if (editMode == IGNORE || !current_dive)
|
||||
// If the field wasn't modified by the user, don't post a new undo command.
|
||||
// Owing to rounding errors, this might lead to undo commands that have
|
||||
// no user visible effects. These can be very confusing.
|
||||
if (editMode == IGNORE || !ui.watertemp->isModified() || !current_dive)
|
||||
return;
|
||||
Command::editWaterTemp(parseTemperatureToMkelvin(ui.watertemp->text()), false);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue