@@ -96,37 +96,41 @@ namespace noggit::ui
9696
9797 void asset_browser::create_tree (std::string filter)
9898 {
99- static const std::regex models_and_wmo (" [^\\ .]+\\ .(m2|wmo)" ), wmo_group (" .*_[0-9]{3}\\ .wmo" );
99+ static const QRegularExpression models_and_wmo (" ([^\\ .]+\\ .(m2|wmo))" );
100+ static const QRegularExpression wmo_group (" (.*_[0-9]{3}\\ .wmo)" );
100101
101102 _asset_tree->clear ();
102103 asset_tree_node root (" root" );
103104
104105 bool use_filter = filter != " " ;
105106
106- filter = noggit::mpq::normalized_filename (filter);
107+ QStringList sorted_listfile;
108+ for (const auto & file : gListfile ) {
109+ sorted_listfile.append (QString::fromStdString (file));
110+ }
111+
112+ sorted_listfile.sort ();
107113
108- for (std::string const & file : gListfile )
114+ for (const QString & file : sorted_listfile )
109115 {
110- if (!std::regex_match (file, models_and_wmo) || std::regex_match (file, wmo_group))
116+ if (!models_and_wmo.match (file).hasMatch () || wmo_group.match (file).hasMatch ())
117+
111118 {
112119 continue ;
113120 }
114121
115- if (use_filter && file.find (filter) != std::string::npos)
122+ if (use_filter && !file.contains (QString::fromStdString (filter), Qt::CaseInsensitive))
123+
116124 {
117125 continue ;
118126 }
119127
120- std::regex delimiter (" /" );
121- std::sregex_token_iterator it (file.begin (), file.end (), delimiter, -1 );
122- std::sregex_token_iterator end;
123-
128+ QStringList parts = file.split (' /' );
124129 asset_tree_node* node = &root;
125-
126- while (it != end )
130+
131+ for ( const QString& part : parts )
127132 {
128- node = &node->add_child (*it);
129- ++it;
133+ node = &node->add_child (part.toStdString ());
130134 }
131135 }
132136
0 commit comments