X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/3a27f307993829fabfa34e89a8e794e8c5c4ebca..5ab90e19e78faebaca3bbffb83f3379ccdfc37f0:/src/dolphindetailsview.cpp diff --git a/src/dolphindetailsview.cpp b/src/dolphindetailsview.cpp index 08d03fb0b..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,7 +188,22 @@ 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) && + (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)) { const Qt::KeyboardModifiers modifier = QApplication::keyboardModifiers(); if (!(modifier & Qt::ShiftModifier) && !(modifier & Qt::ControlModifier)) { @@ -195,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()); @@ -236,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; @@ -250,6 +275,7 @@ void DolphinDetailsView::mouseReleaseEvent(QMouseEvent* event) void DolphinDetailsView::startDrag(Qt::DropActions supportedActions) { DragAndDropHelper::startDrag(this, supportedActions); + m_showElasticBand = false; } void DolphinDetailsView::dragEnterEvent(QDragEnterEvent* event)