20#include "MultiSplitter_p.h"
21#include "LayoutSaver_p.h"
23#include "DockRegistry_p.h"
25#include "DockWidgetBase_p.h"
26#include "FloatingWindow_p.h"
32#include "Position_p.h"
33#include "WindowBeingDragged_p.h"
35#include "multisplitter/Item_p.h"
37#include <QScopedValueRollback>
42 : LayoutWidget(parent)
45 setRootItem(
new Layouting::ItemBoxContainer(
this));
46 DockRegistry::self()->registerLayout(
this);
48 setLayoutSize(parent->
size());
51 updateSizeConstraints();
53 setMinimumSize(minimumSize());
56MultiSplitter::~MultiSplitter()
64 qWarning() << Q_FUNC_INFO <<
"Widget is null";
68 const bool isDockWidget = qobject_cast<DockWidgetBase *>(widget);
71 if (!qobject_cast<Frame *>(widget) && !qobject_cast<MultiSplitter *>(widget) && !isDockWidget) {
72 qWarning() <<
"Unknown widget type" << widget;
76 if (isDockWidget != isStartHidden) {
77 qWarning() <<
"Wrong parameters" << isDockWidget << isStartHidden;
81 if (relativeToFrame && relativeToFrame == widget) {
82 qWarning() <<
"widget can't be relative to itself";
86 Layouting::Item *item = itemForFrame(qobject_cast<Frame *>(widget));
88 if (containsItem(item)) {
89 qWarning() <<
"MultiSplitter::addWidget: Already contains" << widget;
94 qWarning() <<
"MultiSplitter::addWidget: not adding to location None";
98 const bool relativeToThis = relativeToFrame ==
nullptr;
100 Layouting::Item *relativeToItem = itemForFrame(relativeToFrame);
101 if (!relativeToThis && !containsItem(relativeToItem)) {
102 qWarning() <<
"MultiSplitter::addWidget: Doesn't contain relativeTo:"
103 <<
"; relativeToFrame=" << relativeToFrame
104 <<
"; relativeToItem=" << relativeToItem
105 <<
"; options=" << option;
113 Frame *relativeToWidget,
116 auto frame = qobject_cast<Frame *>(w);
117 if (itemForFrame(frame) !=
nullptr) {
120 frame->QWidgetAdapter::setParent(
nullptr);
121 frame->setLayoutItem(
nullptr);
125 if (!validateInputs(w, location, relativeToWidget, option))
128 Layouting::Item *relativeTo = itemForFrame(relativeToWidget);
130 relativeTo = m_rootItem;
132 Layouting::Item *newItem =
nullptr;
134 Frame::List frames = framesFrom(w);
135 unrefOldPlaceholders(frames);
136 auto dw = qobject_cast<DockWidgetBase *>(w);
139 newItem =
new Layouting::Item(
this);
140 newItem->setGuestWidget(frame);
142 newItem =
new Layouting::Item(
this);
144 newItem->setGuestWidget(frame);
145 frame->addWidget(dw, option);
146 }
else if (
auto ms = qobject_cast<MultiSplitter *>(w)) {
147 newItem = ms->m_rootItem;
148 newItem->setHostWidget(
this);
150 if (FloatingWindow *fw = ms->floatingWindow()) {
151 newItem->setSize_recursive(fw->size());
158 qWarning() << Q_FUNC_INFO <<
"Unknown widget added" << w;
162 Q_ASSERT(!newItem->geometry().isEmpty());
163 Layouting::ItemBoxContainer::insertItemRelativeTo(newItem, relativeTo, location, option);
169void MultiSplitter::addMultiSplitter(MultiSplitter *sourceMultiSplitter,
Location location,
173 qCDebug(addwidget) << Q_FUNC_INFO << sourceMultiSplitter << location << relativeTo;
174 addWidget(sourceMultiSplitter, location, relativeTo, option);
179 return m_rootItem->separators_recursive();
182int MultiSplitter::availableLengthForOrientation(
Qt::Orientation orientation)
const
185 return availableSize().height();
187 return availableSize().width();
190QSize MultiSplitter::availableSize()
const
192 return m_rootItem->availableSize();
195void MultiSplitter::layoutEqually()
200 layoutEqually(m_rootItem);
203void MultiSplitter::layoutEqually(Layouting::ItemBoxContainer *container)
206 container->layoutEqually_recursive();
208 qWarning() << Q_FUNC_INFO <<
"null container";
212void MultiSplitter::setRootItem(Layouting::ItemBoxContainer *root)
214 LayoutWidget::setRootItem(root);
218Layouting::ItemBoxContainer *MultiSplitter::rootItem()
const
223QRect MultiSplitter::rectForDrop(
const WindowBeingDragged *wbd,
Location location,
224 const Layouting::Item *relativeTo)
const
226 Layouting::Item item(
nullptr);
230 item.setSize(wbd->size().boundedTo(wbd->maxSize()));
231 item.setMinSize(wbd->minSize());
232 item.setMaxSizeHint(wbd->maxSize());
234 Layouting::ItemBoxContainer *container = relativeTo ? relativeTo->parentBoxContainer()
237 return container->suggestedDropRect(&item, relativeTo, location);
240bool MultiSplitter::deserialize(
const LayoutSaver::MultiSplitter &l)
242 setRootItem(
new Layouting::ItemBoxContainer(
this));
243 return LayoutWidget::deserialize(l);
248 return m_rootItem->numSideBySide_recursive(o);
Application-wide config to tune certain behaviours of the framework.
Class to save and restore dockwidget layouts.
The MainWindow base-class that's shared between QtWidgets and QtQuick stack.