mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
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>
This commit is contained in:
parent
2da7e9e5ad
commit
35adf2d729
2 changed files with 14 additions and 2 deletions
|
@ -1304,8 +1304,9 @@ void ProfileWidget2::contextMenuEvent(QContextMenuEvent *event)
|
||||||
// figure out if we are ontop of the dive computer name in the profile
|
// figure out if we are ontop of the dive computer name in the profile
|
||||||
QGraphicsItem *sceneItem = itemAt(mapFromGlobal(event->globalPos()));
|
QGraphicsItem *sceneItem = itemAt(mapFromGlobal(event->globalPos()));
|
||||||
if (isDiveTextItem(sceneItem, diveComputerText)) {
|
if (isDiveTextItem(sceneItem, diveComputerText)) {
|
||||||
if (dc == 0 && number_of_computers(d) == 1)
|
const struct divecomputer *currentdc = get_dive_dc_const(d, dc);
|
||||||
// nothing to do, can't delete or reorder
|
if (!currentdc->deviceid && dc == 0 && number_of_computers(d) == 1)
|
||||||
|
// nothing to do, can't rename, delete or reorder
|
||||||
return;
|
return;
|
||||||
// create menu to show when right clicking on dive computer name
|
// create menu to show when right clicking on dive computer name
|
||||||
if (dc > 0)
|
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("Delete this dive computer"), this, &ProfileWidget2::deleteCurrentDC);
|
||||||
m.addAction(tr("Split this dive computer into own dive"), this, &ProfileWidget2::splitCurrentDC);
|
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());
|
m.exec(event->globalPos());
|
||||||
// don't show the regular profile context menu
|
// don't show the regular profile context menu
|
||||||
return;
|
return;
|
||||||
|
@ -1442,6 +1445,14 @@ void ProfileWidget2::makeFirstDC()
|
||||||
Command::moveDiveComputerToFront(mutable_dive(), dc);
|
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)
|
void ProfileWidget2::hideEvents(DiveEventItem *item)
|
||||||
{
|
{
|
||||||
const struct event *event = item->getEvent();
|
const struct event *event = item->getEvent();
|
||||||
|
|
|
@ -166,6 +166,7 @@ private:
|
||||||
void makeFirstDC();
|
void makeFirstDC();
|
||||||
void deleteCurrentDC();
|
void deleteCurrentDC();
|
||||||
void splitCurrentDC();
|
void splitCurrentDC();
|
||||||
|
void renameCurrentDC();
|
||||||
|
|
||||||
DivePlotDataModel *dataModel;
|
DivePlotDataModel *dataModel;
|
||||||
DivePlannerPointsModel *plannerModel; // If null, no planning supported.
|
DivePlannerPointsModel *plannerModel; // If null, no planning supported.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue