Fix deprecation warnings.

--HG--
branch : release
This commit is contained in:
Roman Telezhynskyi 2020-01-06 20:10:09 +02:00
parent e8bb4c2af3
commit 1abff6b62c
9 changed files with 58 additions and 5 deletions

View File

@ -2824,8 +2824,13 @@ void TMainWindow::WriteSettings()
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QStringList TMainWindow::FilterMeasurements(const QStringList &mNew, const QStringList &mFilter) QStringList TMainWindow::FilterMeasurements(const QStringList &mNew, const QStringList &mFilter)
{ {
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
const auto import = QSet<QString>(mNew.begin(), mNew.end()).subtract(QSet<QString>(mFilter.begin(), mFilter.end()));
return QStringList(import.begin(), import.end());
#else
const QSet<QString> import = mNew.toSet().subtract(mFilter.toSet()); const QSet<QString> import = mNew.toSet().subtract(mFilter.toSet());
return QStringList(import.toList()); return QStringList(import.toList());
#endif
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -3123,7 +3128,12 @@ QString TMainWindow::CheckMName(const QString &name, const QSet<QString> &import
} }
else else
{ {
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
const QStringList allGroupNames = AllGroupNames();
if (not QSet<QString>(allGroupNames.begin(), allGroupNames.end()).contains(name))
#else
if (not AllGroupNames().toSet().contains(name)) if (not AllGroupNames().toSet().contains(name))
#endif
{ {
throw VException(tr("Measurement '%1' is not one of known measurements.").arg(name)); throw VException(tr("Measurement '%1' is not one of known measurements.").arg(name));
} }

View File

@ -1843,10 +1843,22 @@ QSharedPointer<VMeasurements> MainWindowsNoGUI::OpenMeasurementFile(const QStrin
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void MainWindowsNoGUI::CheckRequiredMeasurements(const VMeasurements *m) const void MainWindowsNoGUI::CheckRequiredMeasurements(const VMeasurements *m) const
{ {
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
QStringList patternMeasurments = doc->ListMeasurements();
QStringList bodyMeasurments = m->ListAll();
const auto match = QSet<QString>(patternMeasurments.begin(), patternMeasurments.end())
.subtract(QSet<QString>(bodyMeasurments.begin(), bodyMeasurments.end()));
#else
const QSet<QString> match = doc->ListMeasurements().toSet().subtract(m->ListAll().toSet()); const QSet<QString> match = doc->ListMeasurements().toSet().subtract(m->ListAll().toSet());
#endif
if (not match.isEmpty()) if (not match.isEmpty())
{ {
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
QList<QString> list = QList<QString>(match.begin(), match.end());
#else
QList<QString> list = match.toList(); QList<QString> list = match.toList();
#endif
for (int i = 0; i < list.size(); ++i) for (int i = 0; i < list.size(); ++i)
{ {
list[i] = qApp->TrVars()->MToUser(list.at(i)); list[i] = qApp->TrVars()->MToUser(list.at(i));

View File

@ -243,7 +243,11 @@ QList<QString> GetTokens(const VFormulaField &formula)
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void GatherTokens(QSet<QString> &tokens, const QList<QString> &tokenList) void GatherTokens(QSet<QString> &tokens, const QList<QString> &tokenList)
{ {
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
tokens = tokens.unite(QSet<QString>(tokenList.begin(), tokenList.end()));
#else
tokens = tokens.unite(tokenList.toSet()); tokens = tokens.unite(tokenList.toSet());
#endif
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -294,11 +298,21 @@ QStringList VAbstractPattern::ListMeasurements() const
{ {
const QFuture<QStringList> futureIncrements = QtConcurrent::run(this, &VAbstractPattern::ListIncrements); const QFuture<QStringList> futureIncrements = QtConcurrent::run(this, &VAbstractPattern::ListIncrements);
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
QSet<QString> results = QtConcurrent::blockingMappedReduced(ListExpressions(), GetTokens, GatherTokens);
const auto tokens = QList<QString>(results.begin(), results.end());
#else
const QList<QString> tokens = QtConcurrent::blockingMappedReduced(ListExpressions(), GetTokens, const QList<QString> tokens = QtConcurrent::blockingMappedReduced(ListExpressions(), GetTokens,
GatherTokens).toList(); GatherTokens).toList();
#endif
QSet<QString> measurements; QSet<QString> measurements;
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
QStringList result = futureIncrements.result();
QSet<QString> others = QSet<QString>(result.begin(), result.end());
#else
QSet<QString> others = futureIncrements.result().toSet(); QSet<QString> others = futureIncrements.result().toSet();
#endif
for (const auto &token : tokens) for (const auto &token : tokens)
{ {
@ -310,7 +324,7 @@ QStringList VAbstractPattern::ListMeasurements() const
IsVariable(token) || IsFunction(token) ? others.insert(token) : measurements.insert(token); IsVariable(token) || IsFunction(token) ? others.insert(token) : measurements.insert(token);
} }
return QStringList(measurements.toList()); return QStringList(measurements.values());
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------

View File

@ -454,7 +454,11 @@ QList<VLayoutPiece> VLayoutGenerator::MoveDetails(qreal length, const QVector<VL
{ {
if (qFuzzyIsNull(length)) if (qFuzzyIsNull(length))
{ {
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
return QList<VLayoutPiece>(details.begin(), details.end());
#else
return details.toList(); return details.toList();
#endif
} }
QList<VLayoutPiece> newDetails; QList<VLayoutPiece> newDetails;

View File

@ -474,7 +474,11 @@ QVector<T> VLayoutPiece::Map(const QVector<T> &points) const
if (d->mirror) if (d->mirror)
{ {
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
auto list = QList<T>(p.begin(), p.end());
#else
QList<T> list = p.toList(); QList<T> list = p.toList();
#endif
for (int k=0, s=list.size(), max=(s/2); k<max; k++) for (int k=0, s=list.size(), max=(s/2); k<max; k++)
{ {
list.swap(k, s-(1+k)); list.swap(k, s-(1+k));

View File

@ -672,7 +672,7 @@ QStringList VContainer::AllUniqueNames(const QString &nspace)
if (uniqueNames.contains(nspace)) if (uniqueNames.contains(nspace))
{ {
QStringList names = builInFunctions; QStringList names = builInFunctions;
names.append(uniqueNames.value(nspace).toList()); names.append(uniqueNames.value(nspace).values());
return names; return names;
} }
else else
@ -720,7 +720,7 @@ void VContainer::ClearUniqueNames() const
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VContainer::ClearUniqueIncrementNames() const void VContainer::ClearUniqueIncrementNames() const
{ {
const QList<QString> list = uniqueNames.value(d->nspace).toList(); const QList<QString> list = uniqueNames.value(d->nspace).values();
ClearUniqueNames(); ClearUniqueNames();
for(auto &name : list) for(auto &name : list)
@ -823,7 +823,11 @@ const QHash<QString, QSharedPointer<VInternalVariable> > *VContainer::DataVariab
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VContainerData::~VContainerData() VContainerData::~VContainerData()
{ {
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
if (ref.loadRelaxed() == 0)
#else
if (ref.load() == 0) if (ref.load() == 0)
#endif
{ {
--VContainer::copyCounter[nspace]; --VContainer::copyCounter[nspace];
} }

View File

@ -60,7 +60,7 @@ QVector<quint32> PieceMissingNodes(const QVector<quint32> &d1Nodes, const QVecto
set2.insert(d2Nodes.at(j)); set2.insert(d2Nodes.at(j));
} }
const QList<quint32> set3 = set1.subtract(set2).toList(); const QList<quint32> set3 = set1.subtract(set2).values();
QVector<quint32> r; QVector<quint32> r;
for (qint32 i = 0; i < set3.size(); ++i) for (qint32 i = 0; i < set3.size(); ++i)
{ {

View File

@ -660,7 +660,7 @@ QVector<quint32> VPiecePath::MissingNodes(const VPiecePath &path) const
set2.insert(path.at(j).GetId()); set2.insert(path.at(j).GetId());
} }
const QList<quint32> set3 = set1.subtract(set2).toList(); const QList<quint32> set3 = set1.subtract(set2).values();
QVector<quint32> nodes; QVector<quint32> nodes;
nodes.reserve(set3.size()); nodes.reserve(set3.size());
for (qint32 i = 0; i < set3.size(); ++i) for (qint32 i = 0; i < set3.size(); ++i)

View File

@ -96,7 +96,12 @@ QVector<quint32> SaveToolOptions::Missing(const QList<quint32> &list1, const QLi
{ {
QSet<quint32> set1 = QSet<quint32>::fromList(list1); QSet<quint32> set1 = QSet<quint32>::fromList(list1);
QSet<quint32> set2 = QSet<quint32>::fromList(list2); QSet<quint32> set2 = QSet<quint32>::fromList(list2);
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
QSet<quint32> substracted = set1.subtract(set2);
return QVector<quint32>(substracted.begin(), substracted.end());
#else
return set1.subtract(set2).toList().toVector(); return set1.subtract(set2).toList().toVector();
#endif
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------