Delegate used by ProjectTreeView. More...
#include <treeview.h>
Public Member Functions | |
TreeViewDelegate (QObject *parent=0) | |
QWidget * | createEditor (QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const |
void | setEditorData (QWidget *editor, const QModelIndex &index) const |
void | setModelData (QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const |
void | updateEditorGeometry (QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &index) const |
Delegate used by ProjectTreeView.
This is mainly used to show a QTextEdit when one doubleclicks a description of a sensor or sensor channel.
TreeViewDelegate::TreeViewDelegate | ( | QObject * | parent = 0 |
) |
: QStyledItemDelegate(parent){};
QWidget * TreeViewDelegate::createEditor | ( | QWidget * | parent, | |
const QStyleOptionViewItem & | option, | |||
const QModelIndex & | index | |||
) | const |
{ if (index.column() == 2) { QTextEdit *textEdit = new QTextEdit(parent); return textEdit; } else { return QStyledItemDelegate::createEditor(parent, option, index); } }
void TreeViewDelegate::setEditorData | ( | QWidget * | editor, | |
const QModelIndex & | index | |||
) | const |
{ // Workaround omdat userProperty() van QTextEdit HTML is en niet plainText, // en er geen manier bestaat blijkbaar om die dynamisch aan te passen if (QTextEdit *textEdit = dynamic_cast<QTextEdit*>(editor)) { Q_ASSERT(index.column() == 2); textEdit->setPlainText(index.data(Qt::EditRole).toString()); } else { QStyledItemDelegate::setEditorData(editor, index); } }
void TreeViewDelegate::setModelData | ( | QWidget * | editor, | |
QAbstractItemModel * | model, | |||
const QModelIndex & | index | |||
) | const |
{ // Workaround omdat userProperty() van QTextEdit HTML is en niet plainText, // en er geen manier bestaat blijkbaar om die dynamisch aan te passen if (QTextEdit *textEdit = dynamic_cast<QTextEdit*>(editor)) { Q_ASSERT(index.column() == 2); model->setData(index, textEdit->toPlainText(), Qt::EditRole); } else { QStyledItemDelegate::setModelData(editor, model, index); } }
void TreeViewDelegate::updateEditorGeometry | ( | QWidget * | editor, | |
const QStyleOptionViewItem & | option, | |||
const QModelIndex & | index | |||
) | const |