From bafb6cfb9f2e15b7c6ec85c6ac2cceb897d5d0e8 Mon Sep 17 00:00:00 2001 From: wmayer Date: Sat, 19 Aug 2023 11:29:49 +0200 Subject: [PATCH] Sheet: modernize C++: return braced init list --- .../App/PropertyColumnWidthsPyImp.cpp | 2 +- .../App/PropertyRowHeightsPyImp.cpp | 2 +- .../Spreadsheet/App/PropertySheetPyImp.cpp | 2 +- src/Mod/Spreadsheet/App/Sheet.cpp | 3 +- src/Mod/Spreadsheet/App/SheetPyImp.cpp | 2 +- src/Mod/Spreadsheet/Gui/SheetModel.cpp | 34 +++++++++---------- .../Spreadsheet/Gui/SpreadsheetDelegate.cpp | 2 +- .../Gui/ViewProviderSpreadsheetPyImp.cpp | 2 +- 8 files changed, 23 insertions(+), 26 deletions(-) diff --git a/src/Mod/Spreadsheet/App/PropertyColumnWidthsPyImp.cpp b/src/Mod/Spreadsheet/App/PropertyColumnWidthsPyImp.cpp index 1e891ec69f..62301901ef 100644 --- a/src/Mod/Spreadsheet/App/PropertyColumnWidthsPyImp.cpp +++ b/src/Mod/Spreadsheet/App/PropertyColumnWidthsPyImp.cpp @@ -33,7 +33,7 @@ using namespace Spreadsheet; // returns a string which represents the object e.g. when printed in python std::string PropertyColumnWidthsPy::representation() const { - return std::string(""); + return {""}; } PyObject *PropertyColumnWidthsPy::PyMake(struct _typeobject *, PyObject *, PyObject *) // Python wrapper diff --git a/src/Mod/Spreadsheet/App/PropertyRowHeightsPyImp.cpp b/src/Mod/Spreadsheet/App/PropertyRowHeightsPyImp.cpp index 34bb95278d..8c0754b0ff 100644 --- a/src/Mod/Spreadsheet/App/PropertyRowHeightsPyImp.cpp +++ b/src/Mod/Spreadsheet/App/PropertyRowHeightsPyImp.cpp @@ -33,7 +33,7 @@ using namespace Spreadsheet; // returns a string which represents the object e.g. when printed in python std::string PropertyRowHeightsPy::representation() const { - return std::string(""); + return {""}; } PyObject *PropertyRowHeightsPy::PyMake(struct _typeobject *, PyObject *, PyObject *) // Python wrapper diff --git a/src/Mod/Spreadsheet/App/PropertySheetPyImp.cpp b/src/Mod/Spreadsheet/App/PropertySheetPyImp.cpp index 8d735b8e27..c0bf240ed2 100644 --- a/src/Mod/Spreadsheet/App/PropertySheetPyImp.cpp +++ b/src/Mod/Spreadsheet/App/PropertySheetPyImp.cpp @@ -33,7 +33,7 @@ using namespace Spreadsheet; // returns a string which represents the object e.g. when printed in python std::string PropertySheetPy::representation() const { - return std::string(""); + return {""}; } PyObject *PropertySheetPy::PyMake(struct _typeobject *, PyObject *, PyObject *) // Python wrapper diff --git a/src/Mod/Spreadsheet/App/Sheet.cpp b/src/Mod/Spreadsheet/App/Sheet.cpp index b74ec465c7..c4b2c6940f 100644 --- a/src/Mod/Spreadsheet/App/Sheet.cpp +++ b/src/Mod/Spreadsheet/App/Sheet.cpp @@ -1399,8 +1399,7 @@ std::string Sheet::getAddressFromAlias(const std::string &alias) const if (cell) return cell->getAddress().toString(); - else - return std::string(); + return {}; } /** diff --git a/src/Mod/Spreadsheet/App/SheetPyImp.cpp b/src/Mod/Spreadsheet/App/SheetPyImp.cpp index 7c84aba63f..65c22eeb2c 100644 --- a/src/Mod/Spreadsheet/App/SheetPyImp.cpp +++ b/src/Mod/Spreadsheet/App/SheetPyImp.cpp @@ -40,7 +40,7 @@ using namespace App; // returns a string which represents the object e.g. when printed in python std::string SheetPy::representation() const { - return std::string(""); + return {""}; } PyObject *SheetPy::PyMake(struct _typeobject *, PyObject *, PyObject *) // Python wrapper diff --git a/src/Mod/Spreadsheet/Gui/SheetModel.cpp b/src/Mod/Spreadsheet/Gui/SheetModel.cpp index 4f45f03d78..86cd2f099d 100644 --- a/src/Mod/Spreadsheet/Gui/SheetModel.cpp +++ b/src/Mod/Spreadsheet/Gui/SheetModel.cpp @@ -176,8 +176,7 @@ QVariant SheetModel::data(const QModelIndex& index, int role) const if (cell->getStringContent(str)) return QVariant(QString::fromUtf8(str.c_str())); - else - return QVariant(); + return {}; } // Get display value as computed property @@ -195,8 +194,7 @@ QVariant SheetModel::data(const QModelIndex& index, int role) const if (cell->getAlias(alias)) { return QVariant::fromValue(aliasBgColor); } - else - return QVariant(); + return {}; } } @@ -250,23 +248,23 @@ QVariant SheetModel::data(const QModelIndex& index, int role) const case Qt::DisplayRole: if (cell->getExpression()) { std::string str; - if (cell->getStringContent(str)) - if (!str.empty() && str[0] == '=') + if (cell->getStringContent(str)) { + if (!str.empty() && str[0] == '=') { // If this is a real computed value, indicate that a recompute is // needed before we can display it return QVariant(QLatin1String("#PENDING")); - else + } + else { // If it's just a simple value, display the new value, but still // format it as a pending value to indicate to the user that // a recompute is needed return QVariant(QString::fromUtf8(str.c_str())); - else - return QVariant(); + } + } } - else - return QVariant(); + return {}; default: - return QVariant(); + return {}; } } else if (prop->isDerivedFrom(App::PropertyString::getClassTypeId())) { @@ -299,7 +297,7 @@ QVariant SheetModel::data(const QModelIndex& index, int role) const return QVariant::fromValue(qtAlignment); } default: - return QVariant(); + return {}; } } else if (prop->isDerivedFrom(App::PropertyQuantity::getClassTypeId())) { @@ -359,7 +357,7 @@ QVariant SheetModel::data(const QModelIndex& index, int role) const return formatCellDisplay(v, cell); } default: - return QVariant(); + return {}; } } else if (prop->isDerivedFrom(App::PropertyFloat::getClassTypeId()) @@ -421,7 +419,7 @@ QVariant SheetModel::data(const QModelIndex& index, int role) const return formatCellDisplay(v, cell); } default: - return QVariant(); + return {}; } } else if (prop->isDerivedFrom(App::PropertyPythonObject::getClassTypeId())) { @@ -470,11 +468,11 @@ QVariant SheetModel::data(const QModelIndex& index, int role) const return formatCellDisplay(v, cell); } default: - return QVariant(); + return {}; } } - return QVariant(); + return {}; } QVariant SheetModel::headerData(int section, Qt::Orientation orientation, int role) const @@ -502,7 +500,7 @@ QVariant SheetModel::headerData(int section, Qt::Orientation orientation, int ro return QString::number(section + 1); } } - return QVariant(); + return {}; } void SheetModel::setCellData(QModelIndex index, QString str) diff --git a/src/Mod/Spreadsheet/Gui/SpreadsheetDelegate.cpp b/src/Mod/Spreadsheet/Gui/SpreadsheetDelegate.cpp index 93c295913b..862d9ebe81 100644 --- a/src/Mod/Spreadsheet/Gui/SpreadsheetDelegate.cpp +++ b/src/Mod/Spreadsheet/Gui/SpreadsheetDelegate.cpp @@ -94,7 +94,7 @@ QSize SpreadsheetDelegate::sizeHint(const QStyleOptionViewItem & option, const Q { Q_UNUSED(option); Q_UNUSED(index); - return QSize(); + return {}; } static inline void drawBorder(QPainter *painter, const QStyleOptionViewItem &option, diff --git a/src/Mod/Spreadsheet/Gui/ViewProviderSpreadsheetPyImp.cpp b/src/Mod/Spreadsheet/Gui/ViewProviderSpreadsheetPyImp.cpp index 6d60b1c504..b8b2783dd9 100644 --- a/src/Mod/Spreadsheet/Gui/ViewProviderSpreadsheetPyImp.cpp +++ b/src/Mod/Spreadsheet/Gui/ViewProviderSpreadsheetPyImp.cpp @@ -32,7 +32,7 @@ using namespace SpreadsheetGui; // returns a string which represents the object e.g. when printed in python std::string ViewProviderSpreadsheetPy::representation() const { - return std::string(""); + return {""}; } PyObject* ViewProviderSpreadsheetPy::getView(PyObject* args)