QXRD  0.11.16
Public Member Functions | Private Slots | List of all members
QxrdROITypeDelegate Class Reference

#include <qxrdroitypedelegate.h>

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

Public Member Functions

 QxrdROITypeDelegate (QWidget *parent=0)
 
QWidget * createEditor (QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const Q_DECL_OVERRIDE
 
void setEditorData (QWidget *editor, const QModelIndex &index) const Q_DECL_OVERRIDE
 
void setModelData (QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const Q_DECL_OVERRIDE
 

Private Slots

void typeChanged (int newType)
 

Detailed Description

Definition at line 6 of file qxrdroitypedelegate.h.

Constructor & Destructor Documentation

QxrdROITypeDelegate::QxrdROITypeDelegate ( QWidget *  parent = 0)

Definition at line 7 of file qxrdroitypedelegate.cpp.

8  : QStyledItemDelegate(parent)
9 {
10 
11 }

Member Function Documentation

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

Definition at line 13 of file qxrdroitypedelegate.cpp.

References QxrdROICoordinates::roiTypeCount(), QxrdROICoordinates::roiTypeName, and QxrdROICoordinatesListModel::TypeCol.

15 {
16  if (index.column() == QxrdROICoordinatesListModel::TypeCol) {
17  QComboBox *editor = new QComboBox(parent);
18 
19  for (int i=0; i<QxrdROICoordinates::roiTypeCount(); i++) {
20  QString name = QxrdROICoordinates::roiTypeName(i);
21  editor->addItem(name);
22  }
23 
24  return editor;
25  } else {
26  return QStyledItemDelegate::createEditor(parent, option, index);
27  }
28 }

Here is the call graph for this function:

void QxrdROITypeDelegate::setEditorData ( QWidget *  editor,
const QModelIndex &  index 
) const

Definition at line 30 of file qxrdroitypedelegate.cpp.

References typeChanged(), and QxrdROICoordinatesListModel::TypeCol.

31 {
32  if (index.column() == QxrdROICoordinatesListModel::TypeCol) {
33  QComboBox *cb = qobject_cast<QComboBox*>(editor);
34 
35  if (cb) {
36  QString roiTypeName = index.data().toString();
37 
38  int cbindex = cb->findText(roiTypeName);
39 
40  if (cbindex >= 0) {
41  cb->setCurrentIndex(cbindex);
42  }
43 
44  connect(cb, (void (QComboBox::*)(int)) &QComboBox::currentIndexChanged,
46  }
47  } else {
48  QStyledItemDelegate::setEditorData(editor, index);
49  }
50 }
void typeChanged(int newType)

Here is the call graph for this function:

void QxrdROITypeDelegate::setModelData ( QWidget *  editor,
QAbstractItemModel *  model,
const QModelIndex &  index 
) const

Definition at line 52 of file qxrdroitypedelegate.cpp.

References QxrdROICoordinatesListModel::TypeCol.

54 {
55  if (index.column() == QxrdROICoordinatesListModel::TypeCol) {
56  QComboBox *cb = qobject_cast<QComboBox*>(editor);
57 
58  if (cb) {
59  QString roiType = cb->currentText();
60 
61  model->setData(index, roiType, Qt::EditRole);
62  }
63  } else {
64  QStyledItemDelegate::setModelData(editor, model, index);
65  }
66 }
void QxrdROITypeDelegate::typeChanged ( int  newType)
privateslot

Definition at line 68 of file qxrdroitypedelegate.cpp.

Referenced by setEditorData().

69 {
70  QComboBox *cb = qobject_cast<QComboBox*>(sender());
71 
72  if (cb) {
73  emit commitData(cb);
74  emit closeEditor(cb);
75  }
76 }

Here is the caller graph for this function:


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