mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Allow the user to delete a dive computer from a dive
This can't be the only dive computer, of course. Goes nicely with the ability to reprder them. Fixes #551 Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
c4aa1f542c
commit
2b59765da3
4 changed files with 78 additions and 22 deletions
|
@ -873,10 +873,14 @@ void ProfileWidget2::contextMenuEvent(QContextMenuEvent *event)
|
|||
parentItem = parentItem->parentItem();
|
||||
}
|
||||
if (isDCName) {
|
||||
if (dc_number == 0)
|
||||
if (dc_number == 0 && count_divecomputers() == 1)
|
||||
// nothing to do, can't delete or reorder
|
||||
return;
|
||||
// create menu to show when right clicking on dive computer name
|
||||
m.addAction(tr("Make first divecomputer"), this, SLOT(makeFirstDC()));
|
||||
if (dc_number > 0)
|
||||
m.addAction(tr("Make first divecomputer"), this, SLOT(makeFirstDC()));
|
||||
if (count_divecomputers() > 1)
|
||||
m.addAction(tr("Delete this divecomputer"), this, SLOT(deleteCurrentDC()));
|
||||
m.exec(event->globalPos());
|
||||
// don't show the regular profile context menu
|
||||
return;
|
||||
|
@ -929,6 +933,15 @@ void ProfileWidget2::contextMenuEvent(QContextMenuEvent *event)
|
|||
m.exec(event->globalPos());
|
||||
}
|
||||
|
||||
void ProfileWidget2::deleteCurrentDC()
|
||||
{
|
||||
delete_current_divecomputer();
|
||||
mark_divelist_changed(true);
|
||||
// we need to force it since it's likely the same dive and same dc_number - but that's a different dive computer now
|
||||
forceReplot = true;
|
||||
MainWindow::instance()->refreshDisplay();
|
||||
}
|
||||
|
||||
void ProfileWidget2::makeFirstDC()
|
||||
{
|
||||
make_first_dc();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue