mirror of
https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System.git
synced 2024-11-15 13:15:43 +08:00
Added support for inserting a dock widget with a given tab index and added test case
This commit is contained in:
parent
3b8775fd86
commit
e4a71982d9
@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user