5#include "QtWidgets/qapplication.h"
6#include "QtWidgets/qwidget.h"
8#include "QtWidgets/qtabbar.h"
10#include "QtWidgets/qstyle.h"
11#include "QtWidgets/qapplication.h"
12#include "QtCore/qvariant.h"
20#include <private/qlayoutengine_p.h>
70 if (
other.subinfo !=
nullptr)
72 else if (
other.placeHolderItem !=
nullptr)
145 return QSize(-1, -1);
156 if (
other.subinfo ==
nullptr)
162 if (
other.placeHolderItem ==
nullptr)
174#ifndef QT_NO_DEBUG_STREAM
179 return item ? dbg << *
item : dbg <<
"QDockAreaLayoutItem(0x0)";
186 dbg <<
"QDockAreaLayoutItem(" <<
static_cast<const void *
>(&
item) <<
"->";
187 if (
item.widgetItem) {
191 }
else if (
auto *groupWindow = qobject_cast<QDockWidgetGroupWindow *>(
widget)) {
192 dbg <<
"widgetItem(" << groupWindow <<
"->(" << groupWindow->dockWidgets() <<
"))";
194 dbg <<
"widgetItem(" <<
widget <<
")";
196 }
else if (
item.subinfo) {
197 dbg <<
"subInfo(" <<
item.subinfo <<
"->(" <<
item.subinfo->item_list <<
")";
198 }
else if (
item.placeHolderItem) {
199 dbg <<
"placeHolderItem(" <<
item.placeHolderItem <<
")";
213 if (
item.widgetItem ==
nullptr)
215 return reinterpret_cast<quintptr>(
item.widgetItem->widget());
232 :
sep(_sep), dockPos(_dockPos),
o(_o), mainWindow(
window)
237#if !QT_CONFIG(tabbar)
259 return next(-1) == -1;
265 if (!
item.placeHolderItem)
305 QSize tbm = tabBarMinimumSize();
307 switch (tabBarShape) {
312 result.rheight() += tbm.height();
320 result.rwidth() += tbm.width();
378 QSize tbh = tabBarSizeHint();
380 switch (tabBarShape) {
383 result.rheight() += tbh.height();
387 result.rwidth() += tbh.width();
435 max_perp =
qMax(max_perp, min_perp);
445 QSize tbh = tabBarSizeHint();
446 switch (tabBarShape) {
451 result.rheight() += tbh.height();
459 result.rwidth() += tbh.width();
490 for (
int i = 0;
i <
info.item_list.size(); ++
i) {
515 for (
int i = 0;
i <
info.item_list.size(); ++
i) {
547 QList<QLayoutStruct> layout_struct_list(
item_list.
size() * 2);
562 if (previous && !gap) {
566 ls.minimumSize = ls.maximumSize = ls.sizeHint = previous->
hasFixedSize(
o) ? 0 : *
sep;
575 if (
size < min_size) {
578 min_size -=
item.size;
580 min_size =
qMax(0, min_size);
581 }
else if (
size > max_size) {
584 max_size -=
item.size;
595 ls.minimumSize = ls.maximumSize = ls.sizeHint =
item.size;
596 ls.expansive =
false;
599 ls.maximumSize =
pick(
o,
item.maximumSize());
600 ls.expansive =
item.expansive(
o);
601 ls.minimumSize =
pick(
o,
item.minimumSize());
603 ls.stretch = ls.expansive ? ls.sizeHint : 0;
609 layout_struct_list.resize(
j);
613 if (
size > max_size && last_index != -1) {
615 layout_struct_list[last_index].expansive =
true;
621 bool prev_gap =
false;
629 if (!
first && !gap && !prev_gap)
636 if (
item.subinfo !=
nullptr) {
638 item.subinfo->fitItems();
658 int w =
rect.width();
659 int h =
rect.height();
663 if (nestingEnabled) {
674 if (center.contains(
pos))
686 if (
x >
w/6 &&
x <
w*5/6)
696 if (
y >
h/6 &&
y < 5*
h/6)
702 if (nestingEnabled) {
749 bool nestingEnabled,
TabMode tabMode)
const
757 item_rect = tabContentRect();
774 if (
item.subinfo !=
nullptr
776 && !
item.subinfo->tabbed
779 result =
item.subinfo->gapIndex(_pos, nestingEnabled,
790 if (item_rect.isNull()) {
806 result << item_index << 0;
813 result << item_index << 1;
817 result << item_index << 0;
823 result << item_index << 1;
828 result << (-item_index - 1) << 0;
843 int old_size = ls.size;
844 ls.size =
qMax(ls.size - delta, ls.minimumSize);
845 return old_size - ls.size;
852 int old_size = ls.size;
853 ls.size =
qMin(ls.size + delta, ls.maximumSize);
854 return ls.size - old_size;
881 growlimit += ls.maximumSize - ls.size;
883 if (delta > growlimit)
891 for (
int i =
index; d < delta && i >= 0; --
i)
893 }
else if (delta < 0) {
903 growlimit += ls.maximumSize - ls.size;
905 if (-delta > growlimit)
909 for (
int i =
index;
d < -delta &&
i >= 0; --
i)
949 const int separatorSpace =
item.hasFixedSize(
o) ? 0 : *
sep;
952 ls.size =
item.size + separatorSpace;
953 ls.minimumSize =
pick(
o,
item.minimumSize()) + separatorSpace;
954 ls.maximumSize =
pick(
o,
item.maximumSize()) + separatorSpace;
967 const int separatorSpace =
item.hasFixedSize(
o) ? 0 : *
sep;
968 item.size = ls.size - separatorSpace;
970 if (
item.subinfo !=
nullptr) {
972 item.subinfo->fitItems();
982 if (
item.subinfo ==
nullptr)
984 if (
item.subinfo->item_list.size() > 1)
987 if (
item.subinfo->item_list.size() == 0) {
989 }
else if (
item.subinfo->item_list.size() == 1) {
991 if (
child.widgetItem !=
nullptr) {
994 item.subinfo =
nullptr;
995 }
else if (
child.subinfo !=
nullptr) {
998 child.subinfo =
nullptr;
1009 if (
path.size() > 1) {
1037 if (
path.size() > 1) {
1040 return item.subinfo->plug(
path.mid(1));
1048 return item.widgetItem;
1056 if (
path.size() > 1) {
1059 return item.subinfo->unplug(
path.mid(1));
1069#if QT_CONFIG(tabbar)
1082 return item.widgetItem;
1085#if QT_CONFIG(tabbar)
1087quintptr QDockAreaLayoutInfo::currentTabId()
const
1089 if (!tabbed || tabBar ==
nullptr)
1092 int index = tabBar->currentIndex();
1096 return qvariant_cast<quintptr>(tabBar->tabData(
index));
1104void QDockAreaLayoutInfo::setCurrentTabId(
quintptr id)
1106 if (!tabbed || tabBar ==
nullptr)
1109 for (
int i = 0;
i < tabBar->count(); ++
i) {
1110 if (qvariant_cast<quintptr>(tabBar->tabData(
i)) ==
id) {
1111 tabBar->setCurrentIndex(
i);
1121 int titleHeight = 0;
1126 titleHeight =
layout->titleHeight();
1152 bool insert_tabbed =
false;
1155 insert_tabbed =
true;
1159 if (
path.size() > 1) {
1162 if (
item.subinfo ==
nullptr
1164 || (
item.subinfo->tabbed && !insert_tabbed)
1176#if !QT_CONFIG(tabbar)
1177 const int tabBarShape = 0;
1183 item.subinfo = new_info;
1184 item.widgetItem =
nullptr;
1185 item.placeHolderItem =
nullptr;
1188 = widgetItem ==
nullptr
1191 new_item.size =
pick(opposite,
r.size());
1192 new_item.pos =
pick(opposite,
r.topLeft());
1193 new_info->item_list.append(new_item);
1194#if QT_CONFIG(tabbar)
1195 if (insert_tabbed) {
1196 new_info->tabbed =
true;
1201 return item.subinfo->insertGap(
path.mid(1), dockWidgetItem);
1207 gap_item.widgetItem = dockWidgetItem;
1209#if QT_CONFIG(tabbar)
1246 "QDockAreaLayoutInfo::insertGap",
"inserting two gaps after each other");
1260 gap_size =
pick(
o,
r.size());
1266 if (gap_size + sep_size > space)
1267 gap_size =
pick(
o, gap_item.minimumSize());
1268 gap_item.size = gap_size + sep_size;
1273 qCDebug(lcQpaDockWidgets) <<
"Insert gap after:" <<
index <<
this;
1285#if QT_CONFIG(tabbar)
1286 if (tabbed &&
widget == tabBar)
1290 if (
item.widgetItem !=
nullptr &&
item.widgetItem->widget() ==
widget)
1293 if (
item.subinfo !=
nullptr) {
1326#if QT_CONFIG(tabbar)
1328 if (isGap || tabId(
item) == currentTabId())
1329 result = tabContentRect();
1364 if (
path.size() > 1) {
1367 return item.subinfo->itemRect(
path.mid(1));
1375#if QT_CONFIG(tabbar)
1397 if (
path.size() > 1) {
1400 return item.subinfo->separatorRect(
path.mid(1));
1407#if QT_CONFIG(tabbar)
1409 return QList<int>();
1420 if (
item.subinfo !=
nullptr) {
1421 QList<int>
result =
item.subinfo->findSeparator(_pos);
1426 return QList<int>();
1436 if (!sepRect.isNull() && *
sep == 1)
1437 sepRect.adjust(-2, -2, 2, 2);
1439 if (sepRect.contains(_pos) && !
item.hasFixedSize(
o)) {
1440 return QList<int>() <<
i;
1445 return QList<int>();
1453 if (
item.subinfo !=
nullptr) {
1454 QList<int>
result =
item.subinfo->indexOfPlaceHolder(objectName);
1462 if (
item.placeHolderItem !=
nullptr &&
item.placeHolderItem->objectName == objectName) {
1469 return QList<int>();
1477 if (
item.placeHolderItem !=
nullptr)
1480 if (
item.subinfo !=
nullptr) {
1496 return QList<int>();
1518#if QT_CONFIG(tabbar)
1521 QSize tbh = tabBarSizeHint();
1523 if (!tbh.isNull()) {
1524 switch (tabBarShape) {
1549 widgetAnimator.
animate(tabBar, tab_rect, animate);
1561 if (
item.subinfo !=
nullptr) {
1562 item.subinfo->apply(animate);
1573 QRect geo =
w->geometry();
1575 if (!
w->isHidden() &&
w->window()->isVisible()) {
1577 if (!
r.isValid() && geo.right() >= 0 && geo.bottom() >= 0) {
1579 emit dw->visibilityChanged(
false);
1580 }
else if (
r.isValid()
1581 && (geo.right() < 0 || geo.bottom() < 0)) {
1582 emit dw->visibilityChanged(
true);
1587#if QT_CONFIG(tabbar)
1589 updateSeparatorWidgets();
1617#if QT_CONFIG(tabbar)
1643 const QPoint &mouse)
const
1647#if QT_CONFIG(tabbar)
1665 item.subinfo->paintSeparators(
p,
widget, clip, mouse);
1687 for (
int i =
index - 1;
i >= 0; --
i) {
1694#if QT_CONFIG(tabbar)
1700 setCurrentTab(dockWidgetItem->widget());
1708 new_info->tabbed =
true;
1709 new_info->updateTabBar();
1710 new_info->setCurrentTab(dockWidgetItem->widget());
1718 if (orientation ==
o) {
1721#if !QT_CONFIG(tabbar)
1722 const int tabBarShape = 0;
1737 if (
path.size() > 1) {
1740 return item.subinfo->item(
path.mid(1));
1749 if (
item.placeHolderItem !=
nullptr)
1754 }
else if (
item.widgetItem) {
1756 return item.widgetItem;
1766 if (
item.placeHolderItem !=
nullptr)
1768 else if (
item.subinfo) {
1773 }
else if (
item.widgetItem) {
1777 item.widgetItem =
nullptr;
1778 if (
item.size != -1)
1799 if (
auto *groupWindow = qobject_cast<QDockWidgetGroupWindow *>(
widget)) {
1804 qFatal(
"Coding error. Add supports only QDockWidget and QDockWidgetGroupWindow");
1812 item.subinfo->deleteAllLayoutItems();
1814 delete item.widgetItem;
1815 item.widgetItem =
nullptr;
1822#if QT_CONFIG(tabbar)
1846 if (
item.widgetItem !=
nullptr) {
1851 qWarning(
"QMainWindow::saveState(): 'objectName' not set for QDockWidget %p '%ls;",
1863 if (
w->isWindow()) {
1864 const QRect geometry =
w->geometry();
1870 }
else if (
item.placeHolderItem !=
nullptr) {
1874 if (!
item.placeHolderItem->hidden)
1880 QRect r =
item.placeHolderItem->topLevelRect;
1881 stream <<
r.
x() <<
r.y() <<
r.width() <<
r.height();
1885 }
else if (
item.subinfo !=
nullptr) {
1911#if QT_CONFIG(tabbar)
1926 for (
int i = 0;
i < cnt; ++
i) {
1933 if (
name.isEmpty()) {
1935 stream >> dummy >> dummy >> dummy >> dummy;
1951 placeHolder->objectName =
name;
1954 if (placeHolder->window) {
1957 placeHolder->topLevelRect =
QRect(
x,
y,
w,
h);
1962 if (
item.size != -1)
1969 bool drawer =
false;
1974 widget->setFloating(
true);
1992 widget->setFloating(
false);
1999 delete item.widgetItem;
2000 item.widgetItem =
nullptr;
2005#if !QT_CONFIG(tabbar)
2006 const int tabBarShape = 0;
2026#if QT_CONFIG(tabbar)
2031 if (!testing && *
sep == 1)
2032 updateSeparatorWidgets();
2038#if QT_CONFIG(tabbar)
2039void QDockAreaLayoutInfo::updateSeparatorWidgets()
const
2059 item.subinfo->updateSeparatorWidgets();
2069 qWarning(
"QDockAreaLayoutInfo::updateSeparatorWidgets: null separator widget");
2083 sepWidget->setGeometry(sepRect);
2099void QDockAreaLayoutInfo::reparentWidgets(
QWidget *parent)
2102 tabBar->setParent(parent);
2109 item.subinfo->reparentWidgets(parent);
2110 if (
item.widgetItem) {
2112 if (qobject_cast<QDockWidgetGroupWindow *>(
w))
2114 if (
w->parent() != parent) {
2115 bool hidden =
w->isHidden();
2116 w->setParent(parent,
w->windowFlags());
2125bool QDockAreaLayoutInfo::updateTabBar()
const
2132 if (that->tabBar ==
nullptr) {
2134 that->tabBar->setShape(
static_cast<QTabBar::Shape>(tabBarShape));
2135 that->tabBar->setDrawBase(
true);
2141 const quintptr oldCurrentId = currentTabId();
2152 if (
item.widgetItem ==
nullptr)
2155 QDockWidget *dw = qobject_cast<QDockWidget*>(
item.widgetItem->widget());
2158 if (tab_idx == tabBar->count()) {
2159 tabBar->insertTab(tab_idx,
title);
2160#if QT_CONFIG(tooltip)
2161 tabBar->setTabToolTip(tab_idx,
title);
2163 tabBar->setTabData(tab_idx,
id);
2164 }
else if (qvariant_cast<quintptr>(tabBar->tabData(tab_idx)) !=
id) {
2165 if (tab_idx + 1 < tabBar->count()
2166 && qvariant_cast<quintptr>(tabBar->tabData(tab_idx + 1)) ==
id)
2167 tabBar->removeTab(tab_idx);
2169 tabBar->insertTab(tab_idx,
title);
2170#if QT_CONFIG(tooltip)
2171 tabBar->setTabToolTip(tab_idx,
title);
2173 tabBar->setTabData(tab_idx,
id);
2177 if (
title != tabBar->tabText(tab_idx)) {
2178 tabBar->setTabText(tab_idx,
title);
2179#if QT_CONFIG(tooltip)
2180 tabBar->setTabToolTip(tab_idx,
title);
2187 while (tab_idx < tabBar->
count()) {
2188 tabBar->removeTab(tab_idx);
2191 if (oldCurrentId > 0 && currentTabId() != oldCurrentId)
2192 that->setCurrentTabId(oldCurrentId);
2194 if (QDockWidgetGroupWindow *dwgw = qobject_cast<QDockWidgetGroupWindow *>(tabBar->parent()))
2195 dwgw->adjustFlags();
2198 return ( (gap ? 1 : 0) + tabBar->
count()) > 1;
2201void QDockAreaLayoutInfo::setTabBarShape(
int shape)
2203 if (shape == tabBarShape)
2205 tabBarShape = shape;
2206 if (tabBar !=
nullptr)
2211 if (
item.subinfo !=
nullptr)
2212 item.subinfo->setTabBarShape(shape);
2216QSize QDockAreaLayoutInfo::tabBarMinimumSize()
const
2218 if (!updateTabBar())
2221 return tabBar->minimumSizeHint();
2224QSize QDockAreaLayoutInfo::tabBarSizeHint()
const
2226 if (!updateTabBar())
2229 return tabBar->sizeHint();
2232QSet<QTabBar*> QDockAreaLayoutInfo::usedTabBars()
const
2243 if (
item.subinfo !=
nullptr)
2252QSet<QWidget*> QDockAreaLayoutInfo::usedSeparatorWidgets()
const
2256 result.reserve(numSeparatorWidgets);
2258 for (
int i = 0;
i < numSeparatorWidgets; ++
i)
2263 if (
item.subinfo !=
nullptr)
2264 result +=
item.subinfo->usedSeparatorWidgets();
2270QRect QDockAreaLayoutInfo::tabContentRect()
const
2276 QSize tbh = tabBarSizeHint();
2278 if (!tbh.isNull()) {
2279 switch (tabBarShape) {
2282 result.adjust(0, tbh.height(), 0, 0);
2286 result.adjust(0, 0, 0, -tbh.height());
2290 result.adjust(0, 0, -tbh.width(), 0);
2294 result.adjust(tbh.width(), 0, 0, 0);
2304int QDockAreaLayoutInfo::tabIndexToListIndex(
int tabIndex)
const
2307 quintptr data = qvariant_cast<quintptr>(tabBar->tabData(tabIndex));
2315void QDockAreaLayoutInfo::moveTab(
int from,
int to)
2317 item_list.
move(tabIndexToListIndex(from), tabIndexToListIndex(to));
2329#if QT_CONFIG(tabbar)
2332 const int tabShape = 0;
2374 for (
int i = 0;
i < 4; ++
i)
2380 QList<QDockWidget*> dockwidgets = _dockwidgets;
2384 for (
int i = 0;
i < cnt; ++
i) {
2393 stream.setStatus(QDataStream::ReadCorruptData);
2402 bool ok =
stream.status() == QDataStream::Ok;
2406 for (
int i = 0;
i < 4; ++
i)
2408 if (
stream.status() == QDataStream::Ok) {
2409 for (
int i = 0;
i < 4; ++
i)
2429 return QList<int>();
2441 return QList<int>();
2449#if QT_CONFIG(tabbar)
2450 if (!disallowTabs) {
2457 nestingEnabled =
false;
2477 if (
info.isEmpty()) {
2479 if (
r.contains(
pos)) {
2483 return QList<int>() <<
i << -1 << 0;
2485 return QList<int>() <<
i << 0;
2491 return QList<int>();
2496 Q_ASSERT_X(
mainWindow,
"QDockAreaLayout::gapRect",
"Called without valid mainWindow pointer.");
2505 "QDockAreaLayout::gapRect: Main window height %i is too small. Docking will not be possible.",
2511 "QDockAreaLayout::gapRect: Main window width %i is too small. Docking will not be possible.",
2544 }
else if (
info.rect.contains(
pos)) {
2572 if (
path.size() == 1)
2607 return QRect(
r.right() + 1,
r.top(),
sep,
r.height());
2611 return QRect(
r.left(),
r.bottom() + 1,
r.width(),
sep);
2627 if (
path.size() == 1)
2643#if QT_CONFIG(tabbar)
2674 if (!
index.isEmpty())
2678 for (QDockWidgetGroupWindow *dwgw :
groups) {
2679 index = dwgw->layoutInfo()->indexOfPlaceHolder(
name);
2680 if (!
index.isEmpty()) {
2681 dwgw->layoutInfo()->remove(
index);
2682 dwgw->destroyOrHideIfEmpty();
2687static inline int qMax(
int i1,
int i2,
int i3) {
return qMax(i1,
qMax(i2, i3)); }
2690 QList<QLayoutStruct> *_hor_struct_list)
2692 QSize center_hint(0, 0);
2693 QSize center_min(0, 0);
2694 QSize center_max(0, 0);
2698 if (!center_hint.isValid())
2719 left_hint = left_hint.
boundedTo(left_max).expandedTo(left_min);
2726 right_hint = right_hint.
boundedTo(right_max).expandedTo(right_min);
2733 top_hint = top_hint.
boundedTo(top_max).expandedTo(top_min);
2740 bottom_hint = bottom_hint.
boundedTo(bottom_max).expandedTo(bottom_min);
2742 if (_ver_struct_list !=
nullptr) {
2743 QList<QLayoutStruct> &ver_struct_list = *_ver_struct_list;
2744 ver_struct_list.resize(3);
2747 ver_struct_list[0].init();
2748 ver_struct_list[0].stretch = 0;
2749 ver_struct_list[0].sizeHint = top_hint.height();
2750 ver_struct_list[0].minimumSize = top_min.height();
2751 ver_struct_list[0].maximumSize = top_max.height();
2752 ver_struct_list[0].expansive =
false;
2758 ver_struct_list[1].init();
2759 ver_struct_list[1].stretch = center_hint.height();
2770 int left = (tl_significant && bl_significant) ? left_hint.height() : 0;
2771 int right = (tr_significant && br_significant) ? right_hint.height() : 0;
2772 ver_struct_list[1].sizeHint =
qMax(
left, center_hint.height(),
right);
2774 left = (tl_significant && bl_significant) ? left_min.height() : 0;
2775 right = (tr_significant && br_significant) ? right_min.height() : 0;
2776 ver_struct_list[1].minimumSize =
qMax(
left, center_min.height(),
right);
2777 ver_struct_list[1].maximumSize = center_max.height();
2778 ver_struct_list[1].expansive = have_central;
2782 ver_struct_list[1].pos = center_rect.top();
2783 ver_struct_list[1].size = center_rect.height();
2786 ver_struct_list[2].init();
2787 ver_struct_list[2].stretch = 0;
2788 ver_struct_list[2].sizeHint = bottom_hint.height();
2789 ver_struct_list[2].minimumSize = bottom_min.height();
2790 ver_struct_list[2].maximumSize = bottom_max.height();
2791 ver_struct_list[2].expansive =
false;
2796 for (
int i = 0;
i < 3; ++
i) {
2797 ver_struct_list[
i].sizeHint
2800 if (have_central && ver_struct_list[0].empty && ver_struct_list[2].empty)
2804 if (_hor_struct_list !=
nullptr) {
2805 QList<QLayoutStruct> &hor_struct_list = *_hor_struct_list;
2806 hor_struct_list.resize(3);
2809 hor_struct_list[0].init();
2810 hor_struct_list[0].stretch = 0;
2811 hor_struct_list[0].sizeHint = left_hint.width();
2812 hor_struct_list[0].minimumSize = left_min.width();
2813 hor_struct_list[0].maximumSize = left_max.width();
2814 hor_struct_list[0].expansive =
false;
2820 hor_struct_list[1].init();
2821 hor_struct_list[1].stretch = center_hint.width();
2832 int top = (tl_significant && tr_significant) ? top_hint.width() : 0;
2833 int bottom = (bl_significant && br_significant) ? bottom_hint.width() : 0;
2834 hor_struct_list[1].sizeHint =
qMax(
top, center_hint.width(),
bottom);
2836 top = (tl_significant && tr_significant) ? top_min.width() : 0;
2837 bottom = (bl_significant && br_significant) ? bottom_min.width() : 0;
2838 hor_struct_list[1].minimumSize =
qMax(
top, center_min.width(),
bottom);
2840 hor_struct_list[1].maximumSize = center_max.width();
2841 hor_struct_list[1].expansive = have_central;
2842 hor_struct_list[1].empty = !have_central;
2843 hor_struct_list[1].pos = center_rect.left();
2844 hor_struct_list[1].size = center_rect.width();
2847 hor_struct_list[2].init();
2848 hor_struct_list[2].stretch = 0;
2849 hor_struct_list[2].sizeHint = right_hint.width();
2850 hor_struct_list[2].minimumSize = right_min.width();
2851 hor_struct_list[2].maximumSize = right_max.width();
2852 hor_struct_list[2].expansive =
false;
2857 for (
int i = 0;
i < 3; ++
i) {
2858 hor_struct_list[
i].sizeHint
2861 if (have_central && hor_struct_list[0].empty && hor_struct_list[2].empty)
2868 QList<QLayoutStruct> *hor_struct_list)
2875 if (hor_struct_list !=
nullptr) {
2878 ?
rect.
left() : hor_struct_list->at(1).pos);
2881 ?
rect.
right() : hor_struct_list->at(2).pos -
sep - 1);
2883 if (ver_struct_list !=
nullptr) {
2885 r.setBottom(ver_struct_list->at(1).pos -
sep - 1);
2895 if (hor_struct_list !=
nullptr) {
2898 ?
rect.
left() : hor_struct_list->at(1).pos);
2901 ?
rect.
right() : hor_struct_list->at(2).pos -
sep - 1);
2903 if (ver_struct_list !=
nullptr) {
2904 r.setTop(ver_struct_list->at(2).pos);
2915 if (hor_struct_list !=
nullptr) {
2917 r.setRight(hor_struct_list->at(1).pos -
sep - 1);
2919 if (ver_struct_list !=
nullptr) {
2922 ?
rect.
top() : ver_struct_list->at(1).pos);
2935 if (hor_struct_list !=
nullptr) {
2936 r.
setLeft(hor_struct_list->at(2).pos);
2939 if (ver_struct_list !=
nullptr) {
2942 ?
rect.
top() : ver_struct_list->at(1).pos);
2953 if (hor_struct_list !=
nullptr) {
2957 if (ver_struct_list !=
nullptr) {
2965 QList<QLayoutStruct> ver_struct_list(3);
2966 QList<QLayoutStruct> hor_struct_list(3);
2967 getGrid(&ver_struct_list, &hor_struct_list);
2972 setGrid(&ver_struct_list, &hor_struct_list);
2984template<
typename SizePMF,
typename CenterPMF>
3006 int row1 =
top.width();
3007 int row2 =
left.width() + center.width() +
right.width();
3008 int row3 =
bottom.width();
3009 int col1 =
left.height();
3010 int col2 =
top.height() + center.height() +
bottom.height();
3011 int col3 =
right.height();
3014 row1 +=
left.width();
3016 col1 +=
top.height();
3019 row1 +=
right.width();
3021 col3 +=
top.height();
3024 row3 +=
left.width();
3029 row3 +=
right.width();
3033 return QSize(
qMax(row1, row2, row3),
qMax(col1, col2, col3));
3088 for (QDockWidgetGroupWindow *dwgw :
groups) {
3090 if (!
index.isEmpty()) {
3098 if (
index.isEmpty())
3108 if (placeHolder->window) {
3114 item->placeHolderItem =
nullptr;
3125 if (orientation ==
info.o ||
info.item_list.size() <= 1) {
3128 info.o = orientation;
3131 info.item_list.append(new_item);
3132#if QT_CONFIG(tabbar)
3133 if (
info.tabbed && !new_item.skip()) {
3134 info.updateTabBar();
3135 info.setCurrentTabId(tabId(new_item));
3139#if QT_CONFIG(tabbar)
3140 int tbshape =
info.tabBarShape;
3153#if QT_CONFIG(tabbar)
3172 qWarning(
"QMainWidget::resizeDocks: size of the lists are not the same");
3180 qWarning(
"QMainWidget::resizeDocks: one QDockWidget is not part of the layout");
3185 qWarning(
"QMainWidget::resizeDocks: all sizes need to be larger than 0");
3189 while (
path.size() > 1) {
3191#if QT_CONFIG(tabbar)
3208 const int dockNum =
path.constFirst();
3210 QRect &
r = this->docks[dockNum].rect;
3242#if QT_CONFIG(tabbar)
3244 updateSeparatorWidgets();
3250 const QPoint &mouse)
const
3257 if (clip.
contains(
r) && !dock.hasFixedSize()) {
3263 dock.paintSeparators(
p,
widget, clip, mouse);
3276 result |= dock.separatorRegion();
3286 int index = separator.last();
3288 if (separator.size() > 1) {
3290 delta =
pick(
info->o, dest - origin);
3292 delta =
info->separatorMove(
index, delta);
3297 QList<QLayoutStruct>
list;
3310 delta =
pick(
o, dest - origin);
3329 int index = separator.last();
3331 delta =
pick(
info->o, dest - origin);
3333 delta =
info->separatorMove(
index, delta);
3338#if QT_CONFIG(tabbar)
3341void QDockAreaLayout::updateSeparatorWidgets()
const
3354 qWarning(
"QDockAreaLayout::updateSeparatorWidgets: null separator widget");
3368 sepWidget->setGeometry(sepRect);
3420#if QT_CONFIG(tabbar)
3421QSet<QTabBar*> QDockAreaLayout::usedTabBars()
const
3426 result += dock.usedTabBars();
3432QSet<QWidget*> QDockAreaLayout::usedSeparatorWidgets()
const
3436 result.reserve(numSeparators);
3437 for (
int i = 0;
i < numSeparators; ++
i)
3441 result += dock.usedSeparatorWidgets();
3450 if (
info ==
nullptr)
3453 if (index < 0 || index >=
info->item_list.size())
3464 if (
item.size != -1)
\inmodule QtCore\reentrant
QLayoutItem * plug(const QList< int > &path)
void split(int index, Qt::Orientation orientation, QLayoutItem *dockWidgetItem)
QMainWindowLayout * mainWindowLayout() const
QSize minimumSize() const
QLayoutItem * takeAt(int *x, int index)
bool hasFixedSize() const
bool expansive(Qt::Orientation o) const
bool restoreState(QDataStream &stream, QList< QDockWidget * > &widgets, bool testing)
QRect separatorRect(int index) const
QDockWidget * apply(bool animate)
QInternal::DockPosition dockPos
QDockAreaLayoutItem & item(const QList< int > &path)
bool onlyHasPlaceholders() const
void saveState(QDataStream &stream) const
void paintSeparators(QPainter *p, QWidget *widget, const QRegion &clip, const QPoint &mouse) const
QLayoutItem * itemAt(int *x, int index) const
QList< int > indexOf(QWidget *widget) const
QList< QDockAreaLayoutItem > item_list
void add(QWidget *widget)
bool insertGap(const QList< int > &path, QLayoutItem *dockWidgetItem)
QLayoutItem * unplug(const QList< int > &path)
QRect itemRect(int index, bool isGap=false) const
QList< int > findSeparator(const QPoint &pos) const
void remove(const QList< int > &path)
int separatorMove(int index, int delta)
QList< int > indexOfPlaceHolder(const QString &objectName) const
QDockAreaLayoutInfo * info(const QList< int > &path)
QSize maximumSize() const
void deleteAllLayoutItems()
QRegion separatorRegion() const
QList< QWidget * > separatorWidgets
QList< int > gapIndex(const QPoint &pos, bool nestingEnabled, TabMode tabMode) const
bool hasGapItem(const QList< int > &path) const
QRect itemRect(const QList< int > &path) const
QSize size_helper(SizePMF sizeFn, CenterPMF centerFn) const
QLayoutItem * centralWidgetItem
QLayoutItem * itemAt(int *x, int index) const
QLayoutItem * unplug(const QList< int > &path)
QLayoutItem * plug(const QList< int > &path)
QList< int > gapIndex(const QPoint &pos, bool disallowTabs) const
QDockAreaLayoutInfo * info(const QList< int > &path)
void splitDockWidget(QDockWidget *after, QDockWidget *dockWidget, Qt::Orientation orientation)
QList< int > findSeparator(const QPoint &pos) const
bool restoreDockWidget(QDockWidget *dockWidget)
void setGrid(QList< QLayoutStruct > *ver_struct_list, QList< QLayoutStruct > *hor_struct_list)
QSize minimumSize() const
bool restoreState(QDataStream &stream, const QList< QDockWidget * > &widgets, bool testing=false)
void resizeDocks(const QList< QDockWidget * > &docks, const QList< int > &sizes, Qt::Orientation o)
QRect gapRect(const QList< int > &path) const
QDockAreaLayout(QMainWindow *win)
void addDockWidget(QInternal::DockPosition pos, QDockWidget *dockWidget, Qt::Orientation orientation)
void keepSize(QDockWidget *w)
QList< int > indexOfPlaceHolder(const QString &objectName) const
void remove(const QList< int > &path)
QDockAreaLayoutItem & item(const QList< int > &path)
QSize minimumStableSize() const
void deleteAllLayoutItems()
static QRect constrainedRect(QRect rect, QWidget *widget)
QRect separatorRect(int index) const
void removePlaceHolder(const QString &name)
void getGrid(QList< QLayoutStruct > *ver_struct_list, QList< QLayoutStruct > *hor_struct_list)
QDockAreaLayoutInfo docks[4]
QRegion separatorRegion() const
int separatorMove(const QList< int > &separator, const QPoint &origin, const QPoint &dest)
Qt::DockWidgetArea corners[4]
bool insertGap(const QList< int > &path, QLayoutItem *dockWidgetItem)
void paintSeparators(QPainter *p, QWidget *widget, const QRegion &clip, const QPoint &mouse) const
QLayoutItem * takeAt(int *x, int index)
QList< QWidget * > separatorWidgets
void saveState(QDataStream &stream) const
QList< int > indexOf(QWidget *dockWidget) const
void show()
Shows the item (items are visible by default).
QPointF pos() const
Returns the position of the item in parent coordinates.
QGraphicsWidget * window() const
qreal x() const
This convenience function is equivalent to calling pos().x().
GraphicsItemFlags flags() const
Returns this item's flags.
QScreen * primaryScreen
the primary (or default) screen of the application.
static QScreen * screenAt(const QPoint &point)
Returns the screen at point, or \nullptr if outside of any screen.
The QLayoutItem class provides an abstract item that a QLayout manipulates.
virtual Qt::Orientations expandingDirections() const =0
Returns whether this layout item can make use of more space than sizeHint().
virtual QSize minimumSize() const =0
Implemented in subclasses to return the minimum size of this item.
virtual bool isEmpty() const =0
Implemented in subclasses to return whether this item is empty, i.e.
virtual QSize maximumSize() const =0
Implemented in subclasses to return the maximum size of this item.
virtual QWidget * widget() const
If this item manages a QWidget, returns that widget.
virtual QSize sizeHint() const =0
Implemented in subclasses to return the preferred size of this item.
qsizetype size() const noexcept
void removeAt(qsizetype i)
iterator insert(qsizetype i, parameter_type t)
const_reference at(qsizetype i) const noexcept
void move(qsizetype from, qsizetype to)
qsizetype count() const noexcept
void prepend(rvalue_ref t)
void resize(qsizetype size)
void append(parameter_type t)
QWidgetAnimator widgetAnimator
The QMainWindow class provides a main application window.
DockOptions dockOptions
the docking behavior of QMainWindow
QString objectName
the name of this object
QList< T > findChildren(QAnyStringView aName, Qt::FindChildOptions options=Qt::FindChildrenRecursively) const
Returns all children of this object with the given name that can be cast to type T,...
The QPainter class performs low-level painting on widgets and other paint devices.
\inmodule QtCore\reentrant
constexpr int x() const noexcept
Returns the x coordinate of this point.
\inmodule QtCore\reentrant
constexpr void adjust(int x1, int y1, int x2, int y2) noexcept
Adds dx1, dy1, dx2 and dy2 respectively to the existing coordinates of the rectangle.
constexpr void moveBottom(int pos) noexcept
Moves the rectangle vertically, leaving the rectangle's bottom edge at the given y coordinate.
constexpr void moveRight(int pos) noexcept
Moves the rectangle horizontally, leaving the rectangle's right edge at the given x coordinate.
constexpr int height() const noexcept
Returns the height of the rectangle.
constexpr bool isValid() const noexcept
Returns true if the rectangle is valid, otherwise returns false.
constexpr bool isNull() const noexcept
Returns true if the rectangle is a null rectangle, otherwise returns false.
constexpr int bottom() const noexcept
Returns the y-coordinate of the rectangle's bottom edge.
constexpr QPoint topLeft() const noexcept
Returns the position of the rectangle's top-left corner.
constexpr QRect adjusted(int x1, int y1, int x2, int y2) const noexcept
Returns a new rectangle with dx1, dy1, dx2 and dy2 added respectively to the existing coordinates of ...
constexpr int top() const noexcept
Returns the y-coordinate of the rectangle's top edge.
constexpr void moveLeft(int pos) noexcept
Moves the rectangle horizontally, leaving the rectangle's left edge at the given x coordinate.
bool contains(const QRect &r, bool proper=false) const noexcept
This is an overloaded member function, provided for convenience. It differs from the above function o...
constexpr void setLeft(int pos) noexcept
Sets the left edge of the rectangle to the given x coordinate.
constexpr int left() const noexcept
Returns the x-coordinate of the rectangle's left edge.
constexpr int x() const noexcept
Returns the x-coordinate of the rectangle's left edge.
constexpr void setWidth(int w) noexcept
Sets the width of the rectangle to the given width.
constexpr QSize size() const noexcept
Returns the size of the rectangle.
constexpr int width() const noexcept
Returns the width of the rectangle.
constexpr int y() const noexcept
Returns the y-coordinate of the rectangle's top edge.
constexpr void setHeight(int h) noexcept
Sets the height of the rectangle to the given height.
constexpr void moveTop(int pos) noexcept
Moves the rectangle vertically, leaving the rectangle's top edge at the given y coordinate.
constexpr int right() const noexcept
Returns the x-coordinate of the rectangle's right edge.
constexpr void setTop(int pos) noexcept
Sets the top edge of the rectangle to the given y coordinate.
The QRegion class specifies a clip region for a painter.
bool contains(const QPoint &p) const
Returns true if the region contains the point p; otherwise returns false.
The QScreen class is used to query screen properties. \inmodule QtGui.
QRect geometry
the screen's geometry in pixels
Exception-safe wrapper around QObject::blockSignals().
constexpr QSize boundedTo(const QSize &) const noexcept
Returns a size holding the minimum width and height of this size and the given otherSize.
\macro QT_RESTRICTED_CAST_FROM_ASCII
The QStyleOption class stores the parameters used by QStyle functions.
@ PM_DockWidgetSeparatorExtent
@ PE_IndicatorDockWidgetResizeHandle
virtual int pixelMetric(PixelMetric metric, const QStyleOption *option=nullptr, const QWidget *widget=nullptr) const =0
Returns the value of the given pixel metric.
The QTabBar class provides a tab bar, e.g.
Shape
This enum type lists the built-in shapes supported by QTabBar.
Combined button and popup list for selecting options.
static int grow(QLayoutStruct &ls, int delta)
QDebug operator<<(QDebug dbg, const QDockAreaLayoutItem *item)
static QRect dockedGeometry(QWidget *widget)
static Qt::DockWidgetArea toDockWidgetArea(QInternal::DockPosition pos)
static int realMinSize(const QDockAreaLayoutInfo &info)
static int qMax(int i1, int i2, int i3)
static int shrink(QLayoutStruct &ls, int delta)
static int separatorMoveHelper(QList< QLayoutStruct > &list, int index, int delta, int sep)
static QInternal::DockPosition dockPosHelper(const QRect &rect, const QPoint &_pos, Qt::Orientation o, bool nestingEnabled, QDockAreaLayoutInfo::TabMode tabMode)
QMainWindowLayout * qt_mainwindow_layout(const QMainWindow *window)
static void paintSep(QPainter *p, QWidget *w, const QRect &r, Qt::Orientation o, bool mouse_over)
static int realMaxSize(const QDockAreaLayoutInfo &info)
void qGeomCalc(QList< QLayoutStruct > &chain, int start, int count, int pos, int space, int spacer)
QT_BEGIN_NAMESPACE constexpr int QLAYOUTSIZE_MAX
#define Q_LOGGING_CATEGORY(name,...)
#define qCWarning(category,...)
#define qCDebug(category,...)
constexpr const T & qMin(const T &a, const T &b)
constexpr const T & qMax(const T &a, const T &b)
GLboolean GLboolean GLboolean b
GLint GLint GLint GLint GLint x
[0]
GLfloat GLfloat GLfloat w
[0]
GLboolean GLboolean GLboolean GLboolean a
[7]
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLdouble GLdouble GLdouble GLdouble top
GLenum GLenum GLsizei count
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLfloat GLfloat GLfloat GLfloat h
GLuint GLsizei const GLuint const GLintptr const GLsizeiptr * sizes
GLsizei const GLchar *const * path
#define Q_ASSERT_X(cond, x, msg)
static constexpr QChar sep
#define qUtf16Printable(string)
#define QT_CONFIG(feature)
if(qFloatDistance(a, b)<(1<< 7))
[0]
QList< QWidget * > widgets
[11]
QPlaceHolderItem * placeHolderItem
QSize maximumSize() const
QDockAreaLayoutItem(QLayoutItem *_widgetItem=nullptr)
bool expansive(Qt::Orientation o) const
bool hasFixedSize(Qt::Orientation o) const
QDockAreaLayoutInfo * subinfo
QDockAreaLayoutItem & operator=(const QDockAreaLayoutItem &other)
QSize minimumSize() const
void init(int stretchFactor=0, int minSize=0)