Changeset View
Changeset View
Standalone View
Standalone View
treeview.cpp
Show First 20 Lines • Show All 135 Lines • ▼ Show 20 Line(s) | |||||
136 | * @param item1 First item. | 136 | * @param item1 First item. | ||
137 | * @param item2 Second item. | 137 | * @param item2 Second item. | ||
138 | * @return Integer less than, equal to, or greater than zero if item1 is less than, equal to, or greater than item2. | 138 | * @return Integer less than, equal to, or greater than zero if item1 is less than, equal to, or greater than item2. | ||
139 | */ | 139 | */ | ||
140 | bool TreeItem::itemNameLessThan(QTreeWidgetItem *item1, QTreeWidgetItem *item2) | 140 | bool TreeItem::itemNameLessThan(QTreeWidgetItem *item1, QTreeWidgetItem *item2) | ||
141 | { | 141 | { | ||
142 | TreeItem *treeItem1 = static_cast<TreeItem *>(item1); | 142 | TreeItem *treeItem1 = static_cast<TreeItem *>(item1); | ||
143 | TreeItem *treeItem2 = static_cast<TreeItem *>(item2); | 143 | TreeItem *treeItem2 = static_cast<TreeItem *>(item2); | ||
144 | return treeItem1->name().toLower() < treeItem2->name().toLower(); | 144 | return QString::localeAwareCompare(treeItem1->name(), treeItem2->name()) < 0; | ||
145 | } | 145 | } | ||
146 | 146 | | |||
147 | /** | 147 | /** | ||
148 | * @brief Compare two items using their descriptions. If both are empty, sort them by name. | 148 | * @brief Compare two items using their descriptions. If both are empty, sort them by name. | ||
149 | * @param item1 First item. | 149 | * @param item1 First item. | ||
150 | * @param item2 Second item. | 150 | * @param item2 Second item. | ||
151 | * @return Integer less than, equal to, or greater than zero if item1 is less than, equal to, or greater than item2. | 151 | * @return Integer less than, equal to, or greater than zero if item1 is less than, equal to, or greater than item2. | ||
152 | */ | 152 | */ | ||
153 | bool TreeItem::itemDescriptionLessThan(QTreeWidgetItem *item1, QTreeWidgetItem *item2) | 153 | bool TreeItem::itemDescriptionLessThan(QTreeWidgetItem *item1, QTreeWidgetItem *item2) | ||
154 | { | 154 | { | ||
155 | // extract descriptions in lower case | 155 | // extract descriptions in lower case | ||
156 | TreeItem *treeItem1 = static_cast<TreeItem *>(item1); | 156 | TreeItem *treeItem1 = static_cast<TreeItem *>(item1); | ||
157 | TreeItem *treeItem2 = static_cast<TreeItem *>(item2); | 157 | TreeItem *treeItem2 = static_cast<TreeItem *>(item2); | ||
158 | const QString description1 = treeItem1->description().toLower(); | 158 | const QString description1 = treeItem1->description(); | ||
159 | const QString description2 = treeItem2->description().toLower(); | 159 | const QString description2 = treeItem2->description(); | ||
160 | 160 | | |||
161 | // if description is missing for both items, sort them using their names | 161 | // if description is missing for both items, sort them using their names | ||
162 | if (description1.isEmpty() && description2.isEmpty()) { | 162 | if (description1.isEmpty() && description2.isEmpty()) { | ||
163 | return itemNameLessThan(item1, item2); | 163 | return itemNameLessThan(item1, item2); | ||
164 | } else { | 164 | } else { | ||
165 | return description1 < description2; | 165 | return QString::localeAwareCompare(description1, description2) < 0; | ||
166 | } | 166 | } | ||
167 | } | 167 | } | ||
168 | 168 | | |||
169 | void TreeItem::setName(const QString &name) | 169 | void TreeItem::setName(const QString &name) | ||
170 | { | 170 | { | ||
171 | if (m_name == name) { | 171 | if (m_name == name) { | ||
172 | return; | 172 | return; | ||
173 | } | 173 | } | ||
▲ Show 20 Lines • Show All 1797 Lines • Show Last 20 Lines |