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/widgets/qdialogbuttonbox.cpp | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'src/widgets/widgets/qdialogbuttonbox.cpp') diff --git a/src/widgets/widgets/qdialogbuttonbox.cpp b/src/widgets/widgets/qdialogbuttonbox.cpp index 9096ee82f6..9867cb5540 100644 --- a/src/widgets/widgets/qdialogbuttonbox.cpp +++ b/src/widgets/widgets/qdialogbuttonbox.cpp @@ -178,15 +178,15 @@ public: }; QDialogButtonBoxPrivate::QDialogButtonBoxPrivate(Qt::Orientation orient) - : orientation(orient), buttonLayout(0), internalRemove(false), center(false) + : orientation(orient), buttonLayout(nullptr), internalRemove(false), center(false) { } void QDialogButtonBoxPrivate::initLayout() { Q_Q(QDialogButtonBox); - layoutPolicy = QDialogButtonBox::ButtonLayout(q->style()->styleHint(QStyle::SH_DialogButtonLayout, 0, q)); - bool createNewLayout = buttonLayout == 0 + layoutPolicy = QDialogButtonBox::ButtonLayout(q->style()->styleHint(QStyle::SH_DialogButtonLayout, nullptr, q)); + bool createNewLayout = buttonLayout == nullptr || (orientation == Qt::Horizontal && qobject_cast(buttonLayout) != 0) || (orientation == Qt::Vertical && qobject_cast(buttonLayout) != 0); if (createNewLayout) { @@ -329,8 +329,8 @@ void QDialogButtonBoxPrivate::layoutButtons() ++currentLayout; } - QWidget *lastWidget = 0; - q->setFocusProxy(0); + QWidget *lastWidget = nullptr; + q->setFocusProxy(nullptr); for (int i = 0; i < buttonLayout->count(); ++i) { QLayoutItem *item = buttonLayout->itemAt(i); if (QWidget *widget = item->widget()) { @@ -408,13 +408,13 @@ QPushButton *QDialogButtonBoxPrivate::createButton(QDialogButtonBox::StandardBut icon = QStyle::SP_RestoreDefaultsButton; break; case QDialogButtonBox::NoButton: - return 0; + return nullptr; ; } QPushButton *button = new QPushButton(QGuiApplicationPrivate::platformTheme()->standardButtonText(sbutton), q); QStyle *style = q->style(); - if (style->styleHint(QStyle::SH_DialogButtonBox_ButtonsHaveIcons, 0, q) && icon != 0) - button->setIcon(style->standardIcon(QStyle::StandardPixmap(icon), 0, q)); + if (style->styleHint(QStyle::SH_DialogButtonBox_ButtonsHaveIcons, nullptr, q) && icon != 0) + button->setIcon(style->standardIcon(QStyle::StandardPixmap(icon), nullptr, q)); if (style != QApplication::style()) // Propagate style button->setStyle(style); standardButtonHash.insert(button, sbutton); @@ -743,7 +743,7 @@ void QDialogButtonBox::removeButton(QAbstractButton *button) } } if (!d->internalRemove) - button->setParent(0); + button->setParent(nullptr); } /*! @@ -781,7 +781,7 @@ QPushButton *QDialogButtonBox::addButton(const QString &text, ButtonRole role) Q_D(QDialogButtonBox); if (Q_UNLIKELY(role <= InvalidRole || role >= NRoles)) { qWarning("QDialogButtonBox::addButton: Invalid ButtonRole, button not added"); - return 0; + return nullptr; } QPushButton *button = new QPushButton(text, this); d->addButton(button, role); @@ -963,7 +963,7 @@ bool QDialogButtonBox::event(QEvent *event) QList acceptRoleList = d->buttonLists[AcceptRole]; QPushButton *firstAcceptButton = acceptRoleList.isEmpty() ? 0 : qobject_cast(acceptRoleList.at(0)); bool hasDefault = false; - QWidget *dialog = 0; + QWidget *dialog = nullptr; QWidget *p = this; while (p && !p->isWindow()) { p = p->parentWidget(); -- cgit v1.2.3