Port some foreach + add QStringLiteral

wilder-5.25
Laurent Montel 4 years ago
parent 1305fe0a87
commit d6b0c0a046
  1. 19
      libdbusmenuqt/dbusmenuimporter.cpp
  2. 4
      libkworkspace/kworkspace.cpp
  3. 2
      libkworkspace/sessionmanagementbackend.cpp
  4. 4
      libkworkspace/updatelaunchenvjob.cpp
  5. 2
      libtaskmanager/waylandtasksmodel.cpp

@ -148,7 +148,7 @@ public:
*/ */
void updateAction(QAction *action, const QVariantMap &map, const QStringList &requestedProperties) void updateAction(QAction *action, const QVariantMap &map, const QStringList &requestedProperties)
{ {
Q_FOREACH (const QString &key, requestedProperties) { for (const QString &key : requestedProperties) {
updateActionProperty(action, key, map.value(key)); updateActionProperty(action, key, map.value(key));
} }
} }
@ -308,9 +308,9 @@ void DBusMenuImporter::slotLayoutUpdated(uint revision, int parentId)
void DBusMenuImporter::processPendingLayoutUpdates() void DBusMenuImporter::processPendingLayoutUpdates()
{ {
QSet<int> ids = d->m_pendingLayoutUpdates; const QSet<int> ids = d->m_pendingLayoutUpdates;
d->m_pendingLayoutUpdates.clear(); d->m_pendingLayoutUpdates.clear();
Q_FOREACH (int id, ids) { for (int id : ids) {
d->refresh(id); d->refresh(id);
} }
} }
@ -325,7 +325,7 @@ QMenu *DBusMenuImporter::menu() const
void DBusMenuImporterPrivate::slotItemsPropertiesUpdated(const DBusMenuItemList &updatedList, const DBusMenuItemKeysList &removedList) void DBusMenuImporterPrivate::slotItemsPropertiesUpdated(const DBusMenuItemList &updatedList, const DBusMenuItemKeysList &removedList)
{ {
Q_FOREACH (const DBusMenuItem &item, updatedList) { for (const DBusMenuItem &item : updatedList) {
QAction *action = m_actionForId.value(item.id); QAction *action = m_actionForId.value(item.id);
if (!action) { if (!action) {
// We don't know this action. It probably is in a menu we haven't fetched yet. // We don't know this action. It probably is in a menu we haven't fetched yet.
@ -338,14 +338,15 @@ void DBusMenuImporterPrivate::slotItemsPropertiesUpdated(const DBusMenuItemList
} }
} }
Q_FOREACH (const DBusMenuItemKeys &item, removedList) { for (const DBusMenuItemKeys &item : removedList) {
QAction *action = m_actionForId.value(item.id); QAction *action = m_actionForId.value(item.id);
if (!action) { if (!action) {
// We don't know this action. It probably is in a menu we haven't fetched yet. // We don't know this action. It probably is in a menu we haven't fetched yet.
continue; continue;
} }
Q_FOREACH (const QString &key, item.properties) { const auto properties{item.properties};
for (const QString &key : properties) {
updateActionProperty(action, key, QVariant()); updateActionProperty(action, key, QVariant());
} }
} }
@ -435,9 +436,9 @@ void DBusMenuImporter::slotGetLayoutFinished(QDBusPendingCallWatcher *watcher)
} else { } else {
action = *it; action = *it;
QStringList filteredKeys = dbusMenuItem.properties.keys(); QStringList filteredKeys = dbusMenuItem.properties.keys();
filteredKeys.removeOne("type"); filteredKeys.removeOne(QStringLiteral("type"));
filteredKeys.removeOne("toggle-type"); filteredKeys.removeOne(QStringLiteral("toggle-type"));
filteredKeys.removeOne("children-display"); filteredKeys.removeOne(QStringLiteral("children-display"));
d->updateAction(*it, dbusMenuItem.properties, filteredKeys); d->updateAction(*it, dbusMenuItem.properties, filteredKeys);
// Move the action to the tail so we can keep the order same as the dbus request. // Move the action to the tail so we can keep the order same as the dbus request.
menu->removeAction(action); menu->removeAction(action);

@ -85,9 +85,9 @@ void propagateSessionManager()
// strip the screen number from the display // strip the screen number from the display
display.remove(QRegularExpression(QStringLiteral("\\.\\d+$"))); display.remove(QRegularExpression(QStringLiteral("\\.\\d+$")));
int i; int i;
while ((i = display.indexOf(':')) >= 0) while ((i = display.indexOf(QLatin1Char(':'))) >= 0)
display[i] = '_'; display[i] = '_';
while ((i = display.indexOf('/')) >= 0) while ((i = display.indexOf(QLatin1Char('/'))) >= 0)
display[i] = '_'; display[i] = '_';
fName += '_'; fName += '_';

@ -45,7 +45,7 @@ SessionBackend *SessionBackend::self()
SessionBackend::SessionBackend() SessionBackend::SessionBackend()
{ {
m_kserverConfig = KConfigWatcher::create(KSharedConfig::openConfig("ksmserverrc")); m_kserverConfig = KConfigWatcher::create(KSharedConfig::openConfig(QStringLiteral("ksmserverrc")));
} }
bool SessionBackend::confirmLogout() const bool SessionBackend::confirmLogout() const

@ -130,11 +130,11 @@ bool UpdateLaunchEnvJob::Private::isPosixName(const QString &name)
// Ensure systemd compat by only allowing alphanumerics and _ in names. // Ensure systemd compat by only allowing alphanumerics and _ in names.
bool first = true; bool first = true;
for (const QChar c : name) { for (const QChar c : name) {
if (first && !c.isLetter() && c != QChar('_')) { if (first && !c.isLetter() && c != QLatin1Char('_')) {
return false; return false;
} else if (first) { } else if (first) {
first = false; first = false;
} else if (!c.isLetterOrNumber() && c != QChar('_')) { } else if (!c.isLetterOrNumber() && c != QLatin1Char('_')) {
return false; return false;
} }
} }

@ -90,7 +90,7 @@ void WaylandTasksModel::Private::init()
rulesConfig = KSharedConfig::openConfig(QStringLiteral("taskmanagerrulesrc")); rulesConfig = KSharedConfig::openConfig(QStringLiteral("taskmanagerrulesrc"));
configWatcher = new KDirWatch(q); configWatcher = new KDirWatch(q);
foreach (const QString &location, QStandardPaths::standardLocations(QStandardPaths::ConfigLocation)) { for (const QString &location : QStandardPaths::standardLocations(QStandardPaths::ConfigLocation)) {
configWatcher->addFile(location + QLatin1String("/taskmanagerrulesrc")); configWatcher->addFile(location + QLatin1String("/taskmanagerrulesrc"));
} }

Loading…
Cancel
Save