From: mkr Date: Thu, 19 Nov 2015 14:44:48 +0000 (+0300) Subject: refs #609: simplify removing rows from tables. X-Git-Tag: v1.5~13 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=f993e4d01e9bb9de221db4c90d7a6c617696f3ec;p=modules%2Fhydro.git refs #609: simplify removing rows from tables. --- diff --git a/src/HYDROGUI/HYDROGUI_PriorityWidget.cxx b/src/HYDROGUI/HYDROGUI_PriorityWidget.cxx index 6c85d3e0..e6e15e01 100644 --- a/src/HYDROGUI/HYDROGUI_PriorityWidget.cxx +++ b/src/HYDROGUI/HYDROGUI_PriorityWidget.cxx @@ -221,9 +221,11 @@ void HYDROGUI_PriorityWidget::onRemoveRule() if (aModel) { QList aRows; - QModelIndexList aSelectedIndexes = myTable->selectionModel()->selectedRows(); + QModelIndexList aSelectedIndexes = myTable->selectionModel()->selectedIndexes(); foreach ( const QModelIndex& anIndex, aSelectedIndexes ) { - aRows << anIndex.row(); + int aRowIndex = anIndex.row(); + if ( !aRows.contains( aRowIndex ) ) + aRows << aRowIndex; } if ( aModel->removeRows( aRows ) ) { @@ -305,7 +307,7 @@ QTableView* HYDROGUI_PriorityWidget::getTable() const */ void HYDROGUI_PriorityWidget::onSelectionChanged() { - QModelIndexList aSelectedIndexes = myTable->selectionModel()->selectedRows(); + QModelIndexList aSelectedIndexes = myTable->selectionModel()->selectedIndexes(); myRemove->setEnabled( aSelectedIndexes.count() > 0 ); } diff --git a/src/HYDROGUI/HYDROGUI_StricklerTableDlg.cxx b/src/HYDROGUI/HYDROGUI_StricklerTableDlg.cxx index 6b861056..4de59f35 100644 --- a/src/HYDROGUI/HYDROGUI_StricklerTableDlg.cxx +++ b/src/HYDROGUI/HYDROGUI_StricklerTableDlg.cxx @@ -386,9 +386,11 @@ Remove the selected Strickler coefficient. void HYDROGUI_StricklerTableDlg::onRemoveCoefficient() { QList aRows; - QModelIndexList aSelectedIndexes = myTable->selectionModel()->selectedRows(); + QModelIndexList aSelectedIndexes = myTable->selectionModel()->selectedIndexes(); foreach ( const QModelIndex& anIndex, aSelectedIndexes ) { - aRows << anIndex.row(); + int aRowIndex = anIndex.row(); + if ( !aRows.contains( aRowIndex ) ) + aRows << aRowIndex; } removeRows( aRows ); @@ -412,6 +414,6 @@ Slot called on table selection change. */ void HYDROGUI_StricklerTableDlg::onSelectionChanged() { - QModelIndexList aSelectedIndexes = myTable->selectionModel()->selectedRows(); + QModelIndexList aSelectedIndexes = myTable->selectionModel()->selectedIndexes(); myRemoveBtn->setEnabled( aSelectedIndexes.count() > 0 ); }