mirror of
https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System.git
synced 2025-01-14 00:52:05 +08:00
Added support for tab index when inserting dockwidgets into area
This commit is contained in:
parent
4600af712b
commit
296c7edbd0
@ -416,6 +416,10 @@ void CDockAreaWidget::addDockWidget(CDockWidget* DockWidget)
|
|||||||
void CDockAreaWidget::insertDockWidget(int index, CDockWidget* DockWidget,
|
void CDockAreaWidget::insertDockWidget(int index, CDockWidget* DockWidget,
|
||||||
bool Activate)
|
bool Activate)
|
||||||
{
|
{
|
||||||
|
if (index < 0 || index > d->ContentsLayout->count())
|
||||||
|
{
|
||||||
|
index = d->ContentsLayout->count();
|
||||||
|
}
|
||||||
d->ContentsLayout->insertWidget(index, DockWidget);
|
d->ContentsLayout->insertWidget(index, DockWidget);
|
||||||
DockWidget->setDockArea(this);
|
DockWidget->setDockArea(this);
|
||||||
DockWidget->tabWidget()->setDockAreaWidget(this);
|
DockWidget->tabWidget()->setDockAreaWidget(this);
|
||||||
|
@ -153,7 +153,7 @@ public:
|
|||||||
* Adds dock widget to a existing DockWidgetArea
|
* Adds dock widget to a existing DockWidgetArea
|
||||||
*/
|
*/
|
||||||
CDockAreaWidget* addDockWidgetToDockArea(DockWidgetArea area, CDockWidget* Dockwidget,
|
CDockAreaWidget* addDockWidgetToDockArea(DockWidgetArea area, CDockWidget* Dockwidget,
|
||||||
CDockAreaWidget* TargetDockArea);
|
CDockAreaWidget* TargetDockArea, int Index = -1);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add dock area to this container
|
* Add dock area to this container
|
||||||
@ -1228,7 +1228,7 @@ void DockContainerWidgetPrivate::dumpRecursive(int level, QWidget* widget)
|
|||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
CDockAreaWidget* DockContainerWidgetPrivate::addDockWidgetToDockArea(DockWidgetArea area,
|
CDockAreaWidget* DockContainerWidgetPrivate::addDockWidgetToDockArea(DockWidgetArea area,
|
||||||
CDockWidget* Dockwidget, CDockAreaWidget* TargetDockArea)
|
CDockWidget* Dockwidget, CDockAreaWidget* TargetDockArea, int Index)
|
||||||
{
|
{
|
||||||
if (CenterDockWidgetArea == area)
|
if (CenterDockWidgetArea == area)
|
||||||
{
|
{
|
||||||
@ -1238,7 +1238,7 @@ CDockAreaWidget* DockContainerWidgetPrivate::addDockWidgetToDockArea(DockWidgetA
|
|||||||
}
|
}
|
||||||
|
|
||||||
CDockAreaWidget* NewDockArea = new CDockAreaWidget(DockManager, _this);
|
CDockAreaWidget* NewDockArea = new CDockAreaWidget(DockManager, _this);
|
||||||
NewDockArea->addDockWidget(Dockwidget);
|
NewDockArea->insertDockWidget(Index, Dockwidget);
|
||||||
auto InsertParam = internal::dockAreaInsertParameters(area);
|
auto InsertParam = internal::dockAreaInsertParameters(area);
|
||||||
|
|
||||||
QSplitter* TargetAreaSplitter = internal::findParent<QSplitter*>(TargetDockArea);
|
QSplitter* TargetAreaSplitter = internal::findParent<QSplitter*>(TargetDockArea);
|
||||||
@ -1315,7 +1315,7 @@ CDockContainerWidget::~CDockContainerWidget()
|
|||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
CDockAreaWidget* CDockContainerWidget::addDockWidget(DockWidgetArea area, CDockWidget* Dockwidget,
|
CDockAreaWidget* CDockContainerWidget::addDockWidget(DockWidgetArea area, CDockWidget* Dockwidget,
|
||||||
CDockAreaWidget* DockAreaWidget)
|
CDockAreaWidget* DockAreaWidget, int Index)
|
||||||
{
|
{
|
||||||
CDockAreaWidget* OldDockArea = Dockwidget->dockAreaWidget();
|
CDockAreaWidget* OldDockArea = Dockwidget->dockAreaWidget();
|
||||||
if (OldDockArea)
|
if (OldDockArea)
|
||||||
@ -1326,7 +1326,7 @@ CDockAreaWidget* CDockContainerWidget::addDockWidget(DockWidgetArea area, CDockW
|
|||||||
Dockwidget->setDockManager(d->DockManager);
|
Dockwidget->setDockManager(d->DockManager);
|
||||||
if (DockAreaWidget)
|
if (DockAreaWidget)
|
||||||
{
|
{
|
||||||
return d->addDockWidgetToDockArea(area, Dockwidget, DockAreaWidget);
|
return d->addDockWidgetToDockArea(area, Dockwidget, DockAreaWidget, Index);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -181,7 +181,7 @@ public:
|
|||||||
* \return Returns the dock area widget that contains the new DockWidget
|
* \return Returns the dock area widget that contains the new DockWidget
|
||||||
*/
|
*/
|
||||||
CDockAreaWidget* addDockWidget(DockWidgetArea area, CDockWidget* Dockwidget,
|
CDockAreaWidget* addDockWidget(DockWidgetArea area, CDockWidget* Dockwidget,
|
||||||
CDockAreaWidget* DockAreaWidget = nullptr);
|
CDockAreaWidget* DockAreaWidget = nullptr, int Index = -1);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes dockwidget
|
* Removes dockwidget
|
||||||
|
@ -842,11 +842,11 @@ void CDockManager::restoreHiddenFloatingWidgets()
|
|||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
CDockAreaWidget* CDockManager::addDockWidget(DockWidgetArea area,
|
CDockAreaWidget* CDockManager::addDockWidget(DockWidgetArea area,
|
||||||
CDockWidget* Dockwidget, CDockAreaWidget* DockAreaWidget)
|
CDockWidget* Dockwidget, CDockAreaWidget* DockAreaWidget, int Index)
|
||||||
{
|
{
|
||||||
d->DockWidgetsMap.insert(Dockwidget->objectName(), Dockwidget);
|
d->DockWidgetsMap.insert(Dockwidget->objectName(), Dockwidget);
|
||||||
auto Container = DockAreaWidget ? DockAreaWidget->dockContainer(): this;
|
auto Container = DockAreaWidget ? DockAreaWidget->dockContainer(): this;
|
||||||
auto AreaOfAddedDockWidget = Container->addDockWidget(area, Dockwidget, DockAreaWidget);
|
auto AreaOfAddedDockWidget = Container->addDockWidget(area, Dockwidget, DockAreaWidget, Index);
|
||||||
Q_EMIT dockWidgetAdded(Dockwidget);
|
Q_EMIT dockWidgetAdded(Dockwidget);
|
||||||
return AreaOfAddedDockWidget;
|
return AreaOfAddedDockWidget;
|
||||||
}
|
}
|
||||||
@ -886,6 +886,14 @@ CDockAreaWidget* CDockManager::addDockWidgetTabToArea(CDockWidget* Dockwidget,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//============================================================================
|
||||||
|
CDockAreaWidget* CDockManager::insertDockWidgetTabIntoArea(CDockWidget* Dockwidget,
|
||||||
|
CDockAreaWidget* DockAreaWidget, int Index)
|
||||||
|
{
|
||||||
|
return addDockWidget(ads::CenterDockWidgetArea, Dockwidget, DockAreaWidget, Index);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
CDockWidget* CDockManager::findDockWidget(const QString& ObjectName) const
|
CDockWidget* CDockManager::findDockWidget(const QString& ObjectName) const
|
||||||
{
|
{
|
||||||
|
@ -281,7 +281,7 @@ public:
|
|||||||
* \return Returns the dock area widget that contains the new DockWidget
|
* \return Returns the dock area widget that contains the new DockWidget
|
||||||
*/
|
*/
|
||||||
CDockAreaWidget* addDockWidget(DockWidgetArea area, CDockWidget* Dockwidget,
|
CDockAreaWidget* addDockWidget(DockWidgetArea area, CDockWidget* Dockwidget,
|
||||||
CDockAreaWidget* DockAreaWidget = nullptr);
|
CDockAreaWidget* DockAreaWidget = nullptr, int Index = -1);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds dockwidget into the given container.
|
* Adds dockwidget into the given container.
|
||||||
@ -308,6 +308,14 @@ public:
|
|||||||
CDockAreaWidget* addDockWidgetTabToArea(CDockWidget* Dockwidget,
|
CDockAreaWidget* addDockWidgetTabToArea(CDockWidget* Dockwidget,
|
||||||
CDockAreaWidget* DockAreaWidget);
|
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);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds the given DockWidget floating and returns the created
|
* Adds the given DockWidget floating and returns the created
|
||||||
* CFloatingDockContainer instance.
|
* CFloatingDockContainer instance.
|
||||||
|
Loading…
Reference in New Issue
Block a user