Replace draggableForQObject with draggableForView

This commit is contained in:
Sergio Martins
2022-07-10 17:58:27 +01:00
parent 233736a20b
commit 897e0debca
2 changed files with 5 additions and 5 deletions

View File

@@ -809,7 +809,7 @@ bool DragController::onMouseEvent(View *w, QMouseEvent *me)
if (auto fw = w->asFloatingWindowController()) { if (auto fw = w->asFloatingWindowController()) {
if (KDDockWidgets::usesNativeTitleBar() || fw->isInDragArea(Qt5Qt6Compat::eventGlobalPos(me))) { if (KDDockWidgets::usesNativeTitleBar() || fw->isInDragArea(Qt5Qt6Compat::eventGlobalPos(me))) {
m_nonClientDrag = true; m_nonClientDrag = true;
return activeState()->handleMouseButtonPress(draggableForQObject(w->asQObject()), Qt5Qt6Compat::eventGlobalPos(me), me->pos()); return activeState()->handleMouseButtonPress(draggableForView(w), Qt5Qt6Compat::eventGlobalPos(me), me->pos());
} }
} }
return false; return false;
@@ -819,7 +819,7 @@ bool DragController::onMouseEvent(View *w, QMouseEvent *me)
// This also forbids dragging a FloatingWindow simply by pressing outside of the title area, in the background // This also forbids dragging a FloatingWindow simply by pressing outside of the title area, in the background
if (!KDDockWidgets::usesNativeDraggingAndResizing() || !w->isRootView()) { if (!KDDockWidgets::usesNativeDraggingAndResizing() || !w->isRootView()) {
Q_ASSERT(activeState()); Q_ASSERT(activeState());
return activeState()->handleMouseButtonPress(draggableForQObject(w->asQObject()), Qt5Qt6Compat::eventGlobalPos(me), me->pos()); return activeState()->handleMouseButtonPress(draggableForView(w), Qt5Qt6Compat::eventGlobalPos(me), me->pos());
} else } else
break; break;
case QEvent::MouseButtonRelease: case QEvent::MouseButtonRelease:
@@ -1033,10 +1033,10 @@ DropArea *DragController::dropAreaUnderCursor() const
return nullptr; return nullptr;
} }
Draggable *DragController::draggableForQObject(QObject *o) const Draggable *DragController::draggableForView(View *view) const
{ {
for (auto draggable : m_draggables) for (auto draggable : m_draggables)
if (draggable->asView()->asQObject() == o) { if (draggable->asView()->equals(view)) {
return draggable; return draggable;
} }

View File

@@ -128,7 +128,7 @@ private:
DragController(QObject * = nullptr); DragController(QObject * = nullptr);
StateBase *activeState() const; StateBase *activeState() const;
std::shared_ptr<View> qtTopLevelUnderCursor() const; std::shared_ptr<View> qtTopLevelUnderCursor() const;
Draggable *draggableForQObject(QObject *o) const; Draggable *draggableForView(View *) const;
bool onDnDEvent(View *, QEvent *) override; bool onDnDEvent(View *, QEvent *) override;
bool onMoveEvent(View *) override; bool onMoveEvent(View *) override;
bool onMouseEvent(View *, QMouseEvent *) override; bool onMouseEvent(View *, QMouseEvent *) override;