Merge pull request #1821 from TheKodeToad/group-click-fix

Only open/close groups on left button
This commit is contained in:
Tayou 2023-11-09 19:18:12 +01:00 committed by GitHub
commit 913d81e371
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -278,12 +278,14 @@ void InstanceView::mousePressEvent(QMouseEvent* event)
m_pressedAlreadySelected = selectionModel()->isSelected(m_pressedIndex); m_pressedAlreadySelected = selectionModel()->isSelected(m_pressedIndex);
m_pressedPosition = geometryPos; m_pressedPosition = geometryPos;
VisualGroup::HitResults hitResult; if (event->button() == Qt::LeftButton) {
m_pressedCategory = categoryAt(geometryPos, hitResult); VisualGroup::HitResults hitResult;
if (m_pressedCategory && hitResult & VisualGroup::CheckboxHit) { m_pressedCategory = categoryAt(geometryPos, hitResult);
setState(m_pressedCategory->collapsed ? ExpandingState : CollapsingState); if (m_pressedCategory && hitResult & VisualGroup::CheckboxHit) {
event->accept(); setState(m_pressedCategory->collapsed ? ExpandingState : CollapsingState);
return; event->accept();
return;
}
} }
if (index.isValid() && (index.flags() & Qt::ItemIsEnabled)) { if (index.isValid() && (index.flags() & Qt::ItemIsEnabled)) {
@ -366,10 +368,7 @@ void InstanceView::mouseReleaseEvent(QMouseEvent* event)
VisualGroup::HitResults hitResult; VisualGroup::HitResults hitResult;
bool click = if (event->button() == Qt::LeftButton && m_pressedCategory != nullptr && m_pressedCategory == categoryAt(geometryPos, hitResult)) {
(index == m_pressedIndex && index.isValid()) || (m_pressedCategory && m_pressedCategory == categoryAt(geometryPos, hitResult));
if (click && m_pressedCategory) {
if (state() == ExpandingState) { if (state() == ExpandingState) {
m_pressedCategory->collapsed = false; m_pressedCategory->collapsed = false;
emit groupStateChanged(m_pressedCategory->text, false); emit groupStateChanged(m_pressedCategory->text, false);
@ -397,7 +396,7 @@ void InstanceView::mouseReleaseEvent(QMouseEvent* event)
setState(NoState); setState(NoState);
if (click) { if (index == m_pressedIndex && index.isValid()) {
if (event->button() == Qt::LeftButton) { if (event->button() == Qt::LeftButton) {
emit clicked(index); emit clicked(index);
} }