From 629875abd995f46f99b3cba3387faa7367a6f823 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 6 Oct 2015 07:06:29 +0200 Subject: main, ui: fix sort order Sort order was applied only to combobox but not to tracker list. Reported-by: @nanospork cf. https://github.com/opentrack/opentrack/issues/231#issuecomment-145741998 --- facetracknoir/ui.cpp | 13 +++---------- opentrack/plugin-support.hpp | 10 ++++++++++ 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/facetracknoir/ui.cpp b/facetracknoir/ui.cpp index ad3c4886..d90fc762 100644 --- a/facetracknoir/ui.cpp +++ b/facetracknoir/ui.cpp @@ -19,13 +19,6 @@ # include #endif -template -static QList sorted(QList xs) -{ - std::sort(xs.begin(), xs.end(), [&](const t& a, const t& b) { return a->name.toLower() < b->name.toLower(); }); - return xs; -} - MainWindow::MainWindow() : pose_update_timer(this), kbd_quit(QKeySequence("Ctrl+Q"), this), @@ -47,13 +40,13 @@ MainWindow::MainWindow() : modules.filters().push_front(std::make_shared("", dylib::Filter)); - for (auto x : sorted(modules.trackers())) + for (auto x : modules.trackers()) ui.iconcomboTrackerSource->addItem(x->icon, x->name); - for (auto x : sorted(modules.protocols())) + for (auto x : modules.protocols()) ui.iconcomboProtocol->addItem(x->icon, x->name); - for (auto x : sorted(modules.filters())) + for (auto x : modules.filters()) ui.iconcomboFilter->addItem(x->icon, x->name); refresh_config_list(); diff --git a/opentrack/plugin-support.hpp b/opentrack/plugin-support.hpp index 8efda800..102d11c4 100644 --- a/opentrack/plugin-support.hpp +++ b/opentrack/plugin-support.hpp @@ -20,6 +20,7 @@ #include #include #include +#include #include #include @@ -245,6 +246,12 @@ private: QList> filter_modules; QList> tracker_modules; QList> protocol_modules; + + template + static void sort(QList& xs) + { + std::sort(xs.begin(), xs.end(), [&](const t& a, const t& b) { return a->name.toLower() < b->name.toLower(); }); + } QList> filter(dylib::Type t) { @@ -252,6 +259,9 @@ private: for (auto x : module_list) if (x->type == t) ret.push_back(x); + + sort(ret); + return ret; } }; -- cgit v1.2.3