Brief description of class still missing. More...
#include <TapeCoordinateDelegate.h>
Public Member Functions | |
| QWidget * | createEditor (QWidget *parent, const QStyleOptionViewItem &, const QModelIndex &index) const |
| void | setEditorData (QWidget *editor, const QModelIndex &index) const |
| void | setModelData (QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const |
| TapeCoordinateDelegate (QObject *parent) | |
Brief description of class still missing.
Full description of class still missing
| TapeCoordinateDelegate::TapeCoordinateDelegate | ( | QObject * | parent | ) |
| QWidget * TapeCoordinateDelegate::createEditor | ( | QWidget * | parent, |
| const QStyleOptionViewItem & | , | ||
| const QModelIndex & | index | ||
| ) | const |
References QGpCoreTools::tr(), TRACE, and w.
{
TRACE;
switch (index.column()) {
case 3: {
QComboBox * w=new QComboBox(parent);
w->addItem(tr("Fixed"));
w->addItem(tr("North"));
w->addItem(tr("Eastward"));
w->addItem(tr("Free"));
return w;
}
default: {
QDoubleSpinBox * w=new QDoubleSpinBox(parent);
w->setMinimum(-1e99);
w->setMaximum(1e99);
w->setSuffix(" m");
w->setDecimals(3);
w->setSingleStep(0.01);
return w;
}
}
return 0;
}
| void TapeCoordinateDelegate::setEditorData | ( | QWidget * | editor, |
| const QModelIndex & | index | ||
| ) | const |
References TapePoint::Eastward, TapePoint::Fixed, TapePoint::Free, TapePoint::North, TRACE, TapePoint::type(), and w.
{
TRACE;
switch (index.column()) {
case 3: {
QComboBox * w=qobject_cast<QComboBox *>(editor);
ASSERT(w);
switch(TapePoint::type(index.model()->data(index).toString())) {
case TapePoint::Fixed:
w->setCurrentIndex(0);
break;
case TapePoint::North:
w->setCurrentIndex(1);
break;
case TapePoint::Eastward:
w->setCurrentIndex(2);
break;
case TapePoint::Free:
w->setCurrentIndex(3);
break;
}
break;
}
default: {
QDoubleSpinBox * w=qobject_cast<QDoubleSpinBox *>(editor);
ASSERT(w);
w->setValue(index.model()->data(index).toDouble());
break;
}
}
}
| void TapeCoordinateDelegate::setModelData | ( | QWidget * | editor, |
| QAbstractItemModel * | model, | ||
| const QModelIndex & | index | ||
| ) | const |
References TapePoint::Eastward, TapePoint::Fixed, TapePoint::Free, TapePoint::North, TRACE, TapePoint::typeString(), and w.
{
TRACE;
switch (index.column()) {
case 3: {
QComboBox * w=qobject_cast<QComboBox *>(editor);
ASSERT(w);
switch(w->currentIndex()) {
case 0:
model->setData(index, TapePoint::typeString(TapePoint::Fixed));
break;
case 1:
model->setData(index, TapePoint::typeString(TapePoint::North));
break;
case 2:
model->setData(index, TapePoint::typeString(TapePoint::Eastward));
break;
case 3:
model->setData(index, TapePoint::typeString(TapePoint::Free));
break;
default:
break;
}
break;
}
default: {
QDoubleSpinBox * w=qobject_cast<QDoubleSpinBox *>(editor);
ASSERT(w);
model->setData(index, w->value());
break;
}
}
}