From 4352a0e199950550277750e0a04845bf0d2740fb Mon Sep 17 00:00:00 2001 From: akl Date: Mon, 31 Mar 2008 12:56:23 +0000 Subject: [PATCH] Fix of IPAL19366(Qt4 porting. Adding of items in the list is very long action). --- src/SMESHGUI/SMESHGUI_GroupDlg.cxx | 83 ++++++++++++++++++++++++------ 1 file changed, 67 insertions(+), 16 deletions(-) diff --git a/src/SMESHGUI/SMESHGUI_GroupDlg.cxx b/src/SMESHGUI/SMESHGUI_GroupDlg.cxx index f252dcce6..0732535ee 100644 --- a/src/SMESHGUI/SMESHGUI_GroupDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_GroupDlg.cxx @@ -1146,12 +1146,21 @@ void SMESHGUI_GroupDlg::onObjectSelectionChanged() aNbItems = SMESH::GetNameOfSelectedElements(mySelector, myActor->getIO(), aListStr); } if (aNbItems > 0) { + QListWidgetItem* anItem; + QList listItemsToSel; QStringList anElements = aListStr.split(" ", QString::SkipEmptyParts); for (QStringList::iterator it = anElements.begin(); it != anElements.end(); ++it) { QList found = myElements->findItems(*it, Qt::MatchExactly); - QListWidgetItem* anItem; - foreach(anItem, found) anItem->setSelected(true); + foreach(anItem, found) + if (!anItem->isSelected()) + listItemsToSel.push_back(anItem); } + bool blocked = myElements->signalsBlocked(); + myElements->blockSignals(true); + foreach(anItem, listItemsToSel) anItem->setSelected(true); + myElements->blockSignals(blocked); + onListSelectionChanged(); + listItemsToSel.clear(); } } } @@ -1357,6 +1366,8 @@ void SMESHGUI_GroupDlg::onAdd() mySelector->SetSelectionMode(ActorSelection); } + QListWidgetItem* anItem = 0; + QList listItemsToSel; if (myCurrentLineEdit == 0) { //if (aNbSel != 1) { myIsBusy = false; return; } @@ -1372,16 +1383,24 @@ void SMESHGUI_GroupDlg::onAdd() QStringList anElements = aListStr.split(" ", QString::SkipEmptyParts); for (QStringList::iterator it = anElements.begin(); it != anElements.end(); ++it) { QList found = myElements->findItems(*it, Qt::MatchExactly); - QListWidgetItem* anItem; if (found.count() == 0) { anItem = new QListWidgetItem(*it); myElements->addItem(anItem); - anItem->setSelected(true); + if (!anItem->isSelected()) + listItemsToSel.push_back(anItem); } else { - foreach(anItem, found) anItem->setSelected(true); + foreach(anItem, found) + if (!anItem->isSelected()) + listItemsToSel.push_back(anItem); } } + bool blocked = myElements->signalsBlocked(); + myElements->blockSignals(true); + foreach(anItem, listItemsToSel) anItem->setSelected(true); + myElements->blockSignals(blocked); + onListSelectionChanged(); + listItemsToSel.clear(); } } else if (myCurrentLineEdit == mySubMeshLine) { //SALOME_ListIteratorOfListIO anIt (mySelectionMgr->StoredIObjects()); @@ -1402,16 +1421,24 @@ void SMESHGUI_GroupDlg::onAdd() for (int i = 0; i < k; i++) { QString aText = QString::number(anElements[i]); QList found = myElements->findItems(aText, Qt::MatchExactly); - QListWidgetItem* anItem = 0; if (found.count() == 0) { anItem = new QListWidgetItem(aText); myElements->addItem(anItem); - anItem->setSelected(true); + if (!anItem->isSelected()) + listItemsToSel.push_back(anItem); } else { - foreach(anItem, found) anItem->setSelected(true); + foreach(anItem, found) + if (!anItem->isSelected()) + listItemsToSel.push_back(anItem); } } + bool blocked = myElements->signalsBlocked(); + myElements->blockSignals(true); + foreach(anItem, listItemsToSel) anItem->setSelected(true); + myElements->blockSignals(blocked); + onListSelectionChanged(); + listItemsToSel.clear(); } catch (const SALOME::SALOME_Exception& ex) { SalomeApp_Tools::QtCatchCorbaException(ex); @@ -1440,16 +1467,24 @@ void SMESHGUI_GroupDlg::onAdd() for (int i = 0; i < k; i++) { QString aText = QString::number(anElements[i]); QList found = myElements->findItems(aText, Qt::MatchExactly); - QListWidgetItem* anItem = 0; if (found.count() == 0) { anItem = new QListWidgetItem(aText); myElements->addItem(anItem); - anItem->setSelected(true); + if (!anItem->isSelected()) + listItemsToSel.push_back(anItem); } else { - foreach(anItem, found) anItem->setSelected(true); + foreach(anItem, found) + if (!anItem->isSelected()) + listItemsToSel.push_back(anItem); } } + bool blocked = myElements->signalsBlocked(); + myElements->blockSignals(true); + foreach(anItem, listItemsToSel) anItem->setSelected(true); + myElements->blockSignals(blocked); + onListSelectionChanged(); + listItemsToSel.clear(); } } } @@ -1490,16 +1525,24 @@ void SMESHGUI_GroupDlg::onAdd() for (int i = 0; i < k; i++) { QString aText = QString::number(anElements[i]); QList found = myElements->findItems(aText, Qt::MatchExactly); - QListWidgetItem* anItem = 0; if (found.count() == 0) { anItem = new QListWidgetItem(aText); myElements->addItem(anItem); - anItem->setSelected(true); + if (!anItem->isSelected()) + listItemsToSel.push_back(anItem); } else { - foreach(anItem, found) anItem->setSelected(true); + foreach(anItem, found) + if (!anItem->isSelected()) + listItemsToSel.push_back(anItem); } } + bool blocked = myElements->signalsBlocked(); + myElements->blockSignals(true); + foreach(anItem, listItemsToSel) anItem->setSelected(true); + myElements->blockSignals(blocked); + onListSelectionChanged(); + listItemsToSel.clear(); } //VSR: mySelectGeomGroup->setChecked(false); @@ -1638,11 +1681,19 @@ void SMESHGUI_GroupDlg::onSort() std::sort(anArray.begin(), anArray.end()); // anArray.sort(); myElements->clear(); + QListWidgetItem* anItem; + QList listItemsToSel; for (i = 0; i < k; i++) { - QListWidgetItem* anItem = new QListWidgetItem(QString::number(anArray[i])); + anItem = new QListWidgetItem(QString::number(anArray[i])); myElements->addItem(anItem); - anItem->setSelected(aSelected.contains(anArray[i])); + if (aSelected.contains(anArray[i])) + listItemsToSel.push_back(anItem); } + bool blocked = myElements->signalsBlocked(); + myElements->blockSignals(true); + foreach(anItem, listItemsToSel) anItem->setSelected(true); + myElements->blockSignals(blocked); + listItemsToSel.clear(); myIsBusy = false; } }