aboutsummaryrefslogtreecommitdiffstats
path: root/desktop-widgets/tab-widgets/maintab.cpp
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2019-01-25 18:27:31 +0100
committerGravatar Dirk Hohndel <dirk@hohndel.org>2019-04-12 18:19:07 +0300
commit9e603cbe2bbcae1822859b284c39dd804bf321fb (patch)
tree9b4091c07aeea8b4abe65593ab07abc2c7326a52 /desktop-widgets/tab-widgets/maintab.cpp
parent8858bfa1f8cf30cc4eb070fb6e709f7051e61241 (diff)
downloadsubsurface-9e603cbe2bbcae1822859b284c39dd804bf321fb.tar.gz
Undo: implement rudimentary undo of dive-notes editing
Implement a first rudimentary dive-editing command. The main code resides in a base class Command::Edit, which calls virtual functions to read / set the fields and extract the field name. Implement an example: editing of dive notes. This dose not yet update the UI on undo / redo. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'desktop-widgets/tab-widgets/maintab.cpp')
-rw-r--r--desktop-widgets/tab-widgets/maintab.cpp23
1 files changed, 12 insertions, 11 deletions
diff --git a/desktop-widgets/tab-widgets/maintab.cpp b/desktop-widgets/tab-widgets/maintab.cpp
index a077ad2a2..ab2eabd4c 100644
--- a/desktop-widgets/tab-widgets/maintab.cpp
+++ b/desktop-widgets/tab-widgets/maintab.cpp
@@ -767,8 +767,6 @@ void MainTab::acceptChanges()
// were identical with the master dive shown (and mark the divelist as changed)
if (!same_string(displayed_dive.suit, cd->suit))
MODIFY_DIVES(selectedDives, EDIT_TEXT(suit));
- if (!same_string(displayed_dive.notes, cd->notes))
- MODIFY_DIVES(selectedDives, EDIT_TEXT(notes));
if (displayed_dive.rating != cd->rating)
MODIFY_DIVES(selectedDives, EDIT_VALUE(rating));
if (displayed_dive.visibility != cd->visibility)
@@ -1343,16 +1341,19 @@ void MainTab::on_notes_textChanged()
return;
free(displayedTrip.notes);
displayedTrip.notes = copy_qstring(ui.notes->toPlainText());
- } else {
- if (same_string(displayed_dive.notes, qPrintable(ui.notes->toPlainText())))
- return;
- free(displayed_dive.notes);
- if (ui.notes->toHtml().indexOf("<div") != -1)
- displayed_dive.notes = copy_qstring(ui.notes->toHtml());
- else
- displayed_dive.notes = copy_qstring(ui.notes->toPlainText());
+ markChangedWidget(ui.notes);
}
- markChangedWidget(ui.notes);
+}
+
+void MainTab::on_notes_editingFinished()
+{
+ if (currentTrip || !current_dive)
+ return; // Trip-note editing is done via on_notes_textChanged()
+
+ QString notes = ui.notes->toHtml().indexOf("<div") != -1 ?
+ ui.notes->toHtml() : ui.notes->toPlainText();
+
+ Command::editNotes(getSelectedDivesCurrentLast(), notes, QString(current_dive->notes));
}
void MainTab::on_rating_valueChanged(int value)