MCPcopy Create free account
hub / github.com/Kitware/CMake / editorEvent

Method editorEvent

Source/QtDialog/QCMakeCacheView.cxx:607–647  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

605}
606
607bool QCMakeCacheModelDelegate::editorEvent(QEvent* e,
608 QAbstractItemModel* model,
609 QStyleOptionViewItem const& option,
610 QModelIndex const& index)
611{
612 Qt::ItemFlags flags = model->flags(index);
613 if (!(flags & Qt::ItemIsUserCheckable) ||
614 !(option.state & QStyle::State_Enabled) ||
615 !(flags & Qt::ItemIsEnabled)) {
616 return false;
617 }
618
619 QVariant value = index.data(Qt::CheckStateRole);
620 if (!value.isValid()) {
621 return false;
622 }
623
624 if ((e->type() == QEvent::MouseButtonRelease) ||
625 (e->type() == QEvent::MouseButtonDblClick)) {
626 // eat the double click events inside the check rect
627 if (e->type() == QEvent::MouseButtonDblClick) {
628 return true;
629 }
630 } else if (e->type() == QEvent::KeyPress) {
631 if (static_cast<QKeyEvent*>(e)->key() != Qt::Key_Space &&
632 static_cast<QKeyEvent*>(e)->key() != Qt::Key_Select) {
633 return false;
634 }
635 } else {
636 return false;
637 }
638
639 Qt::CheckState state =
640 (static_cast<Qt::CheckState>(value.toInt()) == Qt::Checked ? Qt::Unchecked
641 : Qt::Checked);
642 bool success = model->setData(index, state, Qt::CheckStateRole);
643 if (success) {
644 this->recordChange(model, index);
645 }
646 return success;
647}
648
649bool QCMakeCacheModelDelegate::eventFilter(QObject* object, QEvent* evt)
650{

Callers

nothing calls this directly

Calls 6

recordChangeMethod · 0.95
flagsMethod · 0.80
isValidMethod · 0.80
keyMethod · 0.80
dataMethod · 0.45
typeMethod · 0.45

Tested by

no test coverage detected