mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2025-12-22 16:37:21 -06:00
Migrate away from deprecated API in Qt 5.14
This commit is contained in:
@@ -48,3 +48,31 @@ constexpr typename std::add_const<T>::type asConst(T &&t) noexcept { return std:
|
||||
// Prevent const rvalue arguments
|
||||
template <typename T>
|
||||
void asConst(const T &&) = delete;
|
||||
|
||||
namespace List
|
||||
{
|
||||
// Replacement for the deprecated`QSet<T> QSet::fromList(const QList<T> &list)`
|
||||
template <typename T>
|
||||
QSet<T> toSet(const QList<T> &list)
|
||||
{
|
||||
#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
|
||||
return {list.cbegin(), list.cend()};
|
||||
#else
|
||||
return QSet<T>::fromList(list);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
namespace Vector
|
||||
{
|
||||
// Replacement for the deprecated `QVector<T> QVector::fromStdVector(const std::vector<T> &vector)`
|
||||
template <typename T>
|
||||
QVector<T> fromStdVector(const std::vector<T> &vector)
|
||||
{
|
||||
#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
|
||||
return {vector.cbegin(), vector.cend()};
|
||||
#else
|
||||
return QVector<T>::fromStdVector(vector);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user