From: gdd Date: Mon, 17 Jan 2011 10:27:48 +0000 (+0000) Subject: Add default text and style sheet for StdMeshersGUI_ObjectReferenceParamWdg X-Git-Tag: StartingPortingMED3~168 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=41d66a815f39175410002d4b3eeffe1622d11c9a;p=modules%2Fsmesh.git Add default text and style sheet for StdMeshersGUI_ObjectReferenceParamWdg --- diff --git a/src/StdMeshersGUI/StdMeshersGUI_ObjectReferenceParamWdg.cxx b/src/StdMeshersGUI/StdMeshersGUI_ObjectReferenceParamWdg.cxx index e69489aeb..45aba152c 100644 --- a/src/StdMeshersGUI/StdMeshersGUI_ObjectReferenceParamWdg.cxx +++ b/src/StdMeshersGUI/StdMeshersGUI_ObjectReferenceParamWdg.cxx @@ -110,6 +110,8 @@ void StdMeshersGUI_ObjectReferenceParamWdg::init() mySelectionMgr = SMESH::GetSelectionMgr( mySMESHGUI ); mySelectionActivated = false; myParamValue = ""; + myEmptyText = ""; + myEmptyStyleSheet =""; SUIT_ResourceMgr* mgr = SMESH::GetResourceMgr( mySMESHGUI ); QPixmap iconSlct ( mgr->loadPixmap("SMESH", tr("ICON_SELECT"))); @@ -120,6 +122,7 @@ void StdMeshersGUI_ObjectReferenceParamWdg::init() myObjNameLineEdit = new QLineEdit(this); myObjNameLineEdit->setReadOnly(true); + myObjNameLineEdit->setStyleSheet(myEmptyStyleSheet); aHBox->addWidget( mySelButton ); aHBox->addWidget( myObjNameLineEdit ); @@ -190,7 +193,8 @@ void StdMeshersGUI_ObjectReferenceParamWdg::AvoidSimultaneousSelection void StdMeshersGUI_ObjectReferenceParamWdg::SetObject(CORBA::Object_ptr obj) { myObjects.clear(); - myObjNameLineEdit->setText( "" ); + myObjNameLineEdit->setText( myEmptyText ); + myObjNameLineEdit->setStyleSheet(myEmptyStyleSheet); myParamValue = ""; _PTR(SObject) sobj; @@ -199,8 +203,10 @@ void StdMeshersGUI_ObjectReferenceParamWdg::SetObject(CORBA::Object_ptr obj) if ( sobj ) { std::string name = sobj->GetName(); myObjNameLineEdit->setText( name.c_str() ); + myObjNameLineEdit->setStyleSheet(""); myObjects.push_back( CORBA::Object::_duplicate( obj )); myParamValue = sobj->GetID().c_str(); + emit contentModified(); } } @@ -214,9 +220,11 @@ void StdMeshersGUI_ObjectReferenceParamWdg::SetObject(CORBA::Object_ptr obj) void StdMeshersGUI_ObjectReferenceParamWdg::SetObjects(SMESH::string_array_var& objects) { myObjects.clear(); - myObjNameLineEdit->setText( "" ); + myObjNameLineEdit->setText( myEmptyText ); + myObjNameLineEdit->setStyleSheet(myEmptyStyleSheet); myParamValue = ""; - + bool selChanged = false; + for ( unsigned i = 0; i < objects->length(); ++i ) { _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); @@ -225,15 +233,21 @@ void StdMeshersGUI_ObjectReferenceParamWdg::SetObjects(SMESH::string_array_var& if ( !CORBA::is_nil( anObj )) { std::string name = aSObj->GetName(); QString text = myObjNameLineEdit->text(); - if ( !text.isEmpty() ) + if ( text != myEmptyText ) text += " "; + else + text = ""; text += name.c_str(); myObjNameLineEdit->setText( text ); + myObjNameLineEdit->setStyleSheet(""); myObjects.push_back( anObj ); myParamValue += " "; myParamValue += objects[i]; + selChanged = true; } } + if (selChanged) + emit contentModified(); } //================================================================================ @@ -272,3 +286,11 @@ void StdMeshersGUI_ObjectReferenceParamWdg::onSelectionDone() } } } + +void StdMeshersGUI_ObjectReferenceParamWdg::SetDefaultText(QString defaultText, QString styleSheet) +{ + myEmptyText = defaultText; + myEmptyStyleSheet = styleSheet; + myObjNameLineEdit->setText( myEmptyText ); + myObjNameLineEdit->setStyleSheet( myEmptyStyleSheet); +} \ No newline at end of file diff --git a/src/StdMeshersGUI/StdMeshersGUI_ObjectReferenceParamWdg.h b/src/StdMeshersGUI/StdMeshersGUI_ObjectReferenceParamWdg.h index e8c387194..41bd98cfa 100644 --- a/src/StdMeshersGUI/StdMeshersGUI_ObjectReferenceParamWdg.h +++ b/src/StdMeshersGUI/StdMeshersGUI_ObjectReferenceParamWdg.h @@ -79,6 +79,8 @@ public: { return i < myObjects.size() && !CORBA::is_nil(myObjects[i]); } void AvoidSimultaneousSelection( StdMeshersGUI_ObjectReferenceParamWdg* other); + + void SetDefaultText(QString defaultText="", QString styleSheet=""); public slots: /*! @@ -98,6 +100,7 @@ signals: * one is activated */ void selectionActivated(); + void contentModified(); private slots: void onSelectionDone(); @@ -119,6 +122,8 @@ private: QLineEdit* myObjNameLineEdit; QPushButton* mySelButton; QString myParamValue; + QString myEmptyText; + QString myEmptyStyleSheet; }; #endif // STDMESHERSGUI_OBJECTREFERENCEPARAMWDG_H