Version: 8.3.0
YACS::HMI::EditionSwitch Class Reference

#include <EditionSwitch.hxx>

Inheritance diagram for YACS::HMI::EditionSwitch:
Collaboration diagram for YACS::HMI::EditionSwitch:

Public Slots

virtual void onModifySelect (const QString &text)
 
virtual void onCommitData (QWidget *editor)
 

Public Member Functions

 EditionSwitch (Subject *subject, QWidget *parent=0, const char *name=0)
 
virtual ~EditionSwitch ()
 
virtual void synchronize ()
 
virtual void update (GuiEvent event, int type, Subject *son)
 
- Public Member Functions inherited from YACS::HMI::EditionBloc
 EditionBloc (Subject *subject, QWidget *parent=0, const char *name=0)
 
virtual ~EditionBloc ()
 
- Public Member Functions inherited from YACS::HMI::EditionNode
 EditionNode (Subject *subject, QWidget *parent=0, const char *name=0)
 
virtual ~EditionNode ()
 
- 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 Attributes

TableSwitch_tvSwitch
 
ValueDelegate_valueDelegate
 
- Protected Attributes inherited from YACS::HMI::EditionBloc
PropertyEditor_propeditor
 
- 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 34 of file EditionSwitch.hxx.

Constructor & Destructor Documentation

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

Definition at line 38 of file EditionSwitch.cxx.

References _tvSwitch, _valueDelegate, FormEditItem::_wid, YACS::HMI::QtGuiContext::getQtCurrent(), YACS::HMI::QtGuiContext::getSchemaModel(), onCommitData(), onModifySelect(), YACS::HMI::TableSwitch::setEditableCase(), and YACS::HMI::YValue.

41  : EditionBloc(subject, parent, name)
42 {
43  _tvSwitch = new TableSwitch(this);
44  _wid->gridLayout1->addWidget(_tvSwitch);
46  _tvSwitch->tv_nodes->setModel(model);
47  _tvSwitch->sb_select->setMinimum(INT_MIN);
48  _tvSwitch->sb_select->setMaximum(INT_MAX);
49  connect(_tvSwitch->sb_select, SIGNAL(valueChanged(const QString &)),
50  this, SLOT(onModifySelect(const QString &)));
51 
52  _valueDelegate = new ValueDelegate(parent);
53  _tvSwitch->tv_nodes->setItemDelegateForColumn(YValue, _valueDelegate);
55  if (!QtGuiContext::getQtCurrent()->isEdition())
56  _tvSwitch->setEnabled (false);
57 
58  connect(_valueDelegate, SIGNAL(commitData(QWidget*)),
59  this, SLOT(onCommitData(QWidget*)));
60 }
EditionSwitch::~EditionSwitch ( )
virtual

Definition at line 62 of file EditionSwitch.cxx.

63 {
64 }

Member Function Documentation

void EditionSwitch::onCommitData ( QWidget editor)
virtualslot

Definition at line 122 of file EditionSwitch.cxx.

References _valueDelegate, DEBTRACE, YACS::HMI::Subject::getParent(), YACS::HMI::GenericEditor::GetStrValue(), YACS::HMI::GenericEditor::getSubject(), YACS::HMI::SubjectSwitch::setCase(), YACS::HMI::ValueDelegate::setResultEditing(), and YASSERT.

Referenced by EditionSwitch().

123 {
124  DEBTRACE("EditionSwitch::onCommitData " << editor);
125  GenericEditor* gedit = dynamic_cast<GenericEditor*>(editor);
126  YASSERT(gedit);
127  QString val = gedit->GetStrValue();
128  DEBTRACE(val.toStdString());
129  Subject *sub = gedit->getSubject();
130  YASSERT(sub);
131  SubjectNode *snode = dynamic_cast<SubjectNode*>(sub);
132  YASSERT(snode);
133  sub = snode->getParent();
134  SubjectSwitch *sswitch = dynamic_cast<SubjectSwitch*>(sub);
135  YASSERT(sswitch);
136  bool isOk = sswitch->setCase(val.toStdString(), snode);
137  if (_valueDelegate)
138  _valueDelegate->setResultEditing(editor, isOk);
139 
140 }
void EditionSwitch::onModifySelect ( const QString &  text)
virtualslot

Definition at line 91 of file EditionSwitch.cxx.

References YACS::HMI::ItemEditionBase::_subject, DEBTRACE, and YASSERT.

Referenced by EditionSwitch().

92 {
93  DEBTRACE("EditionSwitch::onModifySelect " << text.toStdString());
94  SubjectSwitch *sswitch = dynamic_cast<SubjectSwitch*>(_subject);
95  YASSERT(sswitch);
96  sswitch->setSelect(text.toStdString());
97 }
void EditionSwitch::synchronize ( )
virtual

used in derived nodes for synchronisation with schema model.

Reimplemented from YACS::HMI::ItemEdition.

Definition at line 66 of file EditionSwitch.cxx.

References YACS::HMI::QtGuiContext::_mapOfSchemaItem, YACS::HMI::ItemEditionBase::_subject, _tvSwitch, YACS::HMI::TableSwitch::adjustColumns(), DEBTRACE, YACS::HMI::QtGuiContext::getQtCurrent(), YACS::HMI::QtGuiContext::getSchemaModel(), YACS::HMI::SchemaItem::getSubject(), YACS::HMI::SchemaModel::index(), YACS::HMI::SchemaItem::modelIndex(), YACS::HMI::SchemaModel::rowCount(), YACS::HMI::SETSELECT, and YACS::HMI::Subject::update().

67 {
68  DEBTRACE("EditionSwitch::synchronize");
71  if (schemaItem)
72  {
73  QModelIndex parentIndex = schemaItem->modelIndex();
74  _tvSwitch->tv_nodes->setRootIndex(parentIndex);
75  int numRows = model->rowCount(parentIndex);
76  for (int row = 0; row < numRows; ++row)
77  {
78  QModelIndex index = model->index(row, 0, parentIndex);
79  SchemaItem *childItem = static_cast<SchemaItem*>(index.internalPointer());
80  bool hidden = true;
81  if (Subject *sub = childItem->getSubject())
82  if (dynamic_cast<SubjectNode*>(sub))
83  hidden = false;
84  _tvSwitch->tv_nodes->setRowHidden(row, hidden);
85  }
86  }
89 }
void EditionSwitch::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::EditionBloc.

Definition at line 99 of file EditionSwitch.cxx.

References YACS::HMI::ItemEditionBase::_subject, _tvSwitch, DEBTRACE, YACS::HMI::GuiObserver::eventName(), YACS::HMI::SubjectComposedNode::getValue(), CORBAEngineTest::i, YACS::HMI::SETSELECT, and YACS::HMI::EditionBloc::update().

Referenced by gui.graph.MyCanvas::customEvent().

100 {
101  DEBTRACE("EditionSwitch::update " <<eventName(event) << " " << type);
102  switch (event)
103  {
104 
105  case SETSELECT:
106  {
107  SubjectComposedNode *scn = dynamic_cast<SubjectComposedNode*>(_subject);
108  string val = scn->getValue();
109  istringstream ss(val);
110  DEBTRACE(val);
111  int i = 0;
112  ss >> i;
113  DEBTRACE(i);
114  _tvSwitch->sb_select->setValue(i);
115  }
116  break;
117  default:
118  EditionBloc::update(event, type, son);
119  }
120 }

Member Data Documentation

TableSwitch* YACS::HMI::EditionSwitch::_tvSwitch
protected

Definition at line 51 of file EditionSwitch.hxx.

Referenced by EditionSwitch(), synchronize(), and update().

ValueDelegate* YACS::HMI::EditionSwitch::_valueDelegate
protected

Definition at line 52 of file EditionSwitch.hxx.

Referenced by EditionSwitch(), and onCommitData().


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