From f993e4d01e9bb9de221db4c90d7a6c617696f3ec Mon Sep 17 00:00:00 2001 From: mkr Date: Thu, 19 Nov 2015 17:44:48 +0300 Subject: [PATCH] refs #609: simplify removing rows from tables. --- src/HYDROGUI/HYDROGUI_PriorityWidget.cxx | 8 +++++--- src/HYDROGUI/HYDROGUI_StricklerTableDlg.cxx | 8 +++++--- 2 files changed, 10 insertions(+), 6 deletions(-) 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 ); } -- 2.39.2