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