X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/03aa2029d7c65071d054444c375e2ddb89ea6f12..5ab90e19e78faebaca3bbffb83f3379ccdfc37f0:/src/dolphindetailsview.cpp diff --git a/src/dolphindetailsview.cpp b/src/dolphindetailsview.cpp index 29ee90830..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,10 +188,20 @@ void DolphinDetailsView::mousePressEvent(QMouseEvent* event) QTreeView::mousePressEvent(event); + m_expandingTogglePressed = false; const QModelIndex index = indexAt(event->pos()); - if (index.isValid() && (event->button() == Qt::LeftButton)) { - // TODO: see comment in DolphinIconsView::mousePressEvent() - setState(QAbstractItemView::DraggingState); + const bool updateState = index.isValid() && + (index.column() == DolphinModel::Name) && + (event->button() == Qt::LeftButton); + if (updateState) { + // TODO: See comment in DolphinIconsView::mousePressEvent(). Only update + // the state if no expanding/collapsing area has been hit: + const QRect rect = visualRect(index); + if (event->pos().x() >= rect.x() + indentation()) { + setState(QAbstractItemView::DraggingState); + } else { + m_expandingTogglePressed = true; + } } if (!index.isValid() || (index.column() != DolphinModel::Name)) { @@ -200,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()); @@ -241,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;