From 4874d817bb05733d0ab8b26d1bff4e54b99b85d9 Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Tue, 31 Dec 2024 20:30:31 +0100 Subject: [PATCH] Use libQuotient 0.9.2 facilities ...instead of having them in Quaternion. --- client/logindialog.h | 14 +------------- client/models/orderbytag.cpp | 19 +++++-------------- client/models/userlistmodel.cpp | 9 +++------ 3 files changed, 9 insertions(+), 33 deletions(-) diff --git a/client/logindialog.h b/client/logindialog.h index a0aa4f6f..bb0a405d 100644 --- a/client/logindialog.h +++ b/client/logindialog.h @@ -20,18 +20,6 @@ class AccountSettings; class AccountRegistry; } -#if QT_VERSION_MAJOR > 5 -using DeleteLater = QScopedPointerDeleteLater; -#else -struct DeleteLater { - void operator()(Quotient::Connection* ptr) - { - if (ptr) - ptr->deleteLater(); - } -}; -#endif - static const auto E2eeEnabledSetting = QStringLiteral("enable_e2ee"); class LoginDialog : public Dialog { @@ -66,5 +54,5 @@ private slots: QLineEdit* serverEdit; QCheckBox* saveTokenCheck; - std::unique_ptr m_connection; + Quotient::QObjectHolder m_connection; }; diff --git a/client/models/orderbytag.cpp b/client/models/orderbytag.cpp index baf0ab92..97f05ad8 100644 --- a/client/models/orderbytag.cpp +++ b/client/models/orderbytag.cpp @@ -8,6 +8,7 @@ #include "roomlistmodel.h" +#include #include static const auto Invite = RoomGroup::SystemPrefix + "invite"; @@ -60,26 +61,16 @@ QString captionToTag(const QString& caption) // clang-format on } -template -inline auto findIndex(const QList& list, const VT& value) -{ - // Using std::find() instead of indexOf() so that not found keys were - // naturally sorted after found ones (index == list.end() - list.begin() - // is more than any index in the list, while index == -1 is less). - return std::find(list.begin(), list.end(), value) - list.begin(); -} - auto findIndexWithWildcards(const QStringList& list, const QString& value) { if (list.empty() || value.isEmpty()) return list.size(); - auto i = findIndex(list, value); + auto i = Quotient::findIndex(list, value); // Try namespace groupings (".*" in the list), from right to left - for (int dotPos = 0; - i == list.size() && (dotPos = value.lastIndexOf('.', --dotPos)) != -1;) - { - i = findIndex(list, value.left(dotPos + 1) + '*'); + for (QStringList::size_type dotPos = 0; + i == list.size() && (dotPos = value.lastIndexOf('.', --dotPos)) != -1;) { + i = Quotient::findIndex(list, value.left(dotPos + 1) + '*'); } return i; } diff --git a/client/models/userlistmodel.cpp b/client/models/userlistmodel.cpp index abfffbf3..fa55492b 100644 --- a/client/models/userlistmodel.cpp +++ b/client/models/userlistmodel.cpp @@ -19,11 +19,10 @@ #include #include +#include #include #include -#include - UserListModel::UserListModel(QAbstractItemView* parent) : QAbstractListModel(parent), m_currentRoom(nullptr) { } @@ -162,11 +161,9 @@ void UserListModel::filter(const QString& filterString) QElapsedTimer et; et.start(); beginResetModel(); - // TODO: use std::ranges::to() once it's available from all stdlibs Quotient builds with - auto filteredMembersView = + auto filteredMembers = Quotient::rangeTo( std::views::filter(m_currentRoom->joinedMembers(), - Quotient::memberMatcher(filterString, Qt::CaseInsensitive)); - QList filteredMembers(filteredMembersView.begin(), filteredMembersView.end()); + Quotient::memberMatcher(filterString, Qt::CaseInsensitive))); std::ranges::sort(filteredMembers, Quotient::MemberSorter()); const auto sortedIds = std::views::transform(filteredMembers, &RoomMember::id); #if QT_VERSION >= QT_VERSION_CHECK(6, 6, 0)