diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2021-08-16 19:51:07 -1000 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2021-08-18 13:22:02 -0700 |
commit | 35adf2d72910d0cb287396b08717067d70c8ceb3 (patch) | |
tree | e1ee82b2d8cce7c89588323be10f26662fa6ba5e | |
parent | 2da7e9e5ad15607bb3ef8b198650a688e8f49694 (diff) | |
download | subsurface-35adf2d72910d0cb287396b08717067d70c8ceb3.tar.gz |
Add (nonfunctional) dive computer rename hooks
This adds the menu item to rename a dive computer (ie create a nickname
for it) when right-clicking on the dive computer name of a dive computer
that has a serial number (indicated by having a non-zero ->deviceid).
It is nonfunctional because it's really just the skeleton code: it needs
the UI to actually ask for a new nickname, and then it needs to actually
do the proper "create_device_node(model,serial,nickname)" to set it (or
remove the nickname if empty).
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r-- | profile-widget/profilewidget2.cpp | 15 | ||||
-rw-r--r-- | profile-widget/profilewidget2.h | 1 |
2 files changed, 14 insertions, 2 deletions
diff --git a/profile-widget/profilewidget2.cpp b/profile-widget/profilewidget2.cpp index e296a8b9b..b714f72d4 100644 --- a/profile-widget/profilewidget2.cpp +++ b/profile-widget/profilewidget2.cpp @@ -1304,8 +1304,9 @@ void ProfileWidget2::contextMenuEvent(QContextMenuEvent *event) // figure out if we are ontop of the dive computer name in the profile QGraphicsItem *sceneItem = itemAt(mapFromGlobal(event->globalPos())); if (isDiveTextItem(sceneItem, diveComputerText)) { - if (dc == 0 && number_of_computers(d) == 1) - // nothing to do, can't delete or reorder + const struct divecomputer *currentdc = get_dive_dc_const(d, dc); + if (!currentdc->deviceid && dc == 0 && number_of_computers(d) == 1) + // nothing to do, can't rename, delete or reorder return; // create menu to show when right clicking on dive computer name if (dc > 0) @@ -1314,6 +1315,8 @@ void ProfileWidget2::contextMenuEvent(QContextMenuEvent *event) m.addAction(tr("Delete this dive computer"), this, &ProfileWidget2::deleteCurrentDC); m.addAction(tr("Split this dive computer into own dive"), this, &ProfileWidget2::splitCurrentDC); } + if (currentdc->deviceid) + m.addAction(tr("Rename this dive computer"), this, &ProfileWidget2::renameCurrentDC); m.exec(event->globalPos()); // don't show the regular profile context menu return; @@ -1442,6 +1445,14 @@ void ProfileWidget2::makeFirstDC() Command::moveDiveComputerToFront(mutable_dive(), dc); } +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) +} + void ProfileWidget2::hideEvents(DiveEventItem *item) { const struct event *event = item->getEvent(); diff --git a/profile-widget/profilewidget2.h b/profile-widget/profilewidget2.h index b60fc030e..429fd1800 100644 --- a/profile-widget/profilewidget2.h +++ b/profile-widget/profilewidget2.h @@ -166,6 +166,7 @@ private: void makeFirstDC(); void deleteCurrentDC(); void splitCurrentDC(); + void renameCurrentDC(); DivePlotDataModel *dataModel; DivePlannerPointsModel *plannerModel; // If null, no planning supported. |