Qt: Sort tap list initially

By sorting the list of taps, the initial sorting is kept also
for the tab order
This commit is contained in:
Roland Knall 2022-06-17 14:36:34 +02:00 committed by A Wireshark GitLab Utility
parent 9319394af1
commit b3fd206822
1 changed files with 8 additions and 1 deletions

View File

@ -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<int> _protocols;
for (GList * endTab = *_recentList; endTab; endTab = endTab->next) {
@ -181,7 +185,7 @@ void TrafficTypesModel::selectProtocols(QList<int> 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);