Changeset View
Changeset View
Standalone View
Standalone View
libdbusmenuqt/dbusmenuimporter.cpp
Show First 20 Lines • Show All 155 Lines • ▼ Show 20 Line(s) | 81 | public: | |||
---|---|---|---|---|---|
156 | * for this property. | 156 | * for this property. | ||
157 | * | 157 | * | ||
158 | * @param action the action to update | 158 | * @param action the action to update | ||
159 | * @param map holds the property values | 159 | * @param map holds the property values | ||
160 | * @param requestedProperties which properties has been requested | 160 | * @param requestedProperties which properties has been requested | ||
161 | */ | 161 | */ | ||
162 | void updateAction(QAction *action, const QVariantMap &map, const QStringList &requestedProperties) | 162 | void updateAction(QAction *action, const QVariantMap &map, const QStringList &requestedProperties) | ||
163 | { | 163 | { | ||
164 | Q_FOREACH(const QString &key, requestedProperties) { | 164 | for (const QString &key : requestedProperties) { | ||
165 | updateActionProperty(action, key, map.value(key)); | 165 | updateActionProperty(action, key, map.value(key)); | ||
166 | } | 166 | } | ||
167 | } | 167 | } | ||
168 | 168 | | |||
169 | void updateActionProperty(QAction *action, const QString &key, const QVariant &value) | 169 | void updateActionProperty(QAction *action, const QString &key, const QVariant &value) | ||
170 | { | 170 | { | ||
171 | if (key == QLatin1String("label")) { | 171 | if (key == QLatin1String("label")) { | ||
172 | updateActionLabel(action, value); | 172 | updateActionLabel(action, value); | ||
▲ Show 20 Lines • Show All 140 Lines • ▼ Show 20 Line(s) | 308 | { | |||
313 | d->m_pendingLayoutUpdates << parentId; | 313 | d->m_pendingLayoutUpdates << parentId; | ||
314 | if (!d->m_pendingLayoutUpdateTimer->isActive()) { | 314 | if (!d->m_pendingLayoutUpdateTimer->isActive()) { | ||
315 | d->m_pendingLayoutUpdateTimer->start(); | 315 | d->m_pendingLayoutUpdateTimer->start(); | ||
316 | } | 316 | } | ||
317 | } | 317 | } | ||
318 | 318 | | |||
319 | void DBusMenuImporter::processPendingLayoutUpdates() | 319 | void DBusMenuImporter::processPendingLayoutUpdates() | ||
320 | { | 320 | { | ||
321 | QSet<int> ids = d->m_pendingLayoutUpdates; | 321 | const QSet<int> ids = d->m_pendingLayoutUpdates; | ||
322 | d->m_pendingLayoutUpdates.clear(); | 322 | d->m_pendingLayoutUpdates.clear(); | ||
323 | Q_FOREACH(int id, ids) { | 323 | for (int id : ids) { | ||
324 | d->refresh(id); | 324 | d->refresh(id); | ||
325 | } | 325 | } | ||
326 | } | 326 | } | ||
327 | 327 | | |||
328 | QMenu *DBusMenuImporter::menu() const | 328 | QMenu *DBusMenuImporter::menu() const | ||
329 | { | 329 | { | ||
330 | if (!d->m_menu) { | 330 | if (!d->m_menu) { | ||
331 | d->m_menu = d->createMenu(nullptr); | 331 | d->m_menu = d->createMenu(nullptr); | ||
332 | } | 332 | } | ||
333 | return d->m_menu; | 333 | return d->m_menu; | ||
334 | } | 334 | } | ||
335 | 335 | | |||
336 | void DBusMenuImporterPrivate::slotItemsPropertiesUpdated(const DBusMenuItemList &updatedList, const DBusMenuItemKeysList &removedList) | 336 | void DBusMenuImporterPrivate::slotItemsPropertiesUpdated(const DBusMenuItemList &updatedList, const DBusMenuItemKeysList &removedList) | ||
337 | { | 337 | { | ||
338 | Q_FOREACH(const DBusMenuItem &item, updatedList) { | 338 | for (const DBusMenuItem &item : updatedList) { | ||
339 | QAction *action = m_actionForId.value(item.id); | 339 | QAction *action = m_actionForId.value(item.id); | ||
340 | if (!action) { | 340 | if (!action) { | ||
341 | // We don't know this action. It probably is in a menu we haven't fetched yet. | 341 | // We don't know this action. It probably is in a menu we haven't fetched yet. | ||
342 | continue; | 342 | continue; | ||
343 | } | 343 | } | ||
344 | 344 | | |||
345 | QVariantMap::ConstIterator | 345 | QVariantMap::ConstIterator | ||
346 | it = item.properties.constBegin(), | 346 | it = item.properties.constBegin(), | ||
347 | end = item.properties.constEnd(); | 347 | end = item.properties.constEnd(); | ||
348 | for(; it != end; ++it) { | 348 | for(; it != end; ++it) { | ||
349 | updateActionProperty(action, it.key(), it.value()); | 349 | updateActionProperty(action, it.key(), it.value()); | ||
350 | } | 350 | } | ||
351 | } | 351 | } | ||
352 | 352 | | |||
353 | Q_FOREACH(const DBusMenuItemKeys &item, removedList) { | 353 | for (const DBusMenuItemKeys &item : removedList) { | ||
354 | QAction *action = m_actionForId.value(item.id); | 354 | QAction *action = m_actionForId.value(item.id); | ||
355 | if (!action) { | 355 | if (!action) { | ||
356 | // We don't know this action. It probably is in a menu we haven't fetched yet. | 356 | // We don't know this action. It probably is in a menu we haven't fetched yet. | ||
357 | continue; | 357 | continue; | ||
358 | } | 358 | } | ||
359 | 359 | | |||
360 | Q_FOREACH(const QString &key, item.properties) { | 360 | for (const QString &key : qAsConst(item.properties)) { | ||
361 | updateActionProperty(action, key, QVariant()); | 361 | updateActionProperty(action, key, QVariant()); | ||
362 | } | 362 | } | ||
363 | } | 363 | } | ||
364 | } | 364 | } | ||
365 | 365 | | |||
366 | QAction *DBusMenuImporter::actionForId(int id) const | 366 | QAction *DBusMenuImporter::actionForId(int id) const | ||
367 | { | 367 | { | ||
368 | return d->m_actionForId.value(id); | 368 | return d->m_actionForId.value(id); | ||
▲ Show 20 Lines • Show All 179 Lines • Show Last 20 Lines |