diff options
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(); |