Version: 8.3.0
YACS::HMI::EditionElementaryNode Class Reference

#include <EditionElementaryNode.hxx>

Inheritance diagram for YACS::HMI::EditionElementaryNode:
Collaboration diagram for YACS::HMI::EditionElementaryNode:

Public Slots

virtual void onApply ()
 
virtual void onCancel ()
 
virtual void onPortIndexChanged (int index)
 
virtual void onCommitData (QWidget *editor)
 

Public Member Functions

 EditionElementaryNode (Subject *subject, QWidget *parent=0, const char *name=0)
 
virtual ~EditionElementaryNode ()
 
virtual void synchronize ()
 
virtual void setEditablePorts (bool isEditable)
 
- Public Member Functions inherited from YACS::HMI::EditionNode
 EditionNode (Subject *subject, QWidget *parent=0, const char *name=0)
 
virtual ~EditionNode ()
 
virtual void update (GuiEvent event, int type, Subject *son)
 
- Public Member Functions inherited from YACS::HMI::ItemEdition
 ItemEdition (Subject *subject, QWidget *parent=0, const char *name=0)
 
virtual ~ItemEdition ()
 
virtual void select (bool isSelected)
 
virtual void setName (std::string name)
 
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 ()
 

Protected Member Functions

virtual bool hasInputPorts ()
 
virtual bool hasOutputPorts ()
 
virtual void createTablePorts (QLayout *layout)
 

Protected Attributes

SubjectElementaryNode_subElemNode
 
QTabWidget * _twPorts
 
TablePortsEdition_tvInPorts
 
TablePortsEdition_tvOutPorts
 
ValueDelegate_valueDelegate
 
- Protected Attributes inherited from YACS::HMI::EditionNode
QLineEdit_le_fullName
 
SubjectNode_subjectNode
 
- Protected Attributes inherited from YACS::HMI::ItemEdition
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 Public Member Functions inherited from YACS::HMI::ItemEdition
static std::string filterName (const std::string &name)
 
- Static Protected Attributes inherited from YACS::HMI::GuiObserver
static std::map< int, std::string > _eventNameMap
 

Detailed Description

Definition at line 35 of file EditionElementaryNode.hxx.

Constructor & Destructor Documentation

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

Definition at line 41 of file EditionElementaryNode.cxx.

References _subElemNode, YACS::HMI::ItemEditionBase::_subject, _tvInPorts, _tvOutPorts, _twPorts, _valueDelegate, onCommitData(), and YASSERT.

44  : EditionNode(subject, parent, name)
45 {
46  _subElemNode = 0;
47  _twPorts = 0;
48  _tvInPorts = 0;
49  _tvOutPorts = 0;
50  _valueDelegate = 0;
51 
54  _valueDelegate = new ValueDelegate(parent);
55 
56  connect(_valueDelegate, SIGNAL(commitData(QWidget*)),
57  this, SLOT(onCommitData(QWidget*)));
58 
59 }
EditionElementaryNode::~EditionElementaryNode ( )
virtual

Definition at line 61 of file EditionElementaryNode.cxx.

62 {
63 }

Member Function Documentation

void EditionElementaryNode::createTablePorts ( QLayout *  layout)
protectedvirtual

Definition at line 145 of file EditionElementaryNode.cxx.

References _tvInPorts, _tvOutPorts, _twPorts, _valueDelegate, YACS::HMI::QtGuiContext::getQtCurrent(), YACS::HMI::QtGuiContext::getSchemaModel(), hasInputPorts(), hasOutputPorts(), YACS::HMI::SchemaModel::index(), onPortIndexChanged(), setEditablePorts(), YACS::HMI::YLabel, and YACS::HMI::YValue.

Referenced by YACS::HMI::EditionOutNode::EditionOutNode(), YACS::HMI::EditionPresetNode::EditionPresetNode(), YACS::HMI::EditionSalomeNode::EditionSalomeNode(), and YACS::HMI::EditionScript::EditionScript().

146 {
147  _twPorts = new QTabWidget(this);
148  layout->addWidget(_twPorts);
150 
151  QModelIndex schemIndex = model->index(0, 0, QModelIndex());
152  QModelIndex TypesDirIndex = model->index(0, 0, schemIndex);
153 
154  if (hasInputPorts())
155  {
157  _tvInPorts->tv_ports->setModel(model);
158  _tvInPorts->tv_ports->setItemDelegateForColumn(YLabel, _valueDelegate); // --- port label
159  _tvInPorts->tv_ports->setItemDelegateForColumn(YValue, _valueDelegate); // --- port value
160  _tvInPorts->cb_insert->setModel(model);
161  _tvInPorts->cb_insert->setRootModelIndex(TypesDirIndex);
162  _twPorts->addTab(_tvInPorts, "input Ports");
163  }
164 
165  if (hasOutputPorts())
166  {
168  _tvOutPorts->tv_ports->setModel(model);
169  _tvOutPorts->tv_ports->setItemDelegateForColumn(YLabel, _valueDelegate); // --- port label
170  _tvOutPorts->tv_ports->setItemDelegateForColumn(YValue, _valueDelegate); // --- port value
171  _tvOutPorts->cb_insert->setModel(model);
172  _tvOutPorts->cb_insert->setRootModelIndex(TypesDirIndex);
173  _twPorts->addTab(_tvOutPorts, "output Ports");
174  }
175 
176  connect(_twPorts, SIGNAL(currentChanged(int)),
177  this, SLOT(onPortIndexChanged(int)));
178 
179  setEditablePorts(false);
180 }
bool EditionElementaryNode::hasInputPorts ( )
protectedvirtual

Reimplemented in YACS::HMI::EditionPresetNode.

Definition at line 135 of file EditionElementaryNode.cxx.

Referenced by createTablePorts().

136 {
137  return true;
138 }
bool EditionElementaryNode::hasOutputPorts ( )
protectedvirtual

Reimplemented in YACS::HMI::EditionOutNode.

Definition at line 140 of file EditionElementaryNode.cxx.

Referenced by createTablePorts().

141 {
142  return true;
143 }
void EditionElementaryNode::onApply ( )
virtualslot
void EditionElementaryNode::onCancel ( )
virtualslot

Definition at line 70 of file EditionElementaryNode.cxx.

References YACS::HMI::ItemEdition::onCancel().

Referenced by YACS::HMI::EditionScript::onCancel().

71 {
73 }
void EditionElementaryNode::onCommitData ( QWidget editor)
virtualslot

After edition with a specific editor created by ValueDelegate for a cell of TablePortsEdition, the resulting string is tested for setValue on the corresponding subject. Result of the setValue (succes or failure) is transmitted to ValueDelegate for further action in case of failure.

Definition at line 189 of file EditionElementaryNode.cxx.

References _valueDelegate, DEBTRACE, YACS::HMI::GenericEditor::getColumnInSubject(), YACS::HMI::QtGuiContext::getGuiExecutor(), YACS::HMI::SubjectDataPort::getPort(), YACS::HMI::QtGuiContext::getQtCurrent(), YACS::HMI::GenericEditor::GetStrValue(), YACS::HMI::GenericEditor::getSubject(), YACS::HMI::GuiExecutor::setInPortValue(), YACS::HMI::SubjectDataPort::setName(), YACS::HMI::ValueDelegate::setResultEditing(), YACS::HMI::SubjectDataPort::setValue(), YASSERT, and YACS::HMI::YValue.

Referenced by EditionElementaryNode().

190 {
191  DEBTRACE("EditionElementaryNode::onCommitData " << editor);
192  GenericEditor* gedit = dynamic_cast<GenericEditor*>(editor);
193  YASSERT(gedit);
194  QString val = gedit->GetStrValue();
195  DEBTRACE(val.toStdString());
196  Subject *sub = gedit->getSubject();
197  YASSERT(sub);
198  SubjectDataPort *sdp = dynamic_cast<SubjectDataPort*>(sub);
199  YASSERT(sdp);
200  string strval = val.toStdString();
201  bool isOk = false;
202 
203  if (gedit->getColumnInSubject() == YValue)
204  {
205  DEBTRACE(strval);
206  isOk = sdp->setValue(strval);
207 
209  if (executor) executor->setInPortValue(sdp->getPort(), strval);
210  }
211 
212  else // --- YLabel
213  {
214  isOk = sdp->setName(strval);
215  }
216 
217  if (_valueDelegate)
218  _valueDelegate->setResultEditing(editor, isOk);
219  }
void EditionElementaryNode::onPortIndexChanged ( int  index)
virtualslot

Definition at line 75 of file EditionElementaryNode.cxx.

References DEBTRACE, and synchronize().

Referenced by createTablePorts().

76 {
77  DEBTRACE("EditionElementaryNode::onPortIndexChanged " << index);
78  synchronize();
79 }
void EditionElementaryNode::setEditablePorts ( bool  isEditable)
virtual
void EditionElementaryNode::synchronize ( )
virtual

used in derived nodes for synchronisation with schema model.

Reimplemented from YACS::HMI::ItemEdition.

Reimplemented in YACS::HMI::EditionScript, and YACS::HMI::EditionSalomeNode.

Definition at line 81 of file EditionElementaryNode.cxx.

References YACS::HMI::QtGuiContext::_mapOfSchemaItem, _subElemNode, YACS::HMI::ItemEditionBase::_subject, _tvInPorts, _tvOutPorts, YACS::HMI::TablePortsEdition::adjustColumns(), YACS::HMI::QtGuiContext::getQtCurrent(), YACS::HMI::QtGuiContext::getSchemaModel(), YACS::HMI::SchemaItem::getSubject(), YACS::HMI::SchemaModel::index(), YACS::HMI::SchemaItem::modelIndex(), YACS::HMI::SchemaModel::rowCount(), and YACS::HMI::TablePortsEdition::setNode().

Referenced by onPortIndexChanged(), YACS::HMI::EditionSalomeNode::synchronize(), and YACS::HMI::EditionScript::synchronize().

82 {
83  //DEBTRACE("EditionElementaryNode::synchronize");
86  if (schemaItem)
87  {
88  QModelIndex parentIndex = schemaItem->modelIndex();
89  int numRows = model->rowCount(parentIndex);
90  if (_tvInPorts)
91  {
92  _tvInPorts->cb_insert->setCurrentIndex(0);
94  _tvInPorts->tv_ports->setRootIndex(parentIndex);
95  for (int row = 0; row < numRows; ++row)
96  {
97  QModelIndex index = model->index(row, 0, parentIndex);
98  SchemaItem *childItem = static_cast<SchemaItem*>(index.internalPointer());
99  bool hidden = true;
100  if (Subject *sub = childItem->getSubject())
101  if (dynamic_cast<SubjectInputPort*>(sub)
102  || dynamic_cast<SubjectInputDataStreamPort*>(sub))
103  hidden = false;
104  _tvInPorts->tv_ports->setRowHidden(row, hidden);
105  }
107  }
108  if (_tvOutPorts)
109  {
110  _tvOutPorts->cb_insert->setCurrentIndex(0);
112  _tvOutPorts->tv_ports->setRootIndex(parentIndex);
113  for (int row = 0; row < numRows; ++row)
114  {
115  QModelIndex index = model->index(row, 0, parentIndex);
116  SchemaItem *childItem = static_cast<SchemaItem*>(index.internalPointer());
117  bool hidden = true;
118  if (Subject *sub = childItem->getSubject())
119  if (dynamic_cast<SubjectOutputPort*>(sub)
120  || dynamic_cast<SubjectOutputDataStreamPort*>(sub))
121  hidden = false;
122  _tvOutPorts->tv_ports->setRowHidden(row, hidden);
123  }
125  }
126  }
127 }

Member Data Documentation

SubjectElementaryNode* YACS::HMI::EditionElementaryNode::_subElemNode
protected
TablePortsEdition* YACS::HMI::EditionElementaryNode::_tvInPorts
protected
TablePortsEdition* YACS::HMI::EditionElementaryNode::_tvOutPorts
protected
QTabWidget* YACS::HMI::EditionElementaryNode::_twPorts
protected

Definition at line 58 of file EditionElementaryNode.hxx.

Referenced by createTablePorts(), and EditionElementaryNode().

ValueDelegate* YACS::HMI::EditionElementaryNode::_valueDelegate
protected

Definition at line 61 of file EditionElementaryNode.hxx.

Referenced by createTablePorts(), EditionElementaryNode(), and onCommitData().


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