Version: 8.3.0
FormContainerBase Class Referenceabstract

#include <FormContainerBase.hxx>

Inheritance diagram for FormContainerBase:
Collaboration diagram for FormContainerBase:

Public Slots

void on_ch_advance_stateChanged (int state)
 
void onModifyName (const QString &text)
 

Public Member Functions

 FormContainerBase (QWidget *parent=0)
 
virtual ~FormContainerBase ()
 
virtual void FillPanel (YACS::ENGINE::Container *container)
 
virtual void onModified ()
 
virtual bool onApply ()
 
virtual void onCancel ()
 
virtual QString getTypeStr () const =0
 

Protected Attributes

bool _advanced
 
YACS::ENGINE::Container_container
 
std::map< std::string,
std::string > 
_properties
 
FormAdvParamContainer_advancedParams
 

Detailed Description

Definition at line 37 of file FormContainerBase.hxx.

Constructor & Destructor Documentation

FormContainerBase::FormContainerBase ( QWidget parent = 0)

Definition at line 41 of file FormContainerBase.cxx.

References _advanced, _advancedParams, FillPanel(), on_ch_advance_stateChanged(), and onModifyName().

42 {
43  setupUi(this);
44  _advanced = false;
45  gridLayout_2->addWidget(_advancedParams);
47 
48  FillPanel(0); // --- set widgets before signal connexion to avoid false modif detection
49  connect(le_name, SIGNAL(textChanged(const QString&)), this, SLOT(onModifyName(const QString&)));
50  connect(cb_resource, SIGNAL(activated(const QString&)), _advancedParams, SLOT(onModifyResource(const QString&)));
51 }
FormContainerBase::~FormContainerBase ( )
virtual

Definition at line 53 of file FormContainerBase.cxx.

References _advancedParams.

54 {
55  delete _advancedParams;
56 }

Member Function Documentation

void FormContainerBase::FillPanel ( YACS::ENGINE::Container container)
virtual

Reimplemented in FormHPContainer, and FormContainer.

Definition at line 58 of file FormContainerBase.cxx.

References _advancedParams, _container, _properties, DEBTRACE, FormAdvParamContainer::FillPanel(), YACS::ENGINE::Container::getName(), and YACS::ENGINE::Container::getProperties().

Referenced by FormContainerDecorator::checkAndRepareTypeIfNecessary(), FormContainer::FillPanel(), FormContainerDecorator::FillPanel(), FormHPContainer::FillPanel(), FormContainerBase(), FormContainerDecorator::FormContainerDecorator(), and onCancel().

59 {
60  DEBTRACE("FormContainer::FillPanel");
61  _container = container;
62  if (_container)
63  {
65  le_name->setText(_container->getName().c_str());
66  }
67  else
68  {
69  _properties.clear();
70  le_name->setText("not defined");
71  }
72 
73  //Resources
74  cb_resource->clear();
75  cb_resource->addItem("automatic"); // --- when no resource is selected
76 
77  //add available resources
78  list<string> machines = QtGuiContext::getQtCurrent()->getGMain()->getMachineList();
79  list<string>::iterator itm = machines.begin();
80  for( ; itm != machines.end(); ++itm)
81  {
82  cb_resource->addItem(QString((*itm).c_str()));
83  }
84 
85  std::string resource;
86  if(_properties.count("name") && _properties["name"] != "")
87  {
88  //a resource has been specified
89  int index = cb_resource->findText(_properties["name"].c_str());
90  if (index > 0)
91  {
92  //the resource is found: use it
93  cb_resource->setCurrentIndex(index);
94  resource=_properties["name"];
95  }
96  else
97  {
98  //the resource has not been found: add a false item
99  std::string item="Unknown resource ("+_properties["name"]+")";
100  cb_resource->addItem(item.c_str());
101  cb_resource->setCurrentIndex(cb_resource->count()-1);
102  }
103  }
104  else
105  cb_resource->setCurrentIndex(0);
106  _advancedParams->FillPanel(resource,container);
107 
108  if (!QtGuiContext::getQtCurrent()->isEdition())
109  {
110  //if the schema is in execution do not allow editing
111  le_name->setReadOnly(true);
112  cb_resource->setEnabled(false);
113  }
114 }
virtual QString FormContainerBase::getTypeStr ( ) const
pure virtual
void FormContainerBase::on_ch_advance_stateChanged ( int  state)
slot

Definition at line 129 of file FormContainerBase.cxx.

References _advancedParams, and DEBTRACE.

Referenced by FormContainerBase().

130 {
131  DEBTRACE("FormContainer::on_ch_advance_stateChanged " << state);
132  if (state)
133  _advancedParams->show();
134  else
135  _advancedParams->hide();
136 }
bool FormContainerBase::onApply ( )
virtual

Reimplemented in FormHPContainer.

Definition at line 148 of file FormContainerBase.cxx.

References _container, _properties, DEBTRACE, PMMLBasicsTestLauncher::ret, YACS::HMI::SubjectContainerBase::setName(), YACS::HMI::SubjectContainerBase::setProperties(), and YASSERT.

Referenced by FormContainerDecorator::onApply().

149 {
150  SubjectContainerBase *scont(QtGuiContext::getQtCurrent()->_mapOfSubjectContainer[_container]);
151  YASSERT(scont);
152  bool ret(scont->setName(le_name->text().toStdString()));
153  DEBTRACE(ret);
154  if (ret)
155  ret = scont->setProperties(_properties);
156  return ret;
157 }
void FormContainerBase::onCancel ( )
virtual

Definition at line 159 of file FormContainerBase.cxx.

References _container, FillPanel(), YACS::HMI::SubjectContainerBase::getContainer(), and YASSERT.

Referenced by FormContainerDecorator::onCancel().

160 {
161  SubjectContainerBase *scont(QtGuiContext::getQtCurrent()->_mapOfSubjectContainer[_container]);
162  YASSERT(scont);
163  FillPanel(scont->getContainer());
164 }
void FormContainerBase::onModified ( )
virtual

Definition at line 116 of file FormContainerBase.cxx.

References DEBTRACE, YACS::HMI::ItemEdition::setEdited(), and YASSERT.

Referenced by FormHPContainer::initSciptChanged(), FormContainer::onModifyAOC(), onModifyName(), FormHPContainer::onModifySzOfPool(), and FormContainer::onModifyType().

117 {
118  DEBTRACE("FormContainerBase::onModified");
119  Subject *sub(QtGuiContext::getQtCurrent()->getSelectedSubject());
120  if (!sub)
121  return;
122  YASSERT(QtGuiContext::getQtCurrent()->_mapOfEditionItem.count(sub));
123  QWidget *widget(QtGuiContext::getQtCurrent()->_mapOfEditionItem[sub]);
124  ItemEdition *item(dynamic_cast<ItemEdition*>(widget));
125  YASSERT(item);
126  item->setEdited(true);
127 }
void FormContainerBase::onModifyName ( const QString &  text)
slot

Definition at line 138 of file FormContainerBase.cxx.

References _container, DEBTRACE, onModified(), and YASSERT.

Referenced by FormContainerBase().

139 {
140  DEBTRACE("onModifyName " << text.toStdString());
141  SubjectContainerBase *scont(QtGuiContext::getQtCurrent()->_mapOfSubjectContainer[_container]);
142  YASSERT(scont);
143  string name = scont->getName();
144  if (name != text.toStdString())
145  onModified();
146 }

Member Data Documentation

bool FormContainerBase::_advanced
protected

Definition at line 54 of file FormContainerBase.hxx.

Referenced by FormContainerBase().


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