When calling arg() on a QString constructed from a literal, use QStringLiteral.

This commit is contained in:
Mat Sutcliffe
2018-12-20 21:32:39 +00:00
parent ace7650ebe
commit 6c05c5249d
99 changed files with 227 additions and 291 deletions

View File

@@ -155,7 +155,7 @@ namespace BlackGui
m_currentDataSource = dataSource;
ui->le_modelString->setCompleter(new QCompleter(modelStrings, this));
ui->le_modelString->setPlaceholderText(QString("model strings (%1/%2)").arg(modelStrings.size()).arg(simInfo));
ui->le_modelString->setPlaceholderText(QStringLiteral("model strings (%1/%2)").arg(modelStrings.size()).arg(simInfo));
}
void CAircraftModelStringCompleter::onTextChanged()

View File

@@ -430,8 +430,7 @@ namespace BlackGui
}
else
{
static const QString item("swift %1 (%2)");
ui->cb_OtherVersions->addItem(item.arg(info.getVersionString(), info.getPlatform()));
ui->cb_OtherVersions->addItem(QStringLiteral("swift %1 (%2)").arg(info.getVersionString(), info.getPlatform()));
}
m_otherVersionDirs.push_back(pair.first);
}

View File

@@ -86,7 +86,7 @@ namespace BlackGui
if (this->readDataFile(thisVersionModelSetFile, otherSet, otherVersion, simulator) && !otherSet.isEmpty())
{
CApplication::processEventsFor(250);
if (this->confirmOverride(QString("Override model set for '%1'").arg(simulator.toQString())))
if (this->confirmOverride(QStringLiteral("Override model set for '%1'").arg(simulator.toQString())))
{
m_modelSetCaches.setModelsForSimulator(otherSet, simulator);
}
@@ -105,7 +105,7 @@ namespace BlackGui
if (this->readDataFile(thisVersionModelCacheFile, otherCache, otherVersion, simulator) && !otherCache.isEmpty())
{
CApplication::processEventsFor(250);
if (this->confirmOverride(QString("Override model cache for '%1'").arg(simulator.toQString())))
if (this->confirmOverride(QStringLiteral("Override model cache for '%1'").arg(simulator.toQString())))
{
m_modelCaches.setModelsForSimulator(otherCache, simulator);
}
@@ -136,8 +136,7 @@ namespace BlackGui
const QFileInfo fiOtherModelFile(otherModelFile);
if (!fiOtherModelFile.exists())
{
static const QString noSet("No models here: '%1'");
ui->le_Status->setText(noSet.arg(fiOtherModelFile.absoluteFilePath()));
ui->le_Status->setText(QStringLiteral("No models here: '%1'").arg(fiOtherModelFile.absoluteFilePath()));
return false;
}
@@ -148,18 +147,15 @@ namespace BlackGui
{
models = CAircraftModelList::fromMultipleJsonFormats(jsonString);
ui->tvp_AircraftModels->updateContainerAsync(models);
static const QString importSet("Imported models: '%1'");
ui->le_Status->setText(importSet.arg(fiOtherModelFile.absoluteFilePath()));
ui->le_Status->setText(QStringLiteral("Imported models: '%1'").arg(fiOtherModelFile.absoluteFilePath()));
}
catch (const CJsonException &ex)
{
static const QString m("JSON format error. '%1'");
this->showOverlayMessage(ex.toStatusMessage(this, m.arg(fiOtherModelFile.absoluteFilePath())));
this->showOverlayMessage(ex.toStatusMessage(this, QStringLiteral("JSON format error. '%1'").arg(fiOtherModelFile.absoluteFilePath())));
return false;
}
static const QString importSet("Imported %1 models '%2' for %3");
ui->le_Status->setText(importSet.arg(models.size()).arg(fiOtherModelFile.fileName(), sim.toQString()));
ui->le_Status->setText(QStringLiteral("Imported %1 models '%2' for %3").arg(models.size()).arg(fiOtherModelFile.fileName(), sim.toQString()));
return true;
}

View File

@@ -469,9 +469,7 @@ namespace BlackGui
QString CCopySettingsAndCachesComponent::checkBoxText(const QString &text, bool setting)
{
static const QString s("%1 [setting]");
static const QString c("%1 [cache]");
return setting ? s.arg(text) : c.arg(text);
return setting ? QStringLiteral("%1 [setting]").arg(text) : QStringLiteral("%1 [cache]").arg(text);
}
void CCopySettingsAndCachesWizardPage::initializePage()

View File

@@ -50,7 +50,7 @@ namespace BlackGui
{
// this removes previously stashed models
this->getMappingComponent()->replaceStashedModelsUnvalidated(m_modelsToStash);
const CStatusMessage stashedMsg(this, CStatusMessage::SeverityInfo, QString("Stashed %1 models").arg(m_modelsToStash.size()));
const CStatusMessage stashedMsg(this, CStatusMessage::SeverityInfo, QStringLiteral("Stashed %1 models").arg(m_modelsToStash.size()));
this->addStatusMessage(stashedMsg);
m_modelsToStash.clear();
}

View File

@@ -89,7 +89,7 @@ namespace BlackGui
{
this->currentModelView()->removeModelsWithModelString(m_modelsToStash);
}
const CStatusMessage stashedMsg(this, CStatusMessage::SeverityInfo, QString("Auto stashed %1 models").arg(m_modelsToStash.size()));
const CStatusMessage stashedMsg(this, CStatusMessage::SeverityInfo, QStringLiteral("Auto stashed %1 models").arg(m_modelsToStash.size()));
this->addStatusMessage(stashedMsg);
m_modelsToStash.clear();
}
@@ -285,7 +285,7 @@ namespace BlackGui
this->updateProgressIndicator(100);
sGui->processEventsToRefreshGui();
const CStatusMessage stashedMsg(this, CStatusMessage::SeverityInfo, QString("Ready to auto stash %1 models").arg(autoStashed.size()));
const CStatusMessage stashedMsg(this, CStatusMessage::SeverityInfo, QStringLiteral("Ready to auto stash %1 models").arg(autoStashed.size()));
this->addStatusMessage(stashedMsg);
m_modelsToStash = autoStashed;
m_state = Completed;

View File

@@ -232,8 +232,7 @@ namespace BlackGui
QString CDbOwnModelsComponent::directorySelector(const CSimulatorInfo &simulatorInfo)
{
QString dir = m_directorySettings.get().getLastModelDirectoryOrDefault();
const QString text("Open directory (%1)");
dir = QFileDialog::getExistingDirectory(this, text.arg(simulatorInfo.toQString()), dir,
dir = QFileDialog::getExistingDirectory(this, QStringLiteral("Open directory (%1)").arg(simulatorInfo.toQString()), dir,
QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);
const QDir d(dir);
if (d.exists())

View File

@@ -267,9 +267,8 @@ namespace BlackGui
ui->pb_SaveAsSetForSimulator->setEnabled(canSave);
if (canSave)
{
static const QString ss("save %1");
this->setSaveFileName(this->getModelSetSimulator());
ui->pb_SaveAsSetForSimulator->setText(ss.arg(this->getModelSetSimulator().toQString(true)));
ui->pb_SaveAsSetForSimulator->setText(QStringLiteral("save %1").arg(this->getModelSetSimulator().toQString(true)));
}
else
{

View File

@@ -283,7 +283,7 @@ namespace BlackGui
if (validModels.size() > MaxModelPublished)
{
validModels.truncate(MaxModelPublished);
msgs.push_back(CStatusMessage(validationCategories(), CStatusMessage::SeverityWarning, QString("More than %1 values, values skipped").arg(MaxModelPublished)));
msgs.push_back(CStatusMessage(validationCategories(), CStatusMessage::SeverityWarning, QStringLiteral("More than %1 values, values skipped").arg(MaxModelPublished)));
}
msgs.push_back(sGui->getWebDataServices()->asyncPublishModels(validModels));
@@ -340,7 +340,7 @@ namespace BlackGui
{
return CStatusMessageList(
{
CStatusMessage(validationCategories(), CStatusMessage::SeverityInfo, QString("No errors in %1 model(s)").arg(models.size()))
CStatusMessage(validationCategories(), CStatusMessage::SeverityInfo, QStringLiteral("No errors in %1 model(s)").arg(models.size()))
});
}
else

View File

@@ -303,10 +303,9 @@ namespace BlackGui
void CDownloadComponent::showStartedFileMessage(const CRemoteFile &rf)
{
static const QString of("%1/%2");
const int current = m_remoteFiles.size() - m_waitingForDownload.size();
ui->le_Started->setText(rf.getName());
ui->le_StartedNumber->setText(of.arg(current).arg(m_remoteFiles.size()));
ui->le_StartedNumber->setText(QStringLiteral("%1/%2").arg(current).arg(m_remoteFiles.size()));
ui->le_StartedUrl->setText(rf.getUrl().getFullUrl());
ui->prb_Total->setMaximum(m_remoteFiles.size());
ui->prb_Total->setValue(current - 1);
@@ -314,10 +313,9 @@ namespace BlackGui
void CDownloadComponent::showCompletedFileMessage(const CRemoteFile &rf)
{
static const QString of("%1/%2");
const int current = m_remoteFiles.size() - m_waitingForDownload.size();
ui->le_Completed->setText(rf.getName());
ui->le_CompletedNumber->setText(of.arg(current).arg(m_remoteFiles.size()));
ui->le_CompletedNumber->setText(QStringLiteral("%1/%2").arg(current).arg(m_remoteFiles.size()));
ui->le_CompletedUrl->setText(rf.getUrl().getFullUrl());
ui->prb_Total->setMaximum(m_remoteFiles.size());
ui->prb_Total->setValue(current);
@@ -336,8 +334,7 @@ namespace BlackGui
void CDownloadComponent::showFileInfo()
{
static const QString info("Files: %1 size: %2");
ui->le_Info->setText(info.arg(m_remoteFiles.size()).arg(m_remoteFiles.getTotalFileSizeHumanReadable()));
ui->le_Info->setText(QStringLiteral("Files: %1 size: %2").arg(m_remoteFiles.size()).arg(m_remoteFiles.getTotalFileSizeHumanReadable()));
}
} // ns
} // ns

View File

@@ -232,7 +232,7 @@ namespace BlackGui
ui->led_MapperReady->setOn(on);
if (on)
{
const QString m = QString("Mapper with %1 models").arg(models);
const QString m = QStringLiteral("Mapper with %1 models").arg(models);
ui->led_MapperReady->setToolTip(m);
}
}

View File

@@ -189,9 +189,8 @@ namespace BlackGui
void CInterpolationLogDisplay::onSliderChanged(int timeSecs)
{
static const QString time("%1secs");
m_updateTimer.setInterval(timeSecs * 1000);
ui->le_UpdateTime->setText(time.arg(timeSecs));
ui->le_UpdateTime->setText(QStringLiteral("%1secs").arg(timeSecs));
}
void CInterpolationLogDisplay::onCallsignEntered()

View File

@@ -311,8 +311,7 @@ namespace BlackGui
if (msg.isSuccess())
{
Q_ASSERT_X(currentServer.isValidForLogin(), Q_FUNC_INFO, "invalid server");
static const QString extraInfo("[%1]");
sGui->setExtraWindowTitle(extraInfo.arg(ownAircraft.getCallsignAsString()));
sGui->setExtraWindowTitle(QStringLiteral("[%1]").arg(ownAircraft.getCallsignAsString()));
sGui->crashAndLogInfoUserName(currentServer.getUser().getRealNameAndId());
sGui->crashAndLogInfoFlightNetwork(currentServer.getEcosystem().toQString(true));
sGui->crashAndLogAppendInfo(currentServer.getServerSessionId());
@@ -770,8 +769,7 @@ namespace BlackGui
color = warning;
}
}
static const QString sheet("background-color: %1;");
ui->le_SimulatorModel->setStyleSheet(sheet.arg(color));
ui->le_SimulatorModel->setStyleSheet(QStringLiteral("background-color: %1;").arg(color));
}
bool CLoginComponent::isVatsimNetworkTabSelected() const

View File

@@ -236,8 +236,7 @@ namespace BlackGui
QString CRawFsdMessagesComponent::rawFsdMessageToString(const CRawFsdMessage &rawFsdMessage)
{
static const QString s("%1 %2");
return s.arg(rawFsdMessage.getFormattedUtcTimestampHmsz(), rawFsdMessage.getRawMessage());
return QStringLiteral("%1 %2").arg(rawFsdMessage.getFormattedUtcTimestampHmsz(), rawFsdMessage.getRawMessage());
}
}
} // namespace

View File

@@ -35,10 +35,9 @@ namespace BlackGui
ui->hs_Factor->setMaximum(max);
ui->le_Factor->setValidator(new QIntValidator(min, max, ui->le_Factor));
static const QString info("%1-%2");
ui->le_Factor->setToolTip(info.arg(min).arg(max));
ui->le_Factor->setPlaceholderText(info.arg(min).arg(max));
ui->hs_Factor->setToolTip(info.arg(min, max));
ui->le_Factor->setToolTip(QStringLiteral("%1-%2").arg(min).arg(max));
ui->le_Factor->setPlaceholderText(QStringLiteral("%1-%2").arg(min).arg(max));
ui->hs_Factor->setToolTip(QStringLiteral("%1-%2").arg(min, max));
const int v = (min + max) / 2;
ui->hs_Factor->setValue(v);

View File

@@ -145,7 +145,7 @@ namespace BlackGui
if (!conflicts.isEmpty())
{
QString message = QString("The selected combination conflicts with the following %1 combination(s):\n\n").arg(conflicts.size());
QString message = QStringLiteral("The selected combination conflicts with the following %1 combination(s):\n\n").arg(conflicts.size());
for (const CActionHotkey &conflict : conflicts)
{
message += conflict.toQString();

View File

@@ -183,7 +183,7 @@ namespace BlackGui
void CSetupLoadingDialog::displayOtherVersionsInfo()
{
const int other = CDirectoryUtils::applicationDataDirectoriesCount() - 1 ;
ui->le_OtherSwiftVersions->setText(QString("There is/are %1 other swift version(s) installed").arg(other));
ui->le_OtherSwiftVersions->setText(QStringLiteral("There is/are %1 other swift version(s) installed").arg(other));
ui->pb_CopyFromSwift->setEnabled(other > 0);
}

View File

@@ -22,7 +22,7 @@ namespace BlackGui
QString CTransponderCodeSpinBox::textFromValue(int value) const
{
/* 4 - number of digits, 10 - base of number, '0' - pad character*/
return QString("%1").arg(value, 4 , 10, QChar('0'));
return QStringLiteral("%1").arg(value, 4 , 10, QChar('0'));
}
} // ns
} // ns