Skip to content

Commit 1a11cac

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 1a11cac

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

src/qt/transactionfilterproxy.cpp

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,32 +52,77 @@ 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
{
71+
#if QT_VERSION >= QT_VERSION_CHECK(6, 10, 0)
72+
beginFilterChange();
73+
#endif
74+
6275
if (m_search_string == search_string) return;
6376
m_search_string = search_string;
77+
78+
#if QT_VERSION >= QT_VERSION_CHECK(6, 10, 0)
79+
endFilterChange(QSortFilterProxyModel::Direction::Rows);
80+
#else
6481
invalidateFilter();
82+
#endif
6583
}
6684

6785
void TransactionFilterProxy::setTypeFilter(quint32 modes)
6886
{
87+
#if QT_VERSION >= QT_VERSION_CHECK(6, 10, 0)
88+
beginFilterChange();
89+
#endif
90+
6991
this->typeFilter = modes;
92+
93+
#if QT_VERSION >= QT_VERSION_CHECK(6, 10, 0)
94+
endFilterChange(QSortFilterProxyModel::Direction::Rows);
95+
#else
7096
invalidateFilter();
97+
#endif
7198
}
7299

73100
void TransactionFilterProxy::setMinAmount(const CAmount& minimum)
74101
{
102+
#if QT_VERSION >= QT_VERSION_CHECK(6, 10, 0)
103+
beginFilterChange();
104+
#endif
105+
75106
this->minAmount = minimum;
107+
108+
#if QT_VERSION >= QT_VERSION_CHECK(6, 10, 0)
109+
endFilterChange(QSortFilterProxyModel::Direction::Rows);
110+
#else
76111
invalidateFilter();
112+
#endif
77113
}
78114

79115
void TransactionFilterProxy::setShowInactive(bool _showInactive)
80116
{
117+
#if QT_VERSION >= QT_VERSION_CHECK(6, 10, 0)
118+
beginFilterChange();
119+
#endif
120+
81121
this->showInactive = _showInactive;
122+
123+
#if QT_VERSION >= QT_VERSION_CHECK(6, 10, 0)
124+
endFilterChange(QSortFilterProxyModel::Direction::Rows);
125+
#else
82126
invalidateFilter();
127+
#endif
83128
}

0 commit comments

Comments
 (0)