Salome HOME
lot 10 - warnings for DTM - untested
[modules/hydro.git] / src / HYDROGUI / HYDROGUI_ObjListBox.cxx
index f20715a645dc821e748bbf359ea14fe14f745ccb..1d78a57fd7ac1400a2f1d1333ea379f27529a193 100644 (file)
@@ -18,7 +18,7 @@
 
 #include <HYDROGUI_ObjListBox.h>
 #include <HYDROGUI_ObjComboBox.h>
-#include <HYDROGUI_Tool.h>
+#include <HYDROGUI_Tool2.h>
 #include <QGridLayout>
 #include <QListWidget>
 #include <QLabel>
@@ -94,6 +94,7 @@ void HYDROGUI_ObjListBox::reset()
 {
   myList->clear();
   mySelection.Clear();
+  emit selectionChanged();
 }
 
 void HYDROGUI_ObjListBox::setSelectedObjects( const HYDROData_SequenceOfObjects& theObjects )
@@ -115,6 +116,7 @@ HYDROData_SequenceOfObjects HYDROGUI_ObjListBox::selectedObjects() const
 void HYDROGUI_ObjListBox::OnInclude()
 {
   Append( HYDROGUI_Tool::GetSelectedObjects( module() ) );
+  emit selectionChanged();
 }
 
 void HYDROGUI_ObjListBox::OnExclude()
@@ -122,10 +124,19 @@ void HYDROGUI_ObjListBox::OnExclude()
   QList<QListWidgetItem*> aSelection = myList->selectedItems();
   foreach( QListWidgetItem* anItem, aSelection )
   {
-    int anIndex = myList->row( anItem );
-    myList->takeItem( anIndex );
-    mySelection.Remove( anIndex, anIndex );
+    QString itemText = anItem->text();
+    for (int i=mySelection.Lower();i<=mySelection.Upper();i++)
+    {
+      QString name = mySelection(i)->GetName();
+      if (itemText == name)
+      {
+        mySelection.Remove(i);
+        break;
+      }
+    }
+    delete anItem;
   }
+  emit selectionChanged();
 }
 
 void HYDROGUI_ObjListBox::Append( const HYDROData_SequenceOfObjects& theObjects )
@@ -140,8 +151,11 @@ void HYDROGUI_ObjListBox::Append( const HYDROData_SequenceOfObjects& theObjects
     if( isOK )
     {
       QString aName = anObject->GetName();
-      myList->addItem( aName );
-      mySelection.Append( anObject );
+      if (myList->findItems(aName, Qt::MatchExactly).size() == 0)
+      {
+        myList->addItem( aName );
+        mySelection.Append( anObject );
+      }
     }
   }
 }