Skip to content

Commit 8d0fa5d

Browse files
committed
fix: replace deprecated invalidateFilter in Qt6.10
1 parent c4be0bd commit 8d0fa5d

2 files changed

Lines changed: 54 additions & 0 deletions

File tree

qml/models/activityfilterproxymodel.cpp

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,17 @@ void ActivityFilterProxyModel::setSearchText(const QString& search_text)
7979
{
8080
if (m_search_text == search_text) return;
8181

82+
#if QT_VERSION >= QT_VERSION_CHECK(6, 10, 0)
83+
beginFilterChange();
84+
#endif
85+
8286
m_search_text = search_text;
87+
88+
#if QT_VERSION >= QT_VERSION_CHECK(6, 10, 0)
89+
endFilterChange(QSortFilterProxyModel::Direction::Rows);
90+
#else
8391
invalidateFilter();
92+
#endif
8493
Q_EMIT searchTextChanged();
8594
Q_EMIT countChanged();
8695
}
@@ -94,8 +103,17 @@ void ActivityFilterProxyModel::setDateFilter(DateFilter date_filter)
94103
{
95104
if (m_date_filter == date_filter) return;
96105

106+
#if QT_VERSION >= QT_VERSION_CHECK(6, 10, 0)
107+
beginFilterChange();
108+
#endif
109+
97110
m_date_filter = date_filter;
111+
112+
#if QT_VERSION >= QT_VERSION_CHECK(6, 10, 0)
113+
endFilterChange(QSortFilterProxyModel::Direction::Rows);
114+
#else
98115
invalidateFilter();
116+
#endif
99117
Q_EMIT dateFilterChanged();
100118
Q_EMIT countChanged();
101119
}
@@ -109,8 +127,17 @@ void ActivityFilterProxyModel::setTypeFilter(TypeFilter type_filter)
109127
{
110128
if (m_type_filter == type_filter) return;
111129

130+
#if QT_VERSION >= QT_VERSION_CHECK(6, 10, 0)
131+
beginFilterChange();
132+
#endif
133+
112134
m_type_filter = type_filter;
135+
136+
#if QT_VERSION >= QT_VERSION_CHECK(6, 10, 0)
137+
endFilterChange(QSortFilterProxyModel::Direction::Rows);
138+
#else
113139
invalidateFilter();
140+
#endif
114141
Q_EMIT typeFilterChanged();
115142
Q_EMIT countChanged();
116143
}

test/qml/qml_tests_main.cpp

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2919,8 +2919,17 @@ class MockActivityFilterProxyModel : public QSortFilterProxyModel
29192919
void setSearchText(const QString& search_text)
29202920
{
29212921
if (m_search_text == search_text) return;
2922+
2923+
#if QT_VERSION >= QT_VERSION_CHECK(6, 10, 0)
2924+
beginFilterChange();
2925+
#endif
29222926
m_search_text = search_text;
2927+
2928+
#if QT_VERSION >= QT_VERSION_CHECK(6, 10, 0)
2929+
endFilterChange(QSortFilterProxyModel::Direction::Rows);
2930+
#else
29232931
invalidateFilter();
2932+
#endif
29242933
Q_EMIT searchTextChanged();
29252934
Q_EMIT countChanged();
29262935
}
@@ -2929,8 +2938,17 @@ class MockActivityFilterProxyModel : public QSortFilterProxyModel
29292938
void setDateFilter(DateFilter date_filter)
29302939
{
29312940
if (m_date_filter == date_filter) return;
2941+
2942+
#if QT_VERSION >= QT_VERSION_CHECK(6, 10, 0)
2943+
beginFilterChange();
2944+
#endif
29322945
m_date_filter = date_filter;
2946+
2947+
#if QT_VERSION >= QT_VERSION_CHECK(6, 10, 0)
2948+
endFilterChange(QSortFilterProxyModel::Direction::Rows);
2949+
#else
29332950
invalidateFilter();
2951+
#endif
29342952
Q_EMIT dateFilterChanged();
29352953
Q_EMIT countChanged();
29362954
}
@@ -2939,8 +2957,17 @@ class MockActivityFilterProxyModel : public QSortFilterProxyModel
29392957
void setTypeFilter(TypeFilter type_filter)
29402958
{
29412959
if (m_type_filter == type_filter) return;
2960+
2961+
#if QT_VERSION >= QT_VERSION_CHECK(6, 10, 0)
2962+
beginFilterChange();
2963+
#endif
29422964
m_type_filter = type_filter;
2965+
2966+
#if QT_VERSION >= QT_VERSION_CHECK(6, 10, 0)
2967+
endFilterChange(QSortFilterProxyModel::Direction::Rows);
2968+
#else
29432969
invalidateFilter();
2970+
#endif
29442971
Q_EMIT typeFilterChanged();
29452972
Q_EMIT countChanged();
29462973
}

0 commit comments

Comments
 (0)