From 2c12648156a85efa038e0dfd566cef43f9d46eca Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Tue, 17 Aug 2021 00:10:33 -0700 Subject: 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 --- profile-widget/profilewidget2.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'profile-widget') 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) -- cgit v1.2.3-70-g09d2