Added function to add / remove CAutoHideDockContainer from SideBar

This commit is contained in:
Uwe Kindler 2022-11-15 14:16:01 +01:00
parent 3fded82f26
commit 7b9f9e10e5
4 changed files with 52 additions and 0 deletions

View File

@ -241,6 +241,32 @@ CAutoHideDockContainer* CAutoHideSideBar::insertDockWidget(int Index, CDockWidge
}
//============================================================================
void CAutoHideSideBar::removeAutoHideWidget(CAutoHideDockContainer* AutoHideWidget)
{
AutoHideWidget->autoHideTab()->removeFromSideBar();
auto DockContainer = AutoHideWidget->dockContainer();
if (DockContainer)
{
DockContainer->removeAutoHideWidget(AutoHideWidget);
}
AutoHideWidget->setParent(nullptr);
}
//============================================================================
void CAutoHideSideBar::addAutoHideWidget(CAutoHideDockContainer* AutoHideWidget)
{
auto SideBar = AutoHideWidget->autoHideTab()->sideBar();
if (SideBar)
{
SideBar->removeAutoHideWidget(AutoHideWidget);
}
AutoHideWidget->setParent(d->ContainerWidget);
d->ContainerWidget->registerAutoHideWidget(AutoHideWidget);
insertTab(-1, AutoHideWidget->autoHideTab());
}
//============================================================================
void CAutoHideSideBar::removeTab(CAutoHideTab* SideTab)
{

View File

@ -66,6 +66,7 @@ private:
friend struct AutoHideSideBarPrivate;
friend class DockWidgetSideTab;
friend DockContainerWidgetPrivate;
friend CDockContainerWidget;
protected:
virtual bool eventFilter(QObject *watched, QEvent *event) override;
@ -106,6 +107,18 @@ public:
*/
CAutoHideDockContainer* insertDockWidget(int Index, CDockWidget* DockWidget);
/**
* Removes the auto hide widget from this side bar
*/
void removeAutoHideWidget(CAutoHideDockContainer* AutoHideWidget);
/**
* Adds the given AutoHideWidget to this sidebar.
* If the AutoHideWidget is in another sidebar, then it will be removed
* from this sidebar.
*/
void addAutoHideWidget(CAutoHideDockContainer* AutoHideWidget);
/**
* Returns orientation of side tab.
*/

View File

@ -121,6 +121,13 @@ void CAutoHideTab::setSideBar(CAutoHideSideBar* SideTabBar)
}
//============================================================================
CAutoHideSideBar* CAutoHideTab::sideBar() const
{
return d->SideBar;
}
//============================================================================
void CAutoHideTab::removeFromSideBar()
{

View File

@ -128,6 +128,12 @@ public:
* is set and if the tab has an icon - that means the icon is not null
*/
bool iconOnly() const;
/**
* Returns the side bar that contains this tab or a nullptr if the tab is
* not in a side bar
*/
CAutoHideSideBar* sideBar() const;
}; // class AutoHideTab
}
// namespace ads