@@ -679,6 +679,23 @@ void DockContainerWidgetPrivate::moveToContainer(QWidget* Widget, DockWidgetArea
679679 }
680680 else
681681 {
682+ // We check, if we insert the dropped widget into the same place that
683+ // it already has and do nothing, if it is the same place. It would
684+ // also work without this check, but it looks nicer with the check
685+ // because there will be no layout updates
686+ auto Splitter = internal::findParent<CDockSplitter*>(DroppedDockArea);
687+ auto InsertParam = internal::dockAreaInsertParameters (area);
688+ if (Splitter == RootSplitter && InsertParam.orientation () == Splitter->orientation ())
689+ {
690+ if (InsertParam.append () && Splitter->lastWidget () == DroppedDockArea)
691+ {
692+ return ;
693+ }
694+ else if (!InsertParam.append () && Splitter->firstWidget () == DroppedDockArea)
695+ {
696+ return ;
697+ }
698+ }
682699 DroppedDockArea->dockContainer ()->removeDockArea (DroppedDockArea);
683700 NewDockArea = DroppedDockArea;
684701 }
@@ -1435,42 +1452,38 @@ void CDockContainerWidget::dropFloatingWidget(CFloatingDockContainer* FloatingWi
14351452}
14361453
14371454
1438- // ============================================================================
1439- void CDockContainerWidget::dropWidget (QWidget* Widget, const QPoint& TargetPos)
1455+ /* *
1456+ * Returns the dock area for a dropped widget.
1457+ */
1458+ CDockAreaWidget* droppedDockArea (QWidget* Widget)
14401459{
1441- ADS_PRINT (" CDockContainerWidget::dropFloatingWidget" );
1442- CDockWidget* SingleDockWidget = topLevelDockWidget ();
1443- CDockAreaWidget* DockArea = dockAreaAt (TargetPos);
1444- auto dropArea = InvalidDockWidgetArea;
1445- auto ContainerDropArea = d->DockManager ->containerOverlay ()->dropAreaUnderCursor ();
1446-
1447- if (DockArea)
1460+ auto DroppedArea = qobject_cast<CDockAreaWidget*>(Widget);
1461+ if (!DroppedArea)
14481462 {
1449- auto dropOverlay = d->DockManager ->dockAreaOverlay ();
1450- dropOverlay->setAllowedAreas (DockArea->allowedAreas ());
1451- dropArea = dropOverlay->showOverlay (DockArea);
1452- if (ContainerDropArea != InvalidDockWidgetArea &&
1453- ContainerDropArea != dropArea)
1454- {
1455- dropArea = InvalidDockWidgetArea;
1456- }
1463+ auto DroppedWidget = qobject_cast<CDockWidget*>(Widget);
1464+ DroppedArea = DroppedWidget->dockAreaWidget ();
1465+ }
14571466
1458- if (dropArea != InvalidDockWidgetArea)
1459- {
1460- ADS_PRINT (" Dock Area Drop Content: " << dropArea);
1461- d->moveToNewSection (Widget, DockArea, dropArea);
1462- }
1467+ return DroppedArea;
1468+ }
1469+
1470+
1471+ // ============================================================================
1472+ void CDockContainerWidget::dropWidget (QWidget* Widget, DockWidgetArea DropArea, CDockAreaWidget* TargetAreaWidget)
1473+ {
1474+ if (TargetAreaWidget && TargetAreaWidget == droppedDockArea (Widget))
1475+ {
1476+ return ;
14631477 }
14641478
1465- // mouse is over container
1466- if (InvalidDockWidgetArea == dropArea )
1479+ CDockWidget* SingleDockWidget = topLevelDockWidget ();
1480+ if (TargetAreaWidget )
14671481 {
1468- dropArea = ContainerDropArea;
1469- ADS_PRINT (" Container Drop Content: " << dropArea);
1470- if (dropArea != InvalidDockWidgetArea)
1471- {
1472- d->moveToContainer (Widget, dropArea);
1473- }
1482+ d->moveToNewSection (Widget, TargetAreaWidget, DropArea);
1483+ }
1484+ else
1485+ {
1486+ d->moveToContainer (Widget, DropArea);
14741487 }
14751488
14761489 // If there was a top level widget before the drop, then it is not top
0 commit comments