mirror of
https://invent.kde.org/system/dolphin
synced 2024-08-22 01:40:02 +00:00
Don't consider drops on a row as drops on the row's item
Since d383961719
in details view mode
clicking anywhere within the row is considered a click on the item.
That commit also changed it so that dropping files anywhere inside
a row would make it so the files are received by the folder of that
row.
This commit reverts the drop behaviour to be identical to the old
one.
I am having trouble explaining why this is better because one can
look at it in different ways. Bottom line is that one doesn't
really feel like one is dropping files inside a folder unless the
mouse cursor is actually directly above a folder's icon or name.
Another argument is that it is normal behaviour to just throw files
onto an application and the files then being opened by it.
Having potentially large parts of the view area covered by the rows
of folders means that there has to be more of a conscious effort to
not drop the files inside one of the folders by accident while with
this commit one has to aim precisely onto a folder to do it
intentionally.
CCBUG: 453700
This commit is contained in:
parent
ebe3a111e6
commit
5ebf2065d5
|
@ -724,7 +724,7 @@ bool KItemListController::dragMoveEvent(QGraphicsSceneDragDropEvent* event, cons
|
|||
KItemListWidget* oldHoveredWidget = hoveredWidget();
|
||||
|
||||
const QPointF pos = transform.map(event->pos());
|
||||
KItemListWidget* newHoveredWidget = widgetForPos(pos);
|
||||
KItemListWidget* newHoveredWidget = widgetForDropPos(pos);
|
||||
|
||||
if (oldHoveredWidget != newHoveredWidget) {
|
||||
m_autoActivationTimer->stop();
|
||||
|
@ -806,7 +806,12 @@ bool KItemListController::dropEvent(QGraphicsSceneDragDropEvent* event, const QT
|
|||
Q_EMIT aboveItemDropEvent(dropAboveIndex, event);
|
||||
} else if (!event->mimeData()->hasFormat(m_model->blacklistItemDropEventMimeType())) {
|
||||
// Something has been dropped on an item or on an empty part of the view.
|
||||
Q_EMIT itemDropEvent(m_view->itemAt(pos).value_or(-1), event);
|
||||
const KItemListWidget *receivingWidget = widgetForDropPos(pos);
|
||||
if (receivingWidget) {
|
||||
Q_EMIT itemDropEvent(receivingWidget->index(), event);
|
||||
} else {
|
||||
Q_EMIT itemDropEvent(-1, event);
|
||||
}
|
||||
}
|
||||
|
||||
QAccessibleEvent accessibilityEvent(view(), QAccessible::DragDropEnd);
|
||||
|
@ -1364,6 +1369,21 @@ KItemListWidget* KItemListController::widgetForPos(const QPointF& pos) const
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
KItemListWidget* KItemListController::widgetForDropPos(const QPointF& pos) const
|
||||
{
|
||||
Q_ASSERT(m_view);
|
||||
|
||||
const auto widgets = m_view->visibleItemListWidgets();
|
||||
for (KItemListWidget* widget : widgets) {
|
||||
const QPointF mappedPos = widget->mapFromItem(m_view, pos);
|
||||
if (widget->contains(mappedPos)) {
|
||||
return widget;
|
||||
}
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void KItemListController::updateKeyboardAnchor()
|
||||
{
|
||||
const bool validAnchor = m_keyboardAnchorIndex >= 0 &&
|
||||
|
|
|
@ -253,6 +253,15 @@ private:
|
|||
*/
|
||||
KItemListWidget* widgetForPos(const QPointF& pos) const;
|
||||
|
||||
/**
|
||||
* @return Widget that should receive a drop event if an item is dropped at \a pos. 0 is returned
|
||||
* if no widget should receive a drop event at the position.
|
||||
*
|
||||
* While widgetForPos() returns a widget if \a pos is anywhere inside the hover highlight area of the widget,
|
||||
* widgetForDropPos() only returns a widget if \a pos is directly above the widget (widget->contains(pos) == true).
|
||||
*/
|
||||
KItemListWidget* widgetForDropPos(const QPointF& pos) const;
|
||||
|
||||
/**
|
||||
* Updates m_keyboardAnchorIndex and m_keyboardAnchorPos. If no anchor is
|
||||
* set, it will be adjusted to the current item. If it is set it will be
|
||||
|
|
Loading…
Reference in a new issue