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 );
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,8 +220,10 @@ 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 )
{
@ -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);
}

View File

@ -80,6 +80,8 @@ public:
void AvoidSimultaneousSelection( StdMeshersGUI_ObjectReferenceParamWdg* other);
void SetDefaultText(QString defaultText="", QString styleSheet="");
public slots:
/*!
* \brief Activates selection (if not yet done), emits selectionActivated()
@ -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