Changeset View
Changeset View
Standalone View
Standalone View
addons/xmltools/plugin_katexmltools.cpp
Show First 20 Lines • Show All 1027 Lines • ▼ Show 20 Line(s) | |||||
1028 | } | 1028 | } | ||
1029 | 1029 | | |||
1030 | /** Sort a QStringList case-insensitively. Static. TODO: make it more simple. */ | 1030 | /** Sort a QStringList case-insensitively. Static. TODO: make it more simple. */ | ||
1031 | QStringList PluginKateXMLToolsCompletionModel::sortQStringList(QStringList list) | 1031 | QStringList PluginKateXMLToolsCompletionModel::sortQStringList(QStringList list) | ||
1032 | { | 1032 | { | ||
1033 | // Sort list case-insensitive. This looks complicated but using a QMap | 1033 | // Sort list case-insensitive. This looks complicated but using a QMap | ||
1034 | // is even suggested by the Qt documentation. | 1034 | // is even suggested by the Qt documentation. | ||
1035 | QMap<QString, QString> mapList; | 1035 | QMap<QString, QString> mapList; | ||
1036 | for (QStringList::Iterator it = list.begin(); it != list.end(); ++it) { | 1036 | for (const auto& str : qAsConst(list)) { | ||
1037 | QString str = *it; | | |||
1038 | if (mapList.contains(str.toLower())) { | 1037 | if (mapList.contains(str.toLower())) { | ||
1039 | // do not override a previous value, e.g. "Auml" and "auml" are two different | 1038 | // do not override a previous value, e.g. "Auml" and "auml" are two different | ||
1040 | // entities, but they should be sorted next to each other. | 1039 | // entities, but they should be sorted next to each other. | ||
1041 | // TODO: currently it's undefined if e.g. "A" or "a" comes first, it depends on | 1040 | // TODO: currently it's undefined if e.g. "A" or "a" comes first, it depends on | ||
1042 | // the meta DTD ( really? it seems to work okay?!? ) | 1041 | // the meta DTD ( really? it seems to work okay?!? ) | ||
1043 | mapList[str.toLower() + '_'] = str; | 1042 | mapList[str.toLower() + '_'] = str; | ||
1044 | } else { | 1043 | } else { | ||
1045 | mapList[str.toLower()] = str; | 1044 | mapList[str.toLower()] = str; | ||
▲ Show 20 Lines • Show All 69 Lines • Show Last 20 Lines |