Added support for inserting a dock widget with a given tab index and added test case

This commit is contained in:
Uwe Kindler 2022-11-14 15:10:33 +01:00
parent 3b8775fd86
commit e4a71982d9
4 changed files with 36 additions and 40 deletions

View File

@ -790,28 +790,38 @@ void CMainWindow::createEditor()
FloatingWidget->move(QPoint(20, 20));
d->LastCreatedFloatingEditor = DockWidget;
d->LastDockedEditor.clear();
return;
}
else
{
ads::CDockAreaWidget* EditorArea = d->LastDockedEditor ? d->LastDockedEditor->dockAreaWidget() : nullptr;
if (EditorArea)
{
d->DockManager->setConfigFlag(ads::CDockManager::EqualSplitOnInsertion, true);
d->DockManager->addDockWidget(ads::RightDockWidgetArea, DockWidget, EditorArea);
}
else
{
if (d->LastCreatedFloatingEditor)
{
d->DockManager->addDockWidget(ads::RightDockWidgetArea, DockWidget, d->LastCreatedFloatingEditor->dockAreaWidget());
}
else
{
d->DockManager->addDockWidget(ads::TopDockWidgetArea, DockWidget);
}
}
d->LastDockedEditor = DockWidget;
}
ads::CDockAreaWidget* EditorArea = d->LastDockedEditor ? d->LastDockedEditor->dockAreaWidget() : nullptr;
if (EditorArea)
{
if (Tabbed)
{
// Test inserting the dock widget tab at a given position instead
// of appending it. This function inserts the new dock widget as
// first tab
d->DockManager->addDockWidgetTabToArea(DockWidget, EditorArea, 0);
}
else
{
d->DockManager->setConfigFlag(ads::CDockManager::EqualSplitOnInsertion, true);
d->DockManager->addDockWidget(ads::RightDockWidgetArea, DockWidget, EditorArea);
}
}
else
{
if (d->LastCreatedFloatingEditor)
{
d->DockManager->addDockWidget(ads::RightDockWidgetArea, DockWidget, d->LastCreatedFloatingEditor->dockAreaWidget());
}
else
{
d->DockManager->addDockWidget(ads::TopDockWidgetArea, DockWidget);
}
}
d->LastDockedEditor = DockWidget;
}

View File

@ -1232,13 +1232,13 @@ CDockAreaWidget* DockContainerWidgetPrivate::addDockWidgetToDockArea(DockWidgetA
{
if (CenterDockWidgetArea == area)
{
TargetDockArea->addDockWidget(Dockwidget);
TargetDockArea->insertDockWidget(Index, Dockwidget);
TargetDockArea->updateTitleBarVisibility();
return TargetDockArea;
}
CDockAreaWidget* NewDockArea = new CDockAreaWidget(DockManager, _this);
NewDockArea->insertDockWidget(Index, Dockwidget);
NewDockArea->addDockWidget(Dockwidget);
auto InsertParam = internal::dockAreaInsertParameters(area);
QSplitter* TargetAreaSplitter = internal::findParent<QSplitter*>(TargetDockArea);

View File

@ -880,15 +880,7 @@ CDockAreaWidget* CDockManager::addDockWidgetTab(DockWidgetArea area,
//============================================================================
CDockAreaWidget* CDockManager::addDockWidgetTabToArea(CDockWidget* Dockwidget,
CDockAreaWidget* DockAreaWidget)
{
return addDockWidget(ads::CenterDockWidgetArea, Dockwidget, DockAreaWidget);
}
//============================================================================
CDockAreaWidget* CDockManager::insertDockWidgetTabIntoArea(CDockWidget* Dockwidget,
CDockAreaWidget* DockAreaWidget, int Index)
CDockAreaWidget* DockAreaWidget, int Index)
{
return addDockWidget(ads::CenterDockWidgetArea, Dockwidget, DockAreaWidget, Index);
}

View File

@ -304,16 +304,10 @@ public:
/**
* This function will add the given Dockwidget to the given DockAreaWidget
* as a new tab.
* If index is out of range, the tab is simply appended. Otherwise it is
* inserted at the specified position.
*/
CDockAreaWidget* addDockWidgetTabToArea(CDockWidget* Dockwidget,
CDockAreaWidget* DockAreaWidget);
/**
* This function will inserts the given Dockwidget to the given DockAreaWidget
* as a new tab at the given index.
* If index is out of range, the tab is simply appended. Otherwise it is inserted at the specified position.
*/
CDockAreaWidget* insertDockWidgetTabIntoArea(CDockWidget* Dockwidget,
CDockAreaWidget* DockAreaWidget, int Index = -1);
/**