From 7dd333947711b9ebb54460066a25b07d155fa012 Mon Sep 17 00:00:00 2001 From: Nicolas Werner Date: Sat, 6 May 2023 19:30:29 +0200 Subject: Sort rooms in completer by 'activity' and make tombstoned rooms italic --- src/CompletionProxyModel.h | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'src/CompletionProxyModel.h') diff --git a/src/CompletionProxyModel.h b/src/CompletionProxyModel.h index e0f00788..a72b1d0a 100644 --- a/src/CompletionProxyModel.h +++ b/src/CompletionProxyModel.h @@ -8,6 +8,8 @@ #include +#include + enum class ElementRank { first, @@ -17,7 +19,7 @@ enum class ElementRank template struct trie { - std::vector values; + std::vector> values; std::map next; template @@ -29,9 +31,11 @@ struct trie } if constexpr (r == ElementRank::first) { - t->values.insert(t->values.begin(), v); + auto it = + std::ranges::upper_bound(t->values, r, {}, &std::pair::first); + t->values.emplace(it, r, v); } else if constexpr (r == ElementRank::second) { - t->values.push_back(v); + t->values.emplace_back(r, v); } } @@ -45,7 +49,7 @@ struct trie if (ret.size() >= limit) return ret; else - ret.push_back(v); + ret.push_back(v.second); } for (const auto &[k, t] : next) { -- cgit 1.5.1