[network/kaidan] /: Replace deprecated QSortFilterProxyModel::invalidateFilter()

Melvin Keskin <[email protected]>
Newsgroups gmane.comp.kde.cvs
Message-ID <[email protected]>
Git commit 2be50ac61e6753fba554f6902c41eec2ff36426a by Melvin Keskin, on behalf of Linus Jahn.
Committed on 25/07/2026 at 09:14.
Pushed by melvo into branch 'master'.

Replace deprecated QSortFilterProxyModel::invalidateFilter()

invalidateFilter() is deprecated since Qt 6.10.
It is replaced with beginFilterChange()/endFilterChange(), which are
available since Qt 6.10, in all proxy models.

This needs Qt 6.10.

Co-Authored-By: Claude Opus 4.8 <[email protected]>

M  +2    -2    CMakeLists.txt
M  +1    -1    README.md
M  +13   -5    src/EmojiModel.cpp
M  +8    -4    src/FileProxyModel.cpp
M  +4    -2    src/GroupChatInviteeFilterModel.cpp
M  +4    -2    src/GroupChatUserKeyAuthenticationFilterModel.cpp
M  +3    -2    src/HostCompletionProxyModel.cpp
M  +3    -1    src/PublicGroupChatProxyModel.cpp

https://invent.kde.org/network/kaidan/-/commit/2be50ac61e6753fba554f6902c41eec2ff36426a

diff --git a/CMakeLists.txt b/CMakeLists.txt
index cea34a4d7..ded97cdd5 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -4,7 +4,7 @@
 
 cmake_minimum_required(VERSION 3.16)
 set(CMAKE_CXX_STANDARD 23)
-set(QT_MIN_VERSION "6.9.0")
+set(QT_MIN_VERSION "6.10.0")
 set(KF_MIN_VERSION "6.11.0")
 
 if(POLICY CMP0071)
@@ -53,7 +53,7 @@ set(AUTOMOC_MOC_OPTIONS -Muri=${APPLICATION_ID})
 # Find packages
 find_package(Qt6 ${QT_MIN_VERSION} REQUIRED NO_MODULE COMPONENTS Core Concurrent Qml Quick Svg Sql QuickControls2 Xml Multimedia Positioning Location)
 
-if(Qt6Gui_VERSION VERSION_GREATER_EQUAL "6.10.0" AND NOT WIN32 AND NOT APPLE)
+if(NOT WIN32 AND NOT APPLE)
     find_package(Qt6GuiPrivate ${QT_MIN_VERSION} REQUIRED NO_MODULE)
 endif()
 
diff --git a/README.md b/README.md
index 4bf90cf7d..d1aea0c65 100644
--- a/README.md
+++ b/README.md
@@ -58,7 +58,7 @@ The following dependencies are needed by Kaidan:
 * [KDSingleApplication][kdsingleapplication]
 * [KQuickImageEditor][kquickimageeditor] >= 0.5.0
 * [Kirigami Addons][kirigami-addons] >= 1.8.0
-* [Qt][qt-build-sources] >= 6.9.0 - Concurrent | Core | Multimedia | Location | Positioning | Qml | Qt6GuiPrivate (since Qt 6.10.0) | Quick | QuickControls2 | Sql | Svg | Xml
+* [Qt][qt-build-sources] >= 6.10.0 - Concurrent | Core | Multimedia | Location | Positioning | Qml | Qt6GuiPrivate | Quick | QuickControls2 | Sql | Svg | Xml
 * [QtKeychain][qtkeychain] >= 0.15
 * [QXmpp][qxmpp] (with OMEMO, GStreamer) >= 1.17.0
 
diff --git a/src/EmojiModel.cpp b/src/EmojiModel.cpp
index 65fd7dff0..6bdc30191 100644
--- a/src/EmojiModel.cpp
+++ b/src/EmojiModel.cpp
@@ -1517,10 +1517,11 @@ Emoji::Group EmojiProxyModel::group() const
 void EmojiProxyModel::setGroup(Emoji::Group group)
 {
     if (m_group != group) {
+        beginFilterChange();
         m_group = group;
-        Q_EMIT groupChanged();
+        endFilterChange(QSortFilterProxyModel::Direction::Rows);
 
-        invalidateFilter();
+        Q_EMIT groupChanged();
     }
 }
 
@@ -1534,13 +1535,20 @@ void EmojiProxyModel::addFavoriteEmoji(int proxyRow)
     const Emoji emoji = index(proxyRow, 0).data(static_cast<int>(EmojiModel::Roles::Emoji)).value<Emoji>();
 
     if (!m_favoriteEmojis.contains(emoji.unicode())) {
+        // The favorites only affect the current filtering while the favorites group is shown.
+        const bool filterChanges = m_group == Emoji::Group::Favorites;
+
+        if (filterChanges) {
+            beginFilterChange();
+        }
+
         m_favoriteEmojis << emoji.unicode();
-        Q_EMIT hasFavoriteEmojisChanged();
 
-        if (m_group == Emoji::Group::Favorites) {
-            invalidateFilter();
+        if (filterChanges) {
+            endFilterChange(QSortFilterProxyModel::Direction::Rows);
         }
 
+        Q_EMIT hasFavoriteEmojisChanged();
         Settings::instance()->setFavoriteEmojis(m_favoriteEmojis);
     }
 }
diff --git a/src/FileProxyModel.cpp b/src/FileProxyModel.cpp
index 694cbe3fa..9da2007b0 100644
--- a/src/FileProxyModel.cpp
+++ b/src/FileProxyModel.cpp
@@ -93,9 +93,10 @@ FileProxyModel::Mode FileProxyModel::mode() const
 void FileProxyModel::setMode(Mode mode)
 {
     if (m_mode != mode) {
+        beginFilterChange();
         m_mode = mode;
         m_checkedIds.clear();
-        invalidateFilter();
+        endFilterChange(QSortFilterProxyModel::Direction::Rows);
 
         Q_EMIT modeChanged();
         Q_EMIT rowCountChanged();
@@ -111,9 +112,10 @@ bool FileProxyModel::locallyAvailableOnly() const
 void FileProxyModel::setLocallyAvailableOnly(bool locallyAvailableOnly)
 {
     if (m_locallyAvailableOnly != locallyAvailableOnly) {
+        beginFilterChange();
         m_locallyAvailableOnly = locallyAvailableOnly;
         m_checkedIds.clear();
-        invalidateFilter();
+        endFilterChange(QSortFilterProxyModel::Direction::Rows);
 
         Q_EMIT locallyAvailableOnlyChanged();
         Q_EMIT rowCountChanged();
@@ -129,9 +131,10 @@ bool FileProxyModel::attachmentAudioOnly() const
 void FileProxyModel::setAttachmentAudioOnly(bool attachmentAudioOnly)
 {
     if (m_attachmentAudioOnly != attachmentAudioOnly) {
+        beginFilterChange();
         m_attachmentAudioOnly = attachmentAudioOnly;
         m_checkedIds.clear();
-        invalidateFilter();
+        endFilterChange(QSortFilterProxyModel::Direction::Rows);
 
         Q_EMIT attachmentAudioOnlyChanged();
         Q_EMIT rowCountChanged();
@@ -283,8 +286,9 @@ bool FileProxyModel::filterAcceptsOther(const File &file) const
 
 void FileProxyModel::_filesDeleted(const QStringList &files, const QStringList &errors)
 {
+    beginFilterChange();
     m_checkedIds.clear();
-    invalidateFilter();
+    endFilterChange(QSortFilterProxyModel::Direction::Rows);
 
     Q_EMIT rowCountChanged();
     Q_EMIT checkedCountChanged();
diff --git a/src/GroupChatInviteeFilterModel.cpp b/src/GroupChatInviteeFilterModel.cpp
index b0b0b4bab..395bc334d 100644
--- a/src/GroupChatInviteeFilterModel.cpp
+++ b/src/GroupChatInviteeFilterModel.cpp
@@ -28,16 +28,18 @@ bool GroupChatInviteeFilterModel::filterAcceptsRow(int sourceRow, const QModelIn
 void GroupChatInviteeFilterModel::setAccountJid(const QString &accountJid)
 {
     if (m_accountJid != accountJid) {
+        beginFilterChange();
         m_accountJid = accountJid;
-        invalidateFilter();
+        endFilterChange(QSortFilterProxyModel::Direction::Rows);
     }
 }
 
 void GroupChatInviteeFilterModel::setGroupChatUserJids(const QList<QString> &groupChatUserJids)
 {
     if (m_groupChatUserJids != groupChatUserJids) {
+        beginFilterChange();
         m_groupChatUserJids = groupChatUserJids;
-        invalidateFilter();
+        endFilterChange(QSortFilterProxyModel::Direction::Rows);
     }
 }
 
diff --git a/src/GroupChatUserKeyAuthenticationFilterModel.cpp b/src/GroupChatUserKeyAuthenticationFilterModel.cpp
index c9cae0c8a..3faeaab85 100644
--- a/src/GroupChatUserKeyAuthenticationFilterModel.cpp
+++ b/src/GroupChatUserKeyAuthenticationFilterModel.cpp
@@ -69,8 +69,9 @@ void GroupChatUserKeyAuthenticationFilterModel::updateJids()
     const auto userJids = model->userJids();
 
     if (userJids.isEmpty()) {
+        beginFilterChange();
         m_jids.clear();
-        invalidateFilter();
+        endFilterChange(QSortFilterProxyModel::Direction::Rows);
         return;
     }
 
@@ -84,8 +85,9 @@ void GroupChatUserKeyAuthenticationFilterModel::updateJids()
         });
 
         if (m_jids != jids) {
+            beginFilterChange();
             m_jids = jids;
-            invalidateFilter();
+            endFilterChange(QSortFilterProxyModel::Direction::Rows);
         }
     });
 }
diff --git a/src/HostCompletionProxyModel.cpp b/src/HostCompletionProxyModel.cpp
index f40d35ac4..4db88f4ab 100644
--- a/src/HostCompletionProxyModel.cpp
+++ b/src/HostCompletionProxyModel.cpp
@@ -8,8 +8,6 @@ HostCompletionProxyModel::HostCompletionProxyModel(QObject *parent)
     : QSortFilterProxyModel{parent}
 {
     setSortCaseSensitivity(Qt::CaseInsensitive);
-
-    connect(this, &HostCompletionProxyModel::userInputChanged, this, &HostCompletionProxyModel::invalidateFilter);
 }
 
 QVariant HostCompletionProxyModel::data(const QModelIndex &index, int role) const
@@ -32,7 +30,10 @@ QString HostCompletionProxyModel::userInput() const
 void HostCompletionProxyModel::setUserInput(const QString &userInput)
 {
     if (m_userInput != userInput) {
+        beginFilterChange();
         m_userInput = userInput;
+        endFilterChange(QSortFilterProxyModel::Direction::Rows);
+
         Q_EMIT userInputChanged(userInput);
     }
 }
diff --git a/src/PublicGroupChatProxyModel.cpp b/src/PublicGroupChatProxyModel.cpp
index b9ded99d0..051799f96 100644
--- a/src/PublicGroupChatProxyModel.cpp
+++ b/src/PublicGroupChatProxyModel.cpp
@@ -12,7 +12,6 @@ PublicGroupChatProxyModel::PublicGroupChatProxyModel(QObject *parent)
 {
     sort(0, Qt::AscendingOrder);
 
-    connect(this, &PublicGroupChatProxyModel::languageFilterChanged, this, &PublicGroupChatProxyModel::invalidateFilter);
     connect(this, &PublicGroupChatProxyModel::rowsInserted, this, &PublicGroupChatProxyModel::countChanged);
     connect(this, &PublicGroupChatProxyModel::rowsRemoved, this, &PublicGroupChatProxyModel::countChanged);
     connect(this, &PublicGroupChatProxyModel::layoutChanged, this, &PublicGroupChatProxyModel::countChanged);
@@ -38,7 +37,10 @@ const QString &PublicGroupChatProxyModel::languageFilter() const
 void PublicGroupChatProxyModel::setLanguageFilter(const QString &language)
 {
     if (m_languageFilter != language) {
+        beginFilterChange();
         m_languageFilter = language;
+        endFilterChange(QSortFilterProxyModel::Direction::Rows);
+
         Q_EMIT languageFilterChanged(m_languageFilter);
     }
 }
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.