aboutsummaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
Diffstat (limited to 'src/core')
-rw-r--r--src/core/kauthorized.cpp6
-rw-r--r--src/core/kconfig.cpp6
-rw-r--r--src/core/kconfigdata.cpp2
-rw-r--r--src/core/kconfiggroup.cpp4
-rw-r--r--src/core/kconfigini.cpp14
-rw-r--r--src/core/kcoreconfigskeleton.cpp46
-rw-r--r--src/core/kcoreconfigskeleton_p.h5
-rw-r--r--src/core/kdesktopfile.cpp32
-rw-r--r--src/core/kemailsettings.cpp6
9 files changed, 55 insertions, 66 deletions
diff --git a/src/core/kauthorized.cpp b/src/core/kauthorized.cpp
index 46b33ab2..a8784a1c 100644
--- a/src/core/kauthorized.cpp
+++ b/src/core/kauthorized.cpp
@@ -251,9 +251,9 @@ QStringList KAuthorized::authorizeControlModules(const QStringList &menuIds)
{
KConfigGroup cg(KSharedConfig::openConfig(), "KDE Control Module Restrictions");
QStringList result;
- for (QStringList::ConstIterator it = menuIds.begin(); it != menuIds.end(); ++it) {
- if (cg.readEntry(*it, true)) {
- result.append(*it);
+ for (const auto &id : menuIds) {
+ if (cg.readEntry(id, true)) {
+ result.append(id);
}
}
return result;
diff --git a/src/core/kconfig.cpp b/src/core/kconfig.cpp
index 7f53847f..cc3700e1 100644
--- a/src/core/kconfig.cpp
+++ b/src/core/kconfig.cpp
@@ -125,7 +125,7 @@ void KConfigPrivate::copyGroup(const QByteArray &source, const QByteArray &desti
// as dirty erroneously
bool dirtied = false;
- for (KEntryMap::ConstIterator entryMapIt(entryMap.constBegin()); entryMapIt != entryMap.constEnd(); ++entryMapIt) {
+ for (auto entryMapIt = entryMap.cbegin(); entryMapIt != entryMap.cend(); ++entryMapIt) {
const QByteArray &group = entryMapIt.key().mGroup;
if (!group.startsWith(source)) { // nothing to do
@@ -266,7 +266,7 @@ QStringList KConfig::groupList() const
Q_D(const KConfig);
QSet<QString> groups;
- for (KEntryMap::ConstIterator entryMapIt(d->entryMap.constBegin()); entryMapIt != d->entryMap.constEnd(); ++entryMapIt) {
+ for (auto entryMapIt = d->entryMap.cbegin(); entryMapIt != d->entryMap.cend(); ++entryMapIt) {
const KEntryKey &key = entryMapIt.key();
const QByteArray group = key.mGroup;
if (key.mKey.isNull() && !group.isEmpty() && group != "<default>" && group != "$Version") {
@@ -283,7 +283,7 @@ QStringList KConfigPrivate::groupList(const QByteArray &group) const
QByteArray theGroup = group + '\x1d';
QSet<QString> groups;
- for (KEntryMap::ConstIterator entryMapIt(entryMap.constBegin()); entryMapIt != entryMap.constEnd(); ++entryMapIt) {
+ for (auto entryMapIt = entryMap.cbegin(); entryMapIt != entryMap.cend(); ++entryMapIt) {
const KEntryKey &key = entryMapIt.key();
if (key.mKey.isNull() && key.mGroup.startsWith(theGroup)) {
const QString groupname = QString::fromUtf8(key.mGroup.mid(theGroup.length()));
diff --git a/src/core/kconfigdata.cpp b/src/core/kconfigdata.cpp
index 8ceea7ee..ada7125f 100644
--- a/src/core/kconfigdata.cpp
+++ b/src/core/kconfigdata.cpp
@@ -312,7 +312,7 @@ bool KEntryMap::revertEntry(const QByteArray &group, const QByteArray &key, KEnt
KEntryKey defaultKey(entry.key());
defaultKey.bDefault = true;
// qDebug() << "looking up default entry with key=" << defaultKey;
- const ConstIterator defaultEntry = constFind(defaultKey);
+ const auto defaultEntry = constFind(defaultKey);
if (defaultEntry != constEnd()) {
Q_ASSERT(defaultEntry.key().bDefault);
// qDebug() << "found, update entry";
diff --git a/src/core/kconfiggroup.cpp b/src/core/kconfiggroup.cpp
index 8fcfafe7..c065be81 100644
--- a/src/core/kconfiggroup.cpp
+++ b/src/core/kconfiggroup.cpp
@@ -126,8 +126,8 @@ QByteArray KConfigGroupPrivate::serializeList(const QList<QByteArray> &list)
QByteArray value;
if (!list.isEmpty()) {
- QList<QByteArray>::ConstIterator it = list.constBegin();
- const QList<QByteArray>::ConstIterator end = list.constEnd();
+ auto it = list.cbegin();
+ const auto end = list.cend();
value = QByteArray(*it).replace('\\', QByteArrayLiteral("\\\\")).replace(',', QByteArrayLiteral("\\,"));
diff --git a/src/core/kconfigini.cpp b/src/core/kconfigini.cpp
index dd24a959..8c81db8f 100644
--- a/src/core/kconfigini.cpp
+++ b/src/core/kconfigini.cpp
@@ -298,8 +298,8 @@ void KConfigIniBackend::writeEntries(const QByteArray &locale, QIODevice &file,
{
QByteArray currentGroup;
bool groupIsImmutable = false;
- const KEntryMapConstIterator end = map.constEnd();
- for (KEntryMapConstIterator it = map.constBegin(); it != end; ++it) {
+ const auto end = map.cend();
+ for (auto it = map.cbegin(); it != end; ++it) {
const KEntryKey &key = it.key();
// Either process the default group or all others
@@ -746,13 +746,13 @@ public:
QByteArray KConfigIniBackend::stringToPrintable(const QByteArray &aString, StringType type)
{
- if (aString.isEmpty()) {
+ const int len = aString.size();
+ if (len == 0) {
return aString;
}
- const int l = aString.length();
- QByteArray result; // Guesstimated that it's good to avoid data() initialization for a length of l*4
- result.resize(l * 4); // Maximum 4x as long as source string due to \x<ab> escape sequences
+ QByteArray result; // Guesstimated that it's good to avoid data() initialization for a length of len*4
+ result.resize(len * 4); // Maximum 4x as long as source string due to \x<ab> escape sequences
const char *s = aString.constData();
int i = 0;
char *data = result.data();
@@ -766,7 +766,7 @@ QByteArray KConfigIniBackend::stringToPrintable(const QByteArray &aString, Strin
}
Utf8Char utf8;
- for (; i < l; ++i /*, r++*/) {
+ for (; i < len; ++i) {
switch (s[i]) {
default:
if (utf8.addByte(s[i])) {
diff --git a/src/core/kcoreconfigskeleton.cpp b/src/core/kcoreconfigskeleton.cpp
index 669e0ce5..ab968023 100644
--- a/src/core/kcoreconfigskeleton.cpp
+++ b/src/core/kcoreconfigskeleton.cpp
@@ -11,6 +11,8 @@
#include <QUrl>
+#include <algorithm>
+
static QString obscuredString(const QString &str)
{
QString result;
@@ -606,7 +608,7 @@ void KCoreConfigSkeleton::ItemEnum::readConfig(KConfig *config)
int i = 0;
mReference = -1;
QString tmp = cg.readEntry(mKey, QString()).toLower();
- for (QList<Choice>::ConstIterator it = mChoices.constBegin(); it != mChoices.constEnd(); ++it, ++i) {
+ for (auto it = mChoices.cbegin(); it != mChoices.cend(); ++it, ++i) {
QString choiceName = (*it).name;
if (valueForChoice(choiceName).toLower() == tmp) {
mReference = i;
@@ -1180,19 +1182,18 @@ bool KCoreConfigSkeleton::useDefaults(bool b)
}
d->mUseDefaults = b;
- KConfigSkeletonItem::List::ConstIterator it;
- for (it = d->mItems.constBegin(); it != d->mItems.constEnd(); ++it) {
- (*it)->swapDefault();
+ for (auto *skelItem : qAsConst(d->mItems)) {
+ skelItem->swapDefault();
}
+
usrUseDefaults(b);
return !d->mUseDefaults;
}
void KCoreConfigSkeleton::setDefaults()
{
- KConfigSkeletonItem::List::ConstIterator it;
- for (it = d->mItems.constBegin(); it != d->mItems.constEnd(); ++it) {
- (*it)->setDefault();
+ for (auto *skelItem : qAsConst(d->mItems)) {
+ skelItem->setDefault();
}
usrSetDefaults();
}
@@ -1205,42 +1206,33 @@ void KCoreConfigSkeleton::load()
void KCoreConfigSkeleton::read()
{
- KConfigSkeletonItem::List::ConstIterator it;
- for (it = d->mItems.constBegin(); it != d->mItems.constEnd(); ++it) {
- (*it)->readConfig(d->mConfig.data());
+ for (auto *skelItem : qAsConst(d->mItems)) {
+ skelItem->readConfig(d->mConfig.data());
}
usrRead();
}
bool KCoreConfigSkeleton::isDefaults() const
{
- KConfigSkeletonItem::List::ConstIterator it;
- for (it = d->mItems.constBegin(); it != d->mItems.constEnd(); ++it) {
- if (!(*it)->isDefault()) {
- return false;
- }
- }
- return true;
+ return std::all_of(d->mItems.cbegin(), d->mItems.cend(), [](KConfigSkeletonItem *skelItem) {
+ return skelItem->isDefault();
+ });
}
bool KCoreConfigSkeleton::isSaveNeeded() const
{
- KConfigSkeletonItem::List::ConstIterator it;
- for (it = d->mItems.constBegin(); it != d->mItems.constEnd(); ++it) {
- if ((*it)->isSaveNeeded()) {
- return true;
- }
- }
- return false;
+ return std::any_of(d->mItems.cbegin(), d->mItems.cend(), [](KConfigSkeletonItem *skelItem) {
+ return skelItem->isSaveNeeded();
+ });
}
bool KCoreConfigSkeleton::save()
{
// qDebug();
- KConfigSkeletonItem::List::ConstIterator it;
- for (it = d->mItems.constBegin(); it != d->mItems.constEnd(); ++it) {
- (*it)->writeConfig(d->mConfig.data());
+ for (auto *skelItem : qAsConst(d->mItems)) {
+ skelItem->writeConfig(d->mConfig.data());
}
+
if (!usrSave()) {
return false;
}
diff --git a/src/core/kcoreconfigskeleton_p.h b/src/core/kcoreconfigskeleton_p.h
index d854cc43..a7417430 100644
--- a/src/core/kcoreconfigskeleton_p.h
+++ b/src/core/kcoreconfigskeleton_p.h
@@ -21,10 +21,7 @@ public:
}
~KCoreConfigSkeletonPrivate()
{
- KConfigSkeletonItem::List::ConstIterator it;
- for (it = mItems.constBegin(); it != mItems.constEnd(); ++it) {
- delete *it;
- }
+ qDeleteAll(mItems);
}
QString mCurrentGroup;
diff --git a/src/core/kdesktopfile.cpp b/src/core/kdesktopfile.cpp
index d5029ffe..cae8b98d 100644
--- a/src/core/kdesktopfile.cpp
+++ b/src/core/kdesktopfile.cpp
@@ -8,20 +8,22 @@
#include "kdesktopfile.h"
-#ifndef Q_OS_WIN
-#include <unistd.h>
-#endif
+#include "kauthorized.h"
+#include "kconfig_core_log_settings.h"
+#include "kconfig_p.h"
+#include "kconfiggroup.h"
+#include "kconfigini_p.h"
#include <QDir>
#include <QFileInfo>
#include <QStandardPaths>
#include <QUrl>
-#include "kauthorized.h"
-#include "kconfig_core_log_settings.h"
-#include "kconfig_p.h"
-#include "kconfiggroup.h"
-#include "kconfigini_p.h"
+#ifndef Q_OS_WIN
+#include <unistd.h>
+#endif
+
+#include <algorithm>
class KDesktopFilePrivate : public KConfigPrivate
{
@@ -281,17 +283,15 @@ bool KDesktopFile::tryExec() const
}
}
const QStringList list = d->desktopGroup.readEntry("X-KDE-AuthorizeAction", QStringList());
-
- if (!list.isEmpty()) {
- for (QStringList::ConstIterator it = list.begin(); it != list.end(); ++it) {
- if (!KAuthorized::authorize((*it).trimmed())) {
- return false;
- }
- }
+ const auto isNotAuthorized = std::any_of(list.cbegin(), list.cend(), [](const QString &action) {
+ return !KAuthorized::authorize(action.trimmed());
+ });
+ if (isNotAuthorized) {
+ return false;
}
// See also KService::username()
- bool su = d->desktopGroup.readEntry("X-KDE-SubstituteUID", false);
+ const bool su = d->desktopGroup.readEntry("X-KDE-SubstituteUID", false);
if (su) {
QString user = d->desktopGroup.readEntry("X-KDE-Username", QString());
if (user.isEmpty()) {
diff --git a/src/core/kemailsettings.cpp b/src/core/kemailsettings.cpp
index cfebe2a8..9074a0a2 100644
--- a/src/core/kemailsettings.cpp
+++ b/src/core/kemailsettings.cpp
@@ -227,9 +227,9 @@ KEMailSettings::KEMailSettings()
p->m_pConfig = new KConfig(QStringLiteral("emaildefaults"));
const QStringList groups = p->m_pConfig->groupList();
- for (QStringList::ConstIterator it = groups.begin(); it != groups.end(); ++it) {
- if ((*it).startsWith(QLatin1String("PROFILE_"))) {
- p->profiles += (*it).mid(8, (*it).length());
+ for (const auto &grp : groups) {
+ if (grp.startsWith(QLatin1String("PROFILE_"))) {
+ p->profiles += grp.mid(8 /* length of "PROFILE_" */);
}
}