From ece0c0a5e7e0b18beb58ccd868bde54c7be64f78 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Fri, 22 Nov 2019 14:46:58 +0100 Subject: Tidy nullptr usage Move away from using 0 as pointer literal. Done using clang-tidy. This is not complete as run-clang-tidy can't handle all of qtbase in one go. Change-Id: I1076a21f32aac0dab078af6f175f7508145eece0 Reviewed-by: Friedemann Kleint Reviewed-by: Lars Knoll --- src/widgets/kernel/qformlayout.cpp | 70 +++++++++++++++++++------------------- 1 file changed, 35 insertions(+), 35 deletions(-) (limited to 'src/widgets/kernel/qformlayout.cpp') diff --git a/src/widgets/kernel/qformlayout.cpp b/src/widgets/kernel/qformlayout.cpp index c2838083f3..4ffa226d7f 100644 --- a/src/widgets/kernel/qformlayout.cpp +++ b/src/widgets/kernel/qformlayout.cpp @@ -295,11 +295,11 @@ void QFormLayoutPrivate::updateSizes() bool expandH = false; bool expandV = false; - QFormLayoutItem *prevLbl = 0; - QFormLayoutItem *prevFld = 0; + QFormLayoutItem *prevLbl = nullptr; + QFormLayoutItem *prevFld = nullptr; QWidget *parent = q->parentWidget(); - QStyle *style = parent ? parent->style() : 0; + QStyle *style = parent ? parent->style() : nullptr; int userVSpacing = q->verticalSpacing(); int userHSpacing = wrapAllRows ? 0 : q->horizontalSpacing(); @@ -364,9 +364,9 @@ void QFormLayoutPrivate::updateSizes() QSizePolicy::ControlTypes fldtoptypes = QSizePolicy::ControlTypes(fldtop ? fldtop->controlTypes() : QSizePolicy::DefaultType); if (label && lbltop) - label->vSpace = style->combinedLayoutSpacing(lbltoptypes, lbltypes, Qt::Vertical, 0, parent); + label->vSpace = style->combinedLayoutSpacing(lbltoptypes, lbltypes, Qt::Vertical, nullptr, parent); if (field && fldtop) - field->vSpace = style->combinedLayoutSpacing(fldtoptypes, fldtypes, Qt::Vertical, 0, parent); + field->vSpace = style->combinedLayoutSpacing(fldtoptypes, fldtypes, Qt::Vertical, nullptr, parent); } else { // Side by side.. we have to also consider the spacings to empty cells, which can strangely be more than // non empty cells.. @@ -380,21 +380,21 @@ void QFormLayoutPrivate::updateSizes() // To be compatible to QGridLayout, we have to compare solitary labels & fields with both predecessors if (label) { if (!field) { - int lblspacing = style->combinedLayoutSpacing(lbltoptypes, lbltypes, Qt::Vertical, 0, parent); - int fldspacing = style->combinedLayoutSpacing(fldtoptypes, lbltypes, Qt::Vertical, 0, parent); + int lblspacing = style->combinedLayoutSpacing(lbltoptypes, lbltypes, Qt::Vertical, nullptr, parent); + int fldspacing = style->combinedLayoutSpacing(fldtoptypes, lbltypes, Qt::Vertical, nullptr, parent); label->vSpace = qMax(lblspacing, fldspacing); } else - label->vSpace = style->combinedLayoutSpacing(lbltoptypes, lbltypes, Qt::Vertical, 0, parent); + label->vSpace = style->combinedLayoutSpacing(lbltoptypes, lbltypes, Qt::Vertical, nullptr, parent); } if (field) { // check spacing against both the previous label and field if (!label) { - int lblspacing = style->combinedLayoutSpacing(lbltoptypes, fldtypes, Qt::Vertical, 0, parent); - int fldspacing = style->combinedLayoutSpacing(fldtoptypes, fldtypes, Qt::Vertical, 0, parent); + int lblspacing = style->combinedLayoutSpacing(lbltoptypes, fldtypes, Qt::Vertical, nullptr, parent); + int fldspacing = style->combinedLayoutSpacing(fldtoptypes, fldtypes, Qt::Vertical, nullptr, parent); field->vSpace = qMax(lblspacing, fldspacing); } else - field->vSpace = style->combinedLayoutSpacing(fldtoptypes, fldtypes, Qt::Vertical, 0, parent); + field->vSpace = style->combinedLayoutSpacing(fldtoptypes, fldtypes, Qt::Vertical, nullptr, parent); } } } @@ -403,7 +403,7 @@ void QFormLayoutPrivate::updateSizes() // hard-coded the left and right control types so that all the rows have the same // inter-column spacing (otherwise the right column isn't always left aligned) if (userHSpacing < 0 && !wrapAllRows && (label || !field->fullRow) && field) - field->sbsHSpace = style->combinedLayoutSpacing(QSizePolicy::Label, QSizePolicy::LineEdit, Qt::Horizontal, 0, parent); + field->sbsHSpace = style->combinedLayoutSpacing(QSizePolicy::Label, QSizePolicy::LineEdit, Qt::Horizontal, nullptr, parent); } // Now update our min/sizehint widths @@ -594,13 +594,13 @@ static inline int spacingHelper(QWidget* parent, QStyle *style, int userVSpacing QSizePolicy::ControlTypes(item1 ? item1->controlTypes() : QSizePolicy::DefaultType); int spacing2 = 0; - spacing = style->combinedLayoutSpacing(itemtypes, prevItem1->controlTypes(), Qt::Vertical, 0, parent); + spacing = style->combinedLayoutSpacing(itemtypes, prevItem1->controlTypes(), Qt::Vertical, nullptr, parent); // At most of one of item2 and prevItem2 will be nonnull if (item2) - spacing2 = style->combinedLayoutSpacing(item2->controlTypes(), prevItem1->controlTypes(), Qt::Vertical, 0, parent); + spacing2 = style->combinedLayoutSpacing(item2->controlTypes(), prevItem1->controlTypes(), Qt::Vertical, nullptr, parent); else if (prevItem2) - spacing2 = style->combinedLayoutSpacing(itemtypes, prevItem2->controlTypes(), Qt::Vertical, 0, parent); + spacing2 = style->combinedLayoutSpacing(itemtypes, prevItem2->controlTypes(), Qt::Vertical, nullptr, parent); spacing = qMax(spacing, spacing2); } @@ -648,7 +648,7 @@ void QFormLayoutPrivate::setupVerticalLayoutData(int width) vLayouts.clear(); vLayouts.resize((2 * rr) + 2); // a max, some may be unused - QStyle *style = 0; + QStyle *style = nullptr; int userVSpacing = q->verticalSpacing(); @@ -676,8 +676,8 @@ void QFormLayoutPrivate::setupVerticalLayoutData(int width) maxLabelWidth = width; } - QFormLayoutItem *prevItem1 = 0; - QFormLayoutItem *prevItem2 = 0; + QFormLayoutItem *prevItem1 = nullptr; + QFormLayoutItem *prevItem2 = nullptr; bool prevRowSplit = false; for (int i = 0; i < rr; ++i) { @@ -711,13 +711,13 @@ void QFormLayoutPrivate::setupVerticalLayoutData(int width) initLayoutStruct(vLayouts[vidx], label); if (vidx > 1) - vLayouts[vidx - 1].spacing = spacingHelper(q->parentWidget(), style, userVSpacing, splitSideBySide || prevRowSplit, label, 0, prevItem1, prevItem2); + vLayouts[vidx - 1].spacing = spacingHelper(q->parentWidget(), style, userVSpacing, splitSideBySide || prevRowSplit, label, nullptr, prevItem1, prevItem2); label->vLayoutIndex = vidx; label->sideBySide = false; prevItem1 = label; - prevItem2 = 0; + prevItem2 = nullptr; if (vLayouts[vidx].stretch > 0) addTopBottomStretch = false; @@ -729,13 +729,13 @@ void QFormLayoutPrivate::setupVerticalLayoutData(int width) initLayoutStruct(vLayouts[vidx], field); if (vidx > 1) - vLayouts[vidx - 1].spacing = spacingHelper(q->parentWidget(), style, userVSpacing, splitSideBySide || prevRowSplit, field, 0, prevItem1, prevItem2); + vLayouts[vidx - 1].spacing = spacingHelper(q->parentWidget(), style, userVSpacing, splitSideBySide || prevRowSplit, field, nullptr, prevItem1, prevItem2); field->vLayoutIndex = vidx; field->sideBySide = false; prevItem1 = field; - prevItem2 = 0; + prevItem2 = nullptr; if (vLayouts[vidx].stretch > 0) addTopBottomStretch = false; @@ -758,7 +758,7 @@ void QFormLayoutPrivate::setupVerticalLayoutData(int width) if (label->expandingDirections() & Qt::Vertical) expanding = true; - label->sideBySide = (field != 0); + label->sideBySide = (field != nullptr); label->vLayoutIndex = vidx; stretch1 = label->vStretch(); } @@ -790,7 +790,7 @@ void QFormLayoutPrivate::setupVerticalLayoutData(int width) prevItem2 = field; } else { prevItem1 = field; - prevItem2 = 0; + prevItem2 = nullptr; } prevRowSplit = false; @@ -991,12 +991,12 @@ QLayoutItem* QFormLayoutPrivate::replaceAt(int index, QLayoutItem *newitem) { Q_Q(QFormLayout); if (!newitem) - return 0; + return nullptr; const int storageIndex = storageIndexFromLayoutItem(m_matrix, m_things.value(index)); if (Q_UNLIKELY(storageIndex == -1)) { // ### Qt6 - fix warning too when this class becomes public qWarning("QFormLayoutPrivate::replaceAt: Invalid index %d", index); - return 0; + return nullptr; } int row, col; @@ -1192,7 +1192,7 @@ QLayoutItem* QFormLayoutPrivate::replaceAt(int index, QLayoutItem *newitem) \sa QWidget::setLayout() */ QFormLayout::QFormLayout(QWidget *parent) - : QLayout(*new QFormLayoutPrivate, 0, parent) + : QLayout(*new QFormLayoutPrivate, nullptr, parent) { } @@ -1328,7 +1328,7 @@ void QFormLayout::insertRow(int row, const QString &labelText, QWidget *field) if (field && !d->checkWidget(field)) return; - QLabel *label = 0; + QLabel *label = nullptr; if (!labelText.isEmpty()) { label = new QLabel(labelText); #ifndef QT_NO_SHORTCUT @@ -1350,7 +1350,7 @@ void QFormLayout::insertRow(int row, const QString &labelText, QLayout *field) if (field && !d->checkLayout(field)) return; - insertRow(row, labelText.isEmpty() ? 0 : new QLabel(labelText), field); + insertRow(row, labelText.isEmpty() ? nullptr : new QLabel(labelText), field); } /*! @@ -1653,7 +1653,7 @@ QLayoutItem *QFormLayout::itemAt(int index) const Q_D(const QFormLayout); if (QFormLayoutItem *formItem = d->m_things.value(index)) return formItem->item; - return 0; + return nullptr; } /*! @@ -1666,7 +1666,7 @@ QLayoutItem *QFormLayout::takeAt(int index) const int storageIndex = storageIndexFromLayoutItem(d->m_matrix, d->m_things.value(index)); if (Q_UNLIKELY(storageIndex == -1)) { qWarning("QFormLayout::takeAt: Invalid index %d", index); - return 0; + return nullptr; } int row, col; @@ -1831,7 +1831,7 @@ QLayoutItem *QFormLayout::itemAt(int row, ItemRole role) const { Q_D(const QFormLayout); if (uint(row) >= uint(d->m_matrix.rowCount())) - return 0; + return nullptr; switch (role) { case SpanningRole: if (QFormLayoutItem *item = d->m_matrix(row, 1)) @@ -1844,7 +1844,7 @@ QLayoutItem *QFormLayout::itemAt(int row, ItemRole role) const return item->item; break; } - return 0; + return nullptr; } /*! @@ -1928,7 +1928,7 @@ QWidget *QFormLayout::labelForField(QWidget *field) const if (QFormLayoutItem *label = d->m_matrix(row, LabelRole)) return label->widget(); } - return 0; + return nullptr; } /*! @@ -1947,7 +1947,7 @@ QWidget *QFormLayout::labelForField(QLayout *field) const if (QFormLayoutItem *label = d->m_matrix(row, LabelRole)) return label->widget(); } - return 0; + return nullptr; } /*! -- cgit v1.2.3