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);
}
}