Public Member Functions
TapeCoordinateDelegate Class Reference

Brief description of class still missing. More...

#include <TapeCoordinateDelegate.h>

List of all members.

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)

Detailed Description

Brief description of class still missing.

Full description of class still missing


Constructor & Destructor Documentation

Description of constructor still missing

References TRACE.

  : QItemDelegate(parent)
{
  TRACE;
}

Member Function Documentation

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;
    }
  }
}

The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines