qt: Modernize custom filtering
In `QSortFilterProxyModel`, `invalidateFilter()` is scheduled for deprecation in Qt 6.13. `beginFilterChange()` was introduced in Qt 6.9. `endFilterChange()` was introduced in Qt 6.10.
This commit is contained in:
1 file changed
+46
@@ -52,32 +52,78 @@ bool TransactionFilterProxy::filterAcceptsRow(int sourceRow, const QModelIndex &
|
|||||||
|
|
||||||
void TransactionFilterProxy::setDateRange(const std::optional<QDateTime>& from, const std::optional<QDateTime>& to)
|
void TransactionFilterProxy::setDateRange(const std::optional<QDateTime>& from, const std::optional<QDateTime>& to)
|
||||||
{
|
{
|
||||||
|
#if QT_VERSION >= QT_VERSION_CHECK(6, 10, 0)
|
||||||
|
beginFilterChange();
|
||||||
|
#endif
|
||||||
|
|
||||||
dateFrom = from;
|
dateFrom = from;
|
||||||
dateTo = to;
|
dateTo = to;
|
||||||
|
|
||||||
|
#if QT_VERSION >= QT_VERSION_CHECK(6, 10, 0)
|
||||||
|
endFilterChange(QSortFilterProxyModel::Direction::Rows);
|
||||||
|
#else
|
||||||
invalidateFilter();
|
invalidateFilter();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void TransactionFilterProxy::setSearchString(const QString &search_string)
|
void TransactionFilterProxy::setSearchString(const QString &search_string)
|
||||||
{
|
{
|
||||||
if (m_search_string == search_string) return;
|
if (m_search_string == search_string) return;
|
||||||
|
|
||||||
|
#if QT_VERSION >= QT_VERSION_CHECK(6, 10, 0)
|
||||||
|
beginFilterChange();
|
||||||
|
#endif
|
||||||
|
|
||||||
m_search_string = search_string;
|
m_search_string = search_string;
|
||||||
|
|
||||||
|
#if QT_VERSION >= QT_VERSION_CHECK(6, 10, 0)
|
||||||
|
endFilterChange(QSortFilterProxyModel::Direction::Rows);
|
||||||
|
#else
|
||||||
invalidateFilter();
|
invalidateFilter();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void TransactionFilterProxy::setTypeFilter(quint32 modes)
|
void TransactionFilterProxy::setTypeFilter(quint32 modes)
|
||||||
{
|
{
|
||||||
|
#if QT_VERSION >= QT_VERSION_CHECK(6, 10, 0)
|
||||||
|
beginFilterChange();
|
||||||
|
#endif
|
||||||
|
|
||||||
this->typeFilter = modes;
|
this->typeFilter = modes;
|
||||||
|
|
||||||
|
#if QT_VERSION >= QT_VERSION_CHECK(6, 10, 0)
|
||||||
|
endFilterChange(QSortFilterProxyModel::Direction::Rows);
|
||||||
|
#else
|
||||||
invalidateFilter();
|
invalidateFilter();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void TransactionFilterProxy::setMinAmount(const CAmount& minimum)
|
void TransactionFilterProxy::setMinAmount(const CAmount& minimum)
|
||||||
{
|
{
|
||||||
|
#if QT_VERSION >= QT_VERSION_CHECK(6, 10, 0)
|
||||||
|
beginFilterChange();
|
||||||
|
#endif
|
||||||
|
|
||||||
this->minAmount = minimum;
|
this->minAmount = minimum;
|
||||||
|
|
||||||
|
#if QT_VERSION >= QT_VERSION_CHECK(6, 10, 0)
|
||||||
|
endFilterChange(QSortFilterProxyModel::Direction::Rows);
|
||||||
|
#else
|
||||||
invalidateFilter();
|
invalidateFilter();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void TransactionFilterProxy::setShowInactive(bool _showInactive)
|
void TransactionFilterProxy::setShowInactive(bool _showInactive)
|
||||||
{
|
{
|
||||||
|
#if QT_VERSION >= QT_VERSION_CHECK(6, 10, 0)
|
||||||
|
beginFilterChange();
|
||||||
|
#endif
|
||||||
|
|
||||||
this->showInactive = _showInactive;
|
this->showInactive = _showInactive;
|
||||||
|
|
||||||
|
#if QT_VERSION >= QT_VERSION_CHECK(6, 10, 0)
|
||||||
|
endFilterChange(QSortFilterProxyModel::Direction::Rows);
|
||||||
|
#else
|
||||||
invalidateFilter();
|
invalidateFilter();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user