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
qqstylekitpropertypath.cpp
Go to the documentation of this file.
1// Copyright (C) 2026 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
7
9
10QHash<PropertyPathId, QString> QQStyleKitPropertyPath::s_cachedPathStrings;
11
12QQStyleKitPropertyPath::QQStyleKitPropertyPath(
13 const QQStyleKitPropertyGroup *group, QQSK::Property property, Flag flag)
14 : m_property(property)
15{
16 PropertyPathId subtypeIndex = 0;
17 if (flag == Flag::IncludeSubtype) {
18 if (group->pathFlags() & QQSK::PropertyPathFlag::DelegateSubtype1)
19 subtypeIndex = 1;
20 else if (group->pathFlags() & QQSK::PropertyPathFlag::DelegateSubtype2)
21 subtypeIndex = 2;
22 }
23
24 const PropertyPathId subtypeStart = subtypeIndex * subtypeStorageSpaceSize;
25 const PropertyPathId groupStart = group->groupSpace().start;
26 m_groupStart = subtypeStart + groupStart;
27}
28
29QString QQStyleKitPropertyPath::pathIdToPathString(PropertyPathId pathId)
30{
31 if (s_cachedPathStrings.contains(pathId))
32 return s_cachedPathStrings.value(pathId);
33
34 constexpr PropertyPathId rootGroupsSize = nestedGroupsStartSize / nestedGroupCount;
35 const auto groupMetaEnum = QMetaEnum::fromType<QQSK::PropertyGroup>();
36 const auto propertyMetaEnum = QMetaEnum::fromType<QQSK::Property>();
37
38 const QQSK::PropertyGroup subType = extractSubtype(pathId);
39 PropertyPathId nestedGroupStart = pathId % subtypeStorageSpaceSize;
40 PropertyPathId nestedGroupSize = rootGroupsSize;
41 PropertyPathId nestedGroupIndex = nestedGroupStart / nestedGroupSize;
42 auto groupType = QQSK::PropertyGroup(nestedGroupIndex);
43
44 QString pathString;
45
46 if (groupType != QQSK::PropertyGroup::Control) {
47 QString groupName = QString::fromLatin1(groupMetaEnum.valueToKey(static_cast<int>(groupType)));
48 groupName[0] = groupName[0].toLower();
49 pathString = groupName;
50
51 switch (subType) {
52 case QQSK::PropertyGroup::DelegateSubtype1:
53 pathString += ".first"_L1;
54 break;
55 case QQSK::PropertyGroup::DelegateSubtype2:
56 pathString += ".second"_L1;
57 break;
58 default:
59 break;
60 }
61
62 while (true) {
63 nestedGroupStart -= nestedGroupIndex * nestedGroupSize;
64 nestedGroupSize /= nestedGroupCount;
65 nestedGroupIndex = nestedGroupStart / nestedGroupSize;
66 groupType = QQSK::PropertyGroup(nestedGroupIndex);
67 if (groupType == QQSK::PropertyGroup::Control)
68 break;
69
70 QString nestedName = QString::fromLatin1(groupMetaEnum.valueToKey(static_cast<int>(groupType)));
71 nestedName[0] = nestedName[0].toLower();
72 pathString += '.'_L1 + nestedName;
73 }
74 }
75
76 QQSK::Property property = QQSK::Property(nestedGroupStart);
77 if (property != QQSK::Property::NoProperty) {
78 QString propertyName = QString::fromLatin1(propertyMetaEnum.valueToKey(static_cast<int>(property)));
79 propertyName[0] = propertyName[0].toLower();
80 if (!pathString.isEmpty())
81 pathString += '.'_L1;
82 pathString += propertyName;
83 }
84
85 s_cachedPathStrings.insert(pathId, pathString);
86 return pathString;
87}
88
89QString QQStyleKitPropertyPath::storageIdToPathString(PropertyStorageId storageId)
90{
91 const QString pathStr = pathIdToPathString(extractPropertyPathId(storageId));
92 const QString stateStr = QQStyleKitDebug::stateToString(extractState(storageId));
93 return stateStr + '.'_L1 + pathStr;
94}
95
96QT_END_NAMESPACE
97
98#include "moc_qqstylekitpropertypath_p.cpp"
QQStyleKitPropertyGroupSpace groupSpace() const
Combined button and popup list for selecting options.