Part: modernize C++: return braced init list

This commit is contained in:
wmayer
2023-08-19 11:01:36 +02:00
parent e98891859e
commit 0d854a56cd
56 changed files with 128 additions and 128 deletions

View File

@@ -135,7 +135,7 @@ void TaskSketchBasedParameters::exitSelectionMode()
QVariant TaskSketchBasedParameters::setUpToFace(const QString& text)
{
if (text.isEmpty())
return QVariant();
return {};
QStringList parts = text.split(QChar::fromLatin1(':'));
if (parts.length() < 2)
@@ -144,15 +144,15 @@ QVariant TaskSketchBasedParameters::setUpToFace(const QString& text)
// Check whether this is the name of an App::Plane or Part::Datum feature
App::DocumentObject* obj = vp->getObject()->getDocument()->getObject(parts[0].toLatin1());
if (!obj)
return QVariant();
return {};
if (obj->getTypeId().isDerivedFrom(App::Plane::getClassTypeId())) {
// everything is OK (we assume a Part can only have exactly 3 App::Plane objects located at the base of the feature tree)
return QVariant();
return {};
}
else if (obj->getTypeId().isDerivedFrom(Part::Datum::getClassTypeId())) {
// it's up to the document to check that the datum plane is in the same body
return QVariant();
return {};
}
else {
// We must expect that "parts[1]" is the translation of "Face" followed by an ID.
@@ -162,7 +162,7 @@ QVariant TaskSketchBasedParameters::setUpToFace(const QString& text)
QRegularExpression rx(name);
QRegularExpressionMatch match;
if (parts[1].indexOf(rx, 0, &match) < 0) {
return QVariant();
return {};
}
int faceId = match.captured(1).toInt();
@@ -200,7 +200,7 @@ QVariant TaskSketchBasedParameters::objectNameByLabel(const QString& label,
}
}
return QVariant(); // no such feature found
return {}; // no such feature found
}
QString TaskSketchBasedParameters::getFaceReference(const QString& obj, const QString& sub) const
@@ -209,7 +209,7 @@ QString TaskSketchBasedParameters::getFaceReference(const QString& obj, const QS
QString o = obj.left(obj.indexOf(QString::fromLatin1(":")));
if (o.isEmpty())
return QString();
return {};
return QString::fromLatin1(R"((App.getDocument("%1").%2, ["%3"]))")
.arg(QString::fromLatin1(doc->getName()), o, sub);
@@ -223,7 +223,7 @@ QString TaskSketchBasedParameters::make2DLabel(const App::DocumentObject* sectio
}
else if (subValues.empty()) {
Base::Console().Error("No valid subelement linked in %s\n", section->Label.getValue());
return QString();
return {};
}
else {
return QString::fromStdString((std::string(section->getNameInDocument()) + ":" + subValues[0]));