mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-25 22:14:32 +00:00
Migrate away from deprecated API in Qt 5.14
This commit is contained in:
parent
18de63f743
commit
2422d81de1
@ -501,7 +501,7 @@ Session::Session(QObject *parent)
|
|||||||
m_storedCategories = map_cast(m_categories);
|
m_storedCategories = map_cast(m_categories);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_tags = QSet<QString>::fromList(m_storedTags.value());
|
m_tags = List::toSet(m_storedTags.value());
|
||||||
|
|
||||||
m_refreshTimer->setInterval(refreshInterval());
|
m_refreshTimer->setInterval(refreshInterval());
|
||||||
connect(m_refreshTimer, &QTimer::timeout, this, &Session::refresh);
|
connect(m_refreshTimer, &QTimer::timeout, this, &Session::refresh);
|
||||||
@ -4060,7 +4060,7 @@ void Session::startUpTorrents()
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!queue.empty())
|
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)) {
|
for (const QString &fastresumeName : asConst(fastresumes)) {
|
||||||
|
@ -1246,7 +1246,7 @@ QVector<int> TorrentHandle::pieceAvailability() const
|
|||||||
std::vector<int> avail;
|
std::vector<int> avail;
|
||||||
m_nativeHandle.piece_availability(avail);
|
m_nativeHandle.piece_availability(avail);
|
||||||
|
|
||||||
return QVector<int>::fromStdVector(avail);
|
return Vector::fromStdVector(avail);
|
||||||
}
|
}
|
||||||
|
|
||||||
qreal TorrentHandle::distributedCopies() const
|
qreal TorrentHandle::distributedCopies() const
|
||||||
|
@ -48,3 +48,31 @@ constexpr typename std::add_const<T>::type asConst(T &&t) noexcept { return std:
|
|||||||
// Prevent const rvalue arguments
|
// Prevent const rvalue arguments
|
||||||
template <typename T>
|
template <typename T>
|
||||||
void asConst(const T &&) = delete;
|
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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -39,7 +39,7 @@ public Q_SLOTS: // METHODS
|
|||||||
inline QDBusPendingReply<> CloseNotification(uint id)
|
inline QDBusPendingReply<> CloseNotification(uint id)
|
||||||
{
|
{
|
||||||
QList<QVariant> argumentList;
|
QList<QVariant> argumentList;
|
||||||
argumentList << qVariantFromValue(id);
|
argumentList << QVariant::fromValue(id);
|
||||||
return asyncCallWithArgumentList(QLatin1String("CloseNotification"), argumentList);
|
return asyncCallWithArgumentList(QLatin1String("CloseNotification"), argumentList);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -69,7 +69,7 @@ public Q_SLOTS: // METHODS
|
|||||||
inline QDBusPendingReply<uint> Notify(const QString &app_name, uint id, const QString &icon, const QString &summary, const QString &body, const QStringList &actions, const QVariantMap &hints, int timeout)
|
inline QDBusPendingReply<uint> 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<QVariant> argumentList;
|
QList<QVariant> 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);
|
return asyncCallWithArgumentList(QLatin1String("Notify"), argumentList);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,6 +32,7 @@
|
|||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
|
|
||||||
#include "base/bittorrent/torrenthandle.h"
|
#include "base/bittorrent/torrenthandle.h"
|
||||||
|
#include "base/global.h"
|
||||||
#include "base/types.h"
|
#include "base/types.h"
|
||||||
#include "base/utils/string.h"
|
#include "base/utils/string.h"
|
||||||
#include "transferlistmodel.h"
|
#include "transferlistmodel.h"
|
||||||
@ -73,7 +74,7 @@ void TransferListSortModel::disableTagFilter()
|
|||||||
|
|
||||||
void TransferListSortModel::setTrackerFilter(const QStringList &hashes)
|
void TransferListSortModel::setTrackerFilter(const QStringList &hashes)
|
||||||
{
|
{
|
||||||
if (m_filter.setHashSet(hashes.toSet()))
|
if (m_filter.setHashSet(List::toSet(hashes)))
|
||||||
invalidateFilter();
|
invalidateFilter();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1219,7 +1219,7 @@ void TransferListWidget::displayListMenu(const QPoint &)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Tag Menu
|
// 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<Qt::CaseInsensitive>);
|
std::sort(tags.begin(), tags.end(), Utils::String::naturalLessThan<Qt::CaseInsensitive>);
|
||||||
|
|
||||||
QMenu *tagsMenu = listMenu->addMenu(UIThemeManager::instance()->getIcon("view-categories"), tr("Tags"));
|
QMenu *tagsMenu = listMenu->addMenu(UIThemeManager::instance()->getIcon("view-categories"), tr("Tags"));
|
||||||
|
@ -246,7 +246,7 @@ void TorrentsController::infoAction()
|
|||||||
const bool reverse {parseBool(params()["reverse"], false)};
|
const bool reverse {parseBool(params()["reverse"], false)};
|
||||||
int limit {params()["limit"].toInt()};
|
int limit {params()["limit"].toInt()};
|
||||||
int offset {params()["offset"].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;
|
QVariantList torrentList;
|
||||||
TorrentFilter torrentFilter(filter, (hashSet.isEmpty() ? TorrentFilter::AnyHash : hashSet), category);
|
TorrentFilter torrentFilter(filter, (hashSet.isEmpty() ? TorrentFilter::AnyHash : hashSet), category);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user