Migrate away from deprecated Qt methods

PR #23370.
Closes #23354.
This commit is contained in:
Chocobo1 2025-10-13 06:57:58 +08:00 committed by GitHub
parent 518fd7cc1b
commit 62b5619bc1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 51 additions and 0 deletions

View File

@ -28,6 +28,8 @@
#include "logfiltermodel.h"
#include <QtVersionChecks>
#include "logmodel.h"
LogFilterModel::LogFilterModel(const Log::MsgTypes types, QObject *parent)
@ -38,8 +40,14 @@ LogFilterModel::LogFilterModel(const Log::MsgTypes types, QObject *parent)
void LogFilterModel::setMessageTypes(const Log::MsgTypes types)
{
#if QT_VERSION >= QT_VERSION_CHECK(6, 10, 0)
beginFilterChange();
m_types = types;
endFilterChange(Direction::Rows);
#else
m_types = types;
invalidateRowsFilter();
#endif
}
bool LogFilterModel::filterAcceptsRow(const int sourceRow, const QModelIndex &sourceParent) const

View File

@ -30,6 +30,7 @@
#include <type_traits>
#include <QtVersionChecks>
#include <QDateTime>
#include "base/bittorrent/infohash.h"
@ -125,44 +126,86 @@ void TransferListSortModel::sort(const int column, const Qt::SortOrder order)
void TransferListSortModel::setStatusFilter(const TorrentFilter::Type filter)
{
#if QT_VERSION >= QT_VERSION_CHECK(6, 10, 0)
beginFilterChange();
m_filter.setType(filter);
endFilterChange(Direction::Rows);
#else
if (m_filter.setType(filter))
invalidateRowsFilter();
#endif
}
void TransferListSortModel::setCategoryFilter(const QString &category)
{
#if QT_VERSION >= QT_VERSION_CHECK(6, 10, 0)
beginFilterChange();
m_filter.setCategory(category);
endFilterChange(Direction::Rows);
#else
if (m_filter.setCategory(category))
invalidateRowsFilter();
#endif
}
void TransferListSortModel::disableCategoryFilter()
{
#if QT_VERSION >= QT_VERSION_CHECK(6, 10, 0)
beginFilterChange();
m_filter.setCategory(TorrentFilter::AnyCategory);
endFilterChange(Direction::Rows);
#else
if (m_filter.setCategory(TorrentFilter::AnyCategory))
invalidateRowsFilter();
#endif
}
void TransferListSortModel::setTagFilter(const Tag &tag)
{
#if QT_VERSION >= QT_VERSION_CHECK(6, 10, 0)
beginFilterChange();
m_filter.setTag(tag);
endFilterChange(Direction::Rows);
#else
if (m_filter.setTag(tag))
invalidateRowsFilter();
#endif
}
void TransferListSortModel::disableTagFilter()
{
#if QT_VERSION >= QT_VERSION_CHECK(6, 10, 0)
beginFilterChange();
m_filter.setTag(TorrentFilter::AnyTag);
endFilterChange(Direction::Rows);
#else
if (m_filter.setTag(TorrentFilter::AnyTag))
invalidateRowsFilter();
#endif
}
void TransferListSortModel::setTrackerFilter(const QSet<BitTorrent::TorrentID> &torrentIDs)
{
#if QT_VERSION >= QT_VERSION_CHECK(6, 10, 0)
beginFilterChange();
m_filter.setTorrentIDSet(torrentIDs);
endFilterChange(Direction::Rows);
#else
if (m_filter.setTorrentIDSet(torrentIDs))
invalidateRowsFilter();
#endif
}
void TransferListSortModel::disableTrackerFilter()
{
#if QT_VERSION >= QT_VERSION_CHECK(6, 10, 0)
beginFilterChange();
m_filter.setTorrentIDSet(TorrentFilter::AnyID);
endFilterChange(Direction::Rows);
#else
if (m_filter.setTorrentIDSet(TorrentFilter::AnyID))
invalidateRowsFilter();
#endif
}
int TransferListSortModel::compare(const QModelIndex &left, const QModelIndex &right) const