Marlin  01.17.01
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
paramdelegate.cpp
Go to the documentation of this file.
1 #include <QtGui>
2 
3 #include "paramdelegate.h"
4 
5 ParamDelegate::ParamDelegate(CCProcessor* p, QObject *parent) : QItemDelegate(parent){
6  _parent = qobject_cast<QTableWidget *>(parent);
7  _p=p;
8 }
9 
10 QWidget *ParamDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem & /* option */, const QModelIndex &index) const
11 {
12  QLineEdit *edit = new QLineEdit(parent);
13 
14  if( index.column() == 0 ){
15  edit->setReadOnly(true);
16  return edit;
17  }
18  return edit;
19 }
20 
21 void ParamDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const
22 {
23  QLineEdit *edit = qobject_cast<QLineEdit *>(editor);
24  edit->setText(index.model()->data(index).toString());
25 }
26 
27 void ParamDelegate::setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const
28 {
29  QLineEdit *edit = qobject_cast<QLineEdit *>(editor);
30  model->setData(index, edit->displayText());
31 
32  //update the processor parameter's
33  StringVec value;
34  //save the value
35  value.push_back(edit->displayText().toStdString());
36  //erase the old parameter
37  _p->getParameters()->erase( _parent->item( index.row(), 0)->text().toStdString() );
38  //add a new parameter with updated values
39  _p->getParameters()->add( _parent->item( index.row(), 0)->text().toStdString(), value );
40 }
41 
ParamDelegate(const ParamDelegate &)=default
void setEditorData(QWidget *editor, const QModelIndex &index) const
handles information about marlin processors and their collections needed by MarlinSteerCheck ...
Definition: CCProcessor.h:39
T push_back(T...args)
QTableWidget * _parent
Definition: paramdelegate.h:34
void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const
CCProcessor * _p
Definition: paramdelegate.h:33
QWidget * createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const
std::shared_ptr< StringParameters > getParameters()
Returns the string parameters for this processor.
Definition: CCProcessor.h:103