From 0f7a4ba62369a42cf6b513ce0fa59d117551f0ed Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 6 Oct 2015 05:04:19 +0200 Subject: ui: sort combobox items according to their name, not filename --- facetracknoir/ui.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'facetracknoir/ui.cpp') diff --git a/facetracknoir/ui.cpp b/facetracknoir/ui.cpp index 984901f6..0672d24a 100644 --- a/facetracknoir/ui.cpp +++ b/facetracknoir/ui.cpp @@ -19,6 +19,13 @@ # 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), @@ -40,13 +47,13 @@ MainWindow::MainWindow() : modules.filters().push_front(std::make_shared("", dylib::Filter)); - for (auto x : modules.trackers()) + for (auto x : sorted(modules.trackers())) ui.iconcomboTrackerSource->addItem(x->icon, x->name); - for (auto x : modules.protocols()) + for (auto x : sorted(modules.protocols())) ui.iconcomboProtocol->addItem(x->icon, x->name); - for (auto x : modules.filters()) + for (auto x : sorted(modules.filters())) ui.iconcomboFilter->addItem(x->icon, x->name); refresh_config_list(); -- cgit v1.2.3