Fem: Use QStringLiteral

This commit is contained in:
Benjamin Bræstrup Sayoc
2025-02-09 18:17:43 +01:00
parent 2ea8b4b635
commit 4ed902e07f
7 changed files with 26 additions and 26 deletions

View File

@@ -150,7 +150,7 @@ private:
Gui::getMainWindow()->addWindow(edit);
QFont font = editor->font();
font.setFamily(QString::fromLatin1("Arial"));
font.setFamily(QStringLiteral("Arial"));
editor->setFont(font);
}

View File

@@ -349,7 +349,7 @@ bool TaskDlgFemConstraintBearing::accept()
std::string locobj = parameterBearing->getLocationObject().data();
if (!locname.empty()) {
QString buf = QString::fromUtf8("(App.ActiveDocument.%1,[\"%2\"])");
QString buf = QStringLiteral("(App.ActiveDocument.%1,[\"%2\"])");
buf = buf.arg(QString::fromStdString(locname));
buf = buf.arg(QString::fromStdString(locobj));
Gui::Command::doCommand(Gui::Command::Doc,

View File

@@ -409,21 +409,21 @@ std::string TaskFemConstraintDisplacement::get_spinzRotation() const
std::string TaskFemConstraintDisplacement::get_xFormula() const
{
QString xFormula = ui->DisplacementXFormulaLE->text();
xFormula.replace(QString::fromLatin1("\""), QString::fromLatin1("\\\""));
xFormula.replace(QStringLiteral("\""), QStringLiteral("\\\""));
return xFormula.toStdString();
}
std::string TaskFemConstraintDisplacement::get_yFormula() const
{
QString yFormula = ui->DisplacementYFormulaLE->text();
yFormula.replace(QString::fromLatin1("\""), QString::fromLatin1("\\\""));
yFormula.replace(QStringLiteral("\""), QStringLiteral("\\\""));
return yFormula.toStdString();
}
std::string TaskFemConstraintDisplacement::get_zFormula() const
{
QString zFormula = ui->DisplacementZFormulaLE->text();
zFormula.replace(QString::fromLatin1("\""), QString::fromLatin1("\\\""));
zFormula.replace(QStringLiteral("\""), QStringLiteral("\\\""));
return zFormula.toStdString();
}

View File

@@ -387,31 +387,31 @@ void TaskFemConstraintFluidBoundary::updateBoundaryTypeUI()
// Update subtypes, any change here should be written back to FemConstraintFluidBoundary.cpp
if (boundaryType == "wall") {
ui->labelBoundaryValue->setText(QString::fromUtf8("velocity (m/s)"));
ui->labelBoundaryValue->setText(QStringLiteral("velocity (m/s)"));
ui->tabBasicBoundary->setEnabled(false);
pcConstraint->Subtype.setEnums(WallSubtypes);
}
else if (boundaryType == "interface") {
ui->labelBoundaryValue->setText(QString::fromUtf8("value not needed"));
ui->labelBoundaryValue->setText(QStringLiteral("value not needed"));
ui->tabBasicBoundary->setEnabled(false);
pcConstraint->Subtype.setEnums(InterfaceSubtypes);
}
else if (boundaryType == "freestream") {
ui->tabBasicBoundary->setEnabled(false);
ui->labelBoundaryValue->setText(QString::fromUtf8("value not needed"));
ui->labelBoundaryValue->setText(QStringLiteral("value not needed"));
ui->tabBasicBoundary->setEnabled(false);
pcConstraint->Subtype.setEnums(FreestreamSubtypes);
}
else if (boundaryType == "inlet") {
ui->tabBasicBoundary->setEnabled(true);
pcConstraint->Subtype.setEnums(InletSubtypes);
ui->labelBoundaryValue->setText(QString::fromUtf8("Pressure [Pa]")); // default to pressure
ui->labelBoundaryValue->setText(QStringLiteral("Pressure [Pa]")); // default to pressure
pcConstraint->Reversed.setValue(true); // inlet must point into volume
}
else if (boundaryType == "outlet") {
ui->tabBasicBoundary->setEnabled(true);
pcConstraint->Subtype.setEnums(OutletSubtypes);
ui->labelBoundaryValue->setText(QString::fromUtf8("Pressure [Pa]"));
ui->labelBoundaryValue->setText(QStringLiteral("Pressure [Pa]"));
pcConstraint->Reversed.setValue(false); // outlet must point outward
}
else {
@@ -437,49 +437,49 @@ void TaskFemConstraintFluidBoundary::updateSubtypeUI()
if (boundaryType == "inlet" || boundaryType == "outlet") {
ui->tabBasicBoundary->setEnabled(true);
if (subtype == "totalPressure" || subtype == "staticPressure") {
ui->labelBoundaryValue->setText(QString::fromUtf8("pressure [Pa]"));
ui->labelBoundaryValue->setText(QStringLiteral("pressure [Pa]"));
ui->buttonDirection->setEnabled(false);
ui->lineDirection->setEnabled(false);
}
else if (subtype == "uniformVelocity") {
ui->labelBoundaryValue->setText(QString::fromUtf8("velocity [m/s]"));
ui->labelBoundaryValue->setText(QStringLiteral("velocity [m/s]"));
ui->buttonDirection->setEnabled(true);
ui->lineDirection->setEnabled(true);
}
else if (subtype == "massFlowrate") {
ui->labelBoundaryValue->setText(QString::fromUtf8("flowrate [kg/s]"));
ui->labelBoundaryValue->setText(QStringLiteral("flowrate [kg/s]"));
ui->buttonDirection->setEnabled(false);
ui->lineDirection->setEnabled(false);
}
else if (subtype == "volumetricFlowRate") {
ui->labelBoundaryValue->setText(QString::fromUtf8("flowrate [m3/s]"));
ui->labelBoundaryValue->setText(QStringLiteral("flowrate [m3/s]"));
ui->buttonDirection->setEnabled(false);
ui->lineDirection->setEnabled(false);
}
else {
ui->labelBoundaryValue->setText(QString::fromUtf8("unspecific"));
ui->labelBoundaryValue->setText(QStringLiteral("unspecific"));
ui->tabBasicBoundary->setEnabled(false);
}
}
else if (boundaryType == "wall") {
if (subtype == "moving") {
ui->labelBoundaryValue->setText(QString::fromUtf8("moving speed (m/s)"));
ui->labelBoundaryValue->setText(QStringLiteral("moving speed (m/s)"));
ui->tabBasicBoundary->setEnabled(true);
ui->buttonDirection->setEnabled(false); // moving speed must be parallel to wall
ui->lineDirection->setEnabled(false);
}
else if (subtype == "slip") {
ui->labelBoundaryValue->setText(QString::fromUtf8("not needed"));
ui->labelBoundaryValue->setText(QStringLiteral("not needed"));
ui->tabBasicBoundary->setEnabled(false);
}
else if (subtype == "partialSlip") {
ui->labelBoundaryValue->setText(QString::fromUtf8("slip ratio(0~1)"));
ui->labelBoundaryValue->setText(QStringLiteral("slip ratio(0~1)"));
ui->tabBasicBoundary->setEnabled(true);
ui->buttonDirection->setEnabled(false);
ui->lineDirection->setEnabled(false);
}
else {
ui->labelBoundaryValue->setText(QString::fromUtf8("unspecific"));
ui->labelBoundaryValue->setText(QStringLiteral("unspecific"));
ui->tabBasicBoundary->setEnabled(false);
}
}
@@ -1016,7 +1016,7 @@ bool TaskDlgFemConstraintFluidBoundary::accept()
std::string dirobj = boundary->getDirectionObject().data();
if (!dirname.empty()) {
QString buf = QString::fromUtf8("(App.ActiveDocument.%1,[\"%2\"])");
QString buf = QStringLiteral("(App.ActiveDocument.%1,[\"%2\"])");
buf = buf.arg(QString::fromStdString(dirname));
buf = buf.arg(QString::fromStdString(dirobj));
Gui::Command::doCommand(Gui::Command::Doc,

View File

@@ -434,7 +434,7 @@ bool TaskDlgFemConstraintForce::accept()
std::string scale = "1";
if (!dirname.empty()) {
QString buf = QString::fromUtf8("(App.ActiveDocument.%1,[\"%2\"])");
QString buf = QStringLiteral("(App.ActiveDocument.%1,[\"%2\"])");
buf = buf.arg(QString::fromStdString(dirname));
buf = buf.arg(QString::fromStdString(dirobj));
Gui::Command::doCommand(Gui::Command::Doc,

View File

@@ -298,7 +298,7 @@ bool TaskDlgFemConstraintGear::accept()
std::string dirobj = parameterGear->getDirectionObject().data();
if (!dirname.empty()) {
QString buf = QString::fromUtf8("(App.ActiveDocument.%1,[\"%2\"])");
QString buf = QStringLiteral("(App.ActiveDocument.%1,[\"%2\"])");
buf = buf.arg(QString::fromStdString(dirname));
buf = buf.arg(QString::fromStdString(dirobj));
Gui::Command::doCommand(Gui::Command::Doc,

View File

@@ -390,7 +390,7 @@ TaskPostDisplay::TaskPostDisplay(ViewProviderFemPostObject* view, QWidget* paren
int trans = getTypedView<ViewProviderFemPostObject>()->Transparency.getValue();
// sync the trancparency slider
ui->Transparency->setValue(trans);
ui->Transparency->setToolTip(QString::number(trans) + QString::fromLatin1(" %"));
ui->Transparency->setToolTip(QString::number(trans) + QStringLiteral(" %"));
}
TaskPostDisplay::~TaskPostDisplay() = default;
@@ -441,9 +441,9 @@ void TaskPostDisplay::onVectorModeActivated(int i)
void TaskPostDisplay::onTransparencyValueChanged(int i)
{
getTypedView<ViewProviderFemPostObject>()->Transparency.setValue(i);
ui->Transparency->setToolTip(QString::number(i) + QString::fromLatin1(" %"));
ui->Transparency->setToolTip(QString::number(i) + QStringLiteral(" %"));
// highlight the tooltip
QToolTip::showText(QCursor::pos(), QString::number(i) + QString::fromLatin1(" %"), nullptr);
QToolTip::showText(QCursor::pos(), QString::number(i) + QStringLiteral(" %"), nullptr);
}
void TaskPostDisplay::applyPythonCode()
@@ -1228,7 +1228,7 @@ void TaskPostDataAtPoint::showValue(double pointValue, const char* unitStr)
QString value = QString::fromStdString(toString(pointValue));
QString unit = QString::fromUtf8(unitStr);
ui->ValueAtPoint->setText(QString::fromLatin1("%1 %2").arg(value, unit));
ui->ValueAtPoint->setText(QStringLiteral("%1 %2").arg(value, unit));
QString field = ui->Field->currentText();
QString posX = ui->centerX->text();