Don't automatically expand items in tree views when clicking them if a modifier key is pressed as well.

This commit is contained in:
David Sansome 2010-12-26 18:07:57 +00:00
parent 35242f740e
commit d08782b720
2 changed files with 12 additions and 0 deletions

View File

@ -17,6 +17,7 @@
#include "autoexpandingtreeview.h"
#include <QMouseEvent>
#include <QtDebug>
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);
}

View File

@ -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: