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:
Dirk Hohndel 2014-06-11 13:56:33 -07:00
parent c4aa1f542c
commit 2b59765da3
4 changed files with 78 additions and 22 deletions

View file

@ -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();