Added parentSplitter() fucntion to DockArea and removed dead code from DockContainerWidget

This commit is contained in:
Uwe Kindler 2023-11-27 21:48:14 +01:00
parent 761bfc50d6
commit 68f1084bf0
7 changed files with 28 additions and 23 deletions

View File

@ -464,6 +464,13 @@ CAutoHideDockContainer* CDockAreaWidget::autoHideDockContainer() const
return d->AutoHideDockContainer;
}
//============================================================================
CDockSplitter* CDockAreaWidget::parentSplitter() const
{
return internal::findParent<CDockSplitter*>(this);
}
//============================================================================
bool CDockAreaWidget::isAutoHide() const
{
@ -600,7 +607,7 @@ void CDockAreaWidget::hideAreaWithNoVisibleContent()
this->toggleView(false);
// Hide empty parent splitters
auto Splitter = internal::findParent<CDockSplitter*>(this);
auto Splitter = parentSplitter();
internal::hideEmptyParentSplitters(Splitter);
//Hide empty floating widget

View File

@ -47,6 +47,7 @@ class CDockContainerWidget;
class DockContainerWidgetPrivate;
class CDockAreaTitleBar;
class CDockingStateReader;
class CDockSplitter;
/**
@ -216,6 +217,11 @@ public:
*/
CAutoHideDockContainer* autoHideDockContainer() const;
/**
* Returns the parent splitter that contains this dock area
*/
CDockSplitter* parentSplitter() const;
/**
* Returns true if the dock area is in an auto hide container
*/

View File

@ -587,16 +587,7 @@ void DockContainerWidgetPrivate::dropIntoSection(CFloatingDockContainer* Floatin
auto InsertParam = internal::dockAreaInsertParameters(area);
auto NewDockAreas = FloatingContainer->findChildren<CDockAreaWidget*>(
QString(), Qt::FindChildrenRecursively);
QSplitter* TargetAreaSplitter = internal::findParent<QSplitter*>(TargetArea);
if (!TargetAreaSplitter)
{
QSplitter* Splitter = newSplitter(InsertParam.orientation());
Layout->replaceWidget(TargetArea, Splitter);
Splitter->addWidget(TargetArea);
updateSplitterHandles(Splitter);
TargetAreaSplitter = Splitter;
}
auto TargetAreaSplitter = TargetArea->parentSplitter();
int AreaIndex = TargetAreaSplitter->indexOf(TargetArea);
auto FloatingSplitter = FloatingContainer->rootSplitter();
if (TargetAreaSplitter->orientation() == InsertParam.orientation())
@ -742,7 +733,7 @@ void DockContainerWidgetPrivate::moveToNewSection(QWidget* Widget, CDockAreaWidg
}
auto InsertParam = internal::dockAreaInsertParameters(area);
QSplitter* TargetAreaSplitter = internal::findParent<QSplitter*>(TargetArea);
auto TargetAreaSplitter = TargetArea->parentSplitter();
int AreaIndex = TargetAreaSplitter->indexOf(TargetArea);
auto Sizes = TargetAreaSplitter->sizes();
if (TargetAreaSplitter->orientation() == InsertParam.orientation())
@ -877,7 +868,7 @@ void DockContainerWidgetPrivate::moveToContainer(QWidget* Widget, DockWidgetArea
// it already has and do nothing, if it is the same place. It would
// also work without this check, but it looks nicer with the check
// because there will be no layout updates
auto Splitter = internal::findParent<CDockSplitter*>(DroppedDockArea);
auto Splitter = DroppedDockArea->parentSplitter();
auto InsertParam = internal::dockAreaInsertParameters(area);
if (Splitter == RootSplitter && InsertParam.orientation() == Splitter->orientation())
{
@ -1364,7 +1355,7 @@ CDockAreaWidget* DockContainerWidgetPrivate::addDockWidgetToDockArea(DockWidgetA
NewDockArea->addDockWidget(Dockwidget);
auto InsertParam = internal::dockAreaInsertParameters(area);
QSplitter* TargetAreaSplitter = internal::findParent<QSplitter*>(TargetDockArea);
auto TargetAreaSplitter = TargetDockArea->parentSplitter();
int index = TargetAreaSplitter ->indexOf(TargetDockArea);
if (TargetAreaSplitter->orientation() == InsertParam.orientation())
{
@ -1381,7 +1372,7 @@ CDockAreaWidget* DockContainerWidgetPrivate::addDockWidgetToDockArea(DockWidgetA
{
ADS_PRINT("TargetAreaSplitter->orientation() != InsertParam.orientation()");
auto TargetAreaSizes = TargetAreaSplitter->sizes();
QSplitter* NewSplitter = newSplitter(InsertParam.orientation());
auto NewSplitter = newSplitter(InsertParam.orientation());
NewSplitter->addWidget(TargetDockArea);
insertWidgetIntoSplitter(NewSplitter, NewDockArea, InsertParam.append());
@ -1572,7 +1563,7 @@ void CDockContainerWidget::removeDockArea(CDockAreaWidget* area)
area->disconnect(this);
d->DockAreas.removeAll(area);
CDockSplitter* Splitter = internal::findParent<CDockSplitter*>(area);
auto Splitter = area->parentSplitter();
// Remove are from parent splitter and recursively hide tree of parent
// splitters if it has no visible content
@ -1943,7 +1934,7 @@ bool CDockContainerWidget::restoreState(CDockingStateReader& s, bool Testing)
//============================================================================
QSplitter* CDockContainerWidget::rootSplitter() const
CDockSplitter* CDockContainerWidget::rootSplitter() const
{
return d->RootSplitter;
}

View File

@ -53,6 +53,7 @@ struct FloatingDragPreviewPrivate;
class CDockingStateReader;
class CAutoHideSideBar;
class CAutoHideTab;
class CDockSplitter;
struct AutoHideTabPrivate;
struct AutoHideDockContainerPrivate;
@ -94,7 +95,7 @@ protected:
/**
* Access function for the internal root splitter
*/
QSplitter* rootSplitter() const;
CDockSplitter* rootSplitter() const;
/**
* Creates and initializes a dockwidget auto hide container into the given area.

View File

@ -1318,7 +1318,7 @@ QList<int> CDockManager::splitterSizes(CDockAreaWidget *ContainedArea) const
{
if (ContainedArea)
{
auto Splitter = internal::findParent<CDockSplitter*>(ContainedArea);
auto Splitter = ContainedArea->parentSplitter();
if (Splitter)
{
return Splitter->sizes();
@ -1335,7 +1335,7 @@ void CDockManager::setSplitterSizes(CDockAreaWidget *ContainedArea, const QList<
return;
}
auto Splitter = internal::findParent<CDockSplitter*>(ContainedArea);
auto Splitter = ContainedArea->parentSplitter();
if (Splitter && Splitter->count() == sizes.count())
{
Splitter->setSizes(sizes);

View File

@ -184,11 +184,11 @@ void DockWidgetPrivate::showDockWidget()
DockArea->setCurrentDockWidget(_this);
DockArea->toggleView(true);
TabWidget->show();
QSplitter* Splitter = internal::findParent<QSplitter*>(DockArea);
auto Splitter = DockArea->parentSplitter();
while (Splitter && !Splitter->isVisible() && !DockArea->isAutoHide())
{
Splitter->show();
Splitter = internal::findParent<QSplitter*>(Splitter);
Splitter = internal::findParent<CDockSplitter*>(Splitter);
}
CDockContainerWidget* Container = DockArea->dockContainer();

View File

@ -268,7 +268,7 @@ T findParent(const QWidget* w)
}
parentWidget = parentWidget->parentWidget();
}
return 0;
return nullptr;
}
/**