Commit 66b159ff authored by Ahmad Samir's avatar Ahmad Samir

Port foreach (deprecated) to range-for

kcms/formats
kcms/touchpad
parent c416ec4f
......@@ -74,13 +74,13 @@ void KCMFormats::load()
{
QList<QLocale> allLocales = QLocale::matchingLocales(QLocale::AnyLanguage, QLocale::AnyScript, QLocale::AnyCountry);
std::sort(allLocales.begin(), allLocales.end(), countryLessThan);
foreach(QComboBox * combo, m_combos) {
for (QComboBox *combo : qAsConst(m_combos)) {
initCombo(combo, allLocales);
}
readConfig();
foreach(QComboBox * combo, m_combos) {
for (QComboBox *combo : qAsConst(m_combos)) {
connectCombo(combo);
}
......@@ -100,8 +100,8 @@ void KCMFormats::initCombo(QComboBox *combo, const QList<QLocale> & allLocales)
combo->clear();
const QString clabel = i18n("No change");
combo->addItem(clabel, QString());
foreach(const QLocale & l, allLocales) {
addLocaleToCombo(combo, l);
for (const auto &locale : allLocales) {
addLocaleToCombo(combo, locale);
}
}
......
......@@ -30,7 +30,7 @@ bool XlibTouchpad::applyConfig(const QVariantHash& p)
m_props.clear();
bool error = false;
Q_FOREACH(const QString &name, m_supported) {
for (const QString &name : qAsConst(m_supported)) {
QVariantHash::ConstIterator i = p.find(name);
if (i == p.end()) {
continue;
......@@ -85,7 +85,7 @@ bool XlibTouchpad::getConfig(QVariantHash& p)
m_props.clear();
bool error = false;
Q_FOREACH(const QString &name, m_supported) {
for (const QString &name : qAsConst(m_supported)) {
const Parameter *par = findParameter(name);
if (!par) {
continue;
......@@ -161,7 +161,7 @@ QVariant XlibTouchpad::getParameter(const Parameter* par)
void XlibTouchpad::flush()
{
Q_FOREACH(const QLatin1String &name, m_changed) {
for (const QLatin1String &name : qAsConst(m_changed)) {
m_props[name].set();
}
m_changed.clear();
......
......@@ -36,7 +36,8 @@ CustomConfigDialogManager::CustomConfigDialogManager(QWidget *parent,
{
static const QString kcfgPrefix("kcfg_");
Q_FOREACH(KConfigSkeletonItem *i, conf->items()) {
const auto itemList = conf->items();
for (KConfigSkeletonItem *i : itemList) {
QString name(i->name());
QWidget *child = parent->findChild<QWidget*>(kcfgPrefix + name);
......@@ -60,14 +61,9 @@ CustomConfigDialogManager::CustomConfigDialogManager(QWidget *parent,
}
QStringList choiceList;
Q_FOREACH(const KCoreConfigSkeleton::ItemEnum::Choice &c,
asEnum->choices())
{
if (c.label.isEmpty()) {
choiceList.append(c.name);
} else {
choiceList.append(c.label);
}
const auto asEnumChoices = asEnum->choices();
for (const auto &choice : asEnumChoices) {
choiceList.append(!choice.label.isEmpty() ? choice.label : choice.name);
}
KComboBox *asComboBox = qobject_cast<KComboBox *>(child);
......
......@@ -73,7 +73,8 @@ static void copyHelpFromBuddy(QObject *root)
asLabel->setWhatsThis(asLabel->buddy()->whatsThis());
}
}
Q_FOREACH(QObject *child, root->children()) {
const auto childList = root->children();
for (QObject *child : childList) {
copyHelpFromBuddy(child);
}
}
......@@ -239,8 +240,7 @@ void TouchpadConfigXlib::gotReplyFromDaemon(QDBusPendingCallWatcher *watch)
void TouchpadConfigXlib::updateMouseList()
{
QStringList mouses(
m_backend->listMouses(m_daemonSettings.mouseBlacklist()));
const QStringList mouses(m_backend->listMouses(m_daemonSettings.mouseBlacklist()));
for (int i = 0; i < m_mouseCombo->count(); ) {
if (!mouses.contains(m_mouseCombo->itemText(i))) {
......@@ -250,9 +250,9 @@ void TouchpadConfigXlib::updateMouseList()
}
}
Q_FOREACH (const QString &i, mouses) {
if (!m_mouseCombo->contains(i)) {
m_mouseCombo->addItem(i);
for (const QString &device : mouses) {
if (!m_mouseCombo->contains(device)) {
m_mouseCombo->addItem(device);
}
}
}
......
......@@ -45,8 +45,9 @@ TouchpadParametersBase::TouchpadParametersBase(const QString &configname,
QVariantHash TouchpadParametersBase::values() const
{
QVariantHash r;
Q_FOREACH(const KConfigSkeletonItem *i, items()) {
r[i->name()] = i->property();
const auto itemList = items();
for (const KConfigSkeletonItem *skel : itemList) {
r[skel->name()] = skel->property();
}
return r;
}
......
......@@ -101,8 +101,9 @@ void TouchpadDisabler::serviceNameFetchFinished(QDBusPendingCallWatcher *callWat
return;
}
QStringList allServices = reply.value();
Q_FOREACH (const QString &service, m_dependencies.watchedServices()) {
const QStringList allServices = reply.value();
const QStringList watchedList = m_dependencies.watchedServices();
for (const QString &service : watchedList) {
if (allServices.contains(service)) {
serviceRegistered(service);
}
......
......@@ -56,7 +56,8 @@ TouchpadGlobalActions::TouchpadGlobalActions(bool isConfiguration, QObject *pare
qWarning() << "Couldn't set global shortcut to Qt::Key_TouchpadToggle. There's another program using it, otherwise file a bug against kcm_touchpad";
}
Q_FOREACH (QAction *act, actions()) {
const auto actionsList = actions();
for (QAction *act : actionsList) {
KActionCollection::setShortcutsConfigurable(act,true);
if (isConfiguration) {
act->setProperty("isConfigurationAction", true);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment