diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2014-06-11 13:56:33 -0700 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2014-06-11 13:56:33 -0700 |
commit | 2b59765da3882f1564e5ae034a35c0ce35441108 (patch) | |
tree | f4d37700f4ae3ab36b4a60e3195a539e79a7344a /qt-ui/profile | |
parent | c4aa1f542ccbbbdc78dd3d44fe08f6410b9a5d2c (diff) | |
download | subsurface-2b59765da3882f1564e5ae034a35c0ce35441108.tar.gz |
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>
Diffstat (limited to 'qt-ui/profile')
-rw-r--r-- | qt-ui/profile/profilewidget2.cpp | 17 | ||||
-rw-r--r-- | qt-ui/profile/profilewidget2.h | 1 |
2 files changed, 16 insertions, 2 deletions
diff --git a/qt-ui/profile/profilewidget2.cpp b/qt-ui/profile/profilewidget2.cpp index 681878d0c..0ef645f20 100644 --- a/qt-ui/profile/profilewidget2.cpp +++ b/qt-ui/profile/profilewidget2.cpp @@ -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(); diff --git a/qt-ui/profile/profilewidget2.h b/qt-ui/profile/profilewidget2.h index f908543d1..47e9a51b3 100644 --- a/qt-ui/profile/profilewidget2.h +++ b/qt-ui/profile/profilewidget2.h @@ -90,6 +90,7 @@ slots: // Necessary to call from QAction's signals. void removeEvent(); void editName(); void makeFirstDC(); + void deleteCurrentDC(); void pointInserted(const QModelIndex &parent, int start, int end); void pointsRemoved(const QModelIndex &, int start, int end); void plotPictures(); |