Refactoring.

Method void QMap::insert(const QMap<Key, T> &map) available since Qt 5.15.
This commit is contained in:
Roman Telezhynskyi 2022-12-31 14:41:10 +02:00
parent 376152da8c
commit a547822af1
2 changed files with 18 additions and 12 deletions

View File

@ -286,4 +286,20 @@ inline auto TextWidthF(const QFontMetricsF &fm, const QString &text) -> qreal
#endif
}
//---------------------------------------------------------------------------------------------------------------------
template <typename Key, typename T>
inline auto Insert(QMap<Key, T> &map1, const QMap<Key, T> &map2) -> void
{
#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
map1.insert(map2);
#else
auto i = map2.constBegin();
while (i != map2.constEnd())
{
map1.insert(i.key(), i.value());
++i;
}
#endif
}
#endif // COMPATIBILITY_H

View File

@ -597,12 +597,7 @@ const QMap<QString, QSharedPointer<VMeasurement> > VContainer::DataMeasurementsW
QMap<QString, QSharedPointer<VMeasurement> > measurements = DataVar<VMeasurement>(VarType::Measurement);
QMap<QString, QSharedPointer<VMeasurement> > separators = DataVar<VMeasurement>(VarType::MeasurementSeparator);
QMap<QString, QSharedPointer<VMeasurement>>::const_iterator i = separators.constBegin();
while (i != separators.constEnd())
{
measurements.insert(i.key(), i.value());
++i;
}
Insert(measurements, separators);
return measurements;
}
@ -619,12 +614,7 @@ const QMap<QString, QSharedPointer<VIncrement> > VContainer::DataIncrementsWithS
QMap<QString, QSharedPointer<VIncrement> > increments = DataVar<VIncrement>(VarType::Increment);
QMap<QString, QSharedPointer<VIncrement> > separators = DataVar<VIncrement>(VarType::IncrementSeparator);
QMap<QString, QSharedPointer<VIncrement>>::const_iterator i = separators.constBegin();
while (i != separators.constEnd())
{
increments.insert(i.key(), i.value());
++i;
}
Insert(increments, separators);
return increments;
}