From 6c5dcd6696739ac4c0853798ee10c433652f0439 Mon Sep 17 00:00:00 2001 From: Aleksei Kanash Date: Thu, 4 Oct 2012 10:55:53 +0300 Subject: [PATCH] Corrected moving features to trash. --- src/gui/UBFeaturesWidget.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/gui/UBFeaturesWidget.cpp b/src/gui/UBFeaturesWidget.cpp index 6ee337cf..0709058f 100644 --- a/src/gui/UBFeaturesWidget.cpp +++ b/src/gui/UBFeaturesWidget.cpp @@ -169,10 +169,9 @@ void UBFeaturesWidget::deleteElements( const UBFeaturesMimeData * mimeData ) void UBFeaturesWidget::deleteSelectedElements() { QModelIndexList selected = centralWidget->listView()->selectionModel()->selectedIndexes(); - - foreach ( QModelIndex sel, selected ) + do { - UBFeature feature = sel.data(Qt::UserRole + 1).value(); + UBFeature feature = controller->getFeature(selected.at(0), objNameFeatureList); if (feature.isDeletable()) { if (feature.inTrash()) { controller->deleteItem(feature); @@ -180,8 +179,12 @@ void UBFeaturesWidget::deleteSelectedElements() controller->moveToTrash(feature, true); } } - } - controller->refreshModels(); + selected = centralWidget->listView()->selectionModel()->selectedIndexes(); + if (!selected.isEmpty()) + centralWidget->listView()->selectionModel()->select(selected.at(0), QItemSelectionModel::Deselect); + }while (!selected.isEmpty()); + + controller->refreshModels(); } void UBFeaturesWidget::rescanModel()