forked from qt-creator/qt-creator
Utils: Add toSet/toList functions
As replacement for functionality that's being deprecated in Qt but still useful or needed, or that cannot easily be handled without resorting to #if QT_VERSION checks in user code. Change-Id: Id3575a54ff944bf0e89d452d13944fcaee270208 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
@@ -1243,4 +1243,27 @@ OutputIterator set_union(InputIterator1 first1,
|
||||
return Utils::set_union_impl(
|
||||
first1, last1, first2, last2, result, std::less<typename InputIterator1::value_type>{});
|
||||
}
|
||||
|
||||
// Replacement for deprecated Qt functionality
|
||||
|
||||
template <class T>
|
||||
QSet<T> toSet(const QList<T> &list)
|
||||
{
|
||||
#if (QT_VERSION < QT_VERSION_CHECK(5, 13, 0))
|
||||
return list.toSet();
|
||||
#else
|
||||
return QSet<T>{list.begin(), list.end()};
|
||||
#endif
|
||||
}
|
||||
|
||||
template <class T>
|
||||
QList<T> toList(const QSet<T> &set)
|
||||
{
|
||||
#if (QT_VERSION < QT_VERSION_CHECK(5, 13, 0))
|
||||
return set.toList();
|
||||
#else
|
||||
return QList<T>{set.begin(), set.end()};
|
||||
#endif
|
||||
}
|
||||
|
||||
} // namespace Utils
|
||||
|
||||
Reference in New Issue
Block a user