Marlin  01.17.01
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
aprocdelegate.cpp
Go to the documentation of this file.
1 #include <QtGui>
2 
3 #include "aprocdelegate.h"
4 
5 AProcDelegate::AProcDelegate(QObject *parent) : QItemDelegate(parent){
6  _parent=parent;
7 }
8 
9 QWidget *AProcDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem & /* option */, const QModelIndex &index) const
10 {
11 
12  QLineEdit *edit = new QLineEdit(parent);
13 
14  if( index.column() == 1 ){
15  edit->setReadOnly(true);
16  }
17  else{
18  connect(edit, SIGNAL(editingFinished()), _parent, SLOT(aProcNameChanged()));
19  }
20 
21  return edit;
22 }
23 
24 void AProcDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const
25 {
26  QLineEdit *edit = qobject_cast<QLineEdit *>(editor);
27  edit->setText(index.model()->data(index).toString());
28 }
29 
30 void AProcDelegate::setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const
31 {
32  QLineEdit *edit = qobject_cast<QLineEdit *>(editor);
33  model->setData(index, edit->displayText());
34 }
AProcDelegate(const AProcDelegate &)=default
void setEditorData(QWidget *editor, const QModelIndex &index) const
QWidget * createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const
QObject * _parent
Definition: aprocdelegate.h:28
void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const