Base: Quantity: return std::string

This commit is contained in:
Ladislav Michl
2024-07-13 13:07:27 +02:00
committed by Yorik van Havre
parent c11b37e312
commit 2ea8a633ac
58 changed files with 573 additions and 592 deletions

View File

@@ -78,9 +78,9 @@ std::string DimensionFormatter::formatValue(const qreal value,
asQuantity.setUnit(Base::Unit::Length);
}
QString qUserString = asQuantity.getUserString(); // this handles mm to inch/km/parsec etc
// and decimal positions but won't give more than
// Global_Decimals precision
// this handles mm to inch/km/parsec etc and decimal positions but
// won't give more than Global_Decimals precision
QString qUserString = QString::fromStdString(asQuantity.getUserString());
//get formatSpec prefix/suffix/specifier
QStringList qsl = getPrefixSuffixSpec(qFormatSpec);
@@ -132,7 +132,7 @@ std::string DimensionFormatter::formatValue(const qreal value,
qBasicUnit = QString::fromUtf8("°");
}
else {
double convertValue = Base::Quantity::parse(QString::fromLatin1("1") + qBasicUnit).getValue();
double convertValue = Base::Quantity::parse("1" + qBasicUnit.toStdString()).getValue();
userVal = asQuantity.getValue() / convertValue;
if (areaMeasure) {
userVal = userVal / convertValue; // divide again as area is length²

View File

@@ -182,13 +182,13 @@ void DrawSVGTemplate::extractTemplateAttributes(QDomDocument& templateDocument)
// Obtain the width
QString str = docElement.attribute(QString::fromLatin1("width"));
quantity = Base::Quantity::parse(str);
quantity = Base::Quantity::parse(str.toStdString());
quantity.setUnit(Base::Unit::Length);
Width.setValue(quantity.getValue());
str = docElement.attribute(QString::fromLatin1("height"));
quantity = Base::Quantity::parse(str);
quantity = Base::Quantity::parse(str.toStdString());
quantity.setUnit(Base::Unit::Length);
Height.setValue(quantity.getValue());

View File

@@ -272,8 +272,7 @@ std::string DrawViewSpreadsheet::getSheetImage()
if (prop && cell) {
if (prop->isDerivedFrom(App::PropertyQuantity::getClassTypeId())) {
auto contentAsQuantity = static_cast<App::PropertyQuantity*>(prop)->getQuantityValue();
auto ustring = contentAsQuantity.getUserString();
field << ustring.toStdString();
field << contentAsQuantity.getUserString();
} else if (prop->isDerivedFrom(App::PropertyFloat::getClassTypeId()) ||
prop->isDerivedFrom(App::PropertyInteger::getClassTypeId())) {
std::string temp = cell->getFormattedQuantity();

View File

@@ -1840,7 +1840,7 @@ void CmdTechDrawExtensionAreaAnnotation::activated(int iMsg)
asQuantity.setValue(totalArea);
asQuantity.setUnit(Base::Unit::Area);
QString qUserString = asQuantity.getUserString();
QString qUserString = QString::fromStdString(asQuantity.getUserString());
if (qUserString.endsWith(QString::fromUtf8("^2"))) {
qUserString.chop(2);
qUserString.append(QString::fromUtf8("²"));