diff options
author | Berthold Stoeger <bstoeger@mail.tuwien.ac.at> | 2019-01-28 22:35:07 +0100 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2019-04-12 18:19:07 +0300 |
commit | 42cfd3f9638a5f9d37e51285e6d1eaaad3e78501 (patch) | |
tree | da20dbdfd7358638df99a20eab392cf894f9d609 /desktop-widgets/tab-widgets | |
parent | 512a2e6b684e237c5e6aacd3cba42fb7d2093e0a (diff) | |
download | subsurface-42cfd3f9638a5f9d37e51285e6d1eaaad3e78501.tar.gz |
Undo: implement undo of rating and visibility rating
This was rather trivial and modeled after the previous edit
UndoCommands. Since this is the first time we're editing
integers a new constructor instantiation had to be added.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'desktop-widgets/tab-widgets')
-rw-r--r-- | desktop-widgets/tab-widgets/maintab.cpp | 28 |
1 files changed, 12 insertions, 16 deletions
diff --git a/desktop-widgets/tab-widgets/maintab.cpp b/desktop-widgets/tab-widgets/maintab.cpp index 962cdc645..2f6c8c8cd 100644 --- a/desktop-widgets/tab-widgets/maintab.cpp +++ b/desktop-widgets/tab-widgets/maintab.cpp @@ -342,6 +342,12 @@ void MainTab::divesEdited(const QVector<dive *> &, DiveField field) return; switch(field) { + case DiveField::RATING: + ui.rating->setCurrentStars(current_dive->rating); + break; + case DiveField::VISIBILITY: + ui.visibility->setCurrentStars(current_dive->visibility); + break; case DiveField::SUIT: ui.suit->setText(QString(current_dive->suit)); break; @@ -798,10 +804,6 @@ void MainTab::acceptChanges() struct dive *cd = current_dive; // now check if something has changed and if yes, edit the selected dives that // were identical with the master dive shown (and mark the divelist as changed) - if (displayed_dive.rating != cd->rating) - MODIFY_DIVES(selectedDives, EDIT_VALUE(rating)); - if (displayed_dive.visibility != cd->visibility) - MODIFY_DIVES(selectedDives, EDIT_VALUE(visibility)); if (displayed_dive.airtemp.mkelvin != cd->airtemp.mkelvin) MODIFY_DIVES(selectedDives, EDIT_VALUE(airtemp.mkelvin)); if (displayed_dive.watertemp.mkelvin != cd->watertemp.mkelvin) @@ -1378,24 +1380,18 @@ void MainTab::on_notes_editingFinished() void MainTab::on_rating_valueChanged(int value) { - if (acceptingEdit == true) + if (acceptingEdit == true || !current_dive) return; - if (displayed_dive.rating != value) { - displayed_dive.rating = value; - modified = true; - enableEdition(); - } + + Command::editRating(getSelectedDivesCurrentLast(), value, current_dive->rating); } void MainTab::on_visibility_valueChanged(int value) { - if (acceptingEdit == true) + if (acceptingEdit == true || !current_dive) return; - if (displayed_dive.visibility != value) { - displayed_dive.visibility = value; - modified = true; - enableEdition(); - } + + Command::editVisibility(getSelectedDivesCurrentLast(), value, current_dive->visibility); } #undef MODIFY_DIVES |