TechDraw: Use QStringLiteral

This commit is contained in:
Benjamin Bræstrup Sayoc
2025-02-09 17:51:41 +01:00
parent 97b9b6de89
commit 9a8bdbaf9f
41 changed files with 250 additions and 250 deletions

View File

@@ -108,11 +108,11 @@ std::string DimensionFormatter::formatValue(const qreal value,
// neverheless limited. To keep old drawings, we limit the number of decimals too
// if the TD preferences option to use the global decimal number is set
// the formatSpecifier can have a prefix and/or suffix
if (m_dimension->useDecimals() && formatSpecifier.contains(QString::fromLatin1("%g"), Qt::CaseInsensitive)) {
if (m_dimension->useDecimals() && formatSpecifier.contains(QStringLiteral("%g"), Qt::CaseInsensitive)) {
int globalPrecision = Base::UnitsApi::getDecimals();
// change formatSpecifier to e.g. "%.2f"
QString newSpecifier = QString::fromStdString("%." + std::to_string(globalPrecision) + "f");
formatSpecifier.replace(QString::fromLatin1("%g"), newSpecifier, Qt::CaseInsensitive);
formatSpecifier.replace(QStringLiteral("%g"), newSpecifier, Qt::CaseInsensitive);
}
// since we are not using a multiValueSchema, we know that angles are in '°' and for
@@ -129,14 +129,14 @@ std::string DimensionFormatter::formatValue(const qreal value,
double userVal;
if (angularMeasure) {
userVal = asQuantity.getValue();
qBasicUnit = QString::fromUtf8("°");
qBasicUnit = QStringLiteral("°");
}
else {
double convertValue = Base::Quantity::parse("1" + qBasicUnit.toStdString()).getValue();
userVal = asQuantity.getValue() / convertValue;
if (areaMeasure) {
userVal = userVal / convertValue; // divide again as area is length²
qBasicUnit = qBasicUnit + QString::fromUtf8("²");
qBasicUnit = qBasicUnit + QStringLiteral("²");
}
}
@@ -287,11 +287,11 @@ std::string DimensionFormatter::getFormattedDimensionValue(const int partial) co
// tolerance might start with a plus sign that we don't want, so cut it off
// note plus sign is not at pos = 0!
QRegularExpression plus(QString::fromUtf8("^\\s*\\+"));
QRegularExpression plus(QStringLiteral("^\\s*\\+"));
tolerance.remove(plus);
return (labelText +
QString::fromUtf8(" \xC2\xB1 ") + // +/- symbol
QStringLiteral(" \xC2\xB1 ") + // +/- symbol
tolerance).toStdString();
if (partial == 2) {
@@ -398,7 +398,7 @@ std::string DimensionFormatter::getDefaultFormatSpec(bool isToleranceFormat) con
}
if (isToleranceFormat) {
formatSpec.replace(QString::fromUtf8("%"), QString::fromUtf8("%+"));
formatSpec.replace(QStringLiteral("%"), QStringLiteral("%+"));
}
return formatSpec.toStdString();

View File

@@ -141,7 +141,7 @@ QString DrawSVGTemplate::processTemplate()
// XPath query to select all <tspan> nodes whose <text> parent
// has "freecad:editable" attribute
query.processItems(QString::fromUtf8(
query.processItems(QStringLiteral(
"declare default element namespace \"" SVG_NS_URI "\"; "
"declare namespace freecad=\"" FREECAD_SVG_NS_URI "\"; "
"//text[@" FREECAD_ATTR_EDITABLE "]/tspan"),
@@ -158,7 +158,7 @@ QString DrawSVGTemplate::processTemplate()
QString editableValue = QString::fromUtf8(item->second.c_str());
// Keep all spaces in the text node
tspan.setAttribute(QString::fromUtf8("xml:space"), QString::fromUtf8("preserve"));
tspan.setAttribute(QStringLiteral("xml:space"), QStringLiteral("preserve"));
// Remove all child nodes and append text node with editable replacement as the only descendant
while (!tspan.lastChild().isNull()) {
@@ -181,13 +181,13 @@ void DrawSVGTemplate::extractTemplateAttributes(QDomDocument& templateDocument)
Base::Quantity quantity;
// Obtain the width
QString str = docElement.attribute(QString::fromLatin1("width"));
QString str = docElement.attribute(QStringLiteral("width"));
quantity = Base::Quantity::parse(str.toStdString());
quantity.setUnit(Base::Unit::Length);
Width.setValue(quantity.getValue());
str = docElement.attribute(QString::fromLatin1("height"));
str = docElement.attribute(QStringLiteral("height"));
quantity = Base::Quantity::parse(str.toStdString());
quantity.setUnit(Base::Unit::Length);
@@ -258,7 +258,7 @@ std::map<std::string, std::string> DrawSVGTemplate::getEditableTextsFromTemplate
// XPath query to select all <tspan> nodes whose <text> parent
// has "freecad:editable" attribute
query.processItems(QString::fromUtf8(
query.processItems(QStringLiteral(
"declare default element namespace \"" SVG_NS_URI "\"; "
"declare namespace freecad=\"" FREECAD_SVG_NS_URI "\"; "
"//text[@" FREECAD_ATTR_EDITABLE "]/tspan"),
@@ -301,7 +301,7 @@ QString DrawSVGTemplate::getAutofillByEditableName(QString nameToMatch)
// XPath query to select all <tspan> nodes whose <text> parent
// has "freecad:editable" attribute
query.processItems(QString::fromUtf8(
query.processItems(QStringLiteral(
"declare default element namespace \"" SVG_NS_URI "\"; "
"declare namespace freecad=\"" FREECAD_SVG_NS_URI "\"; "
"//text[@" FREECAD_ATTR_EDITABLE "]/tspan"),

View File

@@ -1964,7 +1964,7 @@ QString DrawUtil::qbaToDebug(const QByteArray& line)
if ((c >= 0x20) && (c <= 126)) {
s.append(QChar::fromLatin1(c));
} else {
s.append(QString::fromUtf8("<%1>").arg(c, 2, 16, QChar::fromLatin1('0')));
s.append(QStringLiteral("<%1>").arg(c, 2, 16, QChar::fromLatin1('0')));
}
}
return s;

View File

@@ -123,7 +123,7 @@ std::vector<std::string> DrawViewSymbol::getEditableFields()
// XPath query to select all <tspan> nodes whose <text> parent
// has "freecad:editable" attribute
query.processItems(QString::fromUtf8("declare default element namespace \"" SVG_NS_URI "\"; "
query.processItems(QStringLiteral("declare default element namespace \"" SVG_NS_URI "\"; "
"declare namespace freecad=\"" FREECAD_SVG_NS_URI "\"; "
"//text[@" FREECAD_ATTR_EDITABLE "]/tspan"),
[&editables](QDomElement& tspan) -> bool {
@@ -152,7 +152,7 @@ void DrawViewSymbol::updateFieldsInSymbol()
// XPath query to select all <tspan> nodes whose <text> parent
// has "freecad:editable" attribute
query.processItems(QString::fromUtf8("declare default element namespace \"" SVG_NS_URI "\"; "
query.processItems(QStringLiteral("declare default element namespace \"" SVG_NS_URI "\"; "
"declare namespace freecad=\"" FREECAD_SVG_NS_URI "\"; "
"//text[@" FREECAD_ATTR_EDITABLE "]/tspan"),
[&symbolDocument, &editText, &count](QDomElement& tspanElement) -> bool {
@@ -161,8 +161,8 @@ void DrawViewSymbol::updateFieldsInSymbol()
return false;
}
// Keep all spaces in the text node
tspanElement.setAttribute(QString::fromUtf8("xml:space"),
QString::fromUtf8("preserve"));
tspanElement.setAttribute(QStringLiteral("xml:space"),
QStringLiteral("preserve"));
// Remove all child nodes (if any)
while (!tspanElement.lastChild().isNull()) {