Base: Drop QString-std::string conversion functions from Tools

Convenience helpers function Tools::toStdString and Tools::fromStdString
were implemented for Qt4 or older to perform utf8 aware conversion as
QString::toStdString/QString::fromStdString were using toAscii/fromAscii
internally (see https://dreamswork.github.io/qt4/classQString.html).

Since Qt5 QString uses toUtf8/fromUTf8, which makes the helper functions
obsolete (see https://doc.qt.io/qt-5/qstring.html#fromStdString).
This commit is contained in:
Ladislav Michl
2024-12-02 12:34:11 +01:00
committed by Chris Hennes
parent 1a13d25811
commit e62b91ada4
54 changed files with 190 additions and 255 deletions

View File

@@ -57,12 +57,12 @@ SheetModel::SheetModel(Sheet* _sheet, QObject* parent)
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath(
"User parameter:BaseApp/Preferences/Mod/Spreadsheet");
aliasBgColor =
QColor(Base::Tools::fromStdString(hGrp->GetASCII("AliasedCellBackgroundColor", "#feff9e")));
textFgColor = QColor(Base::Tools::fromStdString(hGrp->GetASCII("TextColor", "#000000")));
QColor(QString::fromStdString(hGrp->GetASCII("AliasedCellBackgroundColor", "#feff9e")));
textFgColor = QColor(QString::fromStdString(hGrp->GetASCII("TextColor", "#000000")));
positiveFgColor =
QColor(Base::Tools::fromStdString(hGrp->GetASCII("PositiveNumberColor", "#000000")));
QColor(QString::fromStdString(hGrp->GetASCII("PositiveNumberColor", "#000000")));
negativeFgColor =
QColor(Base::Tools::fromStdString(hGrp->GetASCII("NegativeNumberColor", "#000000")));
QColor(QString::fromStdString(hGrp->GetASCII("NegativeNumberColor", "#000000")));
}
SheetModel::~SheetModel()
@@ -145,7 +145,7 @@ QVariant SheetModel::data(const QModelIndex& index, int role) const
if (!cell->hasException() && role == Qt::ToolTipRole) {
std::string alias;
if (cell->getAlias(alias)) {
return QVariant(Base::Tools::fromStdString(alias));
return QVariant(QString::fromStdString(alias));
}
}
#endif
@@ -153,7 +153,7 @@ QVariant SheetModel::data(const QModelIndex& index, int role) const
if (cell->hasException()) {
switch (role) {
case Qt::ToolTipRole: {
QString txt(Base::Tools::fromStdString(cell->getException()).toHtmlEscaped());
QString txt(QString::fromStdString(cell->getException()).toHtmlEscaped());
return QVariant(QString::fromLatin1("<pre>%1</pre>").arg(txt));
}
case Qt::DisplayRole: {
@@ -367,7 +367,7 @@ QVariant SheetModel::data(const QModelIndex& index, int role) const
Base::UnitsApi::getDecimals());
// QString number = QString::number(floatProp->getValue() /
// displayUnit.scaler);
v = number + Base::Tools::fromStdString(" " + displayUnit.stringRep);
v = number + QString::fromStdString(" " + displayUnit.stringRep);
}
else {
v = QString::fromUtf8("#ERR: unit");
@@ -439,7 +439,7 @@ QVariant SheetModel::data(const QModelIndex& index, int role) const
'f',
Base::UnitsApi::getDecimals());
// QString number = QString::number(d / displayUnit.scaler);
v = number + Base::Tools::fromStdString(" " + displayUnit.stringRep);
v = number + QString::fromStdString(" " + displayUnit.stringRep);
}
else if (!isInteger) {
v = QLocale::system().toString(d, 'f', Base::UnitsApi::getDecimals());