COPASI API  4.16.103
Public Member Functions | List of all members
CQSpinBoxDelegate Class Reference

#include <CQSpinBoxDelegate.h>

Inheritance diagram for CQSpinBoxDelegate:
Inheritance graph
[legend]
Collaboration diagram for CQSpinBoxDelegate:
Collaboration graph
[legend]

Public Member Functions

 CQSpinBoxDelegate (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
 

Detailed Description

Definition at line 16 of file CQSpinBoxDelegate.h.

Constructor & Destructor Documentation

CQSpinBoxDelegate::CQSpinBoxDelegate ( QObject *  parent = 0)

Definition at line 18 of file CQSpinBoxDelegate.cpp.

19  : QItemDelegate(parent)
20 {}

Member Function Documentation

QWidget * CQSpinBoxDelegate::createEditor ( QWidget *  parent,
const QStyleOptionViewItem &  option,
const QModelIndex &  index 
) const

Definition at line 22 of file CQSpinBoxDelegate.cpp.

References C_INT32, CQBaseDataModel::isDefaultRow(), and max.

25 {
26  QSpinBox *editor = new QSpinBox(parent);
27  editor->setMinimum(1);
28  unsigned C_INT32 max = 1;
29 
30  const QSortFilterProxyModel *pProxyDM = dynamic_cast<const QSortFilterProxyModel *>(index.model());
31  QModelIndex BDMIndex;
32  const CQBaseDataModel *pBDM;
33 
34  if (pProxyDM)
35  {
36  pBDM = dynamic_cast<const CQBaseDataModel *>(pProxyDM->sourceModel());
37  BDMIndex = pProxyDM->mapToSource(index);
38  }
39  else
40  {
41  pBDM = dynamic_cast<const CQBaseDataModel *>(index.model());
42  BDMIndex = index;
43  }
44 
45  if (pBDM)
46  {
47  if (pBDM->isDefaultRow(BDMIndex))
48  max = pBDM->rowCount();
49  else
50  max = pBDM->rowCount() - 1;
51  }
52 
53  editor->setMaximum(max);
54  return editor;
55 }
#define C_INT32
Definition: copasi.h:90
virtual bool isDefaultRow(const QModelIndex &i) const
#define max(a, b)
Definition: f2c.h:176
void CQSpinBoxDelegate::setEditorData ( QWidget *  editor,
const QModelIndex &  index 
) const

Definition at line 57 of file CQSpinBoxDelegate.cpp.

References C_INT32.

59 {
60  QSpinBox *pSpinBox = static_cast<QSpinBox*>(editor);
61  unsigned C_INT32 value = index.model()->data(index, Qt::EditRole).toUInt();
62  pSpinBox->setValue(value);
63 }
#define C_INT32
Definition: copasi.h:90
void CQSpinBoxDelegate::setModelData ( QWidget *  editor,
QAbstractItemModel *  model,
const QModelIndex &  index 
) const

Definition at line 65 of file CQSpinBoxDelegate.cpp.

67 {
68  QSpinBox *pSpinBox = static_cast<QSpinBox*>(editor);
69  pSpinBox->interpretText();
70  unsigned int value = pSpinBox->value();
71 
72  model->setData(index, value, Qt::EditRole);
73 }
void CQSpinBoxDelegate::updateEditorGeometry ( QWidget *  editor,
const QStyleOptionViewItem &  option,
const QModelIndex &  index 
) const

Definition at line 75 of file CQSpinBoxDelegate.cpp.

77 {
78  editor->setGeometry(option.rect);
79 }

The documentation for this class was generated from the following files: