MCPcopy Create free account
hub / github.com/Codeya-IDE/deepin-ide / editorEvent

Method editorEvent

src/plugins/smartut/common/projectitemdelegate.cpp:66–101  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

64}
65
66bool ProjectItemDelegate::editorEvent(QEvent *event,
67 QAbstractItemModel *model,
68 const QStyleOptionViewItem &option,
69 const QModelIndex &index)
70{
71 if (event->type() == QEvent::MouseButtonRelease || event->type() == QEvent::MouseButtonDblClick) {
72 QStyleOptionViewItem opt = option;
73 opt.rect.adjust(10, 0, -10, 0);
74 QMouseEvent *mouseEvent = static_cast<QMouseEvent *>(event);
75
76 int depth = itemDepth(index);
77 if (index.model()->flags(index).testFlag(Qt::ItemIsUserCheckable)) {
78 const QRect checkRect = checkBoxRect(depth, opt.rect);
79 if (checkRect.contains(mouseEvent->pos())) {
80 Qt::CheckState state = static_cast<Qt::CheckState>(index.data(Qt::CheckStateRole).toInt());
81 Qt::CheckState newState = state == Qt::Checked ? Qt::Unchecked : Qt::Checked;
82
83 updateChildrenCheckState(model, index, newState);
84 updateParentCheckState(model, index);
85 return true;
86 }
87 }
88
89 const QRect arRect = arrowRect(depth, opt.rect);
90 if (arRect.contains(mouseEvent->pos())) {
91 if (view->isExpanded(index)) {
92 view->collapse(index);
93 } else {
94 view->expand(index);
95 }
96 return true;
97 }
98 }
99
100 return false;
101}
102
103bool ProjectItemDelegate::helpEvent(QHelpEvent *event,
104 QAbstractItemView *view,

Callers

nothing calls this directly

Calls 6

typeMethod · 0.45
flagsMethod · 0.45
modelMethod · 0.45
containsMethod · 0.45
dataMethod · 0.45
expandMethod · 0.45

Tested by

no test coverage detected