Fix deprecation warnings.

(grafted from 686129d90f37b8d0c428092668673d44f06545d8)

--HG--
branch : develop
This commit is contained in:
Roman Telezhynskyi 2020-01-06 20:10:09 +02:00
parent d74225e63e
commit 1f6285aef9
11 changed files with 72 additions and 5 deletions

View File

@ -2795,8 +2795,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
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -3065,7 +3070,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

@ -2116,10 +2116,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

@ -98,7 +98,12 @@ void GatherCount(int &count, const int nodes)
QString DefLabelLanguage() QString DefLabelLanguage()
{ {
QString def = qApp->ValentinaSettings()->GetLabelLanguage(); QString def = qApp->ValentinaSettings()->GetLabelLanguage();
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
QStringList languages = VApplication::LabelLanguages();
if (not QSet<QString>(languages.begin(), languages.end()).contains(def));
#else
if (not VApplication::LabelLanguages().toSet().contains(def)) if (not VApplication::LabelLanguages().toSet().contains(def))
#endif
{ {
def = QStringLiteral("en"); def = QStringLiteral("en");
} }
@ -4376,7 +4381,12 @@ void VPattern::SetLabelPrefix(const QString &prefix)
if (not pattern.isNull()) if (not pattern.isNull())
{ {
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
QStringList languages = VApplication::LabelLanguages();
if (QSet<QString>(languages.begin(), languages.end()).contains(prefix));
#else
if (VApplication::LabelLanguages().toSet().contains(prefix)) if (VApplication::LabelLanguages().toSet().contains(prefix))
#endif
{ {
SetAttribute(pattern, AttrLabelPrefix, prefix); SetAttribute(pattern, AttrLabelPrefix, prefix);
modified = true; modified = true;

View File

@ -256,7 +256,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
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -313,11 +317,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)
{ {
@ -329,7 +343,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

@ -343,7 +343,11 @@ bool VBank::PrepareUnsorted()
Insert(unsorted, group, i, square); Insert(unsorted, group, i, square);
} }
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
groups = QVector<uint>(uniqueGroup.begin(), uniqueGroup.end());
#else
groups = QVector<uint>::fromList(uniqueGroup.toList()); groups = QVector<uint>::fromList(uniqueGroup.toList());
#endif
std::sort(groups.begin(), groups.end()); std::sort(groups.begin(), groups.end());
PrepareGroup(); PrepareGroup();

View File

@ -642,7 +642,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

@ -500,7 +500,11 @@ QVector<T> VLayoutPiece::Map(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 = points.toList(); QList<T> list = points.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++)
{ {
#if QT_VERSION >= QT_VERSION_CHECK(5, 13, 0) #if QT_VERSION >= QT_VERSION_CHECK(5, 13, 0)

View File

@ -659,7 +659,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
@ -707,7 +707,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)
@ -810,7 +810,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

@ -67,7 +67,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;
r.reserve(set3.size()); r.reserve(set3.size());
for (qint32 i = 0; i < set3.size(); ++i) for (qint32 i = 0; i < set3.size(); ++i)

View File

@ -629,7 +629,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

@ -95,7 +95,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
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------