Version: 8.3.0
FormHPContainer Class Reference

#include <FormHPContainer.hxx>

Inheritance diagram for FormHPContainer:
Collaboration diagram for FormHPContainer:

Public Slots

void onModifySzOfPool (const QString &newSz)
 
void initSciptChanged ()
 
- Public Slots inherited from FormContainerBase
void on_ch_advance_stateChanged (int state)
 
void onModifyName (const QString &text)
 

Public Member Functions

 FormHPContainer (QWidget *parent=0)
 
virtual ~FormHPContainer ()
 
void FillPanel (YACS::ENGINE::Container *container)
 
QString getTypeStr () const
 
bool onApply ()
 
- Public Member Functions inherited from FormContainerBase
 FormContainerBase (QWidget *parent=0)
 
virtual ~FormContainerBase ()
 
virtual void onModified ()
 
virtual void onCancel ()
 

Static Public Member Functions

static std::string BuildWithFinalEndLine (const std::string &script)
 

Private Attributes

QLineEdit_poolSz
 
QTextEdit * _initScript
 
bool _initScriptModified
 
bool _initScriptLoaded
 

Additional Inherited Members

- Protected Attributes inherited from FormContainerBase
bool _advanced
 
YACS::ENGINE::Container_container
 
std::map< std::string,
std::string > 
_properties
 
FormAdvParamContainer_advancedParams
 

Detailed Description

Definition at line 40 of file FormHPContainer.hxx.

Constructor & Destructor Documentation

FormHPContainer::FormHPContainer ( QWidget parent = 0)

Definition at line 41 of file FormHPContainer.cxx.

References FormContainerBase::_advancedParams, _initScript, _poolSz, FillPanel(), initSciptChanged(), and onModifySzOfPool().

41  :FormContainerBase(parent),_poolSz(new QLineEdit(this)),_initScriptModified(false)
42 {
43  QIntValidator *iv(new QIntValidator(_poolSz)); iv->setRange(1,INT_MAX);
44  _poolSz->setValidator(iv);
45  label_15->setText("Size of pool :");
46  gridLayout_2_2->addWidget(_poolSz);
47  FormHPContainer::FillPanel(0); // --- set widgets before signal connexion to avoid false modif detection
48  connect(_poolSz, SIGNAL(textChanged(const QString&)),this, SLOT(onModifySzOfPool(const QString&)));
49  ch_aoc->setEnabled(false);
50  ch_aoc->setCheckState(Qt::Checked);
51  //
52 #ifdef HAS_PYEDITOR
53  _initScript=new PyEditor_Editor(_advancedParams->tw_advance);
54 #else
55  _initScript=new QTextEdit(this);
56 #endif
57  connect(_initScript,SIGNAL(textChanged()),this,SLOT(initSciptChanged()));
58  QGridLayout *gridLayout(new QGridLayout(_initScript));
59  _advancedParams->tw_advance->addTab(_initScript,"Init Script");
60 }
FormHPContainer::~FormHPContainer ( )
virtual

Definition at line 62 of file FormHPContainer.cxx.

63 {
64 }

Member Function Documentation

std::string FormHPContainer::BuildWithFinalEndLine ( const std::string &  script)
static

Definition at line 136 of file FormHPContainer.cxx.

References PMMLBasicsTestLauncher::ret.

Referenced by FillPanel(), and onApply().

137 {
138  if(script.empty())
139  return std::string("\n");
140  std::size_t sz(script.length());
141  if(script[sz-1]!='\n')
142  {
143  std::string ret(script);
144  ret+="\n";
145  return ret;
146  }
147  else
148  return script;
149 }
void FormHPContainer::FillPanel ( YACS::ENGINE::Container container)
virtual

Reimplemented from FormContainerBase.

Definition at line 66 of file FormHPContainer.cxx.

References _initScript, _poolSz, FormContainerBase::_properties, BuildWithFinalEndLine(), DEBTRACE, FormContainerBase::FillPanel(), YACS::HMI::QtGuiContext::getQtCurrent(), YACS::ENGINE::HomogeneousPoolContainer::getSizeOfPool(), and YACS::ENGINE::HomogeneousPoolContainer::INITIALIZE_SCRIPT_KEY.

Referenced by FormHPContainer().

67 {
68  DEBTRACE("FormHPContainer::FillPanel");
70  if(!container)
71  return ;
72  YACS::ENGINE::HomogeneousPoolContainer *hpc(dynamic_cast<YACS::ENGINE::HomogeneousPoolContainer *>(container));
73  if(!hpc)
74  throw YACS::Exception("FormHPContainer::FillPanel : not a HP Container !");
75  _poolSz->setText(QString("%1").arg(hpc->getSizeOfPool()));
76  std::string initScript;
79  std::string initScript2(BuildWithFinalEndLine(initScript));
80  _initScript->blockSignals(true);
81  _initScript->setText(initScript2.c_str());
82  _initScript->blockSignals(false);
83  if (!YACS::HMI::QtGuiContext::getQtCurrent()->isEdition())
84  {
85  //if the schema is in execution do not allow editing
86  _poolSz->setEnabled(false);
87  _initScript->setEnabled(false);
88  }
89 }
QString FormHPContainer::getTypeStr ( ) const
virtual

Implements FormContainerBase.

Definition at line 91 of file FormHPContainer.cxx.

92 {
93  return QString("Container (HP)");
94 }
void FormHPContainer::initSciptChanged ( )
slot

Definition at line 130 of file FormHPContainer.cxx.

References _initScriptModified, and FormContainerBase::onModified().

Referenced by FormHPContainer().

131 {
132  _initScriptModified=true;
133  onModified();
134 }
bool FormHPContainer::onApply ( )
virtual

Reimplemented from FormContainerBase.

Definition at line 111 of file FormHPContainer.cxx.

References FormContainerBase::_container, _initScript, _initScriptModified, FormContainerBase::_properties, BuildWithFinalEndLine(), DEBTRACE, YACS::HMI::QtGuiContext::getQtCurrent(), YACS::ENGINE::HomogeneousPoolContainer::INITIALIZE_SCRIPT_KEY, PMMLBasicsTestLauncher::ret, YACS::HMI::SubjectContainerBase::setName(), YACS::HMI::SubjectContainerBase::setProperties(), and YASSERT.

112 {
114  YASSERT(scont);
115  bool ret(scont->setName(le_name->text().toStdString()));
116  std::map<std::string,std::string> properties(_properties);
118  {
119  std::string text(_initScript->toPlainText().toStdString());
120  std::string text2(BuildWithFinalEndLine(text));
122  }
123  _initScriptModified=false;
124  DEBTRACE(ret);
125  if(ret)
126  ret = scont->setProperties(properties);
127  return ret;
128 }
void FormHPContainer::onModifySzOfPool ( const QString &  newSz)
slot

Definition at line 96 of file FormHPContainer.cxx.

References FormContainerBase::_container, FormContainerBase::_properties, YACS::ENGINE::Container::getProperties(), FormContainerBase::onModified(), and YACS::ENGINE::HomogeneousPoolContainer::SIZE_OF_POOL_KEY.

Referenced by FormHPContainer().

97 {
98  if (!_container)
99  return;
100  map<string,string> properties(_container->getProperties());
101  uint sz;
102  bool isOK;
103  sz=newSz.toUInt(&isOK);
104  if(!isOK)
105  return ;
107  if(properties[YACS::ENGINE::HomogeneousPoolContainer::SIZE_OF_POOL_KEY] != newSz.toStdString())
108  onModified();
109 }

Member Data Documentation

QTextEdit* FormHPContainer::_initScript
private

Definition at line 60 of file FormHPContainer.hxx.

Referenced by FillPanel(), FormHPContainer(), and onApply().

bool FormHPContainer::_initScriptLoaded
private

Definition at line 63 of file FormHPContainer.hxx.

bool FormHPContainer::_initScriptModified
private

Definition at line 62 of file FormHPContainer.hxx.

Referenced by initSciptChanged(), and onApply().

QLineEdit* FormHPContainer::_poolSz
private

Definition at line 56 of file FormHPContainer.hxx.

Referenced by FillPanel(), and FormHPContainer().


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