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

Method editorEvent

Modules/SegmentationUI/src/QmitkLabelToggleItemDelegate.cpp:55–82  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

53}
54
55bool QmitkLabelToggleItemDelegate::editorEvent(QEvent *event, QAbstractItemModel *model, const QStyleOptionViewItem &,
56 const QModelIndex &index)
57{
58 Q_ASSERT(event);
59 Q_ASSERT(model);
60
61 // make sure that the item is checkable
62 Qt::ItemFlags flags = model->flags(index);
63 if (!(flags & Qt::ItemIsEditable) || !(flags & Qt::ItemIsEnabled))
64 {
65 return false;
66 }
67
68 // make sure that we have the right event type
69 QMouseEvent* mouseEvent = dynamic_cast<QMouseEvent*>(event);
70 if (nullptr == mouseEvent || mouseEvent->type() != QEvent::MouseButtonRelease || mouseEvent->button() != Qt::LeftButton)
71 {
72 return false;
73 }
74
75 auto visVar = index.data(Qt::EditRole);
76 auto data = visVar.isValid()
77 ? QVariant(!(visVar.toBool()))
78 : QVariant(true);
79 return model->setData(index, data, Qt::EditRole);
80
81 return false;
82};

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