diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2021-08-17 11:19:41 -0700 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2021-08-18 13:22:02 -0700 |
commit | b1d53481ad5f28290ed932fcb2a34ea827b819ef (patch) | |
tree | 8c6aa9b4565fdd14f3c705694559786431d96f0d | |
parent | e7a5ec46f5577656acd1ce44b34e761193ab015b (diff) | |
download | subsurface-b1d53481ad5f28290ed932fcb2a34ea827b819ef.tar.gz |
profile: use undo infrastructure for editing nicknames
This does the right thing even when removing a nickname by setting it to
an empty string. The oddly named DiveListNotifier handles the need to
redraw the profile when the name changes.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-rw-r--r-- | profile-widget/profilewidget2.cpp | 11 |
1 files changed, 3 insertions, 8 deletions
diff --git a/profile-widget/profilewidget2.cpp b/profile-widget/profilewidget2.cpp index 7f90c065f..ba29a9640 100644 --- a/profile-widget/profilewidget2.cpp +++ b/profile-widget/profilewidget2.cpp @@ -164,6 +164,7 @@ ProfileWidget2::ProfileWidget2(DivePlannerPointsModel *plannerModelIn, QWidget * connect(&diveListNotifier, &DiveListNotifier::eventsChanged, this, &ProfileWidget2::profileChanged); connect(&diveListNotifier, &DiveListNotifier::pictureOffsetChanged, this, &ProfileWidget2::pictureOffsetChanged); connect(&diveListNotifier, &DiveListNotifier::divesChanged, this, &ProfileWidget2::divesChanged); + connect(&diveListNotifier, &DiveListNotifier::deviceEdited, this, &ProfileWidget2::replot); #endif // SUBSURFACE_MOBILE #if !defined(QT_NO_DEBUG) && defined(SHOW_PLOT_INFO_TABLE) @@ -1451,14 +1452,8 @@ void ProfileWidget2::renameCurrentDC() QString newName = QInputDialog::getText(this, tr("Edit nickname"), tr("Set new nickname for %1 (serial %2):").arg(current_dc->model).arg(current_dc->serial), QLineEdit::Normal, get_dc_nickname(current_dc), &ok); - if (ok) { - // this needs to happen using the Undo code - // note that an empty nickname is valid - it simply removes the nickname for this dive computer - create_device_node(&device_table, current_dc->model, current_dc->serial, qPrintable(newName)); - - // now trigger the redraw of the profile with the updated nickname - } - + if (ok) + Command::editDeviceNickname(current_dc, newName); } void ProfileWidget2::hideEvents(DiveEventItem *item) |