diff --git a/src/base/bittorrent/session.cpp b/src/base/bittorrent/session.cpp index 460a87603..53c63dbd4 100644 --- a/src/base/bittorrent/session.cpp +++ b/src/base/bittorrent/session.cpp @@ -501,7 +501,7 @@ Session::Session(QObject *parent) m_storedCategories = map_cast(m_categories); } - m_tags = QSet::fromList(m_storedTags.value()); + m_tags = List::toSet(m_storedTags.value()); m_refreshTimer->setInterval(refreshInterval()); connect(m_refreshTimer, &QTimer::timeout, this, &Session::refresh); @@ -4060,7 +4060,7 @@ void Session::startUpTorrents() } if (!queue.empty()) - fastresumes = queue + fastresumes.toSet().subtract(queue.toSet()).values(); + fastresumes = queue + List::toSet(fastresumes).subtract(List::toSet(queue)).values(); } for (const QString &fastresumeName : asConst(fastresumes)) { diff --git a/src/base/bittorrent/torrenthandle.cpp b/src/base/bittorrent/torrenthandle.cpp index 9e9e4eb16..df39f8ba7 100644 --- a/src/base/bittorrent/torrenthandle.cpp +++ b/src/base/bittorrent/torrenthandle.cpp @@ -1246,7 +1246,7 @@ QVector TorrentHandle::pieceAvailability() const std::vector avail; m_nativeHandle.piece_availability(avail); - return QVector::fromStdVector(avail); + return Vector::fromStdVector(avail); } qreal TorrentHandle::distributedCopies() const diff --git a/src/base/global.h b/src/base/global.h index b8a74a10a..323d44c3f 100644 --- a/src/base/global.h +++ b/src/base/global.h @@ -48,3 +48,31 @@ constexpr typename std::add_const::type asConst(T &&t) noexcept { return std: // Prevent const rvalue arguments template void asConst(const T &&) = delete; + +namespace List +{ + // Replacement for the deprecated`QSet QSet::fromList(const QList &list)` + template + QSet toSet(const QList &list) + { +#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)) + return {list.cbegin(), list.cend()}; +#else + return QSet::fromList(list); +#endif + } +} + +namespace Vector +{ + // Replacement for the deprecated `QVector QVector::fromStdVector(const std::vector &vector)` + template + QVector fromStdVector(const std::vector &vector) + { +#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)) + return {vector.cbegin(), vector.cend()}; +#else + return QVector::fromStdVector(vector); +#endif + } +} diff --git a/src/gui/qtnotify/notifications.h b/src/gui/qtnotify/notifications.h index 593dac047..b042599d6 100644 --- a/src/gui/qtnotify/notifications.h +++ b/src/gui/qtnotify/notifications.h @@ -39,7 +39,7 @@ public Q_SLOTS: // METHODS inline QDBusPendingReply<> CloseNotification(uint id) { QList argumentList; - argumentList << qVariantFromValue(id); + argumentList << QVariant::fromValue(id); return asyncCallWithArgumentList(QLatin1String("CloseNotification"), argumentList); } @@ -69,7 +69,7 @@ public Q_SLOTS: // METHODS inline QDBusPendingReply Notify(const QString &app_name, uint id, const QString &icon, const QString &summary, const QString &body, const QStringList &actions, const QVariantMap &hints, int timeout) { QList argumentList; - argumentList << qVariantFromValue(app_name) << qVariantFromValue(id) << qVariantFromValue(icon) << qVariantFromValue(summary) << qVariantFromValue(body) << qVariantFromValue(actions) << qVariantFromValue(hints) << qVariantFromValue(timeout); + argumentList << QVariant::fromValue(app_name) << QVariant::fromValue(id) << QVariant::fromValue(icon) << QVariant::fromValue(summary) << QVariant::fromValue(body) << QVariant::fromValue(actions) << QVariant::fromValue(hints) << QVariant::fromValue(timeout); return asyncCallWithArgumentList(QLatin1String("Notify"), argumentList); } diff --git a/src/gui/transferlistsortmodel.cpp b/src/gui/transferlistsortmodel.cpp index 045610141..4e68f225e 100644 --- a/src/gui/transferlistsortmodel.cpp +++ b/src/gui/transferlistsortmodel.cpp @@ -32,6 +32,7 @@ #include #include "base/bittorrent/torrenthandle.h" +#include "base/global.h" #include "base/types.h" #include "base/utils/string.h" #include "transferlistmodel.h" @@ -73,7 +74,7 @@ void TransferListSortModel::disableTagFilter() void TransferListSortModel::setTrackerFilter(const QStringList &hashes) { - if (m_filter.setHashSet(hashes.toSet())) + if (m_filter.setHashSet(List::toSet(hashes))) invalidateFilter(); } diff --git a/src/gui/transferlistwidget.cpp b/src/gui/transferlistwidget.cpp index efec4784f..b9f0ebb8a 100644 --- a/src/gui/transferlistwidget.cpp +++ b/src/gui/transferlistwidget.cpp @@ -1219,7 +1219,7 @@ void TransferListWidget::displayListMenu(const QPoint &) } // Tag Menu - QStringList tags(BitTorrent::Session::instance()->tags().toList()); + QStringList tags(BitTorrent::Session::instance()->tags().values()); std::sort(tags.begin(), tags.end(), Utils::String::naturalLessThan); QMenu *tagsMenu = listMenu->addMenu(UIThemeManager::instance()->getIcon("view-categories"), tr("Tags")); diff --git a/src/webui/api/torrentscontroller.cpp b/src/webui/api/torrentscontroller.cpp index 258039465..c21a1ecca 100644 --- a/src/webui/api/torrentscontroller.cpp +++ b/src/webui/api/torrentscontroller.cpp @@ -246,7 +246,7 @@ void TorrentsController::infoAction() const bool reverse {parseBool(params()["reverse"], false)}; int limit {params()["limit"].toInt()}; int offset {params()["offset"].toInt()}; - const QStringSet hashSet {params()["hashes"].split('|', QString::SkipEmptyParts).toSet()}; + const QStringSet hashSet {List::toSet(params()["hashes"].split('|', QString::SkipEmptyParts))}; QVariantList torrentList; TorrentFilter torrentFilter(filter, (hashSet.isEmpty() ? TorrentFilter::AnyHash : hashSet), category);