From b3fd2068229b0829f529455b4e22b5e74c8f9f96 Mon Sep 17 00:00:00 2001 From: Roland Knall Date: Fri, 17 Jun 2022 14:36:34 +0200 Subject: [PATCH] Qt: Sort tap list initially By sorting the list of taps, the initial sorting is kept also for the tab order --- ui/qt/widgets/traffic_types_list.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/ui/qt/widgets/traffic_types_list.cpp b/ui/qt/widgets/traffic_types_list.cpp index 55a4c6a57a..204c9249c1 100644 --- a/ui/qt/widgets/traffic_types_list.cpp +++ b/ui/qt/widgets/traffic_types_list.cpp @@ -62,6 +62,10 @@ TrafficTypesModel::TrafficTypesModel(GList ** recentList, QObject *parent) : { conversation_table_iterate_tables(iterateProtocols, &_allTaps); + std::sort(_allTaps.begin(), _allTaps.end(), [](TrafficTypesRowData a, TrafficTypesRowData b) { + return a.name().compare(b.name(), Qt::CaseInsensitive) < 0; + }); + QList _protocols; for (GList * endTab = *_recentList; endTab; endTab = endTab->next) { @@ -181,7 +185,7 @@ void TrafficTypesModel::selectProtocols(QList protocols) } -TrafficListSortModel::TrafficListSortModel(QObject * parent) : +TrafficListSortModel::TrafficListSortModel(QObject * parent) : QSortFilterProxyModel(parent) {} @@ -216,6 +220,9 @@ void TrafficTypesList::setProtocolInfo(QString name, GList ** recentList) sortModel->setSourceModel(_model); setModel(sortModel); + setSortingEnabled(true); + sortByColumn(TrafficTypesModel::COL_NAME, Qt::AscendingOrder); + connect(_model, &TrafficTypesModel::protocolsChanged, this, &TrafficTypesList::protocolsChanged); resizeColumnToContents(0);