All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines
Brief description of class still missing. More...
#include <LineDelegate.h>
Signals | |
| void | dataChanged () const |
Public Member Functions | |
| QWidget * | createEditor (QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const |
| LineDelegate (QObject *parent=0) | |
| void | setEditorData (QWidget *editor, const QModelIndex &index) const |
| void | setModelData (QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const |
Brief description of class still missing.
Full description of class still missing
| SciFigs::LineDelegate::LineDelegate | ( | QObject * | parent = 0 | ) | [inline] |
: QItemDelegate(parent) {}
| QWidget * SciFigs::LineDelegate::createEditor | ( | QWidget * | parent, |
| const QStyleOptionViewItem & | option, | ||
| const QModelIndex & | index | ||
| ) | const |
{
TRACE;
const LineItem * item=qobject_cast<const LineItem *>(index.model());
ASSERT(item);
switch (index.column()) {
case 0: {
return QItemDelegate::createEditor(parent, option, index);
}
default: {
QLineEdit * w=new QLineEdit(parent);
w->setAlignment(Qt::AlignRight);
return w;
}
}
}
| void SciFigs::LineDelegate::dataChanged | ( | ) | const [signal] |
Referenced by setModelData().
| void SciFigs::LineDelegate::setEditorData | ( | QWidget * | editor, |
| const QModelIndex & | index | ||
| ) | const |
{
TRACE;
const LineItem * item=qobject_cast<const LineItem *>(index.model());
ASSERT(item);
switch (index.column()) {
case 0:
QItemDelegate::setEditorData(editor, index);
break;
default: {
QLineEdit * w= qobject_cast<QLineEdit *>(editor);
if (!w) return;
w->setText(index.model()->data(index).toString());
w->selectAll();
}
break;
}
}
| void SciFigs::LineDelegate::setModelData | ( | QWidget * | editor, |
| QAbstractItemModel * | model, | ||
| const QModelIndex & | index | ||
| ) | const |
References dataChanged(), TRACE, and w.
{
TRACE;
const LineItem * item=qobject_cast<const LineItem *>(index.model());
ASSERT(item);
switch(index.column()) {
case 0:
QItemDelegate::setModelData(editor, model, index);
emit dataChanged();
break;
default: {
QLineEdit * w=qobject_cast<QLineEdit *>(editor);
if(!w) return;
if(w->isModified() && model->data(index)!=w->text()) {
model->setData(index, w->text());
emit dataChanged();
}
}
break;
}
}