diff options
Diffstat (limited to 'src/widgets/widgets/qdockarealayout.cpp')
-rw-r--r-- | src/widgets/widgets/qdockarealayout.cpp | 234 |
1 files changed, 117 insertions, 117 deletions
diff --git a/src/widgets/widgets/qdockarealayout.cpp b/src/widgets/widgets/qdockarealayout.cpp index 5900326087..87f4519dd6 100644 --- a/src/widgets/widgets/qdockarealayout.cpp +++ b/src/widgets/widgets/qdockarealayout.cpp @@ -85,27 +85,27 @@ QPlaceHolderItem::QPlaceHolderItem(QWidget *w) */ QDockAreaLayoutItem::QDockAreaLayoutItem(QLayoutItem *_widgetItem) - : widgetItem(_widgetItem), subinfo(0), placeHolderItem(0), pos(0), size(-1), flags(NoFlags) + : widgetItem(_widgetItem), subinfo(nullptr), placeHolderItem(nullptr), pos(0), size(-1), flags(NoFlags) { } QDockAreaLayoutItem::QDockAreaLayoutItem(QDockAreaLayoutInfo *_subinfo) - : widgetItem(0), subinfo(_subinfo), placeHolderItem(0), pos(0), size(-1), flags(NoFlags) + : widgetItem(nullptr), subinfo(_subinfo), placeHolderItem(nullptr), pos(0), size(-1), flags(NoFlags) { } QDockAreaLayoutItem::QDockAreaLayoutItem(QPlaceHolderItem *_placeHolderItem) - : widgetItem(0), subinfo(0), placeHolderItem(_placeHolderItem), pos(0), size(-1), flags(NoFlags) + : widgetItem(nullptr), subinfo(nullptr), placeHolderItem(_placeHolderItem), pos(0), size(-1), flags(NoFlags) { } QDockAreaLayoutItem::QDockAreaLayoutItem(const QDockAreaLayoutItem &other) - : widgetItem(other.widgetItem), subinfo(0), placeHolderItem(0), pos(other.pos), + : widgetItem(other.widgetItem), subinfo(nullptr), placeHolderItem(nullptr), pos(other.pos), size(other.size), flags(other.flags) { - if (other.subinfo != 0) + if (other.subinfo != nullptr) subinfo = new QDockAreaLayoutInfo(*other.subinfo); - else if (other.placeHolderItem != 0) + else if (other.placeHolderItem != nullptr) placeHolderItem = new QPlaceHolderItem(*other.placeHolderItem); } @@ -117,16 +117,16 @@ QDockAreaLayoutItem::~QDockAreaLayoutItem() bool QDockAreaLayoutItem::skip() const { - if (placeHolderItem != 0) + if (placeHolderItem != nullptr) return true; if (flags & GapItem) return false; - if (widgetItem != 0) + if (widgetItem != nullptr) return widgetItem->isEmpty(); - if (subinfo != 0) { + if (subinfo != nullptr) { for (int i = 0; i < subinfo->item_list.count(); ++i) { if (!subinfo->item_list.at(i).skip()) return false; @@ -140,7 +140,7 @@ QSize QDockAreaLayoutItem::minimumSize() const { if (widgetItem) return widgetItem->minimumSize().grownBy(widgetItem->widget()->contentsMargins()); - if (subinfo != 0) + if (subinfo != nullptr) return subinfo->minimumSize(); return QSize(0, 0); } @@ -149,7 +149,7 @@ QSize QDockAreaLayoutItem::maximumSize() const { if (widgetItem) return widgetItem->maximumSize().grownBy(widgetItem->widget()->contentsMargins()); - if (subinfo != 0) + if (subinfo != nullptr) return subinfo->maximumSize(); return QSize(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX); } @@ -161,22 +161,22 @@ bool QDockAreaLayoutItem::hasFixedSize(Qt::Orientation o) const bool QDockAreaLayoutItem::expansive(Qt::Orientation o) const { - if ((flags & GapItem) || placeHolderItem != 0) + if ((flags & GapItem) || placeHolderItem != nullptr) return false; - if (widgetItem != 0) + if (widgetItem != nullptr) return ((widgetItem->expandingDirections() & o) == o); - if (subinfo != 0) + if (subinfo != nullptr) return subinfo->expansive(o); return false; } QSize QDockAreaLayoutItem::sizeHint() const { - if (placeHolderItem != 0) + if (placeHolderItem != nullptr) return QSize(0, 0); if (widgetItem) return widgetItem->sizeHint().grownBy(widgetItem->widget()->contentsMargins()); - if (subinfo != 0) + if (subinfo != nullptr) return subinfo->sizeHint(); return QSize(-1, -1); } @@ -185,14 +185,14 @@ QDockAreaLayoutItem &QDockAreaLayoutItem::operator = (const QDockAreaLayoutItem &other) { widgetItem = other.widgetItem; - if (other.subinfo == 0) - subinfo = 0; + if (other.subinfo == nullptr) + subinfo = nullptr; else subinfo = new QDockAreaLayoutInfo(*other.subinfo); delete placeHolderItem; - if (other.placeHolderItem == 0) - placeHolderItem = 0; + if (other.placeHolderItem == nullptr) + placeHolderItem = nullptr; else placeHolderItem = new QPlaceHolderItem(*other.placeHolderItem); @@ -210,7 +210,7 @@ QDockAreaLayoutItem #if QT_CONFIG(tabbar) static quintptr tabId(const QDockAreaLayoutItem &item) { - if (item.widgetItem == 0) + if (item.widgetItem == nullptr) return 0; return reinterpret_cast<quintptr>(item.widgetItem->widget()); } @@ -219,9 +219,9 @@ static quintptr tabId(const QDockAreaLayoutItem &item) static const int zero = 0; QDockAreaLayoutInfo::QDockAreaLayoutInfo() - : sep(&zero), dockPos(QInternal::LeftDock), o(Qt::Horizontal), mainWindow(0) + : sep(&zero), dockPos(QInternal::LeftDock), o(Qt::Horizontal), mainWindow(nullptr) #if QT_CONFIG(tabbar) - , tabbed(false), tabBar(0), tabBarShape(QTabBar::RoundedSouth) + , tabbed(false), tabBar(nullptr), tabBarShape(QTabBar::RoundedSouth) #endif { } @@ -231,7 +231,7 @@ QDockAreaLayoutInfo::QDockAreaLayoutInfo(const int *_sep, QInternal::DockPositio QMainWindow *window) : sep(_sep), dockPos(_dockPos), o(_o), mainWindow(window) #if QT_CONFIG(tabbar) - , tabbed(false), tabBar(0), tabBarShape(static_cast<QTabBar::Shape>(tbshape)) + , tabbed(false), tabBar(nullptr), tabBarShape(static_cast<QTabBar::Shape>(tbshape)) #endif { #if !QT_CONFIG(tabbar) @@ -250,7 +250,7 @@ void QDockAreaLayoutInfo::clear() rect = QRect(); #if QT_CONFIG(tabbar) tabbed = false; - tabBar = 0; + tabBar = nullptr; #endif } @@ -403,7 +403,7 @@ QSize QDockAreaLayoutInfo::sizeHint() const int a = 0, b = 0; int min_perp = 0; int max_perp = QWIDGETSIZE_MAX; - const QDockAreaLayoutItem *previous = 0; + const QDockAreaLayoutItem *previous = nullptr; for (int i = 0; i < item_list.size(); ++i) { const QDockAreaLayoutItem &item = item_list.at(i); if (item.skip()) @@ -552,7 +552,7 @@ void QDockAreaLayoutInfo::fitItems() int max_size = realMaxSize(*this); int last_index = -1; - const QDockAreaLayoutItem *previous = 0; + const QDockAreaLayoutItem *previous = nullptr; for (int i = 0; i < item_list.size(); ++i) { QDockAreaLayoutItem &item = item_list[i]; if (item.skip()) @@ -633,7 +633,7 @@ void QDockAreaLayoutInfo::fitItems() item.size = ls.size; item.pos = ls.pos; - if (item.subinfo != 0) { + if (item.subinfo != nullptr) { item.subinfo->rect = itemRect(i); item.subinfo->fitItems(); } @@ -771,7 +771,7 @@ QList<int> QDockAreaLayoutInfo::gapIndex(const QPoint& _pos, if (item.pos + item.size < pos) continue; - if (item.subinfo != 0 + if (item.subinfo != nullptr #if QT_CONFIG(tabbar) && !item.subinfo->tabbed #endif @@ -967,7 +967,7 @@ int QDockAreaLayoutInfo::separatorMove(int index, int delta) const int separatorSpace = item.hasFixedSize(o) ? 0 : *sep; item.size = ls.size - separatorSpace; item.pos = ls.pos; - if (item.subinfo != 0) { + if (item.subinfo != nullptr) { item.subinfo->rect = itemRect(i); item.subinfo->fitItems(); } @@ -979,7 +979,7 @@ int QDockAreaLayoutInfo::separatorMove(int index, int delta) void QDockAreaLayoutInfo::unnest(int index) { QDockAreaLayoutItem &item = item_list[index]; - if (item.subinfo == 0) + if (item.subinfo == nullptr) return; if (item.subinfo->item_list.count() > 1) return; @@ -988,14 +988,14 @@ void QDockAreaLayoutInfo::unnest(int index) item_list.removeAt(index); } else if (item.subinfo->item_list.count() == 1) { QDockAreaLayoutItem &child = item.subinfo->item_list.first(); - if (child.widgetItem != 0) { + if (child.widgetItem != nullptr) { item.widgetItem = child.widgetItem; delete item.subinfo; - item.subinfo = 0; - } else if (child.subinfo != 0) { + item.subinfo = nullptr; + } else if (child.subinfo != nullptr) { QDockAreaLayoutInfo *tmp = item.subinfo; item.subinfo = child.subinfo; - child.subinfo = 0; + child.subinfo = nullptr; tmp->item_list.clear(); delete tmp; } @@ -1009,7 +1009,7 @@ void QDockAreaLayoutInfo::remove(const QList<int> &path) if (path.count() > 1) { const int index = path.first(); QDockAreaLayoutItem &item = item_list[index]; - Q_ASSERT(item.subinfo != 0); + Q_ASSERT(item.subinfo != nullptr); item.subinfo->remove(path.mid(1)); unnest(index); } else { @@ -1028,13 +1028,13 @@ QLayoutItem *QDockAreaLayoutInfo::plug(const QList<int> &path) if (path.count() > 1) { QDockAreaLayoutItem &item = item_list[index]; - Q_ASSERT(item.subinfo != 0); + Q_ASSERT(item.subinfo != nullptr); return item.subinfo->plug(path.mid(1)); } QDockAreaLayoutItem &item = item_list[index]; - Q_ASSERT(item.widgetItem != 0); + Q_ASSERT(item.widgetItem != nullptr); Q_ASSERT(item.flags & QDockAreaLayoutItem::GapItem); item.flags &= ~QDockAreaLayoutItem::GapItem; return item.widgetItem; @@ -1047,7 +1047,7 @@ QLayoutItem *QDockAreaLayoutInfo::unplug(const QList<int> &path) const int index = path.first(); if (path.count() > 1) { QDockAreaLayoutItem &item = item_list[index]; - Q_ASSERT(item.subinfo != 0); + Q_ASSERT(item.subinfo != nullptr); return item.subinfo->unplug(path.mid(1)); } @@ -1078,7 +1078,7 @@ QLayoutItem *QDockAreaLayoutInfo::unplug(const QList<int> &path) quintptr QDockAreaLayoutInfo::currentTabId() const { - if (!tabbed || tabBar == 0) + if (!tabbed || tabBar == nullptr) return 0; int index = tabBar->currentIndex(); @@ -1095,7 +1095,7 @@ void QDockAreaLayoutInfo::setCurrentTab(QWidget *widget) void QDockAreaLayoutInfo::setCurrentTabId(quintptr id) { - if (!tabbed || tabBar == 0) + if (!tabbed || tabBar == nullptr) return; for (int i = 0; i < tabBar->count(); ++i) { @@ -1114,7 +1114,7 @@ static QRect dockedGeometry(QWidget *widget) QDockWidgetLayout *layout = qobject_cast<QDockWidgetLayout*>(widget->layout()); - if(layout != 0 && layout->nativeWindowDeco()) + if (layout && layout->nativeWindowDeco()) titleHeight = layout->titleHeight(); QRect result = widget->geometry(); @@ -1138,7 +1138,7 @@ bool QDockAreaLayoutInfo::insertGap(const QList<int> &path, QLayoutItem *dockWid if (path.count() > 1) { QDockAreaLayoutItem &item = item_list[index]; - if (item.subinfo == 0 + if (item.subinfo == nullptr #if QT_CONFIG(tabbar) || (item.subinfo->tabbed && !insert_tabbed) #endif @@ -1149,7 +1149,7 @@ bool QDockAreaLayoutInfo::insertGap(const QList<int> &path, QLayoutItem *dockWid QDockAreaLayoutInfo *subinfo = item.subinfo; QLayoutItem *widgetItem = item.widgetItem; QPlaceHolderItem *placeHolderItem = item.placeHolderItem; - QRect r = subinfo == 0 ? widgetItem ? dockedGeometry(widgetItem->widget()) : placeHolderItem->topLevelRect : subinfo->rect; + QRect r = subinfo == nullptr ? widgetItem ? dockedGeometry(widgetItem->widget()) : placeHolderItem->topLevelRect : subinfo->rect; Qt::Orientation opposite = o == Qt::Horizontal ? Qt::Vertical : Qt::Horizontal; #if !QT_CONFIG(tabbar) @@ -1160,11 +1160,11 @@ bool QDockAreaLayoutInfo::insertGap(const QList<int> &path, QLayoutItem *dockWid //item become a new top-level item.subinfo = new_info; - item.widgetItem = 0; - item.placeHolderItem = 0; + item.widgetItem = nullptr; + item.placeHolderItem = nullptr; QDockAreaLayoutItem new_item - = widgetItem == 0 + = widgetItem == nullptr ? QDockAreaLayoutItem(subinfo) : widgetItem ? QDockAreaLayoutItem(widgetItem) : QDockAreaLayoutItem(placeHolderItem); new_item.size = pick(opposite, r.size()); @@ -1265,16 +1265,16 @@ QDockAreaLayoutInfo *QDockAreaLayoutInfo::info(QWidget *widget) return this; #endif - if (item.widgetItem != 0 && item.widgetItem->widget() == widget) + if (item.widgetItem != nullptr && item.widgetItem->widget() == widget) return this; - if (item.subinfo != 0) { + if (item.subinfo != nullptr) { if (QDockAreaLayoutInfo *result = item.subinfo->info(widget)) return result; } } - return 0; + return nullptr; } QDockAreaLayoutInfo *QDockAreaLayoutInfo::info(const QList<int> &path) @@ -1284,7 +1284,7 @@ QDockAreaLayoutInfo *QDockAreaLayoutInfo::info(const QList<int> &path) index = -index - 1; if (index >= item_list.count()) return this; - if (path.count() == 1 || item_list[index].subinfo == 0) + if (path.count() == 1 || item_list[index].subinfo == nullptr) return this; return item_list[index].subinfo->info(path.mid(1)); } @@ -1341,7 +1341,7 @@ QRect QDockAreaLayoutInfo::itemRect(const QList<int> &path) const const int index = path.first(); if (path.count() > 1) { const QDockAreaLayoutItem &item = item_list.at(index); - Q_ASSERT(item.subinfo != 0); + Q_ASSERT(item.subinfo != nullptr); return item.subinfo->itemRect(path.mid(1)); } @@ -1374,7 +1374,7 @@ QRect QDockAreaLayoutInfo::separatorRect(const QList<int> &path) const const int index = path.first(); if (path.count() > 1) { const QDockAreaLayoutItem &item = item_list.at(index); - Q_ASSERT(item.subinfo != 0); + Q_ASSERT(item.subinfo != nullptr); return item.subinfo->separatorRect(path.mid(1)); } return separatorRect(index); @@ -1395,7 +1395,7 @@ QList<int> QDockAreaLayoutInfo::findSeparator(const QPoint &_pos) const continue; if (item.pos + item.size > pos) { - if (item.subinfo != 0) { + if (item.subinfo != nullptr) { QList<int> result = item.subinfo->findSeparator(_pos); if (!result.isEmpty()) { result.prepend(i); @@ -1428,7 +1428,7 @@ QList<int> QDockAreaLayoutInfo::indexOfPlaceHolder(const QString &objectName) co for (int i = 0; i < item_list.size(); ++i) { const QDockAreaLayoutItem &item = item_list.at(i); - if (item.subinfo != 0) { + if (item.subinfo != nullptr) { QList<int> result = item.subinfo->indexOfPlaceHolder(objectName); if (!result.isEmpty()) { result.prepend(i); @@ -1437,7 +1437,7 @@ QList<int> QDockAreaLayoutInfo::indexOfPlaceHolder(const QString &objectName) co continue; } - if (item.placeHolderItem != 0 && item.placeHolderItem->objectName == objectName) { + if (item.placeHolderItem != nullptr && item.placeHolderItem->objectName == objectName) { QList<int> result; result << i; return result; @@ -1452,10 +1452,10 @@ QList<int> QDockAreaLayoutInfo::indexOf(QWidget *widget) const for (int i = 0; i < item_list.size(); ++i) { const QDockAreaLayoutItem &item = item_list.at(i); - if (item.placeHolderItem != 0) + if (item.placeHolderItem != nullptr) continue; - if (item.subinfo != 0) { + if (item.subinfo != nullptr) { QList<int> result = item.subinfo->indexOf(widget); if (!result.isEmpty()) { result.prepend(i); @@ -1477,7 +1477,7 @@ QList<int> QDockAreaLayoutInfo::indexOf(QWidget *widget) const QMainWindowLayout *QDockAreaLayoutInfo::mainWindowLayout() const { QMainWindowLayout *result = qt_mainwindow_layout(mainWindow); - Q_ASSERT(result != 0); + Q_ASSERT(result != nullptr); return result; } @@ -1536,7 +1536,7 @@ QDockWidget *QDockAreaLayoutInfo::apply(bool animate) if (item.flags & QDockAreaLayoutItem::GapItem) continue; - if (item.subinfo != 0) { + if (item.subinfo != nullptr) { item.subinfo->apply(animate); continue; } @@ -1681,7 +1681,7 @@ void QDockAreaLayoutInfo::tab(int index, QLayoutItem *dockWidgetItem) = new QDockAreaLayoutInfo(sep, dockPos, o, tabBarShape, mainWindow); item_list[index].subinfo = new_info; new_info->item_list.append(QDockAreaLayoutItem(item_list.at(index).widgetItem)); - item_list[index].widgetItem = 0; + item_list[index].widgetItem = nullptr; new_info->item_list.append(QDockAreaLayoutItem(dockWidgetItem)); new_info->tabbed = true; new_info->updateTabBar(); @@ -1703,7 +1703,7 @@ void QDockAreaLayoutInfo::split(int index, Qt::Orientation orientation, = new QDockAreaLayoutInfo(sep, dockPos, orientation, tabBarShape, mainWindow); item_list[index].subinfo = new_info; new_info->item_list.append(QDockAreaLayoutItem(item_list.at(index).widgetItem)); - item_list[index].widgetItem = 0; + item_list[index].widgetItem = nullptr; new_info->item_list.append(QDockAreaLayoutItem(dockWidgetItem)); } } @@ -1714,7 +1714,7 @@ QDockAreaLayoutItem &QDockAreaLayoutInfo::item(const QList<int> &path) const int index = path.first(); if (path.count() > 1) { const QDockAreaLayoutItem &item = item_list[index]; - Q_ASSERT(item.subinfo != 0); + Q_ASSERT(item.subinfo != nullptr); return item.subinfo->item(path.mid(1)); } return item_list[index]; @@ -1724,7 +1724,7 @@ QLayoutItem *QDockAreaLayoutInfo::itemAt(int *x, int index) const { for (int i = 0; i < item_list.count(); ++i) { const QDockAreaLayoutItem &item = item_list.at(i); - if (item.placeHolderItem != 0) + if (item.placeHolderItem != nullptr) continue; if (item.subinfo) { if (QLayoutItem *ret = item.subinfo->itemAt(x, index)) @@ -1734,14 +1734,14 @@ QLayoutItem *QDockAreaLayoutInfo::itemAt(int *x, int index) const return item.widgetItem; } } - return 0; + return nullptr; } QLayoutItem *QDockAreaLayoutInfo::takeAt(int *x, int index) { for (int i = 0; i < item_list.count(); ++i) { QDockAreaLayoutItem &item = item_list[i]; - if (item.placeHolderItem != 0) + if (item.placeHolderItem != nullptr) continue; else if (item.subinfo) { if (QLayoutItem *ret = item.subinfo->takeAt(x, index)) { @@ -1752,14 +1752,14 @@ QLayoutItem *QDockAreaLayoutInfo::takeAt(int *x, int index) if ((*x)++ == index) { item.placeHolderItem = new QPlaceHolderItem(item.widgetItem->widget()); QLayoutItem *ret = item.widgetItem; - item.widgetItem = 0; + item.widgetItem = nullptr; if (item.size != -1) item.flags |= QDockAreaLayoutItem::KeepSize; return ret; } } } - return 0; + return nullptr; } void QDockAreaLayoutInfo::deleteAllLayoutItems() @@ -1770,7 +1770,7 @@ void QDockAreaLayoutInfo::deleteAllLayoutItems() item.subinfo->deleteAllLayoutItems(); } else { delete item.widgetItem; - item.widgetItem = 0; + item.widgetItem = nullptr; } } } @@ -1801,7 +1801,7 @@ void QDockAreaLayoutInfo::saveState(QDataStream &stream) const for (int i = 0; i < item_list.count(); ++i) { const QDockAreaLayoutItem &item = item_list.at(i); - if (item.widgetItem != 0) { + if (item.widgetItem != nullptr) { stream << (uchar) WidgetMarker; QWidget *w = item.widgetItem->widget(); QString name = w->objectName(); @@ -1825,7 +1825,7 @@ void QDockAreaLayoutInfo::saveState(QDataStream &stream) const stream << item.pos << item.size << pick(o, item.minimumSize()) << pick(o, item.maximumSize()); } - } else if (item.placeHolderItem != 0) { + } else if (item.placeHolderItem != nullptr) { stream << (uchar) WidgetMarker; stream << item.placeHolderItem->objectName; uchar flags = 0; @@ -1840,7 +1840,7 @@ void QDockAreaLayoutInfo::saveState(QDataStream &stream) const } else { stream << item.pos << item.size << (int)0 << (int)0; } - } else if (item.subinfo != 0) { + } else if (item.subinfo != nullptr) { stream << (uchar) SequenceMarker << item.pos << item.size << pick(o, item.minimumSize()) << pick(o, item.maximumSize()); item.subinfo->saveState(stream); } @@ -1894,7 +1894,7 @@ bool QDockAreaLayoutInfo::restoreState(QDataStream &stream, QList<QDockWidget*> continue; } - QDockWidget *widget = 0; + QDockWidget *widget = nullptr; for (int j = 0; j < widgets.count(); ++j) { if (widgets.at(j)->objectName() == name) { widget = widgets.takeAt(j); @@ -1902,7 +1902,7 @@ bool QDockAreaLayoutInfo::restoreState(QDataStream &stream, QList<QDockWidget*> } } - if (widget == 0) { + if (widget == nullptr) { QPlaceHolderItem *placeHolder = new QPlaceHolderItem; QDockAreaLayoutItem item(placeHolder); @@ -2081,7 +2081,7 @@ bool QDockAreaLayoutInfo::updateTabBar() const QDockAreaLayoutInfo *that = const_cast<QDockAreaLayoutInfo*>(this); - if (that->tabBar == 0) { + if (that->tabBar == nullptr) { that->tabBar = mainWindowLayout()->getTabBar(); that->tabBar->setShape(static_cast<QTabBar::Shape>(tabBarShape)); that->tabBar->setDrawBase(true); @@ -2101,7 +2101,7 @@ bool QDockAreaLayoutInfo::updateTabBar() const gap = true; continue; } - if (item.widgetItem == 0) + if (item.widgetItem == nullptr) continue; QDockWidget *dw = qobject_cast<QDockWidget*>(item.widgetItem->widget()); @@ -2155,12 +2155,12 @@ void QDockAreaLayoutInfo::setTabBarShape(int shape) if (shape == tabBarShape) return; tabBarShape = shape; - if (tabBar != 0) + if (tabBar != nullptr) tabBar->setShape(static_cast<QTabBar::Shape>(shape)); for (int i = 0; i < item_list.count(); ++i) { QDockAreaLayoutItem &item = item_list[i]; - if (item.subinfo != 0) + if (item.subinfo != nullptr) item.subinfo->setTabBarShape(shape); } } @@ -2192,7 +2192,7 @@ QSet<QTabBar*> QDockAreaLayoutInfo::usedTabBars() const for (int i = 0; i < item_list.count(); ++i) { const QDockAreaLayoutItem &item = item_list.at(i); - if (item.subinfo != 0) + if (item.subinfo != nullptr) result += item.subinfo->usedTabBars(); } @@ -2212,7 +2212,7 @@ QSet<QWidget*> QDockAreaLayoutInfo::usedSeparatorWidgets() const for (int i = 0; i < item_list.count(); ++i) { const QDockAreaLayoutItem &item = item_list.at(i); - if (item.subinfo != 0) + if (item.subinfo != nullptr) result += item.subinfo->usedSeparatorWidgets(); } @@ -2277,7 +2277,7 @@ void QDockAreaLayoutInfo::moveTab(int from, int to) QDockAreaLayout::QDockAreaLayout(QMainWindow *win) : fallbackToSizeHints(true) { mainWindow = win; - sep = win->style()->pixelMetric(QStyle::PM_DockWidgetSeparatorExtent, 0, win); + sep = win->style()->pixelMetric(QStyle::PM_DockWidgetSeparatorExtent, nullptr, win); #if QT_CONFIG(tabbar) const int tabShape = QTabBar::RoundedSouth; #else @@ -2291,7 +2291,7 @@ QDockAreaLayout::QDockAreaLayout(QMainWindow *win) : fallbackToSizeHints(true) = QDockAreaLayoutInfo(&sep, QInternal::TopDock, Qt::Horizontal, tabShape, win); docks[QInternal::BottomDock] = QDockAreaLayoutInfo(&sep, QInternal::BottomDock, Qt::Horizontal, tabShape, win); - centralWidgetItem = 0; + centralWidgetItem = nullptr; corners[Qt::TopLeftCorner] = Qt::TopDockWidgetArea; @@ -2491,7 +2491,7 @@ QDockAreaLayoutInfo *QDockAreaLayout::info(QWidget *widget) return result; } - return 0; + return nullptr; } QDockAreaLayoutInfo *QDockAreaLayout::info(const QList<int> &path) @@ -2623,7 +2623,7 @@ void QDockAreaLayout::getGrid(QVector<QLayoutStruct> *_ver_struct_list, QSize center_hint(0, 0); QSize center_min(0, 0); QSize center_max(0, 0); - const bool have_central = centralWidgetItem != 0 && !centralWidgetItem->isEmpty(); + const bool have_central = centralWidgetItem != nullptr && !centralWidgetItem->isEmpty(); if (have_central) { center_hint = centralWidgetRect.size(); if (!center_hint.isValid()) @@ -2670,7 +2670,7 @@ void QDockAreaLayout::getGrid(QVector<QLayoutStruct> *_ver_struct_list, QSize bottom_max = docks[QInternal::BottomDock].maximumSize(); bottom_hint = bottom_hint.boundedTo(bottom_max).expandedTo(bottom_min); - if (_ver_struct_list != 0) { + if (_ver_struct_list != nullptr) { QVector<QLayoutStruct> &ver_struct_list = *_ver_struct_list; ver_struct_list.resize(3); @@ -2732,7 +2732,7 @@ void QDockAreaLayout::getGrid(QVector<QLayoutStruct> *_ver_struct_list, ver_struct_list[1].maximumSize = QWIDGETSIZE_MAX; } - if (_hor_struct_list != 0) { + if (_hor_struct_list != nullptr) { QVector<QLayoutStruct> &hor_struct_list = *_hor_struct_list; hor_struct_list.resize(3); @@ -2803,7 +2803,7 @@ void QDockAreaLayout::setGrid(QVector<QLayoutStruct> *ver_struct_list, if (!docks[QInternal::TopDock].isEmpty()) { QRect r = docks[QInternal::TopDock].rect; - if (hor_struct_list != 0) { + if (hor_struct_list != nullptr) { r.setLeft(corners[Qt::TopLeftCorner] == Qt::TopDockWidgetArea || docks[QInternal::LeftDock].isEmpty() ? rect.left() : hor_struct_list->at(1).pos); @@ -2811,7 +2811,7 @@ void QDockAreaLayout::setGrid(QVector<QLayoutStruct> *ver_struct_list, || docks[QInternal::RightDock].isEmpty() ? rect.right() : hor_struct_list->at(2).pos - sep - 1); } - if (ver_struct_list != 0) { + if (ver_struct_list != nullptr) { r.setTop(rect.top()); r.setBottom(ver_struct_list->at(1).pos - sep - 1); } @@ -2823,7 +2823,7 @@ void QDockAreaLayout::setGrid(QVector<QLayoutStruct> *ver_struct_list, if (!docks[QInternal::BottomDock].isEmpty()) { QRect r = docks[QInternal::BottomDock].rect; - if (hor_struct_list != 0) { + if (hor_struct_list != nullptr) { r.setLeft(corners[Qt::BottomLeftCorner] == Qt::BottomDockWidgetArea || docks[QInternal::LeftDock].isEmpty() ? rect.left() : hor_struct_list->at(1).pos); @@ -2831,7 +2831,7 @@ void QDockAreaLayout::setGrid(QVector<QLayoutStruct> *ver_struct_list, || docks[QInternal::RightDock].isEmpty() ? rect.right() : hor_struct_list->at(2).pos - sep - 1); } - if (ver_struct_list != 0) { + if (ver_struct_list != nullptr) { r.setTop(ver_struct_list->at(2).pos); r.setBottom(rect.bottom()); } @@ -2843,11 +2843,11 @@ void QDockAreaLayout::setGrid(QVector<QLayoutStruct> *ver_struct_list, if (!docks[QInternal::LeftDock].isEmpty()) { QRect r = docks[QInternal::LeftDock].rect; - if (hor_struct_list != 0) { + if (hor_struct_list != nullptr) { r.setLeft(rect.left()); r.setRight(hor_struct_list->at(1).pos - sep - 1); } - if (ver_struct_list != 0) { + if (ver_struct_list != nullptr) { r.setTop(corners[Qt::TopLeftCorner] == Qt::LeftDockWidgetArea || docks[QInternal::TopDock].isEmpty() ? rect.top() : ver_struct_list->at(1).pos); @@ -2863,11 +2863,11 @@ void QDockAreaLayout::setGrid(QVector<QLayoutStruct> *ver_struct_list, if (!docks[QInternal::RightDock].isEmpty()) { QRect r = docks[QInternal::RightDock].rect; - if (hor_struct_list != 0) { + if (hor_struct_list != nullptr) { r.setLeft(hor_struct_list->at(2).pos); r.setRight(rect.right()); } - if (ver_struct_list != 0) { + if (ver_struct_list != nullptr) { r.setTop(corners[Qt::TopRightCorner] == Qt::RightDockWidgetArea || docks[QInternal::TopDock].isEmpty() ? rect.top() : ver_struct_list->at(1).pos); @@ -2881,11 +2881,11 @@ void QDockAreaLayout::setGrid(QVector<QLayoutStruct> *ver_struct_list, // center --------------------------------------------------- - if (hor_struct_list != 0) { + if (hor_struct_list != nullptr) { centralWidgetRect.setLeft(hor_struct_list->at(1).pos); centralWidgetRect.setWidth(hor_struct_list->at(1).size); } - if (ver_struct_list != 0) { + if (ver_struct_list != nullptr) { centralWidgetRect.setTop(ver_struct_list->at(1).pos); centralWidgetRect.setHeight(ver_struct_list->at(1).size); } @@ -2919,7 +2919,7 @@ QSize QDockAreaLayout::sizeHint() const int top_sep = 0; int bottom_sep = 0; - if (centralWidgetItem != 0) { + if (centralWidgetItem != nullptr) { left_sep = docks[QInternal::LeftDock].isEmpty() ? 0 : sep; right_sep = docks[QInternal::RightDock].isEmpty() ? 0 : sep; top_sep = docks[QInternal::TopDock].isEmpty() ? 0 : sep; @@ -2930,7 +2930,7 @@ QSize QDockAreaLayout::sizeHint() const QSize right = docks[QInternal::RightDock].sizeHint() + QSize(right_sep, 0); QSize top = docks[QInternal::TopDock].sizeHint() + QSize(0, top_sep); QSize bottom = docks[QInternal::BottomDock].sizeHint() + QSize(0, bottom_sep); - QSize center = centralWidgetItem == 0 ? QSize(0, 0) : centralWidgetItem->sizeHint(); + QSize center = centralWidgetItem == nullptr ? QSize(0, 0) : centralWidgetItem->sizeHint(); int row1 = top.width(); int row2 = left.width() + center.width() + right.width(); @@ -2969,7 +2969,7 @@ QSize QDockAreaLayout::minimumSize() const int top_sep = 0; int bottom_sep = 0; - if (centralWidgetItem != 0) { + if (centralWidgetItem != nullptr) { left_sep = docks[QInternal::LeftDock].isEmpty() ? 0 : sep; right_sep = docks[QInternal::RightDock].isEmpty() ? 0 : sep; top_sep = docks[QInternal::TopDock].isEmpty() ? 0 : sep; @@ -2980,7 +2980,7 @@ QSize QDockAreaLayout::minimumSize() const QSize right = docks[QInternal::RightDock].minimumSize() + QSize(right_sep, 0); QSize top = docks[QInternal::TopDock].minimumSize() + QSize(0, top_sep); QSize bottom = docks[QInternal::BottomDock].minimumSize() + QSize(0, bottom_sep); - QSize center = centralWidgetItem == 0 ? QSize(0, 0) : centralWidgetItem->minimumSize(); + QSize center = centralWidgetItem == nullptr ? QSize(0, 0) : centralWidgetItem->minimumSize(); int row1 = top.width(); int row2 = left.width() + center.width() + right.width(); @@ -3040,7 +3040,7 @@ QRect QDockAreaLayout::constrainedRect(QRect rect, QWidget* widget) bool QDockAreaLayout::restoreDockWidget(QDockWidget *dockWidget) { - QDockAreaLayoutItem *item = 0; + QDockAreaLayoutItem *item = nullptr; const auto groups = mainWindow->findChildren<QDockWidgetGroupWindow *>(QString(), Qt::FindDirectChildrenOnly); for (QDockWidgetGroupWindow *dwgw : groups) { @@ -3059,7 +3059,7 @@ bool QDockAreaLayout::restoreDockWidget(QDockWidget *dockWidget) } QPlaceHolderItem *placeHolder = item->placeHolderItem; - Q_ASSERT(placeHolder != 0); + Q_ASSERT(placeHolder != nullptr); item->widgetItem = new QDockWidgetItem(dockWidget); @@ -3069,7 +3069,7 @@ bool QDockAreaLayout::restoreDockWidget(QDockWidget *dockWidget) } dockWidget->setVisible(!placeHolder->hidden); - item->placeHolderItem = 0; + item->placeHolderItem = nullptr; delete placeHolder; return true; @@ -3116,7 +3116,7 @@ void QDockAreaLayout::tabifyDockWidget(QDockWidget *first, QDockWidget *second) return; QDockAreaLayoutInfo *info = this->info(path); - Q_ASSERT(info != 0); + Q_ASSERT(info != nullptr); info->tab(path.last(), new QDockWidgetItem(second)); removePlaceHolder(second->objectName()); @@ -3181,7 +3181,7 @@ void QDockAreaLayout::splitDockWidget(QDockWidget *after, return; QDockAreaLayoutInfo *info = this->info(path); - Q_ASSERT(info != 0); + Q_ASSERT(info != nullptr); info->split(path.last(), orientation, new QDockWidgetItem(dockWidget)); removePlaceHolder(dockWidget->objectName()); @@ -3193,7 +3193,7 @@ void QDockAreaLayout::apply(bool animate) for (int i = 0; i < QInternal::DockCount; ++i) docks[i].apply(animate); - if (centralWidgetItem != 0 && !centralWidgetItem->isEmpty()) { + if (centralWidgetItem != nullptr && !centralWidgetItem->isEmpty()) { widgetAnimator.animate(centralWidgetItem->widget(), centralWidgetRect, animate); } @@ -3255,9 +3255,9 @@ int QDockAreaLayout::separatorMove(const QList<int> &separator, const QPoint &or QVector<QLayoutStruct> list; if (index == QInternal::LeftDock || index == QInternal::RightDock) - getGrid(0, &list); + getGrid(nullptr, &list); else - getGrid(&list, 0); + getGrid(&list, nullptr); int sep_index = index == QInternal::LeftDock || index == QInternal::TopDock ? 0 : 1; @@ -3271,9 +3271,9 @@ int QDockAreaLayout::separatorMove(const QList<int> &separator, const QPoint &or fallbackToSizeHints = false; if (index == QInternal::LeftDock || index == QInternal::RightDock) - setGrid(0, &list); + setGrid(nullptr, &list); else - setGrid(&list, 0); + setGrid(&list, nullptr); apply(false); @@ -3330,7 +3330,7 @@ void QDockAreaLayout::updateSeparatorWidgets() const QLayoutItem *QDockAreaLayout::itemAt(int *x, int index) const { - Q_ASSERT(x != 0); + Q_ASSERT(x != nullptr); for (int i = 0; i < QInternal::DockCount; ++i) { const QDockAreaLayoutInfo &dock = docks[i]; @@ -3341,12 +3341,12 @@ QLayoutItem *QDockAreaLayout::itemAt(int *x, int index) const if (centralWidgetItem && (*x)++ == index) return centralWidgetItem; - return 0; + return nullptr; } QLayoutItem *QDockAreaLayout::takeAt(int *x, int index) { - Q_ASSERT(x != 0); + Q_ASSERT(x != nullptr); for (int i = 0; i < QInternal::DockCount; ++i) { QDockAreaLayoutInfo &dock = docks[i]; @@ -3356,11 +3356,11 @@ QLayoutItem *QDockAreaLayout::takeAt(int *x, int index) if (centralWidgetItem && (*x)++ == index) { QLayoutItem *ret = centralWidgetItem; - centralWidgetItem = 0; + centralWidgetItem = nullptr; return ret; } - return 0; + return nullptr; } void QDockAreaLayout::deleteAllLayoutItems() @@ -3399,7 +3399,7 @@ QSet<QWidget*> QDockAreaLayout::usedSeparatorWidgets() const QRect QDockAreaLayout::gapRect(const QList<int> &path) const { const QDockAreaLayoutInfo *info = this->info(path); - if (info == 0) + if (info == nullptr) return QRect(); int index = path.last(); if (index < 0 || index >= info->item_list.count()) @@ -3419,7 +3419,7 @@ void QDockAreaLayout::keepSize(QDockWidget *w) void QDockAreaLayout::styleChangedEvent() { - sep = mainWindow->style()->pixelMetric(QStyle::PM_DockWidgetSeparatorExtent, 0, mainWindow); + sep = mainWindow->style()->pixelMetric(QStyle::PM_DockWidgetSeparatorExtent, nullptr, mainWindow); if (isValid()) fitLayout(); } |