MCPcopy Create free account
hub / github.com/MITK/MITK / editorEvent

Method editorEvent

Modules/RTUI/src/QmitkDoseVisualStyleDelegate.cpp:60–90  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

58}
59
60bool QmitkDoseVisualStyleDelegate::editorEvent(QEvent *event, QAbstractItemModel *model, const QStyleOptionViewItem &,
61 const QModelIndex &index)
62{
63 Q_ASSERT(event);
64 Q_ASSERT(model);
65
66 // make sure that the item is checkable
67 Qt::ItemFlags flags = model->flags(index);
68 if (!(flags & Qt::ItemIsEditable) || !(flags & Qt::ItemIsEnabled))
69 {
70 return false;
71 }
72
73 // make sure that we have the right event type
74 QMouseEvent* mouseEvent = dynamic_cast<QMouseEvent*>(event);
75 if (!mouseEvent)
76 {
77 return false;
78 }
79 else
80 {
81 if (mouseEvent->type() != QEvent::MouseButtonRelease || mouseEvent->button() != Qt::LeftButton)
82 {
83 return false;
84 }
85 }
86
87 bool newState = !(index.data(Qt::EditRole).toBool());
88
89 return model->setData(index, QVariant(newState), Qt::EditRole);
90};

Callers

nothing calls this directly

Calls 4

typeMethod · 0.80
flagsMethod · 0.45
dataMethod · 0.45
setDataMethod · 0.45

Tested by

no test coverage detected