From: Peter Penz Date: Sun, 11 May 2008 19:34:34 +0000 (+0000) Subject: Per default QTreeView starts either a selection or a drag operation when dragging... X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/commitdiff_plain/2ad91b45342ddd49854ae2b31a9c6cada1ad1c4e?ds=sidebyside Per default QTreeView starts either a selection or a drag operation when dragging the expanding toggle button (tricky and hard to reproducible Qt-issue - see TODO comment in DolphinIconsView::mousePressEvent()). Turn off this behavior in Dolphin to stay predictable. svn path=/trunk/KDE/kdebase/apps/; revision=806597 --- diff --git a/src/dolphindetailsview.cpp b/src/dolphindetailsview.cpp index e33d94c18..e3a69fea4 100644 --- a/src/dolphindetailsview.cpp +++ b/src/dolphindetailsview.cpp @@ -46,6 +46,7 @@ DolphinDetailsView::DolphinDetailsView(QWidget* parent, DolphinController* controller) : QTreeView(parent), m_autoResize(true), + m_expandingTogglePressed(false), m_controller(controller), m_selectionManager(0), m_font(), @@ -187,6 +188,7 @@ void DolphinDetailsView::mousePressEvent(QMouseEvent* event) QTreeView::mousePressEvent(event); + m_expandingTogglePressed = false; const QModelIndex index = indexAt(event->pos()); const bool updateState = index.isValid() && (index.column() == DolphinModel::Name) && @@ -197,6 +199,8 @@ void DolphinDetailsView::mousePressEvent(QMouseEvent* event) const QRect rect = visualRect(index); if (event->pos().x() >= rect.x() + indentation()) { setState(QAbstractItemView::DraggingState); + } else { + m_expandingTogglePressed = true; } } @@ -207,7 +211,7 @@ void DolphinDetailsView::mousePressEvent(QMouseEvent* event) } } - if (event->button() == Qt::LeftButton) { + if ((event->button() == Qt::LeftButton) && !m_expandingTogglePressed) { m_showElasticBand = true; const QPoint pos(contentsPos()); @@ -248,11 +252,20 @@ void DolphinDetailsView::mouseMoveEvent(QMouseEvent* event) // QTreeView::mouseMoveEvent(event); QAbstractItemView::mouseMoveEvent(event); } + + if (m_expandingTogglePressed) { + // Per default QTreeView starts either a selection or a drag operation when dragging + // the expanding toggle button (Qt-issue - see TODO comment in DolphinIconsView::mousePressEvent()). + // Turn off this behavior in Dolphin to stay predictable: + clearSelection(); + setState(QAbstractItemView::NoState); + } } void DolphinDetailsView::mouseReleaseEvent(QMouseEvent* event) { QTreeView::mouseReleaseEvent(event); + m_expandingTogglePressed = false; if (m_showElasticBand) { updateElasticBand(); m_showElasticBand = false; diff --git a/src/dolphindetailsview.h b/src/dolphindetailsview.h index 829e53967..0acafddfc 100644 --- a/src/dolphindetailsview.h +++ b/src/dolphindetailsview.h @@ -157,6 +157,7 @@ private: private: bool m_autoResize; // if true, the columns are resized automatically to the available width + bool m_expandingTogglePressed; DolphinController* m_controller; SelectionManager* m_selectionManager;