X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/e65154552769e648bcbe14429123ff9fcd48bd29..e4170c1910ad91fd31bc64edfab17ddc814411d5:/src/dolphindetailsview.cpp diff --git a/src/dolphindetailsview.cpp b/src/dolphindetailsview.cpp index 68b288b0b..886f3f9a6 100644 --- a/src/dolphindetailsview.cpp +++ b/src/dolphindetailsview.cpp @@ -199,9 +199,27 @@ void DolphinDetailsView::mousePressEvent(QMouseEvent* event) void DolphinDetailsView::mouseMoveEvent(QMouseEvent* event) { - QTreeView::mouseMoveEvent(event); if (m_showElasticBand) { + const QPoint mousePos = event->pos(); + const QModelIndex index = indexAt(mousePos); + if (!index.isValid()) { + // the destination of the selection rectangle is above the viewport. In this + // case QTreeView does no selection at all, which is not the wanted behavior + // in Dolphin -> select all items within the elastic band rectangle + clearSelection(); + + const int nameColumnWidth = header()->sectionSize(DolphinModel::Name); + QRect selRect = QRect(m_elasticBandOrigin, m_elasticBandDestination).normalized(); + const QRect nameColumnsRect(0, 0, nameColumnWidth, viewport()->height()); + selRect = nameColumnsRect.intersected(selRect); + + setSelection(selRect, QItemSelectionModel::Select); + } + + QTreeView::mouseMoveEvent(event); updateElasticBand(); + } else { + QTreeView::mouseMoveEvent(event); } } @@ -260,6 +278,11 @@ void DolphinDetailsView::dragMoveEvent(QDragMoveEvent* event) } setDirtyRegion(m_dropRect); } + + if (event->mimeData()->hasUrls()) { + // accept url drops, independently from the destination item + event->acceptProposedAction(); + } } void DolphinDetailsView::dropEvent(QDropEvent* event) @@ -302,7 +325,7 @@ void DolphinDetailsView::paintEvent(QPaintEvent* event) // TODO: remove this code when the issue #160611 is solved in Qt 4.4 if (m_dragging) { const QBrush& brush = viewOptions().palette.brush(QPalette::Normal, QPalette::Highlight); - DragAndDropHelper::drawHoverIndication(viewport(), m_dropRect, brush); + DragAndDropHelper::drawHoverIndication(this, m_dropRect, brush); } } @@ -384,11 +407,12 @@ void DolphinDetailsView::slotEntered(const QModelIndex& index) void DolphinDetailsView::updateElasticBand() { - Q_ASSERT(m_showElasticBand); - QRect dirtyRegion(elasticBandRect()); - m_elasticBandDestination = viewport()->mapFromGlobal(QCursor::pos()); - dirtyRegion = dirtyRegion.united(elasticBandRect()); - setDirtyRegion(dirtyRegion); + if (m_showElasticBand) { + QRect dirtyRegion(elasticBandRect()); + m_elasticBandDestination = viewport()->mapFromGlobal(QCursor::pos()); + dirtyRegion = dirtyRegion.united(elasticBandRect()); + setDirtyRegion(dirtyRegion); + } } QRect DolphinDetailsView::elasticBandRect() const