Changeset View
Changeset View
Standalone View
Standalone View
kcms/solid_actions/ActionItem.cpp
Show First 20 Lines • Show All 82 Lines • ▼ Show 20 Line(s) | |||||
83 | Solid::Predicate ActionItem::predicate() const | 83 | Solid::Predicate ActionItem::predicate() const | ||
84 | { | 84 | { | ||
85 | return predicateItem; | 85 | return predicateItem; | ||
86 | } | 86 | } | ||
87 | 87 | | |||
88 | QString ActionItem::involvedTypes() const | 88 | QString ActionItem::involvedTypes() const | ||
89 | { | 89 | { | ||
90 | SolidActionData * actData = SolidActionData::instance(); | 90 | SolidActionData * actData = SolidActionData::instance(); | ||
91 | QSet<Solid::DeviceInterface::Type> devTypeList = predicateItem.usedTypes(); | 91 | const QSet<Solid::DeviceInterface::Type> devTypeList = predicateItem.usedTypes(); | ||
92 | QStringList deviceTypes; | 92 | QStringList deviceTypes; | ||
93 | foreach( Solid::DeviceInterface::Type devType, devTypeList ) { | 93 | for (Solid::DeviceInterface::Type devType : devTypeList) { | ||
94 | deviceTypes << actData->nameFromInterface( devType ); | 94 | deviceTypes << actData->nameFromInterface( devType ); | ||
95 | } | 95 | } | ||
96 | 96 | | |||
97 | return deviceTypes.join(QLatin1String(", ")); | 97 | return deviceTypes.join(QLatin1String(", ")); | ||
98 | } | 98 | } | ||
99 | 99 | | |||
100 | void ActionItem::setIcon(const QString& nameOfIcon) | 100 | void ActionItem::setIcon(const QString& nameOfIcon) | ||
101 | { | 101 | { | ||
Show All 33 Lines | 134 | { | |||
135 | return configItem(ActionItem::DesktopRead, keyGroup, keyName)->hasKey(keyName); | 135 | return configItem(ActionItem::DesktopRead, keyGroup, keyName)->hasKey(keyName); | ||
136 | } | 136 | } | ||
137 | 137 | | |||
138 | KConfigGroup * ActionItem::configItem(DesktopAction actionType, GroupType keyGroup, const QString& keyName) const | 138 | KConfigGroup * ActionItem::configItem(DesktopAction actionType, GroupType keyGroup, const QString& keyName) const | ||
139 | { | 139 | { | ||
140 | int countAccess = 0; | 140 | int countAccess = 0; | ||
141 | 141 | | |||
142 | if (actionType == ActionItem::DesktopRead) { | 142 | if (actionType == ActionItem::DesktopRead) { | ||
143 | foreach(KConfigGroup * possibleGroup, actionGroups.values(keyGroup)) { | 143 | const auto values = actionGroups.values(keyGroup); | ||
144 | for (KConfigGroup *possibleGroup : values) { | ||||
broulik: Don't iterate `values()`, which creates a temporary list, instead use iterators. | |||||
broulik: Ok, probably not, since this is a `QHash` with `insertMulti`... | |||||
144 | if (possibleGroup->hasKey(keyName)) { | 145 | if (possibleGroup->hasKey(keyName)) { | ||
145 | return possibleGroup; | 146 | return possibleGroup; | ||
146 | break; | | |||
147 | } | 147 | } | ||
148 | } | 148 | } | ||
149 | } else if (actionType == ActionItem::DesktopWrite) { | 149 | } else if (actionType == ActionItem::DesktopWrite) { | ||
150 | if (isUserSupplied()) { | 150 | if (isUserSupplied()) { | ||
151 | countAccess = 1; | 151 | countAccess = 1; | ||
152 | } | 152 | } | ||
153 | return actionGroups.values(keyGroup)[countAccess]; | 153 | return actionGroups.values(keyGroup)[countAccess]; | ||
154 | } | 154 | } | ||
155 | return actionGroups.values(keyGroup)[0]; // Implement a backstop so a valid value is always returned | 155 | return actionGroups.values(keyGroup)[0]; // Implement a backstop so a valid value is always returned | ||
156 | } | 156 | } | ||
157 | 157 | |
Don't iterate values(), which creates a temporary list, instead use iterators.