mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-22 14:55:36 +08:00
Use structured bindings (C++17 feature)
This commit is contained in:
@@ -1871,10 +1871,10 @@ namespace BlackCore
|
||||
}
|
||||
|
||||
if (callStatistics.isEmpty()) { return QString(); }
|
||||
for (const auto pair : makePairsRange(as_const(callStatistics)))
|
||||
for (const auto [key, value] : makePairsRange(as_const(callStatistics)))
|
||||
{
|
||||
// key is pair.first, value is pair.second
|
||||
transformed.push_back({ pair.second, pair.first });
|
||||
transformed.push_back({ value, key });
|
||||
}
|
||||
|
||||
// sorted by value
|
||||
|
||||
@@ -178,10 +178,8 @@ namespace BlackCore
|
||||
}
|
||||
|
||||
QSet<QString> newActiveActions;
|
||||
for (const auto pair : makePairsRange(as_const(m_configuredActions)))
|
||||
for (const auto [combination, action] : makePairsRange(as_const(m_configuredActions)))
|
||||
{
|
||||
const CHotkeyCombination &combination = pair.first;
|
||||
const QString &action = pair.second;
|
||||
if (combination.isSubsetOf(currentCombination))
|
||||
{
|
||||
newActiveActions.insert(action);
|
||||
|
||||
@@ -420,19 +420,18 @@ namespace BlackGui
|
||||
{
|
||||
ui->cb_OtherVersions->clear();
|
||||
const QMap<QString, CApplicationInfo> otherVersions = CApplicationInfoList::currentApplicationDataDirectoryMapWithoutCurrentVersion();
|
||||
for (const auto pair : makePairsRange(otherVersions))
|
||||
for (const auto [dir, info] : makePairsRange(otherVersions))
|
||||
{
|
||||
const CApplicationInfo &info(pair.second);
|
||||
if (info.isNull())
|
||||
{
|
||||
const QString infoString = CDirectoryUtils::decodeNormalizedDirectory(pair.first);
|
||||
const QString infoString = CDirectoryUtils::decodeNormalizedDirectory(dir);
|
||||
ui->cb_OtherVersions->addItem(infoString);
|
||||
}
|
||||
else
|
||||
{
|
||||
ui->cb_OtherVersions->addItem(QStringLiteral("swift %1 (%2)").arg(info.getVersionString(), info.getPlatform()));
|
||||
}
|
||||
m_otherVersionDirs.push_back(pair.first);
|
||||
m_otherVersionDirs.push_back(dir);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -566,11 +566,11 @@ namespace BlackMisc
|
||||
{
|
||||
const QMap<QString, int> modelStrings = this->countPerModelString();
|
||||
CAircraftModelList duplicates;
|
||||
for (const auto pair : makePairsRange(modelStrings))
|
||||
for (const auto [string, count] : makePairsRange(modelStrings))
|
||||
{
|
||||
if (pair.second > 1)
|
||||
if (count > 1)
|
||||
{
|
||||
duplicates.push_back(this->findByModelString(pair.first, Qt::CaseInsensitive));
|
||||
duplicates.push_back(this->findByModelString(string, Qt::CaseInsensitive));
|
||||
}
|
||||
}
|
||||
return duplicates;
|
||||
|
||||
@@ -53,15 +53,14 @@ namespace BlackMisc
|
||||
// used simple string JSON generation as it is faster
|
||||
QString json;
|
||||
|
||||
for (const auto pair : makePairsRange(m_modelStringVsCG))
|
||||
for (const auto [string, cg] : makePairsRange(m_modelStringVsCG))
|
||||
{
|
||||
json += QStringLiteral("{ \"type\": \"cg\", \"modelstring\": \"%1\", \"cgft\": %2 },\n").arg(pair.first, pair.second.valueRoundedAsString(CLengthUnit::ft(), 1));
|
||||
json += QStringLiteral("{ \"type\": \"cg\", \"modelstring\": \"%1\", \"cgft\": %2 },\n").arg(string, cg.valueRoundedAsString(CLengthUnit::ft(), 1));
|
||||
}
|
||||
|
||||
for (const auto pair : makePairsRange(m_modelStringVsSimulatorInfo))
|
||||
for (const auto [string, sim] : makePairsRange(m_modelStringVsSimulatorInfo))
|
||||
{
|
||||
const QString sim = pair.second.toQString(false);
|
||||
json += QStringLiteral("{ \"type\": \"simulatorupdate\", \"modelstring\": \"%1\", \"simulator\": \"%2\" },\n").arg(pair.first, sim);
|
||||
json += QStringLiteral("{ \"type\": \"simulatorupdate\", \"modelstring\": \"%1\", \"simulator\": \"%2\" },\n").arg(string, sim.toQString(false));
|
||||
}
|
||||
|
||||
if (json.isEmpty()) { return {}; }
|
||||
|
||||
@@ -61,9 +61,9 @@ namespace BlackMisc
|
||||
{
|
||||
const SetupsPerCallsign setups = this->getSetupsPerCallsign();
|
||||
CCallsignSet callsigns;
|
||||
for (const auto pair : makePairsRange(setups))
|
||||
for (const auto [callsign, setup] : makePairsRange(setups))
|
||||
{
|
||||
if (pair.second.logInterpolation()) { callsigns.insert(pair.first); }
|
||||
if (setup.logInterpolation()) { callsigns.insert(callsign); }
|
||||
}
|
||||
return callsigns;
|
||||
}
|
||||
@@ -145,19 +145,18 @@ namespace BlackMisc
|
||||
|
||||
void IInterpolationSetupProvider::clearInterpolationLogCallsigns()
|
||||
{
|
||||
const SetupsPerCallsign setupsCopy = this->getSetupsPerCallsign();
|
||||
SetupsPerCallsign setupsCopy = this->getSetupsPerCallsign();
|
||||
if (setupsCopy.isEmpty()) { return; }
|
||||
|
||||
// potential risk, changes inbetween in another thread are missed now
|
||||
// on the other side, we keep locks for a minimal time frame
|
||||
SetupsPerCallsign setupsToKeep;
|
||||
CInterpolationAndRenderingSetupGlobal global = this->getInterpolationSetupGlobal();
|
||||
for (const auto pair : makePairsRange(setupsCopy))
|
||||
for (auto [callsign, setup] : makePairsRange(setupsCopy))
|
||||
{
|
||||
CInterpolationAndRenderingSetupPerCallsign setup = pair.second;
|
||||
setup.setLogInterpolation(false);
|
||||
if (setup.isEqualToGlobal(global)) { continue; }
|
||||
setupsToKeep.insert(pair.first, setup);
|
||||
setupsToKeep.insert(callsign, setup);
|
||||
}
|
||||
{
|
||||
QWriteLocker l(&m_lockSetup);
|
||||
|
||||
Reference in New Issue
Block a user