Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qpoicategoryohosmapkit.cpp
Go to the documentation of this file.
1// Copyright (C) 2025 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#include <QtCore/qhash.h>
5#include <QtCore/qlist.h>
6#include <QtCore/qmetaobject.h>
7#include <QtCore/qstringlist.h>
8#include <QtCore/qstring.h>
9#include <qpoicategoryohosmapkit.h>
10
11namespace OhosPoiInternal {
12
14
902};
903Q_ENUM_NS(CategoryId)
904
905inline uint qHash(OhosPoiInternal::CategoryId key, uint seed = 0) noexcept
906{
907 return ::qHash(static_cast<int>(key), seed);
908}
909
957};
958
1057};
1058
1282};
1283
1347};
1348
1374};
1375
1472};
1473
1500};
1501
1548};
1549
1666};
1667
1703};
1704
1744};
1745
1816};
1817
1832
1834 automotiveHierarchy,
1835 businessHierarchy,
1836 eatingDrinkingHierarchy,
1837 governmentPublicServiceHierarchy,
1838 healthCareHierarchy,
1839 leisureHierarchy,
1840 accommodationHierarchy,
1841 miscellaneousHierarchy,
1842 shoppingHierarchy,
1843 sportFitnessHierarchy,
1844 tourismHierarchy,
1845 transportHierarchy,
1846 othersHierarchy
1847};
1848
1850{
1851 return QString::fromLatin1(QMetaEnum::fromType<CategoryId>().valueToKey(static_cast<int>(categoryId)));
1852}
1853
1854CategoryId tryGetCategoryId(const QString &categoryName)
1855{
1856 bool ok;
1857 auto categoryId =
1858 QMetaEnum::fromType<CategoryId>().keyToValue(
1859 categoryName.toLatin1().constData(), &ok);
1860 return ok ? static_cast<CategoryId>(categoryId) : CategoryId::INVALID;
1861}
1862
1863}
1864
1865namespace QPoiCategoryOhosMapKit {
1866
1867QString tryGetParentCategoryIdOrEmpty(const QString &categoryId)
1868{
1869 auto enumCategoryId = OhosPoiInternal::tryGetCategoryId(categoryId);
1870 if (enumCategoryId == OhosPoiInternal::CategoryId::INVALID)
1871 return QString();
1872
1874
1875 for (const auto &parentChildHierarchy : OhosPoiInternal::allParentChildHierarchies)
1876 if (parentChildHierarchy.contains(enumCategoryId))
1877 parentId = parentChildHierarchy.value(enumCategoryId);
1878
1879 return parentId != OhosPoiInternal::CategoryId::INVALID
1880 ? OhosPoiInternal::getCategoryIdName(parentId)
1881 : QString();
1882}
1883
1885{
1886 auto enumCategoryId = OhosPoiInternal::tryGetCategoryId(categoryId);
1887 if (enumCategoryId == OhosPoiInternal::CategoryId::INVALID)
1888 return QStringList();
1889
1890 QStringList childCategoryIds;
1891
1892 for (const auto &parentChildHierarchy : OhosPoiInternal::allParentChildHierarchies) {
1893 if (parentChildHierarchy.contains(enumCategoryId)) {
1894 for (auto it = parentChildHierarchy.begin(); it != parentChildHierarchy.end(); ++it)
1895 if (it.value() == enumCategoryId)
1896 childCategoryIds.push_back(OhosPoiInternal::getCategoryIdName(it.key()));
1897 break;
1898 }
1899 }
1900
1901 return childCategoryIds;
1902}
1903
1904}
1905
1906#include "qpoicategoryohosmapkit.moc"
const QHash< CategoryId, CategoryId > miscellaneousHierarchy
const QHash< CategoryId, CategoryId > automotiveHierarchy
const QHash< CategoryId, CategoryId > eatingDrinkingHierarchy
QString getCategoryIdName(CategoryId categoryId)
const QHash< CategoryId, CategoryId > businessHierarchy
uint qHash(OhosPoiInternal::CategoryId key, uint seed=0) noexcept
const QHash< CategoryId, CategoryId > sportFitnessHierarchy
const QHash< CategoryId, CategoryId > transportHierarchy
const QHash< CategoryId, CategoryId > accommodationHierarchy
CategoryId tryGetCategoryId(const QString &categoryName)
const QHash< CategoryId, CategoryId > healthCareHierarchy
const QHash< CategoryId, CategoryId > governmentPublicServiceHierarchy
const QList< QHash< CategoryId, CategoryId > > allParentChildHierarchies
const QHash< CategoryId, CategoryId > othersHierarchy
const QHash< CategoryId, CategoryId > leisureHierarchy
const QHash< CategoryId, CategoryId > shoppingHierarchy
const QHash< CategoryId, CategoryId > tourismHierarchy
QString tryGetParentCategoryIdOrEmpty(const QString &categoryId)
QStringList tryGetChildCategoryIdsOrEmpty(const QString &categoryId)