| 395 | } |
| 396 | |
| 397 | void InstanceView::mouseReleaseEvent(QMouseEvent *event) |
| 398 | { |
| 399 | executeDelayedItemsLayout(); |
| 400 | |
| 401 | QPoint visualPos = event->pos(); |
| 402 | QPoint geometryPos = event->pos() + offset(); |
| 403 | QPersistentModelIndex index = indexAt(visualPos); |
| 404 | |
| 405 | VisualGroup::HitResults hitresult; |
| 406 | |
| 407 | bool click = (index == m_pressedIndex && index.isValid()) || |
| 408 | (m_pressedCategory && m_pressedCategory == categoryAt(geometryPos, hitresult)); |
| 409 | |
| 410 | if (click && m_pressedCategory) |
| 411 | { |
| 412 | if (state() == ExpandingState) |
| 413 | { |
| 414 | m_pressedCategory->collapsed = false; |
| 415 | emit groupStateChanged(m_pressedCategory->text, false); |
| 416 | |
| 417 | updateGeometries(); |
| 418 | viewport()->update(); |
| 419 | event->accept(); |
| 420 | m_pressedCategory = nullptr; |
| 421 | setState(NoState); |
| 422 | return; |
| 423 | } |
| 424 | else if (state() == CollapsingState) |
| 425 | { |
| 426 | m_pressedCategory->collapsed = true; |
| 427 | emit groupStateChanged(m_pressedCategory->text, true); |
| 428 | |
| 429 | updateGeometries(); |
| 430 | viewport()->update(); |
| 431 | event->accept(); |
| 432 | m_pressedCategory = nullptr; |
| 433 | setState(NoState); |
| 434 | return; |
| 435 | } |
| 436 | } |
| 437 | |
| 438 | m_ctrlDragSelectionFlag = QItemSelectionModel::NoUpdate; |
| 439 | |
| 440 | setState(NoState); |
| 441 | |
| 442 | if (click) |
| 443 | { |
| 444 | if (event->button() == Qt::LeftButton) |
| 445 | { |
| 446 | emit clicked(index); |
| 447 | } |
| 448 | #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) |
| 449 | QStyleOptionViewItem option; |
| 450 | initViewItemOption(&option); |
| 451 | #else |
| 452 | QStyleOptionViewItem option = viewOptions(); |
| 453 | #endif |
| 454 | if (m_pressedAlreadySelected) |