refactor: use modern range for loops in place of old foreach macro
This commit is contained in:
@ -65,7 +65,7 @@ ActionDialog::ActionDialog(QWidget *parent, ServerConfig &config, Hotkey &hotkey
|
||||
ui->m_pGroupBoxScreens->setChecked(m_Action.haveScreens());
|
||||
|
||||
int idx = 0;
|
||||
foreach (const Screen &screen, serverConfig().screens())
|
||||
for (const Screen &screen : serverConfig().screens()) {
|
||||
if (!screen.isNull()) {
|
||||
QListWidgetItem *pListItem = new QListWidgetItem(screen.name());
|
||||
ui->m_pListScreens->addItem(pListItem);
|
||||
@ -78,6 +78,7 @@ ActionDialog::ActionDialog(QWidget *parent, ServerConfig &config, Hotkey &hotkey
|
||||
|
||||
idx++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ActionDialog::accept()
|
||||
@ -90,7 +91,8 @@ void ActionDialog::accept()
|
||||
m_Action.setHaveScreens(ui->m_pGroupBoxScreens->isChecked());
|
||||
|
||||
m_Action.typeScreenNames().clear();
|
||||
foreach (const QListWidgetItem *pItem, ui->m_pListScreens->selectedItems())
|
||||
|
||||
for (const QListWidgetItem *pItem : ui->m_pListScreens->selectedItems())
|
||||
m_Action.typeScreenNames().append(pItem->text());
|
||||
|
||||
m_Action.setSwitchScreenName(ui->m_pComboSwitchToScreen->currentText());
|
||||
|
||||
@ -100,9 +100,10 @@ QMimeData *ScreenSetupModel::mimeData(const QModelIndexList &indexes) const
|
||||
|
||||
QDataStream stream(&encodedData, QIODevice::WriteOnly);
|
||||
|
||||
foreach (const QModelIndex &index, indexes)
|
||||
for (const QModelIndex &index : indexes) {
|
||||
if (index.isValid())
|
||||
stream << index.column() << index.row() << screen(index);
|
||||
}
|
||||
|
||||
pMimeData->setData(m_MimeType, encodedData);
|
||||
|
||||
|
||||
@ -249,23 +249,25 @@ QTextStream &operator<<(QTextStream &outStream, const ServerConfig &config)
|
||||
|
||||
outStream << "section: screens" << Qt::endl;
|
||||
|
||||
foreach (const Screen &s, config.screens())
|
||||
for (const Screen &s : config.screens()) {
|
||||
if (!s.isNull())
|
||||
s.writeScreensSection(outStream);
|
||||
}
|
||||
|
||||
outStream << "end" << Qt::endl << Qt::endl;
|
||||
|
||||
outStream << "section: aliases" << Qt::endl;
|
||||
|
||||
foreach (const Screen &s, config.screens())
|
||||
for (const Screen &s : config.screens()) {
|
||||
if (!s.isNull())
|
||||
s.writeAliasesSection(outStream);
|
||||
}
|
||||
|
||||
outStream << "end" << Qt::endl << Qt::endl;
|
||||
|
||||
outStream << "section: links" << Qt::endl;
|
||||
|
||||
for (int i = 0; i < config.screens().size(); i++)
|
||||
for (int i = 0; i < config.screens().size(); i++) {
|
||||
if (!config.screens()[i].isNull()) {
|
||||
outStream << "\t" << config.screens()[i].name() << ":" << Qt::endl;
|
||||
|
||||
@ -275,6 +277,7 @@ QTextStream &operator<<(QTextStream &outStream, const ServerConfig &config)
|
||||
outStream << "\t\t" << neighbourDirs[j].name << " = " << config.screens()[idx].name() << Qt::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
outStream << "end" << Qt::endl << Qt::endl;
|
||||
|
||||
@ -325,7 +328,7 @@ QTextStream &operator<<(QTextStream &outStream, const ServerConfig &config)
|
||||
outStream << "\t"
|
||||
<< "switchCornerSize = " << config.switchCornerSize() << Qt::endl;
|
||||
|
||||
foreach (const Hotkey &hotkey, config.hotkeys())
|
||||
for (const Hotkey &hotkey : config.hotkeys())
|
||||
outStream << hotkey;
|
||||
|
||||
outStream << "end" << Qt::endl << Qt::endl;
|
||||
@ -337,9 +340,10 @@ int ServerConfig::numScreens() const
|
||||
{
|
||||
int rval = 0;
|
||||
|
||||
foreach (const Screen &s, screens())
|
||||
for (const Screen &s : screens()) {
|
||||
if (!s.isNull())
|
||||
rval++;
|
||||
}
|
||||
|
||||
return rval;
|
||||
}
|
||||
|
||||
@ -77,7 +77,7 @@ ServerConfigDialog::ServerConfigDialog(QWidget *parent, ServerConfig &config, Ap
|
||||
ui->m_pSpinBoxClipboardSizeLimit->setValue(clipboardSharingSizeM);
|
||||
ui->m_pSpinBoxClipboardSizeLimit->setEnabled(serverConfig().clipboardSharing());
|
||||
|
||||
foreach (const Hotkey &hotkey, serverConfig().hotkeys())
|
||||
for (const Hotkey &hotkey : serverConfig().hotkeys())
|
||||
ui->m_pListHotkeys->addItem(hotkey.text());
|
||||
|
||||
ui->m_pScreenSetupView->setModel(&m_ScreenSetupModel);
|
||||
@ -353,7 +353,7 @@ void ServerConfigDialog::on_m_pListHotkeys_itemSelectionChanged()
|
||||
Q_ASSERT(idx >= 0 && idx < serverConfig().hotkeys().size());
|
||||
|
||||
const Hotkey &hotkey = serverConfig().hotkeys()[idx];
|
||||
foreach (const Action &action, hotkey.actions())
|
||||
for (const Action &action : hotkey.actions())
|
||||
ui->m_pListActions->addItem(action.text());
|
||||
}
|
||||
}
|
||||
|
||||
@ -119,7 +119,7 @@ QTextStream &Screen::writeAliasesSection(QTextStream &outStream) const
|
||||
if (!aliases().isEmpty()) {
|
||||
outStream << "\t" << name() << ":" << Qt::endl;
|
||||
|
||||
foreach (const QString &alias, aliases())
|
||||
for (const QString &alias : aliases())
|
||||
outStream << "\t\t" << alias << Qt::endl;
|
||||
}
|
||||
|
||||
|
||||
@ -65,7 +65,7 @@ bool TlsFingerprint::fileExists() const
|
||||
bool TlsFingerprint::isTrusted(const QString &fingerprintText) const
|
||||
{
|
||||
QStringList list = readList();
|
||||
foreach (QString trusted, list) {
|
||||
for (QString trusted : list) {
|
||||
if (trusted == fingerprintText) {
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user