From: vsv Date: Thu, 5 May 2016 08:54:50 +0000 (+0300) Subject: Improve deletion behavior: select last item if last item was deleted X-Git-Tag: V_2.3.0~20 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=f571f3c2e76f6fb9cb4e88775bd21c36633e062c;p=modules%2Fshaper.git Improve deletion behavior: select last item if last item was deleted --- diff --git a/src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp b/src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp index b7f2995af..a651aa185 100755 --- a/src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp +++ b/src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp @@ -326,9 +326,6 @@ bool ModuleBase_WidgetMultiSelector::processDelete() getSelectedAttributeIndices(anAttributeIds); QModelIndexList aIndexes = myListControl->selectionModel()->selectedIndexes(); - //foreach(QModelIndex aIndex, aIndexes) { - // aIndex.row(); - //} // refill attribute by the items which indices are not in the list of ids bool aDone = false; @@ -363,8 +360,18 @@ bool ModuleBase_WidgetMultiSelector::processDelete() myWorkshop->module()->customizeObject(myFeature, ModuleBase_IModule::CustomizeArguments, true); /// hope that something is redisplayed by object updated } - foreach(QModelIndex aIndex, aIndexes) { - myListControl->selectionModel()->select(aIndex, QItemSelectionModel::Select); + + // Restore selection + int aRows = myListControl->model()->rowCount(); + if (aRows > 0) { + foreach(QModelIndex aIndex, aIndexes) { + if (aIndex.row() < aRows) + myListControl->selectionModel()->select(aIndex, QItemSelectionModel::Select); + else { + QModelIndex aIdx = myListControl->model()->index(aRows - 1, 0); + myListControl->selectionModel()->select(aIdx, QItemSelectionModel::Select); + } + } } return aDone; }