Add delete dive context menu entry

Getting closer to the way this should work. Adjusted the call to reload
to not switch back to tree view and resort (oops).

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Dirk Hohndel 2013-06-06 10:37:18 +09:00
parent cd7488491f
commit 3f7490c205
2 changed files with 11 additions and 1 deletions

View file

@ -279,7 +279,15 @@ void DiveListView::removeFromTrip()
if (!d) // shouldn't happen as we only are setting up this action if this is a dive if (!d) // shouldn't happen as we only are setting up this action if this is a dive
return; return;
remove_dive_from_trip(d); remove_dive_from_trip(d);
reload(); reload(currentLayout, false);
}
void DiveListView::deleteDive()
{
struct dive *d = (struct dive *) contextMenuIndex.data(TreeItemDT::DIVE_ROLE).value<void*>();
if (d)
delete_single_dive(get_index_for_dive(d));
reload(currentLayout, false);
} }
void DiveListView::testSlot() void DiveListView::testSlot()
@ -312,6 +320,7 @@ void DiveListView::contextMenuEvent(QContextMenuEvent *event)
popup.addAction(tr("remove dive from trip"), this, SLOT(removeFromTrip())); popup.addAction(tr("remove dive from trip"), this, SLOT(removeFromTrip()));
} }
} }
popup.addAction(tr("delete dive"), this, SLOT(deleteDive()));
// "collapse all" really closes all trips, // "collapse all" really closes all trips,
// "collapse" keeps the trip with the selected dive open // "collapse" keeps the trip with the selected dive open
QAction * actionTaken = popup.exec(event->globalPos()); QAction * actionTaken = popup.exec(event->globalPos());

View file

@ -36,6 +36,7 @@ public slots:
void headerClicked(int); void headerClicked(int);
void showSearchEdit(); void showSearchEdit();
void removeFromTrip(); void removeFromTrip();
void deleteDive();
void testSlot(); void testSlot();
Q_SIGNALS: Q_SIGNALS: