summaryrefslogtreecommitdiffstats
path: root/src/widgets/widgets/qdockarealayout.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/widgets/widgets/qdockarealayout.cpp')
-rw-r--r--src/widgets/widgets/qdockarealayout.cpp118
1 files changed, 57 insertions, 61 deletions
diff --git a/src/widgets/widgets/qdockarealayout.cpp b/src/widgets/widgets/qdockarealayout.cpp
index 60f6f6d26d..5edcbcf4ec 100644
--- a/src/widgets/widgets/qdockarealayout.cpp
+++ b/src/widgets/widgets/qdockarealayout.cpp
@@ -40,7 +40,9 @@
#include "QtWidgets/qapplication.h"
#include "QtWidgets/qwidget.h"
+#if QT_CONFIG(tabbar)
#include "QtWidgets/qtabbar.h"
+#endif
#include "QtWidgets/qstyle.h"
#include "QtWidgets/qdesktopwidget.h"
#include "QtWidgets/qapplication.h"
@@ -56,8 +58,6 @@
#include <qpainter.h>
#include <qstyleoption.h>
-#ifndef QT_NO_DOCKWIDGET
-
QT_BEGIN_NAMESPACE
// qmainwindow.cpp
@@ -214,7 +214,7 @@ QDockAreaLayoutItem
** QDockAreaLayoutInfo
*/
-#ifndef QT_NO_TABBAR
+#if QT_CONFIG(tabbar)
static quintptr tabId(const QDockAreaLayoutItem &item)
{
if (item.widgetItem == 0)
@@ -227,7 +227,7 @@ static const int zero = 0;
QDockAreaLayoutInfo::QDockAreaLayoutInfo()
: sep(&zero), dockPos(QInternal::LeftDock), o(Qt::Horizontal), mainWindow(0)
-#ifndef QT_NO_TABBAR
+#if QT_CONFIG(tabbar)
, tabbed(false), tabBar(0), tabBarShape(QTabBar::RoundedSouth)
#endif
{
@@ -237,11 +237,11 @@ QDockAreaLayoutInfo::QDockAreaLayoutInfo(const int *_sep, QInternal::DockPositio
Qt::Orientation _o, int tbshape,
QMainWindow *window)
: sep(_sep), dockPos(_dockPos), o(_o), mainWindow(window)
-#ifndef QT_NO_TABBAR
+#if QT_CONFIG(tabbar)
, tabbed(false), tabBar(0), tabBarShape(static_cast<QTabBar::Shape>(tbshape))
#endif
{
-#ifdef QT_NO_TABBAR
+#if !QT_CONFIG(tabbar)
Q_UNUSED(tbshape);
#endif
}
@@ -255,7 +255,7 @@ void QDockAreaLayoutInfo::clear()
{
item_list.clear();
rect = QRect();
-#ifndef QT_NO_TABBAR
+#if QT_CONFIG(tabbar)
tabbed = false;
tabBar = 0;
#endif
@@ -289,7 +289,7 @@ QSize QDockAreaLayoutInfo::minimumSize() const
continue;
QSize min_size = item.minimumSize();
-#ifndef QT_NO_TABBAR
+#if QT_CONFIG(tabbar)
if (tabbed) {
a = qMax(a, pick(o, min_size));
} else
@@ -308,7 +308,7 @@ QSize QDockAreaLayoutInfo::minimumSize() const
rpick(o, result) = a;
rperp(o, result) = b;
-#ifndef QT_NO_TABBAR
+#if QT_CONFIG(tabbar)
QSize tbm = tabBarMinimumSize();
if (!tbm.isNull()) {
switch (tabBarShape) {
@@ -330,7 +330,7 @@ QSize QDockAreaLayoutInfo::minimumSize() const
break;
}
}
-#endif // QT_NO_TABBAR
+#endif // QT_CONFIG(tabbar)
return result;
}
@@ -341,7 +341,7 @@ QSize QDockAreaLayoutInfo::maximumSize() const
return QSize(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX);
int a = 0, b = QWIDGETSIZE_MAX;
-#ifndef QT_NO_TABBAR
+#if QT_CONFIG(tabbar)
if (tabbed)
a = QWIDGETSIZE_MAX;
#endif
@@ -357,7 +357,7 @@ QSize QDockAreaLayoutInfo::maximumSize() const
QSize max_size = item.maximumSize();
min_perp = qMax(min_perp, perp(o, item.minimumSize()));
-#ifndef QT_NO_TABBAR
+#if QT_CONFIG(tabbar)
if (tabbed) {
a = qMin(a, pick(o, max_size));
} else
@@ -381,7 +381,7 @@ QSize QDockAreaLayoutInfo::maximumSize() const
rpick(o, result) = a;
rperp(o, result) = b;
-#ifndef QT_NO_TABBAR
+#if QT_CONFIG(tabbar)
QSize tbh = tabBarSizeHint();
if (!tbh.isNull()) {
switch (tabBarShape) {
@@ -397,7 +397,7 @@ QSize QDockAreaLayoutInfo::maximumSize() const
break;
}
}
-#endif // QT_NO_TABBAR
+#endif // QT_CONFIG(tabbar)
return result;
}
@@ -422,7 +422,7 @@ QSize QDockAreaLayoutInfo::sizeHint() const
min_perp = qMax(min_perp, perp(o, item.minimumSize()));
max_perp = qMin(max_perp, perp(o, item.maximumSize()));
-#ifndef QT_NO_TABBAR
+#if QT_CONFIG(tabbar)
if (tabbed) {
a = qMax(a, gap ? item.size : pick(o, size_hint));
} else
@@ -447,7 +447,7 @@ QSize QDockAreaLayoutInfo::sizeHint() const
rpick(o, result) = a;
rperp(o, result) = b;
-#ifndef QT_NO_TABBAR
+#if QT_CONFIG(tabbar)
if (tabbed) {
QSize tbh = tabBarSizeHint();
switch (tabBarShape) {
@@ -469,7 +469,7 @@ QSize QDockAreaLayoutInfo::sizeHint() const
break;
}
}
-#endif // QT_NO_TABBAR
+#endif // QT_CONFIG(tabbar)
return result;
}
@@ -545,7 +545,7 @@ static int realMaxSize(const QDockAreaLayoutInfo &info)
void QDockAreaLayoutInfo::fitItems()
{
-#ifndef QT_NO_TABBAR
+#if QT_CONFIG(tabbar)
if (tabbed) {
return;
}
@@ -759,7 +759,7 @@ QList<int> QDockAreaLayoutInfo::gapIndex(const QPoint& _pos,
QRect item_rect;
int item_index = 0;
-#ifndef QT_NO_TABBAR
+#if QT_CONFIG(tabbar)
if (tabbed) {
item_rect = tabContentRect();
} else
@@ -779,7 +779,7 @@ QList<int> QDockAreaLayoutInfo::gapIndex(const QPoint& _pos,
continue;
if (item.subinfo != 0
-#ifndef QT_NO_TABBAR
+#if QT_CONFIG(tabbar)
&& !item.subinfo->tabbed
#endif
) {
@@ -941,7 +941,7 @@ static int separatorMoveHelper(QVector<QLayoutStruct> &list, int index, int delt
int QDockAreaLayoutInfo::separatorMove(int index, int delta)
{
-#ifndef QT_NO_TABBAR
+#if QT_CONFIG(tabbar)
Q_ASSERT(!tabbed);
#endif
@@ -1065,7 +1065,7 @@ QLayoutItem *QDockAreaLayoutInfo::unplug(const QList<int> &path)
Q_ASSERT(!(item.flags & QDockAreaLayoutItem::GapItem));
item.flags |= QDockAreaLayoutItem::GapItem;
-#ifndef QT_NO_TABBAR
+#if QT_CONFIG(tabbar)
if (tabbed) {
} else
#endif
@@ -1081,7 +1081,7 @@ QLayoutItem *QDockAreaLayoutInfo::unplug(const QList<int> &path)
return item.widgetItem;
}
-#ifndef QT_NO_TABBAR
+#if QT_CONFIG(tabbar)
quintptr QDockAreaLayoutInfo::currentTabId() const
{
@@ -1113,7 +1113,7 @@ void QDockAreaLayoutInfo::setCurrentTabId(quintptr id)
}
}
-#endif // QT_NO_TABBAR
+#endif // QT_CONFIG(tabbar)
static QRect dockedGeometry(QWidget *widget)
{
@@ -1146,7 +1146,7 @@ bool QDockAreaLayoutInfo::insertGap(const QList<int> &path, QLayoutItem *dockWid
QDockAreaLayoutItem &item = item_list[index];
if (item.subinfo == 0
-#ifndef QT_NO_TABBAR
+#if QT_CONFIG(tabbar)
|| (item.subinfo->tabbed && !insert_tabbed)
#endif
) {
@@ -1159,7 +1159,7 @@ bool QDockAreaLayoutInfo::insertGap(const QList<int> &path, QLayoutItem *dockWid
QRect r = subinfo == 0 ? widgetItem ? dockedGeometry(widgetItem->widget()) : placeHolderItem->topLevelRect : subinfo->rect;
Qt::Orientation opposite = o == Qt::Horizontal ? Qt::Vertical : Qt::Horizontal;
-#ifdef QT_NO_TABBAR
+#if !QT_CONFIG(tabbar)
const int tabBarShape = 0;
#endif
QDockAreaLayoutInfo *new_info
@@ -1177,7 +1177,7 @@ bool QDockAreaLayoutInfo::insertGap(const QList<int> &path, QLayoutItem *dockWid
new_item.size = pick(opposite, r.size());
new_item.pos = pick(opposite, r.topLeft());
new_info->item_list.append(new_item);
-#ifndef QT_NO_TABBAR
+#if QT_CONFIG(tabbar)
if (insert_tabbed) {
new_info->tabbed = true;
}
@@ -1192,7 +1192,7 @@ bool QDockAreaLayoutInfo::insertGap(const QList<int> &path, QLayoutItem *dockWid
gap_item.flags |= QDockAreaLayoutItem::GapItem;
gap_item.widgetItem = dockWidgetItem; // so minimumSize(), maximumSize() and
// sizeHint() will work
-#ifndef QT_NO_TABBAR
+#if QT_CONFIG(tabbar)
if (!tabbed)
#endif
{
@@ -1267,7 +1267,7 @@ QDockAreaLayoutInfo *QDockAreaLayoutInfo::info(QWidget *widget)
if (item.skip())
continue;
-#ifndef QT_NO_TABBAR
+#if QT_CONFIG(tabbar)
if (tabbed && widget == tabBar)
return this;
#endif
@@ -1308,7 +1308,7 @@ QRect QDockAreaLayoutInfo::itemRect(int index, bool isGap) const
QRect result;
-#ifndef QT_NO_TABBAR
+#if QT_CONFIG(tabbar)
if (tabbed) {
if (isGap || tabId(item) == currentTabId())
result = tabContentRect();
@@ -1357,7 +1357,7 @@ QRect QDockAreaLayoutInfo::itemRect(const QList<int> &path) const
QRect QDockAreaLayoutInfo::separatorRect(int index) const
{
-#ifndef QT_NO_TABBAR
+#if QT_CONFIG(tabbar)
if (tabbed)
return QRect();
#endif
@@ -1389,7 +1389,7 @@ QRect QDockAreaLayoutInfo::separatorRect(const QList<int> &path) const
QList<int> QDockAreaLayoutInfo::findSeparator(const QPoint &_pos) const
{
-#ifndef QT_NO_TABBAR
+#if QT_CONFIG(tabbar)
if (tabbed)
return QList<int>();
#endif
@@ -1500,7 +1500,7 @@ QDockWidget *QDockAreaLayoutInfo::apply(bool animate)
{
QWidgetAnimator &widgetAnimator = mainWindowLayout()->widgetAnimator;
-#ifndef QT_NO_TABBAR
+#if QT_CONFIG(tabbar)
if (tabbed) {
QRect tab_rect;
QSize tbh = tabBarSizeHint();
@@ -1533,7 +1533,7 @@ QDockWidget *QDockAreaLayoutInfo::apply(bool animate)
widgetAnimator.animate(tabBar, tab_rect, animate);
}
-#endif // QT_NO_TABBAR
+#endif // QT_CONFIG(tabbar)
QDockWidget *activated = nullptr;
@@ -1569,10 +1569,10 @@ QDockWidget *QDockAreaLayoutInfo::apply(bool animate)
}
}
}
-#ifndef QT_NO_TABBAR
+#if QT_CONFIG(tabbar)
if (*sep == 1)
updateSeparatorWidgets();
-#endif //QT_NO_TABBAR
+#endif // QT_CONFIG(tabbar)
return activated;
}
@@ -1599,7 +1599,7 @@ QRegion QDockAreaLayoutInfo::separatorRegion() const
if (isEmpty())
return result;
-#ifndef QT_NO_TABBAR
+#if QT_CONFIG(tabbar)
if (tabbed)
return result;
#endif
@@ -1629,7 +1629,7 @@ void QDockAreaLayoutInfo::paintSeparators(QPainter *p, QWidget *widget,
{
if (isEmpty())
return;
-#ifndef QT_NO_TABBAR
+#if QT_CONFIG(tabbar)
if (tabbed)
return;
#endif
@@ -1678,7 +1678,7 @@ int QDockAreaLayoutInfo::prev(int index) const
void QDockAreaLayoutInfo::tab(int index, QLayoutItem *dockWidgetItem)
{
-#ifdef QT_NO_TABBAR
+#if !QT_CONFIG(tabbar)
Q_UNUSED(index);
Q_UNUSED(dockWidgetItem);
#else
@@ -1697,7 +1697,7 @@ void QDockAreaLayoutInfo::tab(int index, QLayoutItem *dockWidgetItem)
new_info->updateTabBar();
new_info->setCurrentTab(dockWidgetItem->widget());
}
-#endif // QT_NO_TABBAR
+#endif // QT_CONFIG(tabbar)
}
void QDockAreaLayoutInfo::split(int index, Qt::Orientation orientation,
@@ -1706,7 +1706,7 @@ void QDockAreaLayoutInfo::split(int index, Qt::Orientation orientation,
if (orientation == o) {
item_list.insert(index + 1, QDockAreaLayoutItem(dockWidgetItem));
} else {
-#ifdef QT_NO_TABBAR
+#if !QT_CONFIG(tabbar)
const int tabBarShape = 0;
#endif
QDockAreaLayoutInfo *new_info
@@ -1787,7 +1787,7 @@ void QDockAreaLayoutInfo::deleteAllLayoutItems()
void QDockAreaLayoutInfo::saveState(QDataStream &stream) const
{
-#ifndef QT_NO_TABBAR
+#if QT_CONFIG(tabbar)
if (tabbed) {
stream << (uchar) TabMarker;
@@ -1802,7 +1802,7 @@ void QDockAreaLayoutInfo::saveState(QDataStream &stream) const
}
stream << index;
} else
-#endif // QT_NO_TABBAR
+#endif // QT_CONFIG(tabbar)
{
stream << (uchar) SequenceMarker;
}
@@ -1876,7 +1876,7 @@ bool QDockAreaLayoutInfo::restoreState(QDataStream &stream, QList<QDockWidget*>
if (marker != TabMarker && marker != SequenceMarker)
return false;
-#ifndef QT_NO_TABBAR
+#if QT_CONFIG(tabbar)
tabbed = marker == TabMarker;
int index = -1;
@@ -1981,7 +1981,7 @@ bool QDockAreaLayoutInfo::restoreState(QDataStream &stream, QList<QDockWidget*>
}
} else if (nextMarker == SequenceMarker) {
int dummy;
-#ifdef QT_NO_TABBAR
+#if !QT_CONFIG(tabbar)
const int tabBarShape = 0;
#endif
QDockAreaLayoutItem item(new QDockAreaLayoutInfo(sep, dockPos, o,
@@ -2002,7 +2002,7 @@ bool QDockAreaLayoutInfo::restoreState(QDataStream &stream, QList<QDockWidget*>
}
}
-#ifndef QT_NO_TABBAR
+#if QT_CONFIG(tabbar)
if (!testing && tabbed && index >= 0 && index < item_list.count()) {
updateTabBar();
setCurrentTabId(tabId(item_list.at(index)));
@@ -2014,7 +2014,7 @@ bool QDockAreaLayoutInfo::restoreState(QDataStream &stream, QList<QDockWidget*>
return true;
}
-#ifndef QT_NO_TABBAR
+#if QT_CONFIG(tabbar)
void QDockAreaLayoutInfo::updateSeparatorWidgets() const
{
if (tabbed) {
@@ -2065,9 +2065,7 @@ void QDockAreaLayoutInfo::updateSeparatorWidgets() const
separatorWidgets.resize(j);
Q_ASSERT(separatorWidgets.size() == j);
}
-#endif //QT_NO_TABBAR
-#ifndef QT_NO_TABBAR
/*! \internal
reparent all the widgets contained in this layout portion to the
specified parent. This is used to reparent dock widgets and tabbars
@@ -2293,7 +2291,7 @@ void QDockAreaLayoutInfo::moveTab(int from, int to)
{
item_list.move(tabIndexToListIndex(from), tabIndexToListIndex(to));
}
-#endif // QT_NO_TABBAR
+#endif // QT_CONFIG(tabbar)
/******************************************************************************
** QDockAreaLayout
@@ -2303,7 +2301,7 @@ QDockAreaLayout::QDockAreaLayout(QMainWindow *win) : fallbackToSizeHints(true)
{
mainWindow = win;
sep = win->style()->pixelMetric(QStyle::PM_DockWidgetSeparatorExtent, 0, win);
-#ifndef QT_NO_TABBAR
+#if QT_CONFIG(tabbar)
const int tabShape = QTabBar::RoundedSouth;
#else
const int tabShape = 0;
@@ -2423,7 +2421,7 @@ QList<int> QDockAreaLayout::gapIndex(const QPoint &pos, bool disallowTabs) const
QMainWindow::DockOptions opts = mainWindow->dockOptions();
bool nestingEnabled = opts & QMainWindow::AllowNestedDocks;
QDockAreaLayoutInfo::TabMode tabMode = QDockAreaLayoutInfo::NoTabs;
-#ifndef QT_NO_TABBAR
+#if QT_CONFIG(tabbar)
if (!disallowTabs) {
if (opts & QMainWindow::AllowTabbedDocks || opts & QMainWindow::VerticalTabs)
tabMode = QDockAreaLayoutInfo::AllowTabs;
@@ -3115,14 +3113,14 @@ void QDockAreaLayout::addDockWidget(QInternal::DockPosition pos, QDockWidget *do
QDockAreaLayoutItem new_item(dockWidgetItem);
info.item_list.append(new_item);
-#ifndef QT_NO_TABBAR
+#if QT_CONFIG(tabbar)
if (info.tabbed && !new_item.skip()) {
info.updateTabBar();
info.setCurrentTabId(tabId(new_item));
}
#endif
} else {
-#ifndef QT_NO_TABBAR
+#if QT_CONFIG(tabbar)
int tbshape = info.tabBarShape;
#else
int tbshape = 0;
@@ -3223,10 +3221,10 @@ void QDockAreaLayout::apply(bool animate)
widgetAnimator.animate(centralWidgetItem->widget(), centralWidgetRect,
animate);
}
-#ifndef QT_NO_TABBAR
+#if QT_CONFIG(tabbar)
if (sep == 1)
updateSeparatorWidgets();
-#endif //QT_NO_TABBAR
+#endif // QT_CONFIG(tabbar)
}
void QDockAreaLayout::paintSeparators(QPainter *p, QWidget *widget,
@@ -3317,7 +3315,7 @@ int QDockAreaLayoutInfo::separatorMove(const QList<int> &separator, const QPoint
return delta;
}
-#ifndef QT_NO_TABBAR
+#if QT_CONFIG(tabbar)
// Sets the correct positions for the separator widgets
// Allocates new sepearator widgets with getSeparatorWidget
void QDockAreaLayout::updateSeparatorWidgets() const
@@ -3351,7 +3349,7 @@ void QDockAreaLayout::updateSeparatorWidgets() const
separatorWidgets.resize(j);
}
-#endif //QT_NO_TABBAR
+#endif // QT_CONFIG(tabbar)
QLayoutItem *QDockAreaLayout::itemAt(int *x, int index) const
{
@@ -3394,7 +3392,7 @@ void QDockAreaLayout::deleteAllLayoutItems()
docks[i].deleteAllLayoutItems();
}
-#ifndef QT_NO_TABBAR
+#if QT_CONFIG(tabbar)
QSet<QTabBar*> QDockAreaLayout::usedTabBars() const
{
QSet<QTabBar*> result;
@@ -3450,5 +3448,3 @@ void QDockAreaLayout::styleChangedEvent()
}
QT_END_NAMESPACE
-
-#endif // QT_NO_DOCKWIDGET