diff --git a/src/libs/vlayout/vbank.cpp b/src/libs/vlayout/vbank.cpp index 1affaa69b..17d47e772 100644 --- a/src/libs/vlayout/vbank.cpp +++ b/src/libs/vlayout/vbank.cpp @@ -32,6 +32,7 @@ #include "../vmisc/diagnostic.h" #include "../vmisc/vabstractapplication.h" +#include "../vmisc/compatibility.h" #include "vlayoutdef.h" #include "../ifc/exception/vexception.h" #include "../vpatterndb/floatItemData/floatitemdef.h" @@ -343,11 +344,7 @@ bool VBank::PrepareUnsorted() Insert(unsorted, group, i, square); } -#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0) - groups = QVector(uniqueGroup.begin(), uniqueGroup.end()); -#else - groups = QVector::fromList(uniqueGroup.toList()); -#endif + groups = ConvertToVector(uniqueGroup); std::sort(groups.begin(), groups.end()); PrepareGroup(); diff --git a/src/libs/vmisc/compatibility.h b/src/libs/vmisc/compatibility.h index e350f6e0d..570b9cacb 100644 --- a/src/libs/vmisc/compatibility.h +++ b/src/libs/vmisc/compatibility.h @@ -113,6 +113,17 @@ inline QVector ConvertToVector(const C &container) #endif } +//--------------------------------------------------------------------------------------------------------------------- +template +inline QVector ConvertToVector(const QSet &container) +{ +#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0) + return QVector(container.begin(), container.end()); +#else + return container.toList().toVector(); +#endif +} + //--------------------------------------------------------------------------------------------------------------------- template inline void SwapItemsAt(T &container, int i, int j) diff --git a/src/libs/vtools/undocommands/savepieceoptions.cpp b/src/libs/vtools/undocommands/savepieceoptions.cpp index 5260961dc..7d4597a6b 100644 --- a/src/libs/vtools/undocommands/savepieceoptions.cpp +++ b/src/libs/vtools/undocommands/savepieceoptions.cpp @@ -36,6 +36,7 @@ #include "../ifc/xml/vabstractpattern.h" #include "../ifc/ifcdef.h" #include "../vmisc/def.h" +#include "../vmisc/compatibility.h" #include "../vpatterndb/vpiecenode.h" #include "../vpatterndb/floatItemData/vpatternlabeldata.h" #include "../vpatterndb/floatItemData/vpiecelabeldata.h" @@ -162,16 +163,8 @@ bool SavePieceOptions::mergeWith(const QUndoCommand *command) { const VPiece candidate = saveCommand->NewDet(); -#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0) - QList currentDependencies = m_newDet.Dependencies(); - QList candidateDependencies = candidate.Dependencies(); - - auto currentSet = QSet(currentDependencies.begin(), currentDependencies.end()); - auto candidateSet = QSet(candidateDependencies.begin(), candidateDependencies.end()); -#else - auto currentSet = QSet::fromList(m_newDet.Dependencies()); - auto candidateSet = QSet::fromList(candidate.Dependencies()); -#endif + auto currentSet = ConvertToSet(m_newDet.Dependencies()); + auto candidateSet = ConvertToSet(candidate.Dependencies()); if (currentSet != candidateSet) { diff --git a/src/libs/vtools/undocommands/savepiecepathoptions.cpp b/src/libs/vtools/undocommands/savepiecepathoptions.cpp index 28e7d0669..bec556567 100644 --- a/src/libs/vtools/undocommands/savepiecepathoptions.cpp +++ b/src/libs/vtools/undocommands/savepiecepathoptions.cpp @@ -36,6 +36,7 @@ #include "../tools/nodeDetails/vtoolpiecepath.h" #include "../tools/vtoolseamallowance.h" #include "../vpatterndb/vpiecenode.h" +#include "../vmisc/compatibility.h" //--------------------------------------------------------------------------------------------------------------------- SavePiecePathOptions::SavePiecePathOptions(quint32 pieceId, const VPiecePath &oldPath, const VPiecePath &newPath, @@ -129,16 +130,8 @@ bool SavePiecePathOptions::mergeWith(const QUndoCommand *command) { const VPiecePath candidate = saveCommand->NewPath(); -#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0) - QList currentDependencies = m_newPath.Dependencies(); - QList candidateDependencies = candidate.Dependencies(); - - auto currentSet = QSet(currentDependencies.begin(), currentDependencies.end()); - auto candidateSet = QSet(candidateDependencies.begin(), candidateDependencies.end()); -#else - auto currentSet = QSet::fromList(m_newPath.Dependencies()); - auto candidateSet = QSet::fromList(candidate.Dependencies()); -#endif + auto currentSet = ConvertToSet(m_newPath.Dependencies()); + auto candidateSet = ConvertToSet(candidate.Dependencies()); if (currentSet != candidateSet) { diff --git a/src/libs/vtools/undocommands/savetooloptions.cpp b/src/libs/vtools/undocommands/savetooloptions.cpp index 312b43008..501232825 100644 --- a/src/libs/vtools/undocommands/savetooloptions.cpp +++ b/src/libs/vtools/undocommands/savetooloptions.cpp @@ -31,6 +31,7 @@ #include #include "../vmisc/def.h" +#include "../vmisc/compatibility.h" #include "../ifc/xml/vabstractpattern.h" #include "vundocommand.h" @@ -93,16 +94,7 @@ void SaveToolOptions::redo() //--------------------------------------------------------------------------------------------------------------------- QVector SaveToolOptions::Missing(const QList &list1, const QList &list2) const { -#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0) - auto set1 = QSet(list1.begin(), list1.end()); - auto set2 = QSet(list2.begin(), list2.end()); - QSet substracted = set1.subtract(set2); - return QVector(substracted.begin(), substracted.end()); -#else - auto set1 = QSet::fromList(list1); - auto set2 = QSet::fromList(list2); - return set1.subtract(set2).toList().toVector(); -#endif + return ConvertToVector(ConvertToSet(list1).subtract(ConvertToSet(list2))); } //--------------------------------------------------------------------------------------------------------------------- @@ -116,13 +108,8 @@ bool SaveToolOptions::mergeWith(const QUndoCommand *command) } else { -#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0) - auto currentSet = QSet(newDependencies.begin(), newDependencies.end()); - auto candidateSet = QSet(saveCommand->NewDependencies().begin(), saveCommand->NewDependencies().end()); -#else - auto currentSet = QSet::fromList(newDependencies); - auto candidateSet = QSet::fromList(saveCommand->NewDependencies()); -#endif + auto currentSet = ConvertToSet(newDependencies); + auto candidateSet = ConvertToSet(saveCommand->NewDependencies()); if (currentSet != candidateSet) { diff --git a/src/test/TranslationsTest/tst_abstractregexp.cpp b/src/test/TranslationsTest/tst_abstractregexp.cpp index 24664ee9a..629b53e1e 100644 --- a/src/test/TranslationsTest/tst_abstractregexp.cpp +++ b/src/test/TranslationsTest/tst_abstractregexp.cpp @@ -31,6 +31,7 @@ #include "../qmuparser/qmuformulabase.h" #include "../vpatterndb/vtranslatevars.h" #include "../ifc/ifcdef.h" +#include "../vmisc/compatibility.h" #include #include @@ -185,11 +186,7 @@ void TST_AbstractRegExp::CallTestCheckNoOriginalNamesInTranslation() QFETCH(QString, originalName); static const QStringList originalNames = AllNames(); -#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0) - static const auto names = QSet(originalNames.begin(), originalNames.end()); -#else - static const auto names = QSet::fromList(originalNames); -#endif + static const auto names = ConvertToSet(originalNames); const QString translated = m_trMs->VarToUser(originalName); if (names.contains(translated))