refactor: ServerConfig: used ranged loop to process neighbours

This commit is contained in:
sithlord48
2025-08-04 10:16:28 -04:00
committed by Nick Bolton
parent d321e2a874
commit 048ce47008

View File

@ -246,15 +246,18 @@ QTextStream &operator<<(QTextStream &outStream, const ServerConfig &config)
outStream << "section: links" << Qt::endl;
for (int i = 0; i < config.screens().size(); i++) {
if (!config.screens()[i].isNull()) {
outStream << "\t" << config.screens()[i].name() << ":" << Qt::endl;
for (unsigned int j = 0; j < std::size(neighbourDirs); j++) {
int idx = config.adjacentScreenIndex(i, neighbourDirs[j].x, neighbourDirs[j].y);
if (idx != -1 && !config.screens()[idx].isNull())
outStream << "\t\t" << neighbourDirs[j].name << " = " << config.screens()[idx].name() << Qt::endl;
}
for (int i = 0; const auto &screen : config.screens()) {
if (screen.isNull()) {
i++;
continue;
}
outStream << "\t" << screen.name() << ":\n";
for (const auto &neighbour : std::as_const(neighbourDirs)) {
int idx = config.adjacentScreenIndex(i, neighbour.x, neighbour.y);
if (idx != -1 && !config.screens()[idx].isNull())
outStream << "\t\t" << neighbour.name << " = " << config.screens()[idx].name() << Qt::endl;
}
i++;
}
outStream << "end" << Qt::endl << Qt::endl;