refactor: use const for ranged loops
This commit is contained in:
@ -92,7 +92,8 @@ void ActionDialog::accept()
|
||||
|
||||
m_Action.typeScreenNames().clear();
|
||||
|
||||
for (const QListWidgetItem *pItem : ui->m_pListScreens->selectedItems())
|
||||
const auto &selection = ui->m_pListScreens->selectedItems();
|
||||
for (const QListWidgetItem *pItem : selection)
|
||||
m_Action.typeScreenNames().append(pItem->text());
|
||||
|
||||
m_Action.setSwitchScreenName(ui->m_pComboSwitchToScreen->currentText());
|
||||
|
||||
@ -77,7 +77,7 @@ ServerConfigDialog::ServerConfigDialog(QWidget *parent, ServerConfig &config, Ap
|
||||
ui->m_pSpinBoxClipboardSizeLimit->setValue(clipboardSharingSizeM);
|
||||
ui->m_pSpinBoxClipboardSizeLimit->setEnabled(serverConfig().clipboardSharing());
|
||||
|
||||
for (const Hotkey &hotkey : serverConfig().hotkeys())
|
||||
for (const Hotkey &hotkey : std::as_const(serverConfig().hotkeys()))
|
||||
ui->m_pListHotkeys->addItem(hotkey.text());
|
||||
|
||||
ui->m_pScreenSetupView->setModel(&m_ScreenSetupModel);
|
||||
|
||||
@ -97,7 +97,7 @@ QString makeQuotedArgs(const QString &app, const QStringList &args)
|
||||
command << args;
|
||||
|
||||
QStringList quoted;
|
||||
for (const auto &arg : command) {
|
||||
for (const auto &arg : std::as_const(command)) {
|
||||
if (arg.contains(' ')) {
|
||||
quoted << QString("\"%1\"").arg(arg);
|
||||
} else {
|
||||
@ -350,7 +350,8 @@ void CoreProcess::stopService()
|
||||
|
||||
void CoreProcess::handleLogLines(const QString &text)
|
||||
{
|
||||
for (const auto &line : text.split(kLineSplitRegex)) {
|
||||
const auto lines = text.split(kLineSplitRegex);
|
||||
for (const auto &line : lines) {
|
||||
if (line.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -73,7 +73,8 @@ void migrateLegacySystemSettings(QSettings &settings)
|
||||
);
|
||||
|
||||
if (QFile(oldSystemSettings.fileName()).exists()) {
|
||||
for (const auto &key : oldSystemSettings.allKeys()) {
|
||||
const auto keys = oldSystemSettings.allKeys();
|
||||
for (const auto &key : keys) {
|
||||
settings.setValue(key, oldSystemSettings.value(key));
|
||||
}
|
||||
}
|
||||
@ -112,7 +113,7 @@ void migrateLegacyUserSettings(QSettings &newSettings)
|
||||
);
|
||||
|
||||
QStringList keys = oldSettings.allKeys();
|
||||
for (const QString &key : keys) {
|
||||
for (const QString &key : std::as_const(keys)) {
|
||||
QVariant oldValue = oldSettings.value(key);
|
||||
newSettings.setValue(key, oldValue);
|
||||
logVerbose(QString("migrating setting '%1' = '%2'").arg(key, oldValue.toString()));
|
||||
|
||||
@ -116,7 +116,7 @@ bool TlsCertificate::runTool(const QStringList &args)
|
||||
|
||||
QProcess process;
|
||||
process.setEnvironment(environment);
|
||||
for (const auto &envVar : environment) {
|
||||
for (const auto &envVar : std::as_const(environment)) {
|
||||
qDebug("set env var: %s", qUtf8Printable(envVar));
|
||||
}
|
||||
|
||||
|
||||
@ -64,8 +64,8 @@ bool TlsFingerprint::fileExists() const
|
||||
|
||||
bool TlsFingerprint::isTrusted(const QString &fingerprintText) const
|
||||
{
|
||||
QStringList list = readList();
|
||||
for (QString trusted : list) {
|
||||
const QStringList list = readList();
|
||||
for (const auto &trusted : list) {
|
||||
if (trusted == fingerprintText) {
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user