X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2FHYDROGUI%2FHYDROGUI_ObjListBox.cxx;h=38ffb4c16dbb1261d47e29c54d513338a113b864;hb=d5ba71b0ced3160edd96ba0e60a9b22edb7e9490;hp=513e08a4cdf93d62fe72b4a2849cad9a84dcc6eb;hpb=c46fa6f178bf824f147f41ca3bc8bc98b8def0ef;p=modules%2Fhydro.git diff --git a/src/HYDROGUI/HYDROGUI_ObjListBox.cxx b/src/HYDROGUI/HYDROGUI_ObjListBox.cxx index 513e08a4..38ffb4c1 100644 --- a/src/HYDROGUI/HYDROGUI_ObjListBox.cxx +++ b/src/HYDROGUI/HYDROGUI_ObjListBox.cxx @@ -18,7 +18,7 @@ #include #include -#include +#include #include #include #include @@ -26,9 +26,23 @@ HYDROGUI_ObjListBox::HYDROGUI_ObjListBox( HYDROGUI_Module* theModule, const QString& theTitle, const ObjectKind& theType, QWidget* theParent ) : QWidget( theParent ), - myType( theType ), myModule( theModule ), myFilter( 0 ) +{ + myTypes.append( theType ); + Init(theTitle); +} + +HYDROGUI_ObjListBox::HYDROGUI_ObjListBox( HYDROGUI_Module* theModule, const QString& theTitle, const QList& theTypes, QWidget* theParent ) +: QWidget( theParent ), + myTypes( theTypes ), + myModule( theModule ), + myFilter( 0 ) +{ + Init(theTitle); +} + +void HYDROGUI_ObjListBox::Init(const QString& theTitle) { QGridLayout* aBase = new QGridLayout( this ); aBase->setMargin( 0 ); @@ -61,9 +75,9 @@ HYDROGUI_Module* HYDROGUI_ObjListBox::module() const return myModule; } -ObjectKind HYDROGUI_ObjListBox::objectType() const +QList HYDROGUI_ObjListBox::objectTypes() const { - return myType; + return myTypes; } HYDROGUI_ObjComboBoxFilter* HYDROGUI_ObjListBox::objectFilter() const @@ -80,6 +94,7 @@ void HYDROGUI_ObjListBox::reset() { myList->clear(); mySelection.Clear(); + emit selectionChanged(); } void HYDROGUI_ObjListBox::setSelectedObjects( const HYDROData_SequenceOfObjects& theObjects ) @@ -101,17 +116,15 @@ HYDROData_SequenceOfObjects HYDROGUI_ObjListBox::selectedObjects() const void HYDROGUI_ObjListBox::OnInclude() { Append( HYDROGUI_Tool::GetSelectedObjects( module() ) ); + emit selectionChanged(); } void HYDROGUI_ObjListBox::OnExclude() { QList aSelection = myList->selectedItems(); foreach( QListWidgetItem* anItem, aSelection ) - { - int anIndex = myList->row( anItem ); - myList->takeItem( anIndex ); - mySelection.Remove( anIndex, anIndex ); - } + delete anItem; + emit selectionChanged(); } void HYDROGUI_ObjListBox::Append( const HYDROData_SequenceOfObjects& theObjects ) @@ -119,15 +132,18 @@ void HYDROGUI_ObjListBox::Append( const HYDROData_SequenceOfObjects& theObjects for( int i=theObjects.Lower(), n=theObjects.Upper(); i<=n; i++ ) { Handle( HYDROData_Entity ) anObject = theObjects.Value( i ); - bool isOK = !anObject.IsNull() && anObject->GetKind()==myType; + bool isOK = !anObject.IsNull() && myTypes.contains(anObject->GetKind()); if( myFilter && isOK ) isOK = myFilter->isOk( anObject ); 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 ); + } } } }