Spreadsheet: Use QStringLiteral

This commit is contained in:
Benjamin Bræstrup Sayoc
2025-02-09 18:20:52 +01:00
parent e2f018ceeb
commit 240912e470
7 changed files with 29 additions and 33 deletions

View File

@@ -912,7 +912,7 @@ void Sheet::recomputeCell(CellAddress p)
}
}
catch (const Base::Exception& e) {
QString msg = QString::fromUtf8("ERR: %1").arg(QString::fromUtf8(e.what()));
QString msg = QStringLiteral("ERR: %1").arg(QString::fromUtf8(e.what()));
setStringProperty(p, msg.toStdString());
if (cell) {

View File

@@ -99,9 +99,8 @@ DlgBindSheet::DlgBindSheet(Sheet* sheet, const std::vector<Range>& ranges, QWidg
ui->lineEditToStart->setText(QLatin1String(toStart.c_str()));
ui->lineEditToEnd->setText(QLatin1String(toEnd.c_str()));
ui->comboBox->addItem(
QString::fromLatin1(". (%1)").arg(QString::fromUtf8(sheet->Label.getValue())),
QByteArray(""));
ui->comboBox->addItem(QStringLiteral(". (%1)").arg(QString::fromUtf8(sheet->Label.getValue())),
QByteArray(""));
App::DocumentObject* target = bindingTarget.getDocumentObject();
for (auto obj : sheet->getDocument()->getObjectsOfType<Sheet>()) {
@@ -110,9 +109,8 @@ DlgBindSheet::DlgBindSheet(Sheet* sheet, const std::vector<Range>& ranges, QWidg
}
QString label;
if (obj->Label.getStrValue() != obj->getNameInDocument()) {
label =
QString::fromLatin1("%1 (%2)").arg(QString::fromLatin1(obj->getNameInDocument()),
QString::fromUtf8(obj->Label.getValue()));
label = QStringLiteral("%1 (%2)").arg(QString::fromLatin1(obj->getNameInDocument()),
QString::fromUtf8(obj->Label.getValue()));
}
else {
label = QLatin1String(obj->getNameInDocument());
@@ -133,9 +131,8 @@ DlgBindSheet::DlgBindSheet(Sheet* sheet, const std::vector<Range>& ranges, QWidg
std::string fullname = obj->getFullName();
QString label;
if (obj->Label.getStrValue() != obj->getNameInDocument()) {
label =
QString::fromLatin1("%1 (%2)").arg(QString::fromLatin1(fullname.c_str()),
QString::fromUtf8(obj->Label.getValue()));
label = QStringLiteral("%1 (%2)").arg(QString::fromLatin1(fullname.c_str()),
QString::fromUtf8(obj->Label.getValue()));
}
else {
label = QLatin1String(fullname.c_str());

View File

@@ -125,19 +125,19 @@ QVariant SheetModel::data(const QModelIndex& index, int role) const
sheet->providesTo(CellAddress(row, col), provides);
if (deps.size() > 0) {
v += QString::fromUtf8("Depends on:");
v += QStringLiteral("Depends on:");
for (std::set<std::string>::const_iterator i = deps.begin(); i != deps.end(); ++i) {
v += QString::fromUtf8("\n\t") + Tools::fromStdString(*i);
v += QStringLiteral("\n\t") + Tools::fromStdString(*i);
}
v += QString::fromUtf8("\n");
v += QStringLiteral("\n");
}
if (provides.size() > 0) {
v += QString::fromUtf8("Used by:");
v += QStringLiteral("Used by:");
for (std::set<std::string>::const_iterator i = provides.begin(); i != provides.end();
++i) {
v += QString::fromUtf8("\n\t") + Tools::fromStdString(*i);
v += QStringLiteral("\n\t") + Tools::fromStdString(*i);
}
v += QString::fromUtf8("\n");
v += QStringLiteral("\n");
}
return QVariant(v);
}
@@ -154,18 +154,18 @@ QVariant SheetModel::data(const QModelIndex& index, int role) const
switch (role) {
case Qt::ToolTipRole: {
QString txt(QString::fromStdString(cell->getException()).toHtmlEscaped());
return QVariant(QString::fromLatin1("<pre>%1</pre>").arg(txt));
return QVariant(QStringLiteral("<pre>%1</pre>").arg(txt));
}
case Qt::DisplayRole: {
#ifdef DEBUG_DEPS
return QVariant::fromValue(
QString::fromUtf8("#ERR: %1").arg(Tools::fromStdString(cell->getException())));
QStringLiteral("#ERR: %1").arg(Tools::fromStdString(cell->getException())));
#else
std::string str;
if (cell->getStringContent(str)) {
return QVariant::fromValue(QString::fromUtf8(str.c_str()));
}
return QVariant::fromValue(QString::fromUtf8("#ERR"));
return QVariant::fromValue(QStringLiteral("#ERR"));
#endif
}
case Qt::ForegroundRole:
@@ -370,7 +370,7 @@ QVariant SheetModel::data(const QModelIndex& index, int role) const
v = number + QString::fromStdString(" " + displayUnit.stringRep);
}
else {
v = QString::fromUtf8("#ERR: unit");
v = QStringLiteral("#ERR: unit");
}
}
else {
@@ -523,7 +523,7 @@ QVariant SheetModel::headerData(int section, Qt::Orientation orientation, int ro
}
if (role == Qt::DisplayRole) {
if (orientation == Qt::Horizontal) {
static QString labels = QString::fromUtf8("ABCDEFGHIJKLMNOPQRSTUVWXYZ");
static QString labels = QStringLiteral("ABCDEFGHIJKLMNOPQRSTUVWXYZ");
if (section < 26) {
return QVariant(labels[section]);
}

View File

@@ -46,7 +46,7 @@ SheetTableViewAccessibleInterface::SheetTableViewAccessibleInterface(
QString SheetTableViewAccessibleInterface::text(QAccessible::Text txt) const
{
if (txt == QAccessible::Help) {
return QString::fromLatin1("Implement me");
return QStringLiteral("Implement me");
}
return QAccessibleWidget::text(txt);
}
@@ -81,7 +81,7 @@ QAccessibleInterface* SheetTableViewAccessibleInterface::child(int index) const
QAccessibleInterface* SheetTableViewAccessibleInterface::ifactory(const QString& key, QObject* obj)
{
if (key == QString::fromUtf8("SpreadsheetGui::SheetTableView")) {
if (key == QStringLiteral("SpreadsheetGui::SheetTableView")) {
return new SheetTableViewAccessibleInterface(
static_cast<SpreadsheetGui::SheetTableView*>(obj));
}

View File

@@ -133,13 +133,13 @@ SheetView::SheetView(Gui::Document* pcDocument, App::DocumentObject* docObj, QWi
ui->cells->setPalette(palette);
QList<QtColorPicker*> bgList = Gui::getMainWindow()->findChildren<QtColorPicker*>(
QString::fromLatin1("Spreadsheet_BackgroundColor"));
QStringLiteral("Spreadsheet_BackgroundColor"));
if (!bgList.empty()) {
bgList[0]->setCurrentColor(palette.color(QPalette::Base));
}
QList<QtColorPicker*> fgList = Gui::getMainWindow()->findChildren<QtColorPicker*>(
QString::fromLatin1("Spreadsheet_ForegroundColor"));
QStringLiteral("Spreadsheet_ForegroundColor"));
if (!fgList.empty()) {
fgList[0]->setCurrentColor(palette.color(QPalette::Text));
}
@@ -299,7 +299,7 @@ void SheetView::printPdf()
FileDialog::getSaveFileName(this,
tr("Export PDF"),
QString(),
QString::fromLatin1("%1 (*.pdf)").arg(tr("PDF file")));
QStringLiteral("%1 (*.pdf)").arg(tr("PDF file")));
if (!filename.isEmpty()) {
QPrinter printer(QPrinter::ScreenResolution);
// setPdfVersion sets the printied PDF Version to comply with PDF/A-1b, more details under:

View File

@@ -167,8 +167,7 @@ SheetView* ViewProviderSheet::showSpreadsheetView()
Gui::Document* doc = Gui::Application::Instance->getDocument(this->pcObject->getDocument());
view = new SheetView(doc, this->pcObject, Gui::getMainWindow());
view->setWindowIcon(Gui::BitmapFactory().pixmap(":icons/Spreadsheet.svg"));
view->setWindowTitle(QString::fromUtf8(pcObject->Label.getValue())
+ QString::fromLatin1("[*]"));
view->setWindowTitle(QString::fromUtf8(pcObject->Label.getValue()) + QStringLiteral("[*]"));
Gui::getMainWindow()->addWindow(view);
startEditing();
}

View File

@@ -68,7 +68,7 @@ void Workbench::activated()
{
if (!initialized) {
QList<QToolBar*> bars =
Gui::getMainWindow()->findChildren<QToolBar*>(QString::fromLatin1("Spreadsheet"));
Gui::getMainWindow()->findChildren<QToolBar*>(QStringLiteral("Spreadsheet"));
if (bars.size() == 1) {
QToolBar* bar = bars[0];
@@ -77,13 +77,13 @@ void Workbench::activated()
QPalette palette = Gui::getMainWindow()->palette();
QList<QtColorPicker*> fgList = Gui::getMainWindow()->findChildren<QtColorPicker*>(
QString::fromLatin1("Spreadsheet_ForegroundColor"));
QStringLiteral("Spreadsheet_ForegroundColor"));
if (!fgList.empty()) {
foregroundColor = fgList[0];
}
else {
foregroundColor = new QtColorPicker(bar);
foregroundColor->setObjectName(QString::fromLatin1("Spreadsheet_ForegroundColor"));
foregroundColor->setObjectName(QStringLiteral("Spreadsheet_ForegroundColor"));
foregroundColor->setStandardColors();
foregroundColor->setCurrentColor(palette.color(QPalette::WindowText));
QObject::connect(foregroundColor,
@@ -97,13 +97,13 @@ void Workbench::activated()
bar->addWidget(foregroundColor);
QList<QtColorPicker*> bgList = Gui::getMainWindow()->findChildren<QtColorPicker*>(
QString::fromLatin1("Spreadsheet_BackgroundColor"));
QStringLiteral("Spreadsheet_BackgroundColor"));
if (!bgList.empty()) {
backgroundColor = bgList[0];
}
else {
backgroundColor = new QtColorPicker(bar);
backgroundColor->setObjectName(QString::fromLatin1("Spreadsheet_BackgroundColor"));
backgroundColor->setObjectName(QStringLiteral("Spreadsheet_BackgroundColor"));
backgroundColor->setStandardColors();
backgroundColor->setCurrentColor(palette.color(QPalette::Base));
QObject::connect(backgroundColor,