Skip to content

Commit e15e8cb

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 e15e8cb

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed

src/qt/transactionfilterproxy.cpp

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,32 +52,78 @@ bool TransactionFilterProxy::filterAcceptsRow(int sourceRow, const QModelIndex &
5252

5353
void TransactionFilterProxy::setDateRange(const std::optional<QDateTime>& from, const std::optional<QDateTime>& to)
5454
{
55+
#if QT_VERSION >= QT_VERSION_CHECK(6, 10, 0)
56+
beginFilterChange();
57+
#endif
58+
5559
dateFrom = from;
5660
dateTo = to;
61+
62+
#if QT_VERSION >= QT_VERSION_CHECK(6, 10, 0)
63+
endFilterChange(QSortFilterProxyModel::Direction::Rows);
64+
#else
5765
invalidateFilter();
66+
#endif
5867
}
5968

6069
void TransactionFilterProxy::setSearchString(const QString &search_string)
6170
{
6271
if (m_search_string == search_string) return;
72+
73+
#if QT_VERSION >= QT_VERSION_CHECK(6, 10, 0)
74+
beginFilterChange();
75+
#endif
76+
6377
m_search_string = search_string;
78+
79+
#if QT_VERSION >= QT_VERSION_CHECK(6, 10, 0)
80+
endFilterChange(QSortFilterProxyModel::Direction::Rows);
81+
#else
6482
invalidateFilter();
83+
#endif
6584
}
6685

6786
void TransactionFilterProxy::setTypeFilter(quint32 modes)
6887
{
88+
#if QT_VERSION >= QT_VERSION_CHECK(6, 10, 0)
89+
beginFilterChange();
90+
#endif
91+
6992
this->typeFilter = modes;
93+
94+
#if QT_VERSION >= QT_VERSION_CHECK(6, 10, 0)
95+
endFilterChange(QSortFilterProxyModel::Direction::Rows);
96+
#else
7097
invalidateFilter();
98+
#endif
7199
}
72100

73101
void TransactionFilterProxy::setMinAmount(const CAmount& minimum)
74102
{
103+
#if QT_VERSION >= QT_VERSION_CHECK(6, 10, 0)
104+
beginFilterChange();
105+
#endif
106+
75107
this->minAmount = minimum;
108+
109+
#if QT_VERSION >= QT_VERSION_CHECK(6, 10, 0)
110+
endFilterChange(QSortFilterProxyModel::Direction::Rows);
111+
#else
76112
invalidateFilter();
113+
#endif
77114
}
78115

79116
void TransactionFilterProxy::setShowInactive(bool _showInactive)
80117
{
118+
#if QT_VERSION >= QT_VERSION_CHECK(6, 10, 0)
119+
beginFilterChange();
120+
#endif
121+
81122
this->showInactive = _showInactive;
123+
124+
#if QT_VERSION >= QT_VERSION_CHECK(6, 10, 0)
125+
endFilterChange(QSortFilterProxyModel::Direction::Rows);
126+
#else
82127
invalidateFilter();
128+
#endif
83129
}

0 commit comments

Comments
 (0)