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());
|
setCurrentIndex(d->ContentsLayout->currentIndex());
|
||||||
d->updateTabsMenu();
|
d->updateTabsMenu();
|
||||||
|
|
||||||
|
CDockContainerWidget* DockContainer = dockContainer();
|
||||||
if (d->ContentsLayout->isEmpty())
|
if (d->ContentsLayout->isEmpty())
|
||||||
{
|
{
|
||||||
std::cout << "Dock Area empty" << std::endl;
|
std::cout << "Dock Area empty" << std::endl;
|
||||||
dockContainer()->removeDockArea(this);
|
dockContainer()->removeDockArea(this);
|
||||||
this->deleteLater();
|
this->deleteLater();;
|
||||||
}
|
}
|
||||||
|
|
||||||
d->updateTabBar();
|
d->updateTabBar();
|
||||||
DockWidget->setDockArea(nullptr);
|
DockWidget->setDockArea(nullptr);
|
||||||
|
DockContainer->dumpLayout();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -145,6 +145,11 @@ struct DockContainerWidgetPrivate
|
|||||||
*/
|
*/
|
||||||
bool restoreDockArea(QDataStream& Stream, QWidget*& CreatedWidget,
|
bool restoreDockArea(QDataStream& Stream, QWidget*& CreatedWidget,
|
||||||
bool Testing);
|
bool Testing);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helper function for recursive dumping of layout
|
||||||
|
*/
|
||||||
|
void dumpRecursive(int level, QWidget* widget);
|
||||||
}; // struct DockContainerWidgetPrivate
|
}; // struct DockContainerWidgetPrivate
|
||||||
|
|
||||||
|
|
||||||
@ -169,7 +174,7 @@ void DockContainerWidgetPrivate::dropIntoContainer(CFloatingDockContainer* Float
|
|||||||
{
|
{
|
||||||
Splitter->setOrientation(InsertParam.orientation());
|
Splitter->setOrientation(InsertParam.orientation());
|
||||||
}
|
}
|
||||||
else
|
else if (Splitter->orientation() != InsertParam.orientation())
|
||||||
{
|
{
|
||||||
QSplitter* NewSplitter = internal::newSplitter(InsertParam.orientation());
|
QSplitter* NewSplitter = internal::newSplitter(InsertParam.orientation());
|
||||||
QLayoutItem* li = Layout->replaceWidget(Splitter, NewSplitter);
|
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
|
// Now we can insert the floating widget content into this container
|
||||||
auto Widget = FloatingWidget->dockContainer()->findChild<QWidget*>(QString(), Qt::FindDirectChildrenOnly);
|
auto FloatingSplitter = FloatingWidget->dockContainer()->rootSplitter();
|
||||||
auto FloatingSplitter = dynamic_cast<QSplitter*>(Widget);
|
if (FloatingSplitter->count() == 1)
|
||||||
if (DockAreas.isEmpty())
|
|
||||||
{
|
|
||||||
Splitter->addWidget(Widget);
|
|
||||||
}
|
|
||||||
else if (FloatingSplitter->count() == 1)
|
|
||||||
{
|
{
|
||||||
insertWidgetIntoSplitter(Splitter, FloatingSplitter->widget(0), InsertParam.append());
|
insertWidgetIntoSplitter(Splitter, FloatingSplitter->widget(0), InsertParam.append());
|
||||||
}
|
}
|
||||||
@ -203,6 +203,7 @@ void DockContainerWidgetPrivate::dropIntoContainer(CFloatingDockContainer* Float
|
|||||||
RootSplitter = Splitter;
|
RootSplitter = Splitter;
|
||||||
addDockAreasToList(NewDockAreas);
|
addDockAreasToList(NewDockAreas);
|
||||||
FloatingWidget->deleteLater();
|
FloatingWidget->deleteLater();
|
||||||
|
_this->dumpLayout();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -278,6 +279,7 @@ void DockContainerWidgetPrivate::dropIntoSection(CFloatingDockContainer* Floatin
|
|||||||
|
|
||||||
FloatingWidget->deleteLater();
|
FloatingWidget->deleteLater();
|
||||||
addDockAreasToList(NewDockAreas);
|
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,
|
CDockAreaWidget* DockContainerWidgetPrivate::dockWidgetIntoDockArea(DockWidgetArea area,
|
||||||
CDockWidget* Dockwidget, CDockAreaWidget* TargetDockArea)
|
CDockWidget* Dockwidget, CDockAreaWidget* TargetDockArea)
|
||||||
@ -681,6 +710,7 @@ void CDockContainerWidget::removeDockArea(CDockAreaWidget* area)
|
|||||||
QSplitter* ParentSplitter = internal::findParent<QSplitter*>(Splitter);
|
QSplitter* ParentSplitter = internal::findParent<QSplitter*>(Splitter);
|
||||||
internal::replaceSplitterWidget(ParentSplitter, Splitter, widget);
|
internal::replaceSplitterWidget(ParentSplitter, Splitter, widget);
|
||||||
delete Splitter;
|
delete Splitter;
|
||||||
|
dumpLayout();
|
||||||
emit dockAreasRemoved();
|
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
|
} // namespace ads
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
@ -59,6 +59,11 @@ protected:
|
|||||||
*/
|
*/
|
||||||
virtual bool event(QEvent *e) override;
|
virtual bool event(QEvent *e) override;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Access function for the internal root splitter
|
||||||
|
*/
|
||||||
|
QSplitter* rootSplitter() const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* Default Constructor
|
* Default Constructor
|
||||||
@ -147,6 +152,11 @@ public:
|
|||||||
*/
|
*/
|
||||||
bool restoreState(QDataStream& Stream, bool Testing);
|
bool restoreState(QDataStream& Stream, bool Testing);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Dumps the layout for debugging purposes
|
||||||
|
*/
|
||||||
|
void dumpLayout();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
/**
|
/**
|
||||||
* This signal is emitted if one or multiple dock areas has been added to
|
* 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)
|
if (CDockOverlay::ModeContainerOverlay == Mode && DockWidgetArea != CenterDockWidgetArea)
|
||||||
{
|
{
|
||||||
QRectF ArrowRect;
|
QRectF ArrowRect;
|
||||||
ArrowRect.setSize(ShadowRect.size() * 0.7);
|
ArrowRect.setSize(baseSize);
|
||||||
ArrowRect.setWidth(ArrowRect.width() / 4.6);
|
ArrowRect.setWidth(ArrowRect.width() / 4.6);
|
||||||
ArrowRect.setHeight(ArrowRect.height() / 2);
|
ArrowRect.setHeight(ArrowRect.height() / 2);
|
||||||
ArrowRect.moveCenter(QPointF(0, 0));
|
ArrowRect.moveCenter(QPointF(0, 0));
|
||||||
|
@ -267,8 +267,8 @@ void CDockWidgetTitleBar::mouseReleaseEvent(QMouseEvent* ev)
|
|||||||
//============================================================================
|
//============================================================================
|
||||||
void CDockWidgetTitleBar::mouseMoveEvent(QMouseEvent* ev)
|
void CDockWidgetTitleBar::mouseMoveEvent(QMouseEvent* ev)
|
||||||
{
|
{
|
||||||
std::cout << "CDockWidgetTitleBar::mouseMoveEventmouseMoveEvent DragState "
|
/*std::cout << "CDockWidgetTitleBar::mouseMoveEventmouseMoveEvent DragState "
|
||||||
<< d->DragState << std::endl;
|
<< d->DragState << std::endl;*/
|
||||||
if (!(ev->buttons() & Qt::LeftButton) || d->isDraggingState(DraggingInactive))
|
if (!(ev->buttons() & Qt::LeftButton) || d->isDraggingState(DraggingInactive))
|
||||||
{
|
{
|
||||||
d->DragState = DraggingInactive;
|
d->DragState = DraggingInactive;
|
||||||
@ -278,7 +278,7 @@ void CDockWidgetTitleBar::mouseMoveEvent(QMouseEvent* ev)
|
|||||||
|
|
||||||
if (d->isDraggingState(DraggingFloatingWidget))
|
if (d->isDraggingState(DraggingFloatingWidget))
|
||||||
{
|
{
|
||||||
std::cout << "DraggingFloatingWidget" << std::endl;
|
//std::cout << "DraggingFloatingWidget" << std::endl;
|
||||||
d->FloatingWidget->moveFloating();
|
d->FloatingWidget->moveFloating();
|
||||||
QFrame::mouseMoveEvent(ev);
|
QFrame::mouseMoveEvent(ev);
|
||||||
return;
|
return;
|
||||||
|
Loading…
Reference in New Issue
Block a user