Version: 8.3.0
YACS::HMI::ItemEdition Class Reference

#include <ItemEdition.hxx>

Inheritance diagram for YACS::HMI::ItemEdition:
Collaboration diagram for YACS::HMI::ItemEdition:

Public Slots

virtual void onApply ()
 
virtual void onCancel ()
 
virtual void onModifyName (const QString &text)
 

Public Member Functions

 ItemEdition (Subject *subject, QWidget *parent=0, const char *name=0)
 
virtual ~ItemEdition ()
 
virtual void synchronize ()
 
virtual void select (bool isSelected)
 
virtual void setName (std::string name)
 
virtual void update (GuiEvent event, int type, Subject *son)
 
virtual void setEdited (bool isEdited)
 
- Public Member Functions inherited from FormEditItem
 FormEditItem (QWidget *parent=0)
 
virtual ~FormEditItem ()
 
- Public Member Functions inherited from YACS::HMI::ItemEditionBase
 ItemEditionBase (Subject *subject)
 
virtual ~ItemEditionBase ()
 
virtual SubjectgetSubject ()
 
- Public Member Functions inherited from YACS::HMI::GuiObserver
 GuiObserver ()
 
virtual ~GuiObserver ()
 
virtual void incrementSubjects (Subject *subject)
 
virtual void decrementSubjects (Subject *subject)
 
int getNbSubjects ()
 
bool isDestructible ()
 

Static Public Member Functions

static std::string filterName (const std::string &name)
 

Protected Attributes

bool _isEdited
 
bool _haveScript
 
- Protected Attributes inherited from FormEditItem
WidEditItem_wid
 
- Protected Attributes inherited from YACS::HMI::ItemEditionBase
Subject_subject
 
int _stackId
 
std::string _name
 
std::string _type
 
std::string _category
 
- Protected Attributes inherited from YACS::HMI::GuiObserver
std::set< Subject * > _subjectSet
 
bool _destructible
 

Additional Inherited Members

- Static Protected Attributes inherited from YACS::HMI::GuiObserver
static std::map< int, std::string > _eventNameMap
 

Detailed Description

Definition at line 53 of file ItemEdition.hxx.

Constructor & Destructor Documentation

ItemEdition::ItemEdition ( Subject subject,
QWidget parent = 0,
const char *  name = 0 
)

generic item edition based on a FormEditItem widget to be completed in derived classes. Apply - cancel edition buttons are not always relevants.

Definition at line 151 of file ItemEdition.cxx.

References _haveScript, _isEdited, YACS::HMI::QtGuiContext::_mapOfEditionItem, YACS::HMI::ItemEditionBase::_name, YACS::HMI::ItemEditionBase::_stackId, YACS::HMI::ItemEditionBase::_subject, YACS::HMI::ItemEditionBase::_type, FormEditItem::_wid, DEBTRACE, YACS::HMI::QtGuiContext::getQtCurrent(), YACS::HMI::QtGuiContext::getStackedWidget(), onApply(), onCancel(), onModifyName(), setEdited(), and YASSERT.

Referenced by update().

154  : FormEditItem(parent), ItemEditionBase(subject)
155 {
156  DEBTRACE("ItemEdition::ItemEdition " << name);
157 
158  _haveScript = false;
159  _isEdited = false;
160  setEdited(false);
161 
162  connect(_wid->pb_apply, SIGNAL(clicked()), this, SLOT(onApply()));
163  connect(_wid->pb_cancel, SIGNAL(clicked()), this, SLOT(onCancel()));
164 
165  // --- type of item and name
166 
167  _wid->la_type->setText(_type.c_str());
168  _wid->le_name->setText(_name.c_str());
169  connect(_wid->le_name, SIGNAL(textChanged(const QString&)),
170  this, SLOT(onModifyName(const QString&)));
171  _wid->le_name->setReadOnly(true); // to be changed on derived classes depending on context
172 
173  _stackId = QtGuiContext::getQtCurrent()->getStackedWidget()->addWidget(this);
174  DEBTRACE("_stackId " << _stackId);
175  YASSERT(!QtGuiContext::getQtCurrent()->_mapOfEditionItem.count(_subject));
177  //QtGuiContext::getQtCurrent()->getStackedWidget()->raiseWidget(_stackId);
178 }
ItemEdition::~ItemEdition ( )
virtual

Member Function Documentation

std::string ItemEdition::filterName ( const std::string &  name)
static

Definition at line 242 of file ItemEdition.cxx.

References gui.CONNECTOR::a, DEBTRACE, and CORBAEngineTest::i.

Referenced by YACS::HMI::NameEditor::GetStrValue(), onApply(), and YACS::HMI::NameEditor::setData().

243 {
244  string nameFiltered;
245  nameFiltered = "";
246  for (int i= 0; i< name.size(); i++)
247  {
248  unsigned char a = (unsigned char)(name[i]);
249  if ( ((a >= '0') && (a <= '9'))
250  || ((a >= 'A') && (a <= 'Z'))
251  || ((a >= 'a') && (a <= 'z'))
252  || ( a == '_'))
253  nameFiltered += a;
254  }
255  DEBTRACE(name << " " << nameFiltered);
256  return nameFiltered;
257 }
void ItemEdition::onApply ( )
virtualslot

Definition at line 214 of file ItemEdition.cxx.

References _isEdited, YACS::HMI::ItemEditionBase::_name, YACS::HMI::ItemEditionBase::_subject, FormEditItem::_wid, DEBTRACE, filterName(), PMMLBasicsTestLauncher::ret, setEdited(), and YACS::HMI::Subject::setName().

Referenced by ItemEdition(), YACS::HMI::EditionElementaryNode::onApply(), and YACS::HMI::EditionContainer::onApply().

215 {
216  DEBTRACE("onApply");
217  string name = _wid->le_name->text().toStdString();
218  name = filterName(name);
219  bool nameEdited = false;
220  if (name != _name)
221  {
222  nameEdited = true;
223  bool ret = _subject->setName(name);
224  if (ret)
225  {
226  nameEdited = false;
227  _name = name;
228  }
229  }
230  DEBTRACE(_isEdited << " " << nameEdited);
231  _isEdited = nameEdited;
233 }
void ItemEdition::onCancel ( )
virtualslot

Definition at line 235 of file ItemEdition.cxx.

References YACS::HMI::ItemEditionBase::_name, FormEditItem::_wid, DEBTRACE, and setEdited().

Referenced by ItemEdition(), YACS::HMI::EditionElementaryNode::onCancel(), and YACS::HMI::EditionContainer::onCancel().

236 {
237  DEBTRACE("onCancel");
238  _wid->le_name->setText(_name.c_str());
239  setEdited(false);
240 }
void ItemEdition::onModifyName ( const QString &  text)
virtualslot

Definition at line 259 of file ItemEdition.cxx.

References YACS::HMI::ItemEditionBase::_name, and setEdited().

Referenced by ItemEdition().

260 {
261  if (_name != text.toStdString()) setEdited(true);
262 }
void ItemEdition::select ( bool  isSelected)
virtual

Reimplemented from YACS::HMI::ItemEditionBase.

Reimplemented in YACS::HMI::EditionInputPort, and YACS::HMI::EditionOutputPort.

Definition at line 198 of file ItemEdition.cxx.

References DEBTRACE, YACS::HMI::QtGuiContext::getQtCurrent(), YACS::HMI::QtGuiContext::getStackedWidget(), and synchronize().

199 {
200  DEBTRACE("ItemEdition::select " << isSelected);
201  if (isSelected)
202  {
203  synchronize();
204  QtGuiContext::getQtCurrent()->getStackedWidget()->setCurrentWidget(this);
205  }
206 }
void ItemEdition::setEdited ( bool  isEdited)
virtual

Definition at line 264 of file ItemEdition.cxx.

References YACS::HMI::QtGuiContext::_mapOfSchemaItem, YACS::HMI::QtGuiContext::_setOfModifiedSubjects, YACS::HMI::ItemEditionBase::_subject, FormEditItem::_wid, DEBTRACE, YACS::HMI::EDIT, YACS::HMI::QtGuiContext::getQtCurrent(), YACS::HMI::QtGuiContext::getSchemaModel(), YACS::HMI::GuiContext::getSubjectProc(), YACS::HMI::SchemaItem::modelIndex(), YACS::HMI::SchemaModel::setData(), YACS::HMI::Subject::update(), and YACS::HMI::SubjectNode::update().

Referenced by ItemEdition(), onApply(), onCancel(), YACS::HMI::EditionPyFunc::onFuncNameModified(), FormContainerBase::onModified(), FormAdvParamContainer::onModified(), onModifyName(), YACS::HMI::EditionScript::onScriptModified(), and setName().

265 {
266  DEBTRACE("ItemEdition::setEdited " << isEdited);
267  if (isEdited)
268  {
271  if (QtGuiContext::getQtCurrent()->getSubjectProc())
273  }
274  else
275  {
278  if (QtGuiContext::getQtCurrent()->_setOfModifiedSubjects.empty() && QtGuiContext::getQtCurrent()->getSubjectProc())
280  }
281 
284  if (schemaItem)
285  {
286  QModelIndex index = schemaItem->modelIndex();
287  model->setData(index, QVariant()); // just to emit dataChanged signal
288  }
289 
290  _wid->pb_apply->setEnabled(isEdited);
291  _wid->pb_cancel->setEnabled(isEdited);
292 }
void ItemEdition::setName ( std::string  name)
virtual

Definition at line 208 of file ItemEdition.cxx.

References YACS::HMI::ItemEditionBase::_name, and setEdited().

209 {
210  _name = name;
211  setEdited(false);
212 }
void ItemEdition::update ( GuiEvent  event,
int  type,
Subject son 
)
virtual

when loading a schema, creation of all edition widgets is time and memory consuming, so, widget edition creation is differed until user select an item in tree or 2D vue.

Reimplemented from YACS::HMI::ItemEditionBase.

Reimplemented in YACS::HMI::EditionSalomeNode, YACS::HMI::EditionSwitch, YACS::HMI::EditionOptimizerLoop, YACS::HMI::EditionForEachLoop, YACS::HMI::EditionProc, YACS::HMI::EditionLoop, YACS::HMI::EditionNode, YACS::HMI::EditionWhile, YACS::HMI::EditionContainer, YACS::HMI::EditionComponent, YACS::HMI::EditionBloc, and YACS::HMI::EditionDataLink.

Definition at line 298 of file ItemEdition.cxx.

References YACS::HMI::ItemEditionBase::_name, YACS::HMI::ItemEditionBase::_subject, FormEditItem::_wid, YACS::HMI::ADD, YACS::HMI::ADDCONTROLLINK, YACS::HMI::ADDLINK, YACS::HMI::BLOC, YACS::HMI::COMPONENT, YACS::HMI::CONTAINER, YACS::HMI::CONTROLLINK, YACS::HMI::CORBANODE, YACS::HMI::CPPNODE, YACS::HMI::DATALINK, YACS::HMI::DATATYPE, DEBTRACE, YACS::HMI::DFTODSFORLOOPNODE, YACS::HMI::DSTODFFORLOOPNODE, YACS::HMI::GuiObserver::eventName(), YACS::HMI::FOREACHLOOP, YACS::HMI::FORLOOP, YACS::HMI::Subject::getName(), YACS::HMI::QtGuiContext::getQtCurrent(), YACS::HMI::INPUTDATASTREAMPORT, YACS::HMI::INPUTPORT, ItemEdition(), YACS::HMI::NEWROOT, YACS::HMI::OPTIMIZERLOOP, YACS::HMI::OUTNODE, YACS::HMI::OUTPUTDATASTREAMPORT, YACS::HMI::OUTPUTPORT, YACS::HMI::PRESETNODE, YACS::HMI::PYFUNCNODE, YACS::HMI::PYTHONNODE, YACS::HMI::REFERENCE, YACS::HMI::RENAME, YACS::HMI::SALOMENODE, YACS::HMI::SALOMEPROC, YACS::HMI::SALOMEPYTHONNODE, YACS::HMI::SPLITTERNODE, YACS::HMI::STUDYINNODE, YACS::HMI::STUDYOUTNODE, YACS::HMI::SWITCH, YACS::HMI::SYNCHRO, synchronize(), YACS::HMI::WHILELOOP, and YACS::HMI::XMLNODE.

Referenced by gui.graph.MyCanvas::customEvent(), YACS::HMI::EditionOutputPort::select(), YACS::HMI::EditionInputPort::select(), YACS::HMI::EditionContainer::update(), and YACS::HMI::EditionNode::update().

299 {
300  DEBTRACE("ItemEdition::update " <<eventName(event) << " " << type);
301  if (QtGuiContext::getQtCurrent()->isLoading())
302  {
303  // --- create only EditionProc while loading to store status
304  if (event == NEWROOT)
305  ItemEdition *item = new EditionProc(son,
306  QtGuiContext::getQtCurrent()->getStackedWidget(),
307  son->getName().c_str());
308  return;
309  }
310 
311  ItemEdition *item = 0;
312  switch (event)
313  {
314  case NEWROOT:
315  item = new EditionProc(son,
316  QtGuiContext::getQtCurrent()->getStackedWidget(),
317  son->getName().c_str());
318  break;
319  case ADD:
320  switch (type)
321  {
323  item = new EditionProc(son,
324  QtGuiContext::getQtCurrent()->getStackedWidget(),
325  son->getName().c_str());
326  break;
327  case YACS::HMI::BLOC:
328  item = new EditionBloc(son,
329  QtGuiContext::getQtCurrent()->getStackedWidget(),
330  son->getName().c_str());
331  break;
333  item = new EditionForEachLoop(son,
334  QtGuiContext::getQtCurrent()->getStackedWidget(),
335  son->getName().c_str());
336  break;
338  item = new EditionOptimizerLoop(son, QtGuiContext::getQtCurrent()->getStackedWidget(),
339  son->getName().c_str());
340  break;
341  case YACS::HMI::FORLOOP:
342  item = new EditionLoop(son,
343  QtGuiContext::getQtCurrent()->getStackedWidget(),
344  son->getName().c_str());
345  break;
347  item = new EditionWhile(son,
348  QtGuiContext::getQtCurrent()->getStackedWidget(),
349  son->getName().c_str());
350  break;
351  case YACS::HMI::SWITCH:
352  item = new EditionSwitch(son,
353  QtGuiContext::getQtCurrent()->getStackedWidget(),
354  son->getName().c_str());
355  break;
357  item = new EditionScript(son,
358  QtGuiContext::getQtCurrent()->getStackedWidget(),
359  son->getName().c_str());
360  break;
362  item = new EditionPyFunc(son,
363  QtGuiContext::getQtCurrent()->getStackedWidget(),
364  son->getName().c_str());
365  break;
368  item = new EditionSalomeNode(son,
369  QtGuiContext::getQtCurrent()->getStackedWidget(),
370  son->getName().c_str());
371  break;
373  item = new EditionPresetNode(son,
374  QtGuiContext::getQtCurrent()->getStackedWidget(),
375  son->getName().c_str());
376  break;
377  case YACS::HMI::OUTNODE:
378  item = new EditionOutNode(son,
379  QtGuiContext::getQtCurrent()->getStackedWidget(),
380  son->getName().c_str());
381  break;
383  item = new EditionStudyInNode(son,
384  QtGuiContext::getQtCurrent()->getStackedWidget(),
385  son->getName().c_str());
386  break;
388  item = new EditionStudyOutNode(son,
389  QtGuiContext::getQtCurrent()->getStackedWidget(),
390  son->getName().c_str());
391  break;
394  item = new EditionInputPort(son,
395  QtGuiContext::getQtCurrent()->getStackedWidget(),
396  son->getName().c_str());
397  break;
400  item = new EditionOutputPort(son,
401  QtGuiContext::getQtCurrent()->getStackedWidget(),
402  son->getName().c_str());
403  break;
405  item = new EditionContainer(son,QtGuiContext::getQtCurrent()->getStackedWidget(),son->getName().c_str());
406  break;
408  item = new EditionComponent(son,
409  QtGuiContext::getQtCurrent()->getStackedWidget(),
410  son->getName().c_str());
411 
412  break;
413  case YACS::HMI::DATATYPE:
414  item = new EditionDataType(son,
415  QtGuiContext::getQtCurrent()->getStackedWidget(),
416  son->getName().c_str());
417  break;
419  case YACS::HMI::CPPNODE:
421  case YACS::HMI::XMLNODE:
425  item = new ItemEdition(son,
426  QtGuiContext::getQtCurrent()->getStackedWidget(),
427  son->getName().c_str());
428  break;
429  default:
430  DEBTRACE("ItemEdition::update() ADD, type not handled:" << type);
431  }
432  break;
433  case ADDLINK:
434  switch (type)
435  {
436  case YACS::HMI::DATALINK:
437  item = new EditionDataLink(son,
438  QtGuiContext::getQtCurrent()->getStackedWidget(),
439  son->getName().c_str());
440  break;
441  default:
442  DEBTRACE("ItemEdition::update() ADDLINK, type not handled:" << type);
443  }
444  break;
445  case ADDCONTROLLINK:
446  switch (type)
447  {
449  item = new EditionControlLink(son,
450  QtGuiContext::getQtCurrent()->getStackedWidget(),
451  son->getName().c_str());
452  break;
453  default:
454  DEBTRACE("ItemEdition::update() ADDCONTROLLINK, type not handled:" << type);
455  }
456  break;
457  case RENAME:
458  _name = _subject->getName();
459  _wid->le_name->setText(_name.c_str());
460  break;
461  case SYNCHRO:
462  synchronize();
463  break;
464 // default:
465 // DEBTRACE("ItemEdition::update(), event not handled: " << eventName(event));
466  }
467 }

Member Data Documentation

bool YACS::HMI::ItemEdition::_haveScript
protected

The documentation for this class was generated from the following files: