profile: fix logic in keyDeleteAction()

The code took care to not delete planner-points when no
points are selected. However, it assumed that all selected
objects are planner-points. But then it checked whether
the selected object actually is a planner-point. So which
is it?

Remove the outter check for an empty selection. This makes
things more logical and more robust, should there ever
be other objects that can be selected.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2021-01-26 18:35:48 +01:00 committed by Dirk Hohndel
parent 1ec0790d50
commit 752724aa1e

View file

@ -1910,17 +1910,15 @@ void ProfileWidget2::keyDeleteAction()
if ((currentState != ADD && currentState != PLAN) || !plannerModel)
return;
int selCount = scene()->selectedItems().count();
if (selCount) {
QVector<int> selectedIndices;
Q_FOREACH (QGraphicsItem *i, scene()->selectedItems()) {
if (DiveHandler *handler = qgraphicsitem_cast<DiveHandler *>(i)) {
selectedIndices.push_back(handleIndex(handler));
handler->hide();
}
QVector<int> selectedIndices;
Q_FOREACH (QGraphicsItem *i, scene()->selectedItems()) {
if (DiveHandler *handler = qgraphicsitem_cast<DiveHandler *>(i)) {
selectedIndices.push_back(handleIndex(handler));
handler->hide();
}
plannerModel->removeSelectedPoints(selectedIndices);
}
if (!selectedIndices.isEmpty())
plannerModel->removeSelectedPoints(selectedIndices);
}
void ProfileWidget2::keyEscAction()