diff --git a/kcms/keys/export_scheme_dialog.cpp b/kcms/keys/export_scheme_dialog.cpp --- a/kcms/keys/export_scheme_dialog.cpp +++ b/kcms/keys/export_scheme_dialog.cpp @@ -43,8 +43,7 @@ QGridLayout *vb = new QGridLayout(this); int item=0; - Q_FOREACH(QString component, mComponents) - { + for (const QString &component : qAsConst(mComponents)) { QCheckBox *cb = new QCheckBox(component); vb->addWidget(cb, item / 2, item % 2); mButtons.addButton(cb, item); @@ -70,8 +69,8 @@ QStringList ExportSchemeDialog::selectedComponents() const { QStringList rc; - Q_FOREACH(QAbstractButton const *button, mButtons.buttons()) - { + const auto buttons = mButtons.buttons(); + for (const QAbstractButton *button : buttons) { if (button->isChecked()) { // Remove the '&' added by KAcceleratorManager magically diff --git a/kcms/keys/globalshortcuts.cpp b/kcms/keys/globalshortcuts.cpp --- a/kcms/keys/globalshortcuts.cpp +++ b/kcms/keys/globalshortcuts.cpp @@ -37,10 +37,9 @@ { KCModule::setButtons(KCModule::Buttons(KCModule::Default | KCModule::Apply | KCModule::Help)); - // Create the kglobaleditor editor = new KGlobalShortcutsEditor(this, KShortcutsEditor::GlobalAction); - connect(editor, SIGNAL(changed(bool)), this, SIGNAL(changed(bool))); + connect(editor, &KGlobalShortcutsEditor::changed, this, &GlobalShortcutsModule::markAsChanged); // Layout the hole bunch QVBoxLayout *global = new QVBoxLayout; diff --git a/kcms/keys/kglobalshortcutseditor.h b/kcms/keys/kglobalshortcutseditor.h --- a/kcms/keys/kglobalshortcutseditor.h +++ b/kcms/keys/kglobalshortcutseditor.h @@ -81,7 +81,7 @@ /** * Save the shortcuts to the configuration. */ - void exportConfiguration(QStringList componentsFriendly, KConfig *config) const; + void exportConfiguration(const QStringList &componentsFriendly, KConfig *config) const; /** diff --git a/kcms/keys/kglobalshortcutseditor.cpp b/kcms/keys/kglobalshortcutseditor.cpp --- a/kcms/keys/kglobalshortcutseditor.cpp +++ b/kcms/keys/kglobalshortcutseditor.cpp @@ -82,8 +82,8 @@ ~ComponentData(); QString uniqueName() const; - KShortcutsEditor *editor(); - QDBusObjectPath dbusPath(); + KShortcutsEditor *editor() const; + QDBusObjectPath dbusPath() const; private: @@ -115,13 +115,13 @@ } -QDBusObjectPath ComponentData::dbusPath() +QDBusObjectPath ComponentData::dbusPath() const { return _path; } -KShortcutsEditor *ComponentData::editor() +KShortcutsEditor *ComponentData::editor() const { return _editor; } @@ -165,7 +165,7 @@ if (group && group->isValid()) { KServiceGroup::List list = group->entries(); - for( KServiceGroup::List::ConstIterator it = list.constBegin(); + for (KServiceGroup::List::ConstIterator it = list.constBegin(); it != list.constEnd(); ++it) { const KSycocaEntry::Ptr p = (*it); @@ -266,7 +266,8 @@ // Create a action collection for our current component:context KActionCollection *col = new KActionCollection(q, desktopFile); - foreach(const QString &actionId, sourceDF.readActions()) { + const auto actions = sourceDF.readActions(); + for (const QString &actionId : actions) { const QString friendlyName = sourceDF.actionGroup(actionId).readEntry(QStringLiteral("Name")); QAction *action = col->addAction(actionId); @@ -276,10 +277,10 @@ KGlobalAccel::self()->setShortcut(action, QList()); - QStringList sequencesStrings = sourceDF.actionGroup(actionId).readEntry(QStringLiteral("X-KDE-Shortcuts"), QString()).split(QLatin1Char('/')); + const QStringList sequencesStrings = sourceDF.actionGroup(actionId).readEntry(QStringLiteral("X-KDE-Shortcuts"), QString()).split(QLatin1Char('/')); QList sequences; if (!sequencesStrings.isEmpty()) { - Q_FOREACH (const QString &seqString, sequencesStrings) { + for (const QString &seqString : sequencesStrings) { sequences.append(QKeySequence(seqString)); } } @@ -298,10 +299,10 @@ KGlobalAccel::self()->setShortcut(action, QList()); - QStringList sequencesStrings = sourceDF.desktopGroup().readEntry(QStringLiteral("X-KDE-Shortcuts"), QString()).split(QLatin1Char('/')); + const QStringList sequencesStrings = sourceDF.desktopGroup().readEntry(QStringLiteral("X-KDE-Shortcuts"), QString()).split(QLatin1Char('/')); QList sequences; if (!sequencesStrings.isEmpty()) { - Q_FOREACH (const QString &seqString, sequencesStrings) { + for (const QString &seqString : sequencesStrings) { sequences.append(QKeySequence(seqString)); } } @@ -546,13 +547,13 @@ if (!url.isEmpty()) { KConfig config(url.path(), KConfig::SimpleConfig); // TODO: Bug ossi to provide a method for this - Q_FOREACH(const QString &group, config.groupList()) - { - // do not overwrite the Settings group. That makes it possible to - // update the standard scheme kksrc file with the editor. - if (group == QLatin1String("Settings")) continue; - config.deleteGroup(group); - } + const auto groupList = config.groupList(); + for (const QString &group : groupList) { + // do not overwrite the Settings group. That makes it possible to + // update the standard scheme kksrc file with the editor. + if (group == QLatin1String("Settings")) continue; + config.deleteGroup(group); + } exportConfiguration(dia.selectedComponents(), &config); } } @@ -638,20 +639,20 @@ i18n("Failed to contact the KDE global shortcuts daemon\n") + errorString ); return; - } - QList components = componentsRc; + } - Q_FOREACH(const QDBusObjectPath &componentPath, components) { + const QList components = componentsRc; + for (const QDBusObjectPath &componentPath : components) { d->loadComponent(componentPath); - } // Q_FOREACH(component) + } } void KGlobalShortcutsEditor::save() { // The editors are responsible for the saving //qDebug() << "Save the changes"; - Q_FOREACH (ComponentData *cd, d->components) { + for (ComponentData *cd : qAsConst(d->components)) { cd->editor()->commit(); } } @@ -663,7 +664,7 @@ // In a first step clean out the current configurations. We do this // because we want to minimize the chance of conflicts. - Q_FOREACH (ComponentData *cd, d->components) { + for (ComponentData *cd : qAsConst(d->components)) { KConfigGroup group(config, cd->uniqueName()); //qDebug() << cd->uniqueName() << group.name(); if (group.exists()) { @@ -673,18 +674,18 @@ } // Now import the new configurations. - Q_FOREACH (ComponentData *cd, d->components) { + for (ComponentData *cd : qAsConst(d->components)) { KConfigGroup group(config, cd->uniqueName()); if (group.exists()) { //qDebug() << "Importing" << cd->uniqueName(); cd->editor()->importConfiguration(&group); } } } -void KGlobalShortcutsEditor::exportConfiguration(QStringList components, KConfig *config) const +void KGlobalShortcutsEditor::exportConfiguration(const QStringList &components, KConfig *config) const { - Q_FOREACH (const QString &componentFriendly, components) + for (const QString &componentFriendly : components) { QHash::Iterator iter = d->components.find(componentFriendly); if (iter == d->components.end()) @@ -705,15 +706,15 @@ { // The editors are responsible for the undo //qDebug() << "Undo the changes"; - Q_FOREACH (ComponentData *cd, d->components) { + for (ComponentData *cd : qAsConst(d->components)) { cd->editor()->undoChanges(); } } bool KGlobalShortcutsEditor::isModified() const { - Q_FOREACH (ComponentData *cd, d->components) { + for (const ComponentData *cd : qAsConst(d->components)) { if (cd->editor()->isModified()) { return true; } @@ -754,20 +755,20 @@ //qDebug() << shortcutContextsRc.error(); return false; } - QStringList shortcutContexts = shortcutContextsRc; + const QStringList shortcutContexts = shortcutContextsRc; // We add the shortcuts for all shortcut contexts to the editor. This // way the user keeps full control of it's shortcuts. - Q_FOREACH (const QString &shortcutContext, shortcutContexts) { + for (const QString &shortcutContext : shortcutContexts) { QDBusReply< QList > shortcutsRc = component.allShortcutInfos(shortcutContext); if (!shortcutsRc.isValid()) { //qDebug() << "allShortcutInfos() failed for " << componentPath.path() << shortcutContext; continue; } - QList shortcuts = shortcutsRc; + const QList shortcuts = shortcutsRc; // Shouldn't happen. But you never know if (shortcuts.isEmpty()) { //qDebug() << "Got shortcut context" << shortcutContext << "without shortcuts for" @@ -790,7 +791,7 @@ componentContextId); // Now add the shortcuts. - Q_FOREACH (const KGlobalShortcutInfo &shortcut, shortcuts) { + for (const KGlobalShortcutInfo &shortcut : shortcuts) { const QString &objectName = shortcut.uniqueName(); QAction *action = col->addAction(objectName); @@ -812,7 +813,7 @@ if (sc.count()>0) { KGlobalAccel::self()->setDefaultShortcut(action, sc); } - } // Q_FOREACH(shortcut) + } QString componentFriendlyName = shortcuts[0].componentFriendlyName(); @@ -824,21 +825,20 @@ q->addCollection(col, componentPath, componentContextId, componentFriendlyName ); - } // Q_FOREACH(context) + } return true; } void KGlobalShortcutsEditor::KGlobalShortcutsEditorPrivate::removeComponent( const QString &componentUnique ) - { +{ // TODO: Remove contexts too. - Q_FOREACH (const QString &text, components.keys()) - { - if (components.value(text)->uniqueName() == componentUnique) - { + const auto keys = components.keys(); + for (const QString &text : keys) { + if (components.value(text)->uniqueName() == componentUnique) { // Remove from QComboBox QModelIndexList results = proxyModel->match(proxyModel->index(0, 0), Qt::DisplayRole, text); Q_ASSERT(!results.isEmpty()); @@ -849,8 +849,8 @@ // Remove the componentData delete components.take(text); - } } } +} diff --git a/kcms/keys/select_scheme_dialog.cpp b/kcms/keys/select_scheme_dialog.cpp --- a/kcms/keys/select_scheme_dialog.cpp +++ b/kcms/keys/select_scheme_dialog.cpp @@ -70,8 +70,8 @@ ui->m_url->setMode(KFile::LocalOnly | KFile::ExistingOnly); - connect(ui->m_schemes, SIGNAL(activated(int)), - this, SLOT(schemeActivated(int))); + connect(ui->m_schemes, QOverload::of(&KComboBox::activated), + this, &SelectSchemeDialog::schemeActivated); connect(ui->m_url->lineEdit(), &QLineEdit::textChanged, this, &SelectSchemeDialog::slotUrlChanged); mOkButton->setEnabled(false);