From 78c3c000f02596407d386bf623e94c75580a47ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Blin?= <sebastien.blin@savoirfairelinux.com> Date: Fri, 6 Jul 2018 13:44:13 -0400 Subject: [PATCH] temporaryItem: only show temporary item for current filter Change-Id: I20e3ffd7da7c4fb9e5c5b424fd2e5cd867c438d6 Gitlab: #367 Reviewed-by: Andreas Traczyk <andreas.traczyk@savoirfairelinux.com> --- src/contactmodel.cpp | 1 + src/conversationmodel.cpp | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/contactmodel.cpp b/src/contactmodel.cpp index 79528b45..83653f85 100644 --- a/src/contactmodel.cpp +++ b/src/contactmodel.cpp @@ -689,6 +689,7 @@ ContactModelPimpl::slotRegisteredNameFound(const std::string& accountId, } { std::lock_guard<std::mutex> lk(contactsMtx_); + temporaryContact.registeredName = registeredName; temporaryContact.profileInfo.alias = "Not found"; } emit linked.modelUpdated(uri); diff --git a/src/conversationmodel.cpp b/src/conversationmodel.cpp index cb506ba2..d6296c6f 100644 --- a/src/conversationmodel.cpp +++ b/src/conversationmodel.cpp @@ -301,13 +301,16 @@ ConversationModel::allFilteredConversations() const || contactInfo.registeredName == pimpl_->filter; } + auto regexFilter = std::regex(pimpl_->filter, std::regex_constants::icase); /* Check type */ if (pimpl_->typeFilter != profile::Type::PENDING) { // Remove pending contacts and get the temporary item if filter is not empty if (contactInfo.profileInfo.type == profile::Type::PENDING) return false; if (contactInfo.profileInfo.type == profile::Type::TEMPORARY) - return not contactInfo.profileInfo.alias.empty() || not contactInfo.profileInfo.uri.empty(); + return (!contactInfo.profileInfo.uri.empty() + && std::regex_search(contactInfo.profileInfo.uri, regexFilter)) + || std::regex_search(contactInfo.registeredName, regexFilter); } else { // We only want pending requests matching with the filter if (contactInfo.profileInfo.type != profile::Type::PENDING) @@ -316,7 +319,6 @@ ConversationModel::allFilteredConversations() const // Otherwise perform usual regex search try { - auto regexFilter = std::regex(pimpl_->filter, std::regex_constants::icase); bool result = std::regex_search(contactInfo.profileInfo.uri, regexFilter) | std::regex_search(contactInfo.profileInfo.alias, regexFilter) | std::regex_search(contactInfo.registeredName, regexFilter); -- GitLab