1 #include "cell-delegate.h"
5 CellDelegate::CellDelegate(QObject *parent) : QItemDelegate(parent)
10 QWidget *CellDelegate::createEditor(QWidget *parent,
11 const QStyleOptionViewItem &,
12 const QModelIndex &index) const
14 CellFilter *filter = new CellFilter(m_parent); // HACK
16 //CellFilter filter(parent);
18 QLineEdit *le = new QLineEdit(parent);
20 le->installEventFilter(filter);
22 qDebug() << "parent=" << parent << " m_parent=" << m_parent;
23 // HACK: Connect CellFilter signal to CourseDialog nextCell slot
24 connect(filter, SIGNAL(nextCell(QObject *)), m_parent, SLOT(nextCell(QObject *)));
29 void CellDelegate::commitAndCloseEditor()
31 QLineEdit *editor = qobject_cast<QLineEdit *>(sender());
34 emit commitData(editor);
35 emit closeEditor(editor);
38 void CellDelegate::setEditorData(QWidget *editor,
39 const QModelIndex &index) const
41 QString value = index.model()->data(index, Qt::EditRole).toString();
43 QLineEdit *le = static_cast<QLineEdit *>(editor);
48 void CellDelegate::setModelData(QWidget *editor,
49 QAbstractItemModel *model, const QModelIndex &index) const
51 QLineEdit *le = static_cast<QLineEdit*>(editor);
53 QString value = le->text();
55 model->setData(index, value, Qt::EditRole);