| 73 | } |
| 74 | |
| 75 | bool ToolItemDelegate::editorEvent(QEvent *event, QAbstractItemModel *model, |
| 76 | const QStyleOptionViewItem &option, |
| 77 | const QModelIndex &index) |
| 78 | { |
| 79 | if (event->type() == QEvent::MouseButtonRelease || event->type() == QEvent::MouseButtonDblClick) { |
| 80 | QMouseEvent *mouseEvent = static_cast<QMouseEvent *>(event); |
| 81 | const QRect arRect = arrowRect(option.rect); |
| 82 | if (arRect.contains(mouseEvent->pos())) { |
| 83 | if (view()->isExpanded(index)) { |
| 84 | view()->collapse(index); |
| 85 | } else { |
| 86 | view()->expand(index); |
| 87 | } |
| 88 | return true; |
| 89 | } |
| 90 | } |
| 91 | |
| 92 | return false; |
| 93 | } |
| 94 | |
| 95 | QTreeView *ToolItemDelegate::view() const |
| 96 | { |