mirror of
https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System.git
synced 2024-12-26 08:01:32 +08:00
Merge pull request #1 from simulton/feature/remove_docks
Feature/remove docks
This commit is contained in:
commit
ca5683f5bf
@ -414,14 +414,15 @@ void CDockAreaWidget::removeDockWidget(CDockWidget* DockWidget)
|
|||||||
auto TabWidget = DockWidget->tabWidget();
|
auto TabWidget = DockWidget->tabWidget();
|
||||||
TabWidget->hide();
|
TabWidget->hide();
|
||||||
d->tabBar()->removeTab(TabWidget);
|
d->tabBar()->removeTab(TabWidget);
|
||||||
|
CDockContainerWidget* DockContainer = dockContainer();
|
||||||
if (NextOpenDockWidget)
|
if (NextOpenDockWidget)
|
||||||
{
|
{
|
||||||
setCurrentDockWidget(NextOpenDockWidget);
|
setCurrentDockWidget(NextOpenDockWidget);
|
||||||
}
|
}
|
||||||
else if (d->ContentsLayout->isEmpty())
|
else if (d->ContentsLayout->isEmpty() && DockContainer->dockAreaCount() > 1)
|
||||||
{
|
{
|
||||||
qDebug() << "Dock Area empty";
|
qDebug() << "Dock Area empty";
|
||||||
dockContainer()->removeDockArea(this);
|
DockContainer->removeDockArea(this);
|
||||||
this->deleteLater();
|
this->deleteLater();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -434,14 +435,13 @@ void CDockAreaWidget::removeDockWidget(CDockWidget* DockWidget)
|
|||||||
|
|
||||||
d->updateCloseButtonState();
|
d->updateCloseButtonState();
|
||||||
updateTitleBarVisibility();
|
updateTitleBarVisibility();
|
||||||
auto TopLevelDockWidget = dockContainer()->topLevelDockWidget();
|
auto TopLevelDockWidget = DockContainer->topLevelDockWidget();
|
||||||
if (TopLevelDockWidget)
|
if (TopLevelDockWidget)
|
||||||
{
|
{
|
||||||
TopLevelDockWidget->emitTopLevelChanged(true);
|
TopLevelDockWidget->emitTopLevelChanged(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if (ADS_DEBUG_LEVEL > 0)
|
#if (ADS_DEBUG_LEVEL > 0)
|
||||||
CDockContainerWidget* DockContainer = dockContainer();
|
|
||||||
DockContainer->dumpLayout();
|
DockContainer->dumpLayout();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -998,6 +998,15 @@ CDockAreaWidget* CDockContainerWidget::addDockWidget(DockWidgetArea area, CDockW
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//============================================================================
|
||||||
|
void CDockContainerWidget::removeDockWidget(CDockWidget* Dockwidget)
|
||||||
|
{
|
||||||
|
CDockAreaWidget* Area = Dockwidget->dockAreaWidget();
|
||||||
|
if (Area)
|
||||||
|
{
|
||||||
|
Area->removeDockWidget(Dockwidget);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
unsigned int CDockContainerWidget::zOrderIndex() const
|
unsigned int CDockContainerWidget::zOrderIndex() const
|
||||||
@ -1057,6 +1066,12 @@ void CDockContainerWidget::removeDockArea(CDockAreaWidget* area)
|
|||||||
area->setParent(nullptr);
|
area->setParent(nullptr);
|
||||||
internal::hideEmptyParentSplitters(Splitter);
|
internal::hideEmptyParentSplitters(Splitter);
|
||||||
|
|
||||||
|
// Remove this area from cached areas
|
||||||
|
const auto& cache = d->LastAddedAreaCache;
|
||||||
|
if (auto p = std::find(cache, cache+sizeof(cache)/sizeof(cache[0]), area)) {
|
||||||
|
d->LastAddedAreaCache[std::distance(cache, p)] = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
// If splitter has more than 1 widgets, we are finished and can leave
|
// If splitter has more than 1 widgets, we are finished and can leave
|
||||||
if (Splitter->count() > 1)
|
if (Splitter->count() > 1)
|
||||||
{
|
{
|
||||||
@ -1274,6 +1289,7 @@ bool CDockContainerWidget::restoreState(QXmlStreamReader& s, bool Testing)
|
|||||||
{
|
{
|
||||||
d->VisibleDockAreaCount = -1;// invalidate the dock area count
|
d->VisibleDockAreaCount = -1;// invalidate the dock area count
|
||||||
d->DockAreas.clear();
|
d->DockAreas.clear();
|
||||||
|
std::fill(std::begin(d->LastAddedAreaCache),std::end(d->LastAddedAreaCache), nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IsFloating)
|
if (IsFloating)
|
||||||
|
@ -166,6 +166,11 @@ public:
|
|||||||
CDockAreaWidget* addDockWidget(DockWidgetArea area, CDockWidget* Dockwidget,
|
CDockAreaWidget* addDockWidget(DockWidgetArea area, CDockWidget* Dockwidget,
|
||||||
CDockAreaWidget* DockAreaWidget = nullptr);
|
CDockAreaWidget* DockAreaWidget = nullptr);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes dockwidget
|
||||||
|
*/
|
||||||
|
void removeDockWidget(CDockWidget* Dockwidget);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the current zOrderIndex
|
* Returns the current zOrderIndex
|
||||||
*/
|
*/
|
||||||
|
@ -565,9 +565,13 @@ CDockAreaWidget* CDockManager::addDockWidgetTab(DockWidgetArea area,
|
|||||||
{
|
{
|
||||||
return addDockWidget(ads::CenterDockWidgetArea, Dockwidget, AreaWidget);
|
return addDockWidget(ads::CenterDockWidgetArea, Dockwidget, AreaWidget);
|
||||||
}
|
}
|
||||||
|
else if (!openedDockAreas().isEmpty())
|
||||||
|
{
|
||||||
|
return addDockWidget(area, Dockwidget, openedDockAreas().last());
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return addDockWidget(area, Dockwidget, AreaWidget);
|
return addDockWidget(area, Dockwidget, nullptr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -586,6 +590,12 @@ CDockWidget* CDockManager::findDockWidget(const QString& ObjectName) const
|
|||||||
return d->DockWidgetsMap.value(ObjectName, nullptr);
|
return d->DockWidgetsMap.value(ObjectName, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//============================================================================
|
||||||
|
void CDockManager::removeDockWidget(CDockWidget* Dockwidget)
|
||||||
|
{
|
||||||
|
d->DockWidgetsMap.remove(Dockwidget->objectName());
|
||||||
|
CDockContainerWidget::removeDockWidget(Dockwidget);
|
||||||
|
}
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
QMap<QString, CDockWidget*> CDockManager::dockWidgetsMap() const
|
QMap<QString, CDockWidget*> CDockManager::dockWidgetsMap() const
|
||||||
|
@ -192,6 +192,11 @@ public:
|
|||||||
*/
|
*/
|
||||||
CDockWidget* findDockWidget(const QString& ObjectName) const;
|
CDockWidget* findDockWidget(const QString& ObjectName) const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove the given Dock from the dock manager
|
||||||
|
*/
|
||||||
|
void removeDockWidget(CDockWidget* Dockwidget);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This function returns a readable reference to the internal dock
|
* This function returns a readable reference to the internal dock
|
||||||
* widgets map so that it is possible to iterate over all dock widgets
|
* widgets map so that it is possible to iterate over all dock widgets
|
||||||
|
@ -262,6 +262,16 @@ void CDockWidget::setWidget(QWidget* widget, eInsertMode InsertMode)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//============================================================================
|
||||||
|
QWidget* CDockWidget::takeWidget()
|
||||||
|
{
|
||||||
|
d->ScrollArea->takeWidget();
|
||||||
|
d->Layout->removeWidget(d->Widget);
|
||||||
|
d->Widget->setParent(nullptr);
|
||||||
|
return d->Widget;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
QWidget* CDockWidget::widget() const
|
QWidget* CDockWidget::widget() const
|
||||||
{
|
{
|
||||||
|
@ -238,6 +238,11 @@ public:
|
|||||||
*/
|
*/
|
||||||
void setWidget(QWidget* widget, eInsertMode InsertMode = AutoScrollArea);
|
void setWidget(QWidget* widget, eInsertMode InsertMode = AutoScrollArea);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove the widget from the dock and give ownership back to the caller
|
||||||
|
*/
|
||||||
|
QWidget* takeWidget();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the widget for the dock widget. This function returns zero if
|
* Returns the widget for the dock widget. This function returns zero if
|
||||||
* the widget has not been set.
|
* the widget has not been set.
|
||||||
|
Loading…
Reference in New Issue
Block a user