diff options
author | Berthold Stoeger <bstoeger@mail.tuwien.ac.at> | 2019-02-07 21:23:00 +0100 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2019-04-12 18:19:07 +0300 |
commit | 02d572226df82ccbdfff3c455c9e5b20a7992bc4 (patch) | |
tree | 26b213e2a2af1302631dd2dd2fd2ed3e622793ed /desktop-widgets/tab-widgets/maintab.cpp | |
parent | a9bd0690fe1d6bd841b0ede2ac53b280ef907b93 (diff) | |
download | subsurface-02d572226df82ccbdfff3c455c9e5b20a7992bc4.tar.gz |
Undo: implement undo of divemaster editing
This is mostly a trivial copy of the buddies code.
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.cpp | 18 |
1 files changed, 6 insertions, 12 deletions
diff --git a/desktop-widgets/tab-widgets/maintab.cpp b/desktop-widgets/tab-widgets/maintab.cpp index eff22192b..77a6c9f5c 100644 --- a/desktop-widgets/tab-widgets/maintab.cpp +++ b/desktop-widgets/tab-widgets/maintab.cpp @@ -378,6 +378,9 @@ void MainTab::divesEdited(const QVector<dive *> &, DiveField field) case DiveField::BUDDY: ui.buddy->setText(current_dive->buddy); break; + case DiveField::DIVEMASTER: + ui.divemaster->setText(current_dive->divemaster); + break; default: break; } @@ -998,21 +1001,12 @@ void MainTab::on_buddy_editingFinished() Command::editBuddies(getSelectedDivesCurrentLast(), stringToList(ui.buddy->toPlainText()), current_dive); } -void MainTab::on_divemaster_textChanged() +void MainTab::on_divemaster_editingFinished() { - if (editMode == IGNORE || acceptingEdit == true) - return; - - if (same_string(displayed_dive.divemaster, qPrintable(ui.divemaster->toPlainText()))) + if (editMode == IGNORE || acceptingEdit == true || !current_dive) return; - QStringList text_list = ui.divemaster->toPlainText().split(",", QString::SkipEmptyParts); - for (int i = 0; i < text_list.size(); i++) - text_list[i] = text_list[i].trimmed(); - QString text = text_list.join(", "); - free(displayed_dive.divemaster); - displayed_dive.divemaster = copy_qstring(text); - markChangedWidget(ui.divemaster); + Command::editDiveMaster(getSelectedDivesCurrentLast(), stringToList(ui.divemaster->toPlainText()), current_dive); } void MainTab::on_duration_textChanged(const QString &text) |