From d08782b720103628d2c3aaa10c34675621384fc6 Mon Sep 17 00:00:00 2001 From: David Sansome Date: Sun, 26 Dec 2010 18:07:57 +0000 Subject: [PATCH] Don't automatically expand items in tree views when clicking them if a modifier key is pressed as well. --- src/widgets/autoexpandingtreeview.cpp | 9 +++++++++ src/widgets/autoexpandingtreeview.h | 3 +++ 2 files changed, 12 insertions(+) diff --git a/src/widgets/autoexpandingtreeview.cpp b/src/widgets/autoexpandingtreeview.cpp index 0accb7c97..cf32f56fe 100644 --- a/src/widgets/autoexpandingtreeview.cpp +++ b/src/widgets/autoexpandingtreeview.cpp @@ -17,6 +17,7 @@ #include "autoexpandingtreeview.h" +#include #include const int AutoExpandingTreeView::kRowsToShow = 50; @@ -87,3 +88,11 @@ void AutoExpandingTreeView::ItemClicked(const QModelIndex& index) { void AutoExpandingTreeView::ItemDoubleClicked(const QModelIndex& index) { ignore_next_click_ = true; } + +void AutoExpandingTreeView::mousePressEvent(QMouseEvent* event) { + if (event->modifiers() != Qt::NoModifier) { + ignore_next_click_ = true; + } + + QTreeView::mousePressEvent(event); +} diff --git a/src/widgets/autoexpandingtreeview.h b/src/widgets/autoexpandingtreeview.h index d410d5ae0..1ae4757f5 100644 --- a/src/widgets/autoexpandingtreeview.h +++ b/src/widgets/autoexpandingtreeview.h @@ -38,6 +38,9 @@ class AutoExpandingTreeView : public QTreeView { // QAbstractItemView void reset(); + // QWidget + void mousePressEvent(QMouseEvent* event); + virtual bool CanRecursivelyExpand(const QModelIndex& index) const { return true; } private slots: