aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2021-08-17 00:10:33 -0700
committerGravatar Dirk Hohndel <dirk@hohndel.org>2021-08-18 13:22:02 -0700
commit2c12648156a85efa038e0dfd566cef43f9d46eca (patch)
treeea40a2aeaeb9c2a6c7eea2b8f87f38965c30c658
parentd141bbf38fab99ea31ba45a79a95046ce152b982 (diff)
downloadsubsurface-2c12648156a85efa038e0dfd566cef43f9d46eca.tar.gz
WIP profile: add UI to edit dc nickname
This is just a quick first implementation - it will need to use the undo code in the future, but for now this is a reasonable first step. It's also missing the code to redraw the profile with the updated DC name. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-rw-r--r--profile-widget/profilewidget2.cpp16
1 files changed, 12 insertions, 4 deletions
diff --git a/profile-widget/profilewidget2.cpp b/profile-widget/profilewidget2.cpp
index b714f72d4..7f90c065f 100644
--- a/profile-widget/profilewidget2.cpp
+++ b/profile-widget/profilewidget2.cpp
@@ -1447,10 +1447,18 @@ void ProfileWidget2::makeFirstDC()
void ProfileWidget2::renameCurrentDC()
{
- // Add UI code to give a new name, and do
- // create_device_node(device_table, dc->model, serial, nickname)
- // where 'serial' is the dc extradata for "Serial" and
- // nickname is the new nickname (empty deletes the entry)
+ bool ok;
+ 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
+ }
+
}
void ProfileWidget2::hideEvents(DiveEventItem *item)