mirror of
https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System.git
synced 2025-01-24 13:32:06 +08:00
Fixed creation of superfluous splitter when docking into container
This commit is contained in:
parent
549646d113
commit
9adc524a42
@ -475,15 +475,17 @@ void CDockAreaWidget::removeDockWidget(CDockWidget* DockWidget)
|
||||
setCurrentIndex(d->ContentsLayout->currentIndex());
|
||||
d->updateTabsMenu();
|
||||
|
||||
CDockContainerWidget* DockContainer = dockContainer();
|
||||
if (d->ContentsLayout->isEmpty())
|
||||
{
|
||||
std::cout << "Dock Area empty" << std::endl;
|
||||
dockContainer()->removeDockArea(this);
|
||||
this->deleteLater();
|
||||
this->deleteLater();;
|
||||
}
|
||||
|
||||
d->updateTabBar();
|
||||
DockWidget->setDockArea(nullptr);
|
||||
DockContainer->dumpLayout();
|
||||
}
|
||||
|
||||
|
||||
|
@ -145,6 +145,11 @@ struct DockContainerWidgetPrivate
|
||||
*/
|
||||
bool restoreDockArea(QDataStream& Stream, QWidget*& CreatedWidget,
|
||||
bool Testing);
|
||||
|
||||
/**
|
||||
* Helper function for recursive dumping of layout
|
||||
*/
|
||||
void dumpRecursive(int level, QWidget* widget);
|
||||
}; // struct DockContainerWidgetPrivate
|
||||
|
||||
|
||||
@ -169,7 +174,7 @@ void DockContainerWidgetPrivate::dropIntoContainer(CFloatingDockContainer* Float
|
||||
{
|
||||
Splitter->setOrientation(InsertParam.orientation());
|
||||
}
|
||||
else
|
||||
else if (Splitter->orientation() != InsertParam.orientation())
|
||||
{
|
||||
QSplitter* NewSplitter = internal::newSplitter(InsertParam.orientation());
|
||||
QLayoutItem* li = Layout->replaceWidget(Splitter, NewSplitter);
|
||||
@ -178,13 +183,8 @@ void DockContainerWidgetPrivate::dropIntoContainer(CFloatingDockContainer* Float
|
||||
}
|
||||
|
||||
// Now we can insert the floating widget content into this container
|
||||
auto Widget = FloatingWidget->dockContainer()->findChild<QWidget*>(QString(), Qt::FindDirectChildrenOnly);
|
||||
auto FloatingSplitter = dynamic_cast<QSplitter*>(Widget);
|
||||
if (DockAreas.isEmpty())
|
||||
{
|
||||
Splitter->addWidget(Widget);
|
||||
}
|
||||
else if (FloatingSplitter->count() == 1)
|
||||
auto FloatingSplitter = FloatingWidget->dockContainer()->rootSplitter();
|
||||
if (FloatingSplitter->count() == 1)
|
||||
{
|
||||
insertWidgetIntoSplitter(Splitter, FloatingSplitter->widget(0), InsertParam.append());
|
||||
}
|
||||
@ -203,6 +203,7 @@ void DockContainerWidgetPrivate::dropIntoContainer(CFloatingDockContainer* Float
|
||||
RootSplitter = Splitter;
|
||||
addDockAreasToList(NewDockAreas);
|
||||
FloatingWidget->deleteLater();
|
||||
_this->dumpLayout();
|
||||
}
|
||||
|
||||
|
||||
@ -278,6 +279,7 @@ void DockContainerWidgetPrivate::dropIntoSection(CFloatingDockContainer* Floatin
|
||||
|
||||
FloatingWidget->deleteLater();
|
||||
addDockAreasToList(NewDockAreas);
|
||||
_this->dumpLayout();
|
||||
}
|
||||
|
||||
|
||||
@ -523,6 +525,33 @@ void DockContainerWidgetPrivate::addDockArea(CDockAreaWidget* NewDockArea, DockW
|
||||
}
|
||||
|
||||
|
||||
//============================================================================
|
||||
void DockContainerWidgetPrivate::dumpRecursive(int level, QWidget* widget)
|
||||
{
|
||||
QSplitter* Splitter = dynamic_cast<QSplitter*>(widget);
|
||||
QByteArray buf;
|
||||
buf.fill(' ', level * 4);
|
||||
if (Splitter)
|
||||
{
|
||||
std::cout << buf.toStdString() << "Splitter " << ((Splitter->orientation() == Qt::Vertical)
|
||||
? "-" : "|") << std::endl;
|
||||
for (int i = 0; i < Splitter->count(); ++i)
|
||||
{
|
||||
dumpRecursive(level + 1, Splitter->widget(i));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
CDockAreaWidget* DockArea = dynamic_cast<CDockAreaWidget*>(widget);
|
||||
if (!DockArea)
|
||||
{
|
||||
return;
|
||||
}
|
||||
std::cout << buf.toStdString() << "DockArea" << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//============================================================================
|
||||
CDockAreaWidget* DockContainerWidgetPrivate::dockWidgetIntoDockArea(DockWidgetArea area,
|
||||
CDockWidget* Dockwidget, CDockAreaWidget* TargetDockArea)
|
||||
@ -681,6 +710,7 @@ void CDockContainerWidget::removeDockArea(CDockAreaWidget* area)
|
||||
QSplitter* ParentSplitter = internal::findParent<QSplitter*>(Splitter);
|
||||
internal::replaceSplitterWidget(ParentSplitter, Splitter, widget);
|
||||
delete Splitter;
|
||||
dumpLayout();
|
||||
emit dockAreasRemoved();
|
||||
}
|
||||
|
||||
@ -845,6 +875,20 @@ bool CDockContainerWidget::restoreState(QDataStream& stream, bool Testing)
|
||||
}
|
||||
|
||||
|
||||
//============================================================================
|
||||
QSplitter* CDockContainerWidget::rootSplitter() const
|
||||
{
|
||||
return d->RootSplitter;
|
||||
}
|
||||
|
||||
|
||||
//============================================================================
|
||||
void CDockContainerWidget::dumpLayout()
|
||||
{
|
||||
d->dumpRecursive(0, d->RootSplitter);
|
||||
}
|
||||
|
||||
|
||||
} // namespace ads
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
@ -59,6 +59,11 @@ protected:
|
||||
*/
|
||||
virtual bool event(QEvent *e) override;
|
||||
|
||||
/**
|
||||
* Access function for the internal root splitter
|
||||
*/
|
||||
QSplitter* rootSplitter() const;
|
||||
|
||||
public:
|
||||
/**
|
||||
* Default Constructor
|
||||
@ -147,6 +152,11 @@ public:
|
||||
*/
|
||||
bool restoreState(QDataStream& Stream, bool Testing);
|
||||
|
||||
/**
|
||||
* Dumps the layout for debugging purposes
|
||||
*/
|
||||
void dumpLayout();
|
||||
|
||||
signals:
|
||||
/**
|
||||
* This signal is emitted if one or multiple dock areas has been added to
|
||||
|
@ -136,7 +136,7 @@ static QPixmap createDropIndicatorPixmap(const QPalette& pal, const QSizeF& size
|
||||
if (CDockOverlay::ModeContainerOverlay == Mode && DockWidgetArea != CenterDockWidgetArea)
|
||||
{
|
||||
QRectF ArrowRect;
|
||||
ArrowRect.setSize(ShadowRect.size() * 0.7);
|
||||
ArrowRect.setSize(baseSize);
|
||||
ArrowRect.setWidth(ArrowRect.width() / 4.6);
|
||||
ArrowRect.setHeight(ArrowRect.height() / 2);
|
||||
ArrowRect.moveCenter(QPointF(0, 0));
|
||||
|
@ -267,8 +267,8 @@ void CDockWidgetTitleBar::mouseReleaseEvent(QMouseEvent* ev)
|
||||
//============================================================================
|
||||
void CDockWidgetTitleBar::mouseMoveEvent(QMouseEvent* ev)
|
||||
{
|
||||
std::cout << "CDockWidgetTitleBar::mouseMoveEventmouseMoveEvent DragState "
|
||||
<< d->DragState << std::endl;
|
||||
/*std::cout << "CDockWidgetTitleBar::mouseMoveEventmouseMoveEvent DragState "
|
||||
<< d->DragState << std::endl;*/
|
||||
if (!(ev->buttons() & Qt::LeftButton) || d->isDraggingState(DraggingInactive))
|
||||
{
|
||||
d->DragState = DraggingInactive;
|
||||
@ -278,7 +278,7 @@ void CDockWidgetTitleBar::mouseMoveEvent(QMouseEvent* ev)
|
||||
|
||||
if (d->isDraggingState(DraggingFloatingWidget))
|
||||
{
|
||||
std::cout << "DraggingFloatingWidget" << std::endl;
|
||||
//std::cout << "DraggingFloatingWidget" << std::endl;
|
||||
d->FloatingWidget->moveFloating();
|
||||
QFrame::mouseMoveEvent(ev);
|
||||
return;
|
||||
|
Loading…
Reference in New Issue
Block a user