comparison transform/TransformDescription.h @ 1546:9c14dee72329

Use locale-aware comparators for user-visible string sorting
author Chris Cannam
date Mon, 01 Oct 2018 14:37:30 +0100
parents 45e95de8b11d
children 6f626cfdba51
comparison
equal deleted inserted replaced
1545:b89705af7a60 1546:9c14dee72329
11 published by the Free Software Foundation; either version 2 of the 11 published by the Free Software Foundation; either version 2 of the
12 License, or (at your option) any later version. See the file 12 License, or (at your option) any later version. See the file
13 COPYING included with this distribution for more information. 13 COPYING included with this distribution for more information.
14 */ 14 */
15 15
16 #ifndef _TRANSFORM_DESCRIPTION_H_ 16 #ifndef SV_TRANSFORM_DESCRIPTION_H
17 #define _TRANSFORM_DESCRIPTION_H_ 17 #define SV_TRANSFORM_DESCRIPTION_H
18 18
19 #include "Transform.h" 19 #include "Transform.h"
20 20
21 #include <QString> 21 #include <QString>
22 22
75 QString longDescription; // description "using" plugin name "by" maker 75 QString longDescription; // description "using" plugin name "by" maker
76 QString maker; 76 QString maker;
77 QString infoUrl; 77 QString infoUrl;
78 QString units; 78 QString units;
79 bool configurable; 79 bool configurable;
80
81 // User-visible strings (name, maker etc) should be sorted in a
82 // locale-aware way
83 static bool compareUserStrings(QString s1, QString s2) {
84 return QString::localeAwareCompare(s1, s2) < 0;
85 };
80 86
81 bool operator<(const TransformDescription &od) const { 87 bool operator<(const TransformDescription &od) const {
82 return 88 if (name == od.name) {
83 (name < od.name) || 89 return identifier < od.identifier;
84 (name == od.name && identifier < od.identifier); 90 } else {
91 return compareUserStrings(name, od.name);
92 }
85 }; 93 };
86 }; 94 };
87 95
88 typedef std::vector<TransformDescription> TransformList; 96 typedef std::vector<TransformDescription> TransformList;
89 97