Skip to content

Commit 9a045b6

Browse files
committed
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.
1 parent b510893 commit 9a045b6

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed

src/qt/transactionfilterproxy.cpp

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
#include <qt/transactiontablemodel.h>
88
#include <qt/transactionrecord.h>
99

10+
#include <QtVersionChecks>
11+
1012
#include <algorithm>
1113
#include <cstdlib>
1214
#include <optional>
@@ -52,32 +54,77 @@ bool TransactionFilterProxy::filterAcceptsRow(int sourceRow, const QModelIndex &
5254

5355
void TransactionFilterProxy::setDateRange(const std::optional<QDateTime>& from, const std::optional<QDateTime>& to)
5456
{
57+
#if QT_VERSION >= QT_VERSION_CHECK(6, 10, 0)
58+
beginFilterChange();
59+
#endif
60+
5561
dateFrom = from;
5662
dateTo = to;
63+
64+
#if QT_VERSION >= QT_VERSION_CHECK(6, 10, 0)
65+
endFilterChange(QSortFilterProxyModel::Direction::Rows);
66+
#else
5767
invalidateFilter();
68+
#endif
5869
}
5970

6071
void TransactionFilterProxy::setSearchString(const QString &search_string)
6172
{
73+
#if QT_VERSION >= QT_VERSION_CHECK(6, 10, 0)
74+
beginFilterChange();
75+
#endif
76+
6277
if (m_search_string == search_string) return;
6378
m_search_string = search_string;
79+
80+
#if QT_VERSION >= QT_VERSION_CHECK(6, 10, 0)
81+
endFilterChange(QSortFilterProxyModel::Direction::Rows);
82+
#else
6483
invalidateFilter();
84+
#endif
6585
}
6686

6787
void TransactionFilterProxy::setTypeFilter(quint32 modes)
6888
{
89+
#if QT_VERSION >= QT_VERSION_CHECK(6, 10, 0)
90+
beginFilterChange();
91+
#endif
92+
6993
this->typeFilter = modes;
94+
95+
#if QT_VERSION >= QT_VERSION_CHECK(6, 10, 0)
96+
endFilterChange(QSortFilterProxyModel::Direction::Rows);
97+
#else
7098
invalidateFilter();
99+
#endif
71100
}
72101

73102
void TransactionFilterProxy::setMinAmount(const CAmount& minimum)
74103
{
104+
#if QT_VERSION >= QT_VERSION_CHECK(6, 10, 0)
105+
beginFilterChange();
106+
#endif
107+
75108
this->minAmount = minimum;
109+
110+
#if QT_VERSION >= QT_VERSION_CHECK(6, 10, 0)
111+
endFilterChange(QSortFilterProxyModel::Direction::Rows);
112+
#else
76113
invalidateFilter();
114+
#endif
77115
}
78116

79117
void TransactionFilterProxy::setShowInactive(bool _showInactive)
80118
{
119+
#if QT_VERSION >= QT_VERSION_CHECK(6, 10, 0)
120+
beginFilterChange();
121+
#endif
122+
81123
this->showInactive = _showInactive;
124+
125+
#if QT_VERSION >= QT_VERSION_CHECK(6, 10, 0)
126+
endFilterChange(QSortFilterProxyModel::Direction::Rows);
127+
#else
82128
invalidateFilter();
129+
#endif
83130
}

0 commit comments

Comments
 (0)