Add default text and style sheet for StdMeshersGUI_ObjectReferenceParamWdg

This commit is contained in:
gdd 2011-01-17 10:27:48 +00:00
parent 96cbac2048
commit 41d66a815f
2 changed files with 31 additions and 4 deletions

View File

@ -110,6 +110,8 @@ void StdMeshersGUI_ObjectReferenceParamWdg::init()
mySelectionMgr = SMESH::GetSelectionMgr( mySMESHGUI ); mySelectionMgr = SMESH::GetSelectionMgr( mySMESHGUI );
mySelectionActivated = false; mySelectionActivated = false;
myParamValue = ""; myParamValue = "";
myEmptyText = "";
myEmptyStyleSheet ="";
SUIT_ResourceMgr* mgr = SMESH::GetResourceMgr( mySMESHGUI ); SUIT_ResourceMgr* mgr = SMESH::GetResourceMgr( mySMESHGUI );
QPixmap iconSlct ( mgr->loadPixmap("SMESH", tr("ICON_SELECT"))); QPixmap iconSlct ( mgr->loadPixmap("SMESH", tr("ICON_SELECT")));
@ -120,6 +122,7 @@ void StdMeshersGUI_ObjectReferenceParamWdg::init()
myObjNameLineEdit = new QLineEdit(this); myObjNameLineEdit = new QLineEdit(this);
myObjNameLineEdit->setReadOnly(true); myObjNameLineEdit->setReadOnly(true);
myObjNameLineEdit->setStyleSheet(myEmptyStyleSheet);
aHBox->addWidget( mySelButton ); aHBox->addWidget( mySelButton );
aHBox->addWidget( myObjNameLineEdit ); aHBox->addWidget( myObjNameLineEdit );
@ -190,7 +193,8 @@ void StdMeshersGUI_ObjectReferenceParamWdg::AvoidSimultaneousSelection
void StdMeshersGUI_ObjectReferenceParamWdg::SetObject(CORBA::Object_ptr obj) void StdMeshersGUI_ObjectReferenceParamWdg::SetObject(CORBA::Object_ptr obj)
{ {
myObjects.clear(); myObjects.clear();
myObjNameLineEdit->setText( "" ); myObjNameLineEdit->setText( myEmptyText );
myObjNameLineEdit->setStyleSheet(myEmptyStyleSheet);
myParamValue = ""; myParamValue = "";
_PTR(SObject) sobj; _PTR(SObject) sobj;
@ -199,8 +203,10 @@ void StdMeshersGUI_ObjectReferenceParamWdg::SetObject(CORBA::Object_ptr obj)
if ( sobj ) { if ( sobj ) {
std::string name = sobj->GetName(); std::string name = sobj->GetName();
myObjNameLineEdit->setText( name.c_str() ); myObjNameLineEdit->setText( name.c_str() );
myObjNameLineEdit->setStyleSheet("");
myObjects.push_back( CORBA::Object::_duplicate( obj )); myObjects.push_back( CORBA::Object::_duplicate( obj ));
myParamValue = sobj->GetID().c_str(); 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) void StdMeshersGUI_ObjectReferenceParamWdg::SetObjects(SMESH::string_array_var& objects)
{ {
myObjects.clear(); myObjects.clear();
myObjNameLineEdit->setText( "" ); myObjNameLineEdit->setText( myEmptyText );
myObjNameLineEdit->setStyleSheet(myEmptyStyleSheet);
myParamValue = ""; myParamValue = "";
bool selChanged = false;
for ( unsigned i = 0; i < objects->length(); ++i ) for ( unsigned i = 0; i < objects->length(); ++i )
{ {
_PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
@ -225,15 +233,21 @@ void StdMeshersGUI_ObjectReferenceParamWdg::SetObjects(SMESH::string_array_var&
if ( !CORBA::is_nil( anObj )) { if ( !CORBA::is_nil( anObj )) {
std::string name = aSObj->GetName(); std::string name = aSObj->GetName();
QString text = myObjNameLineEdit->text(); QString text = myObjNameLineEdit->text();
if ( !text.isEmpty() ) if ( text != myEmptyText )
text += " "; text += " ";
else
text = "";
text += name.c_str(); text += name.c_str();
myObjNameLineEdit->setText( text ); myObjNameLineEdit->setText( text );
myObjNameLineEdit->setStyleSheet("");
myObjects.push_back( anObj ); myObjects.push_back( anObj );
myParamValue += " "; myParamValue += " ";
myParamValue += objects[i]; 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);
}

View File

@ -79,6 +79,8 @@ public:
{ return i < myObjects.size() && !CORBA::is_nil(myObjects[i]); } { return i < myObjects.size() && !CORBA::is_nil(myObjects[i]); }
void AvoidSimultaneousSelection( StdMeshersGUI_ObjectReferenceParamWdg* other); void AvoidSimultaneousSelection( StdMeshersGUI_ObjectReferenceParamWdg* other);
void SetDefaultText(QString defaultText="", QString styleSheet="");
public slots: public slots:
/*! /*!
@ -98,6 +100,7 @@ signals:
* one is activated * one is activated
*/ */
void selectionActivated(); void selectionActivated();
void contentModified();
private slots: private slots:
void onSelectionDone(); void onSelectionDone();
@ -119,6 +122,8 @@ private:
QLineEdit* myObjNameLineEdit; QLineEdit* myObjNameLineEdit;
QPushButton* mySelButton; QPushButton* mySelButton;
QString myParamValue; QString myParamValue;
QString myEmptyText;
QString myEmptyStyleSheet;
}; };
#endif // STDMESHERSGUI_OBJECTREFERENCEPARAMWDG_H #endif // STDMESHERSGUI_OBJECTREFERENCEPARAMWDG_H