From 1e8b9167ef1c07b0f9c6d59a5de60740dad127d2 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Thorbj=C3=B8rn=20Lindeijer?= <thorbjorn.lindeijer@nokia.com>
Date: Tue, 9 Dec 2008 17:16:26 +0100
Subject: [PATCH] Sort C++ QuickOpen with less than 1000 results

In this case it's fast enough and sorting the list makes it easier to
find what you're looking for.

Though because of the substring matching, what you're looking for might
still be way down the list.

Reviewed-by: con
---
 src/plugins/cpptools/cppquickopenfilter.cpp | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/src/plugins/cpptools/cppquickopenfilter.cpp b/src/plugins/cpptools/cppquickopenfilter.cpp
index a1f1a9b3713..ac69c9cc6df 100644
--- a/src/plugins/cpptools/cppquickopenfilter.cpp
+++ b/src/plugins/cpptools/cppquickopenfilter.cpp
@@ -75,6 +75,12 @@ void CppQuickOpenFilter::refresh(QFutureInterface<void> &future)
     Q_UNUSED(future);
 }
 
+static bool compareLexigraphically(const QuickOpen::FilterEntry &a,
+                                   const QuickOpen::FilterEntry &b)
+{
+    return a.displayName < b.displayName;
+}
+
 QList<QuickOpen::FilterEntry> CppQuickOpenFilter::matchesFor(const QString &origEntry)
 {
     QString entry = trimWildcards(origEntry);
@@ -109,6 +115,9 @@ QList<QuickOpen::FilterEntry> CppQuickOpenFilter::matchesFor(const QString &orig
         }
     }
 
+    if (entries.size() < 1000)
+        qSort(entries.begin(), entries.end(), compareLexigraphically);
+
     return entries;
 }
 
-- 
GitLab