summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@kdab.com>2019-07-10 15:35:08 +0200
committerMarc Mutz <marc.mutz@kdab.com>2019-07-10 16:32:24 +0200
commitab02e8629d6272b00fbff24b38ee007358f184a1 (patch)
tree10cd5ba7b05ad2b22e4b3eb45d5e851a1989ba70
parent93fcae54d5f8cebf2e8988a5bc50ecb7a4f6b60c (diff)
downloadqtlocation-ab02e8629d6272b00fbff24b38ee007358f184a1.tar.gz
QDeclarativeSupportedCategoriesModel: don't use a QMap just to sort a container
... use std::sort() Change-Id: I2b40f475f44b41a9f0540602085f0a430eed9508 Reviewed-by: Paolo Angelelli <paolo.angelelli@qt.io>
-rw-r--r--src/location/declarativeplaces/qdeclarativesupportedcategoriesmodel.cpp22
1 files changed, 11 insertions, 11 deletions
diff --git a/src/location/declarativeplaces/qdeclarativesupportedcategoriesmodel.cpp b/src/location/declarativeplaces/qdeclarativesupportedcategoriesmodel.cpp
index 38bfb249..08179c93 100644
--- a/src/location/declarativeplaces/qdeclarativesupportedcategoriesmodel.cpp
+++ b/src/location/declarativeplaces/qdeclarativesupportedcategoriesmodel.cpp
@@ -631,24 +631,24 @@ QStringList QDeclarativeSupportedCategoriesModel::populateCategories(QPlaceManag
Q_ASSERT(manager);
QStringList childIds;
- PlaceCategoryNode *node;
- QMap<QString, QPlaceCategory> sortedCategories;
- foreach ( const QPlaceCategory &category, manager->childCategories(parent.categoryId()))
- sortedCategories.insert(category.name(), category);
+ const auto byName = [](const QPlaceCategory &lhs, const QPlaceCategory &rhs) {
+ return lhs.name() < rhs.name();
+ };
- QMapIterator<QString, QPlaceCategory> iter(sortedCategories);
- while (iter.hasNext()) {
- iter.next();
- node = new PlaceCategoryNode;
+ auto categories = manager->childCategories(parent.categoryId());
+ std::sort(categories.begin(), categories.end(), byName);
+
+ for (const auto &category : qAsConst(categories)) {
+ auto node = new PlaceCategoryNode;
node->parentId = parent.categoryId();
- node->declCategory = QSharedPointer<QDeclarativeCategory>(new QDeclarativeCategory(iter.value(), m_plugin ,this));
+ node->declCategory = QSharedPointer<QDeclarativeCategory>(new QDeclarativeCategory(category, m_plugin ,this));
if (m_hierarchical)
- node->childIds = populateCategories(manager, iter.value());
+ node->childIds = populateCategories(manager, category);
m_categoriesTree.insert(node->declCategory->categoryId(), node);
- childIds.append(iter.value().categoryId());
+ childIds.append(category.categoryId());
if (!m_hierarchical) {
childIds.append(populateCategories(manager,node->declCategory->category()));