Marlin  01.17.01
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
nparamvecsetd.cpp
Go to the documentation of this file.
1 #include <QtGui>
2 
3 #include "marlin/CMProcessor.h"
4 #include "nparamvecsetd.h"
5 
7  MarlinSteerCheck* msc,
8  CCProcessor* p,
9  QTableWidget* paramTable,
10  QObject *parent
11  ):
12  QItemDelegate(parent),
13  _msc(msc),
14  _p(p),
15  _paramTable(paramTable)
16 {
17 }
18 
20 {
21  QLineEdit *edit = new QLineEdit(parent);
22 
23  return edit;
24 }
25 
26 void NParamVecSetD::setEditorData(QWidget *editor, const QModelIndex &index) const
27 {
28  QLineEdit *edit = qobject_cast<QLineEdit *>(editor);
29  if( !index.model()->data(index).toString().isEmpty() ){
30  edit->setText(index.model()->data(index).toString());
31  }
32  else{
33  edit->setText("0");
34  }
35 }
36 
37 void NParamVecSetD::setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const
38 {
39  QLineEdit *edit = qobject_cast<QLineEdit *>(editor);
40  if( !edit->displayText().isEmpty() ){
41  model->setData(index, edit->displayText());
42  }
43  else{
44  model->setData(index, "0");
45  }
46 
47  //get the parameter's values
48  std::string key=_paramTable->item(_paramTable->currentRow(), 0)->text().toStdString();
49  StringVec values;
50  _p->getParameters()->getStringVals( key, values );
51 
52  //get the set size
53  int ssize= _msc->getMProcs()->getParamSetSize(_p->getType(), key );
54 
55  //update the changed value
56  if( !edit->displayText().isEmpty() ){
57  values[ (index.row()*ssize)+index.column() ]=edit->displayText().toStdString();
58  }
59  else{
60  values[ (index.row()*ssize)+index.column() ]="0";
61  edit->setText("0");
62  }
63 
64  //erase the parameter
65  _p->getParameters()->erase( key );
66 
67  //add the parameter with updated values
68  _p->getParameters()->add( key, values );
69 
70  //update param table
71  QString val;
72  for( unsigned int i=0; i<values.size(); i++ ){
73  val += values[i].c_str();
74  val += " ";
75  }
76 
77  _paramTable->item(_paramTable->currentRow(), 1)->setText(val);
78 }
79 
MarlinSteerCheck * _msc
Definition: nparamvecsetd.h:42
CCProcessor * _p
Definition: nparamvecsetd.h:43
this class is a Marlin Steering File consistency check Tool.
void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const
QWidget * createEditor(QWidget *parent) const
handles information about marlin processors and their collections needed by MarlinSteerCheck ...
Definition: CCProcessor.h:39
STL class.
const std::string & getType()
Returns the Type of the processor.
Definition: CCProcessor.h:77
void setEditorData(QWidget *editor, const QModelIndex &index) const
CMProcessor * getMProcs()
Returns the Marlin Processors.
T size(T...args)
int getParamSetSize(const std::string &type, const std::string &key)
returns the set_size of the parameter with the given key for the processor with the given type ...
Definition: CMProcessor.cc:181
NParamVecSetD(const NParamVecSetD &)=default
QTableWidget * _paramTable
Definition: nparamvecsetd.h:44
std::shared_ptr< StringParameters > getParameters()
Returns the string parameters for this processor.
Definition: CCProcessor.h:103