Skip to content

Commit 7b9f9e1

Browse files
Added function to add / remove CAutoHideDockContainer from SideBar
1 parent 3fded82 commit 7b9f9e1

File tree

4 files changed

+52
-0
lines changed

4 files changed

+52
-0
lines changed

src/AutoHideSideBar.cpp

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,32 @@ CAutoHideDockContainer* CAutoHideSideBar::insertDockWidget(int Index, CDockWidge
241241
}
242242

243243

244+
//============================================================================
245+
void CAutoHideSideBar::removeAutoHideWidget(CAutoHideDockContainer* AutoHideWidget)
246+
{
247+
AutoHideWidget->autoHideTab()->removeFromSideBar();
248+
auto DockContainer = AutoHideWidget->dockContainer();
249+
if (DockContainer)
250+
{
251+
DockContainer->removeAutoHideWidget(AutoHideWidget);
252+
}
253+
AutoHideWidget->setParent(nullptr);
254+
}
255+
256+
//============================================================================
257+
void CAutoHideSideBar::addAutoHideWidget(CAutoHideDockContainer* AutoHideWidget)
258+
{
259+
auto SideBar = AutoHideWidget->autoHideTab()->sideBar();
260+
if (SideBar)
261+
{
262+
SideBar->removeAutoHideWidget(AutoHideWidget);
263+
}
264+
AutoHideWidget->setParent(d->ContainerWidget);
265+
d->ContainerWidget->registerAutoHideWidget(AutoHideWidget);
266+
insertTab(-1, AutoHideWidget->autoHideTab());
267+
}
268+
269+
244270
//============================================================================
245271
void CAutoHideSideBar::removeTab(CAutoHideTab* SideTab)
246272
{

src/AutoHideSideBar.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ class ADS_EXPORT CAutoHideSideBar : public QScrollArea
6666
friend struct AutoHideSideBarPrivate;
6767
friend class DockWidgetSideTab;
6868
friend DockContainerWidgetPrivate;
69+
friend CDockContainerWidget;
6970

7071
protected:
7172
virtual bool eventFilter(QObject *watched, QEvent *event) override;
@@ -106,6 +107,18 @@ class ADS_EXPORT CAutoHideSideBar : public QScrollArea
106107
*/
107108
CAutoHideDockContainer* insertDockWidget(int Index, CDockWidget* DockWidget);
108109

110+
/**
111+
* Removes the auto hide widget from this side bar
112+
*/
113+
void removeAutoHideWidget(CAutoHideDockContainer* AutoHideWidget);
114+
115+
/**
116+
* Adds the given AutoHideWidget to this sidebar.
117+
* If the AutoHideWidget is in another sidebar, then it will be removed
118+
* from this sidebar.
119+
*/
120+
void addAutoHideWidget(CAutoHideDockContainer* AutoHideWidget);
121+
109122
/**
110123
* Returns orientation of side tab.
111124
*/

src/AutoHideTab.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,13 @@ void CAutoHideTab::setSideBar(CAutoHideSideBar* SideTabBar)
121121
}
122122

123123

124+
//============================================================================
125+
CAutoHideSideBar* CAutoHideTab::sideBar() const
126+
{
127+
return d->SideBar;
128+
}
129+
130+
124131
//============================================================================
125132
void CAutoHideTab::removeFromSideBar()
126133
{

src/AutoHideTab.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,12 @@ class ADS_EXPORT CAutoHideTab : public CPushButton
128128
* is set and if the tab has an icon - that means the icon is not null
129129
*/
130130
bool iconOnly() const;
131+
132+
/**
133+
* Returns the side bar that contains this tab or a nullptr if the tab is
134+
* not in a side bar
135+
*/
136+
CAutoHideSideBar* sideBar() const;
131137
}; // class AutoHideTab
132138
}
133139
// namespace ads

0 commit comments

Comments
 (0)