From 304ff66b068fa24b18bf2162a602d4687b17f0a2 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Mon, 19 Feb 2024 11:24:10 +0200 Subject: [PATCH] Use the "nullptr" literal. --- src/libs/vdxf/libdxfrw/libdxfrw.cpp | 4 +-- .../plugins/vemptyproperty.cpp | 26 +++++++++--------- .../vpropertyfactorymanager.cpp | 27 +++++++++---------- src/libs/vwidgets/qtcolorpicker.cpp | 10 +++---- src/libs/vwidgets/qtcolorpicker.h | 2 +- 5 files changed, 33 insertions(+), 36 deletions(-) diff --git a/src/libs/vdxf/libdxfrw/libdxfrw.cpp b/src/libs/vdxf/libdxfrw/libdxfrw.cpp index 78287d897..99747e36d 100644 --- a/src/libs/vdxf/libdxfrw/libdxfrw.cpp +++ b/src/libs/vdxf/libdxfrw/libdxfrw.cpp @@ -1641,7 +1641,7 @@ auto dxfRW::writeImage(DRW_Image *ent, const std::string &name) -> DRW_ImageDef { // search if exist imagedef with this mane (image inserted more than 1 time) // RLZ: imagedef_reactor seem needed to read in acad - DRW_ImageDef *id = NULL; + DRW_ImageDef *id = nullptr; for (unsigned int i = 0; i < imageDef.size(); i++) { if (imageDef.at(i)->name == name) @@ -1682,7 +1682,7 @@ auto dxfRW::writeImage(DRW_Image *ent, const std::string &name) -> DRW_ImageDef id->reactors[idReactor] = toHexStr(static_cast(ent->handle)); return id; } - return NULL; // not exist in acad 12 + return nullptr; // not exist in acad 12 } auto dxfRW::writeBlockRecord(std::string name) -> bool diff --git a/src/libs/vpropertyexplorer/plugins/vemptyproperty.cpp b/src/libs/vpropertyexplorer/plugins/vemptyproperty.cpp index d2c7944f7..836277339 100644 --- a/src/libs/vpropertyexplorer/plugins/vemptyproperty.cpp +++ b/src/libs/vpropertyexplorer/plugins/vemptyproperty.cpp @@ -20,35 +20,34 @@ #include "vemptyproperty.h" -#include #include #include #include #include +#include #include "../vproperty.h" -namespace VPE { +namespace VPE +{ class VPropertyPrivate; -} // namespace VPE +} // namespace VPE -VPE::VEmptyProperty::VEmptyProperty(const QString& name) - : VProperty(name, +VPE::VEmptyProperty::VEmptyProperty(const QString &name) + : VProperty(name, #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) - QMetaType::UnknownType) + QMetaType::UnknownType) #else - QVariant::Invalid) + QVariant::Invalid) #endif { } - VPE::VEmptyProperty::VEmptyProperty(VPropertyPrivate *d) - : VProperty(d) + : VProperty(d) { } - VPE::VEmptyProperty::~VEmptyProperty() { // @@ -61,12 +60,12 @@ auto VPE::VEmptyProperty::data(int column, int role) const -> QVariant { return QVariant(); } - + if (role == Qt::BackgroundRole) { return QBrush(QColor(217, 217, 217)); } - + if (role == Qt::FontRole) { QFont tmpFont; @@ -85,10 +84,9 @@ auto VPE::VEmptyProperty::createEditor(QWidget *parent, const QStyleOptionViewIt Q_UNUSED(parent) Q_UNUSED(delegate) - return NULL; + return nullptr; } - //! Gets the data from the widget auto VPE::VEmptyProperty::getEditorData(const QWidget *editor) const -> QVariant { diff --git a/src/libs/vpropertyexplorer/vpropertyfactorymanager.cpp b/src/libs/vpropertyexplorer/vpropertyfactorymanager.cpp index 94b2241cb..a74e7c6b8 100644 --- a/src/libs/vpropertyexplorer/vpropertyfactorymanager.cpp +++ b/src/libs/vpropertyexplorer/vpropertyfactorymanager.cpp @@ -20,36 +20,35 @@ #include "vpropertyfactorymanager.h" -#include #include #include #include +#include #include "vabstractpropertyfactory.h" #include "vproperty.h" #include "vpropertyfactorymanager_p.h" #include "vstandardpropertyfactory.h" -VPE::VPropertyFactoryManager* VPE::VPropertyFactoryManager::DefaultManager = NULL; +VPE::VPropertyFactoryManager *VPE::VPropertyFactoryManager::DefaultManager = nullptr; VPE::VPropertyFactoryManager::VPropertyFactoryManager(QObject *parent) - : QObject(parent), d_ptr(new VPropertyFactoryManagerPrivate()) + : QObject(parent), + d_ptr(new VPropertyFactoryManagerPrivate()) { - } VPE::VPropertyFactoryManager::~VPropertyFactoryManager() { // Delete all factories - QList tmpFactories = d_ptr->Factories.values(); + QList tmpFactories = d_ptr->Factories.values(); while (!tmpFactories.isEmpty()) { - VAbstractPropertyFactory* tmpFactory = tmpFactories.takeLast(); + VAbstractPropertyFactory *tmpFactory = tmpFactories.takeLast(); tmpFactories.removeAll(tmpFactory); delete tmpFactory; } - delete d_ptr; if (this == DefaultManager) { @@ -57,7 +56,7 @@ VPE::VPropertyFactoryManager::~VPropertyFactoryManager() } } -void VPE::VPropertyFactoryManager::registerFactory(const QString& type, VAbstractPropertyFactory* factory) +void VPE::VPropertyFactoryManager::registerFactory(const QString &type, VAbstractPropertyFactory *factory) { if (type.isEmpty()) { @@ -70,8 +69,8 @@ void VPE::VPropertyFactoryManager::registerFactory(const QString& type, VAbstrac d_ptr->Factories[type] = factory; } -void VPE::VPropertyFactoryManager::unregisterFactory(VAbstractPropertyFactory* factory, const QString& type, - bool delete_if_unused) +void VPE::VPropertyFactoryManager::unregisterFactory(VAbstractPropertyFactory *factory, const QString &type, + bool delete_if_unused) { if (!factory) { @@ -89,7 +88,7 @@ void VPE::VPropertyFactoryManager::unregisterFactory(VAbstractPropertyFactory* f { d_ptr->Factories.remove(tmpKey); } - } while(!tmpKey.isEmpty()); + } while (!tmpKey.isEmpty()); } else { @@ -119,8 +118,8 @@ auto VPE::VPropertyFactoryManager::getFactory(const QString &type) -> VPE::VAbst auto VPE::VPropertyFactoryManager::createProperty(const QString &type, const QString &name, const QString &description, const QString &default_value) -> VPE::VProperty * { - VAbstractPropertyFactory* tmpFactory = getFactory(type); - VProperty* tmpResult = NULL; + VAbstractPropertyFactory *tmpFactory = getFactory(type); + VProperty *tmpResult = nullptr; if (tmpFactory) { tmpResult = tmpFactory->createProperty(type, name); @@ -140,7 +139,7 @@ auto VPE::VPropertyFactoryManager::createProperty(const QString &type, const QSt } // cppcheck-suppress unusedFunction -//VPE::VPropertyFactoryManager *VPE::VPropertyFactoryManager::getDefaultManager() +// VPE::VPropertyFactoryManager *VPE::VPropertyFactoryManager::getDefaultManager() //{ // if (!DefaultManager) // { diff --git a/src/libs/vwidgets/qtcolorpicker.cpp b/src/libs/vwidgets/qtcolorpicker.cpp index e0cfb8eb0..e1e4d920f 100644 --- a/src/libs/vwidgets/qtcolorpicker.cpp +++ b/src/libs/vwidgets/qtcolorpicker.cpp @@ -168,7 +168,7 @@ class ColorPickerItem : public QFrame Q_OBJECT // NOLINT public: - ColorPickerItem(const QColor &color = Qt::white, const QString &text = QString(), QWidget *parent = 0); + ColorPickerItem(const QColor &color = Qt::white, const QString &text = QString(), QWidget *parent = nullptr); ~ColorPickerItem(); auto color() const -> QColor; @@ -573,7 +573,7 @@ ColorPickerPopup::ColorPickerPopup(int width, bool withColorDialog, QWidget *par } else { - moreButton = 0; + moreButton = nullptr; } eventLoop = nullptr; @@ -709,7 +709,7 @@ void ColorPickerPopup::updateSelected() { QLayoutItem *layoutItem; int i = 0; - while ((layoutItem = grid->itemAt(i)) != 0) + while ((layoutItem = grid->itemAt(i)) != nullptr) { QWidget *w = layoutItem->widget(); if (w && w->inherits("ColorPickerItem")) @@ -832,7 +832,7 @@ void ColorPickerPopup::keyPressEvent(QKeyEvent *e) QLayoutItem *layoutItem; int i = 0; - while ((layoutItem = grid->itemAt(i)) != 0) + while ((layoutItem = grid->itemAt(i)) != nullptr) { QWidget *wl = layoutItem->widget(); if (wl && wl->inherits("ColorPickerItem")) @@ -857,7 +857,7 @@ void ColorPickerPopup::keyPressEvent(QKeyEvent *e) QLayoutItem *layoutItem; int i = 0; - while ((layoutItem = grid->itemAt(i)) != 0) + while ((layoutItem = grid->itemAt(i)) != nullptr) { QWidget *wl = layoutItem->widget(); if (wl && wl->inherits("ColorPickerItem")) diff --git a/src/libs/vwidgets/qtcolorpicker.h b/src/libs/vwidgets/qtcolorpicker.h index 24e1d3fe7..8a157a352 100644 --- a/src/libs/vwidgets/qtcolorpicker.h +++ b/src/libs/vwidgets/qtcolorpicker.h @@ -64,7 +64,7 @@ class QtColorPicker : public QPushButton Q_PROPERTY(bool colorDialog READ colorDialogEnabled WRITE setColorDialogEnabled) public: - explicit QtColorPicker(QWidget *parent = 0, int columns = -1, bool enableColorDialog = true); + explicit QtColorPicker(QWidget *parent = nullptr, int columns = -1, bool enableColorDialog = true); ~QtColorPicker() override;