From: isn Date: Thu, 18 Jun 2015 11:35:23 +0000 (+0300) Subject: Allowing to add multiple object-types to ObjListBox X-Git-Tag: v1.4.2~58 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=b51f9d9384bca57f8a0536490c6e372f4c10394a;p=modules%2Fhydro.git Allowing to add multiple object-types to ObjListBox --- diff --git a/src/HYDROGUI/HYDROGUI_ObjListBox.cxx b/src/HYDROGUI/HYDROGUI_ObjListBox.cxx index 513e08a4..f20715a6 100644 --- a/src/HYDROGUI/HYDROGUI_ObjListBox.cxx +++ b/src/HYDROGUI/HYDROGUI_ObjListBox.cxx @@ -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 @@ -119,7 +133,7 @@ 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 ); diff --git a/src/HYDROGUI/HYDROGUI_ObjListBox.h b/src/HYDROGUI/HYDROGUI_ObjListBox.h index a31cf26d..7d599dd3 100644 --- a/src/HYDROGUI/HYDROGUI_ObjListBox.h +++ b/src/HYDROGUI/HYDROGUI_ObjListBox.h @@ -33,10 +33,12 @@ class HYDROGUI_ObjListBox : public QWidget public: HYDROGUI_ObjListBox( HYDROGUI_Module* theModule, const QString& theTitle, const ObjectKind& = KIND_UNKNOWN, QWidget* = 0 ); + HYDROGUI_ObjListBox( HYDROGUI_Module* theModule, const QString& theTitle, + const QList& theTypes, QWidget* = 0 ); virtual ~HYDROGUI_ObjListBox(); HYDROGUI_Module* module() const; - ObjectKind objectType() const; + QList objectTypes() const; HYDROGUI_ObjComboBoxFilter* objectFilter() const; void setObjectFilter( HYDROGUI_ObjComboBoxFilter* ); @@ -46,6 +48,9 @@ public: void setObjectsFromSelection(); void reset(); +private: + void Init(const QString& theTitle); + private slots: void OnInclude(); void OnExclude(); @@ -54,7 +59,7 @@ private: void Append( const HYDROData_SequenceOfObjects& ); private: - ObjectKind myType; + QList myTypes; QListWidget* myList; HYDROGUI_Module* myModule; HYDROGUI_ObjComboBoxFilter* myFilter;