diff options
| author | Ahmad Samir <a.samirh78@gmail.com> | 2021-02-22 17:38:09 +0200 | 
|---|---|---|
| committer | Ahmad Samir <a.samirh78@gmail.com> | 2021-02-22 17:38:09 +0200 | 
| commit | 8bed00ab34e31f2b9c70026d418d923913325798 (patch) | |
| tree | f289c15575415a36bc19c047a2037998e9b11ce8 /src | |
| parent | 186755fd56b58dc97250846c5305ef89f9487f86 (diff) | |
| download | kconfig-8bed00ab34e31f2b9c70026d418d923913325798.tar.gz kconfig-8bed00ab34e31f2b9c70026d418d923913325798.tar.bz2 | |
Run clang-format on all cpp/h files
NO_CHANGELOG
Diffstat (limited to 'src')
56 files changed, 1671 insertions, 1709 deletions
| diff --git a/src/core/bufferfragment_p.h b/src/core/bufferfragment_p.h index 3edbb6b6..f75af1d6 100644 --- a/src/core/bufferfragment_p.h +++ b/src/core/bufferfragment_p.h @@ -24,14 +24,16 @@  class KConfigIniBackend::BufferFragment  { -  public: - -    BufferFragment() : d(nullptr), len(0) +    BufferFragment() +        : d(nullptr) +        , len(0)      {      } -    BufferFragment(char *buf, int size) : d(buf), len(size) +    BufferFragment(char *buf, int size) +        : d(buf) +        , len(size)      {      } @@ -184,7 +186,7 @@ private:  uint qHash(const KConfigIniBackend::BufferFragment fragment)  { -    const uchar *p = reinterpret_cast<const uchar*>(fragment.constData()); +    const uchar *p = reinterpret_cast<const uchar *>(fragment.constData());      const int len = fragment.length();      // This algorithm is copied from qhash.cpp (Qt5 version). diff --git a/src/core/conversioncheck.h b/src/core/conversioncheck.h index 7f0e78a4..8537d81e 100644 --- a/src/core/conversioncheck.h +++ b/src/core/conversioncheck.h @@ -8,11 +8,11 @@  #ifndef CONVERSION_CHECK_H  #define CONVERSION_CHECK_H -#include <QString>  #include <QDate>  #include <QPoint> -#include <QSize>  #include <QRect> +#include <QSize> +#include <QString>  #include <QVariant>  class QColor; @@ -20,20 +20,21 @@ class QFont;  namespace ConversionCheck  { -  // used to distinguish between supported/unsupported types -struct supported { }; -struct unsupported { }; +struct supported { +}; +struct unsupported { +};  // traits type class to define support for constraints -template <typename T> +template<typename T>  struct QVconvertible {      typedef unsupported toQString;      typedef unsupported toQVariant;  };  // constraint classes -template <typename T> +template<typename T>  struct type_toQString {      void constraint()      { @@ -43,7 +44,7 @@ struct type_toQString {      typename QVconvertible<T>::toQString y;  }; -template <typename T> +template<typename T>  struct type_toQVariant {      void constraint()      { @@ -55,7 +56,7 @@ struct type_toQVariant {  // check if T is convertible to QString thru QVariant  // if not supported can't be used in QList<T> functions -template <typename T> +template<typename T>  inline void to_QString()  {      void (type_toQString<T>::*x)() = &type_toQString<T>::constraint; @@ -63,7 +64,7 @@ inline void to_QString()  }  // check if T is convertible to QVariant & supported in readEntry/writeEntry -template <typename T> +template<typename T>  inline void to_QVariant()  {      void (type_toQVariant<T>::*x)() = &type_toQVariant<T>::constraint; @@ -74,10 +75,11 @@ inline void to_QVariant()  // string_support - is supported by QVariant(type).toString(),  //                  can be used in QList<T> functions  // variant_support - has a QVariant constructor -#define QVConversions(type, string_support, variant_support) \ -    template <> struct QVconvertible<type> {\ -        typedef string_support toQString;\ -        typedef variant_support toQVariant;\ +#define QVConversions(type, string_support, variant_support)                                                                                                   \ +    template<>                                                                                                                                                 \ +    struct QVconvertible<type> {                                                                                                                               \ +        typedef string_support toQString;                                                                                                                      \ +        typedef variant_support toQVariant;                                                                                                                    \      }  // The only types needed here are the types handled in readEntry/writeEntry @@ -108,4 +110,3 @@ QVConversions(QList<QUrl>, unsupported, supported);  }  #endif - diff --git a/src/core/kauthorized.cpp b/src/core/kauthorized.cpp index 1abd83eb..a08586c5 100644 --- a/src/core/kauthorized.cpp +++ b/src/core/kauthorized.cpp @@ -15,41 +15,54 @@  #include <ksharedconfig.h>  #include <stdlib.h> // srand(), rand()  #ifndef Q_OS_WIN -#include <unistd.h>  #include <netdb.h> +#include <unistd.h>  #endif  #include <kconfiggroup.h> -#include <QRecursiveMutex>  #include <QMutexLocker> +#include <QRecursiveMutex>  extern bool kde_kiosk_exception;  class URLActionRule  {  public: -#define checkExactMatch(s, b) \ -    if (s.isEmpty()) b = true; \ -    else if (s[s.length()-1] == QLatin1Char('!')) \ -    { b = false; s.chop(1); } \ -    else b = true; -#define checkStartWildCard(s, b) \ -    if (s.isEmpty()) b = true; \ -    else if (s[0] == QLatin1Char('*')) \ -    { b = true; s.remove(0, 1); } \ -    else b = false; -#define checkEqual(s, b) \ -    b = (s == QLatin1String("=")); +#define checkExactMatch(s, b)                                                                                                                                  \ +    if (s.isEmpty())                                                                                                                                           \ +        b = true;                                                                                                                                              \ +    else if (s[s.length() - 1] == QLatin1Char('!')) {                                                                                                          \ +        b = false;                                                                                                                                             \ +        s.chop(1);                                                                                                                                             \ +    } else                                                                                                                                                     \ +        b = true; +#define checkStartWildCard(s, b)                                                                                                                               \ +    if (s.isEmpty())                                                                                                                                           \ +        b = true;                                                                                                                                              \ +    else if (s[0] == QLatin1Char('*')) {                                                                                                                       \ +        b = true;                                                                                                                                              \ +        s.remove(0, 1);                                                                                                                                        \ +    } else                                                                                                                                                     \ +        b = false; +#define checkEqual(s, b) b = (s == QLatin1String("="));      URLActionRule(const QByteArray &act, -                  const QString &bProt, const QString &bHost, const QString &bPath, -                  const QString &dProt, const QString &dHost, const QString &dPath, +                  const QString &bProt, +                  const QString &bHost, +                  const QString &bPath, +                  const QString &dProt, +                  const QString &dHost, +                  const QString &dPath,                    bool perm) -        : action(act), -          baseProt(bProt), baseHost(bHost), basePath(bPath), -          destProt(dProt), destHost(dHost), destPath(dPath), -          permission(perm) +        : action(act) +        , baseProt(bProt) +        , baseHost(bHost) +        , basePath(bPath) +        , destProt(dProt) +        , destHost(dHost) +        , destPath(dPath) +        , permission(perm)      {          checkExactMatch(baseProt, baseProtWildCard);          checkStartWildCard(baseHost, baseHostWildCard); @@ -64,13 +77,11 @@ public:      bool baseMatch(const QUrl &url, const QString &protClass) const      {          if (baseProtWildCard) { -            if (!baseProt.isEmpty() && !url.scheme().startsWith(baseProt) && -                    (protClass.isEmpty() || (protClass != baseProt))) { +            if (!baseProt.isEmpty() && !url.scheme().startsWith(baseProt) && (protClass.isEmpty() || (protClass != baseProt))) {                  return false;              }          } else { -            if ((url.scheme() != baseProt) && -                    (protClass.isEmpty() || (protClass != baseProt))) { +            if ((url.scheme() != baseProt) && (protClass.isEmpty() || (protClass != baseProt))) {                  return false;              }          } @@ -98,18 +109,15 @@ public:      bool destMatch(const QUrl &url, const QString &protClass, const QUrl &base, const QString &baseClass) const      {          if (destProtEqual) { -            if ((url.scheme() != base.scheme()) && -                    (protClass.isEmpty() || baseClass.isEmpty() || protClass != baseClass)) { +            if ((url.scheme() != base.scheme()) && (protClass.isEmpty() || baseClass.isEmpty() || protClass != baseClass)) {                  return false;              }          } else if (destProtWildCard) { -            if (!destProt.isEmpty() && !url.scheme().startsWith(destProt) && -                    (protClass.isEmpty() || (protClass != destProt))) { +            if (!destProt.isEmpty() && !url.scheme().startsWith(destProt) && (protClass.isEmpty() || (protClass != destProt))) {                  return false;              }          } else { -            if ((url.scheme() != destProt) && -                    (protClass.isEmpty() || (protClass != destProt))) { +            if ((url.scheme() != destProt) && (protClass.isEmpty() || (protClass != destProt))) {                  return false;              }          } @@ -151,8 +159,8 @@ public:      bool destProtWildCard : 1;      bool destHostWildCard : 1;      bool destPathWildCard : 1; -    bool destProtEqual    : 1; -    bool destHostEqual    : 1; +    bool destProtEqual : 1; +    bool destHostEqual : 1;      bool permission;  }; @@ -160,7 +168,8 @@ class KAuthorizedPrivate  {  public:      KAuthorizedPrivate() -        :   actionRestrictions(false), blockEverything(false) +        : actionRestrictions(false) +        , blockEverything(false)      {          Q_ASSERT_X(QCoreApplication::instance(), "KAuthorizedPrivate()", "There has to be an existing QCoreApplication::instance() pointer"); @@ -185,12 +194,12 @@ public:  };  Q_GLOBAL_STATIC(KAuthorizedPrivate, authPrivate) -#define MY_D KAuthorizedPrivate *d=authPrivate(); +#define MY_D KAuthorizedPrivate *d = authPrivate();  bool KAuthorized::authorize(const QString &genericAction)  { -    MY_D -    if (d->blockEverything) { +    MY_D if (d->blockEverything) +    {          return false;      } @@ -204,8 +213,8 @@ bool KAuthorized::authorize(const QString &genericAction)  bool KAuthorized::authorizeAction(const QString &action)  { -    MY_D -    if (d->blockEverything) { +    MY_D if (d->blockEverything) +    {          return false;      }      if (!d->actionRestrictions || action.isEmpty()) { @@ -235,8 +244,7 @@ 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) { +    for (QStringList::ConstIterator it = menuIds.begin(); it != menuIds.end(); ++it) {          if (cg.readEntry(*it, true)) {              result.append(*it);          } @@ -247,49 +255,37 @@ QStringList KAuthorized::authorizeControlModules(const QStringList &menuIds)  // Exported for unittests (e.g. in KIO, we're missing tests for this in kconfig)  KCONFIGCORE_EXPORT void loadUrlActionRestrictions(const KConfigGroup &cg)  { -    MY_D -    const QString Any; +    MY_D const QString Any;      d->urlActionRestrictions.clear(); -    d->urlActionRestrictions.append( -        URLActionRule("open", Any, Any, Any, Any, Any, Any, true)); -    d->urlActionRestrictions.append( -        URLActionRule("list", Any, Any, Any, Any, Any, Any, true)); -// TEST: -//  d->urlActionRestrictions.append( -//  URLActionRule("list", Any, Any, Any, Any, Any, Any, false)); -//  d->urlActionRestrictions.append( -//  URLActionRule("list", Any, Any, Any, "file", Any, QDir::homePath(), true)); -    d->urlActionRestrictions.append( -        URLActionRule("link", Any, Any, Any, QStringLiteral(":internet"), Any, Any, true)); -    d->urlActionRestrictions.append( -        URLActionRule("redirect", Any, Any, Any, QStringLiteral(":internet"), Any, Any, true)); +    d->urlActionRestrictions.append(URLActionRule("open", Any, Any, Any, Any, Any, Any, true)); +    d->urlActionRestrictions.append(URLActionRule("list", Any, Any, Any, Any, Any, Any, true)); +    // TEST: +    //  d->urlActionRestrictions.append( +    //  URLActionRule("list", Any, Any, Any, Any, Any, Any, false)); +    //  d->urlActionRestrictions.append( +    //  URLActionRule("list", Any, Any, Any, "file", Any, QDir::homePath(), true)); +    d->urlActionRestrictions.append(URLActionRule("link", Any, Any, Any, QStringLiteral(":internet"), Any, Any, true)); +    d->urlActionRestrictions.append(URLActionRule("redirect", Any, Any, Any, QStringLiteral(":internet"), Any, Any, true));      // We allow redirections to file: but not from internet protocols, redirecting to file:      // is very popular among io-slaves and we don't want to break them -    d->urlActionRestrictions.append( -        URLActionRule("redirect", Any, Any, Any, QStringLiteral("file"), Any, Any, true)); -    d->urlActionRestrictions.append( -        URLActionRule("redirect", QStringLiteral(":internet"), Any, Any, QStringLiteral("file"), Any, Any, false)); +    d->urlActionRestrictions.append(URLActionRule("redirect", Any, Any, Any, QStringLiteral("file"), Any, Any, true)); +    d->urlActionRestrictions.append(URLActionRule("redirect", QStringLiteral(":internet"), Any, Any, QStringLiteral("file"), Any, Any, false));      // local protocols may redirect everywhere -    d->urlActionRestrictions.append( -        URLActionRule("redirect", QStringLiteral(":local"), Any, Any, Any, Any, Any, true)); +    d->urlActionRestrictions.append(URLActionRule("redirect", QStringLiteral(":local"), Any, Any, Any, Any, Any, true));      // Anyone may redirect to about: -    d->urlActionRestrictions.append( -        URLActionRule("redirect", Any, Any, Any, QStringLiteral("about"), Any, Any, true)); +    d->urlActionRestrictions.append(URLActionRule("redirect", Any, Any, Any, QStringLiteral("about"), Any, Any, true));      // Anyone may redirect to mailto: -    d->urlActionRestrictions.append( -        URLActionRule("redirect", Any, Any, Any, QStringLiteral("mailto"), Any, Any, true)); +    d->urlActionRestrictions.append(URLActionRule("redirect", Any, Any, Any, QStringLiteral("mailto"), Any, Any, true));      // Anyone may redirect to itself, cq. within it's own group -    d->urlActionRestrictions.append( -        URLActionRule("redirect", Any, Any, Any, QStringLiteral("="), Any, Any, true)); +    d->urlActionRestrictions.append(URLActionRule("redirect", Any, Any, Any, QStringLiteral("="), Any, Any, true)); -    d->urlActionRestrictions.append( -        URLActionRule("redirect", QStringLiteral("about"), Any, Any, Any, Any, Any, true)); +    d->urlActionRestrictions.append(URLActionRule("redirect", QStringLiteral("about"), Any, Any, Any, Any, Any, true));      int count = cg.readEntry("rule_count", 0);      QString keyFormat = QStringLiteral("rule_%1"); @@ -326,8 +322,7 @@ KCONFIGCORE_EXPORT void loadUrlActionRestrictions(const KConfigGroup &cg)              urlPath.replace(0, 4, QDir::tempPath());          } -        d->urlActionRestrictions.append( -            URLActionRule(action, refProt, refHost, refPath, urlProt, urlHost, urlPath, bEnabled)); +        d->urlActionRestrictions.append(URLActionRule(action, refProt, refHost, refPath, urlProt, urlHost, urlPath, bEnabled));      }  } @@ -339,25 +334,23 @@ namespace KAuthorized   */  KCONFIGCORE_EXPORT void allowUrlActionInternal(const QString &action, const QUrl &_baseURL, const QUrl &_destURL)  { -    MY_D -    QMutexLocker locker((&d->mutex)); +    MY_D QMutexLocker locker((&d->mutex));      const QString basePath = _baseURL.adjusted(QUrl::StripTrailingSlash).path();      const QString destPath = _destURL.adjusted(QUrl::StripTrailingSlash).path(); -    d->urlActionRestrictions.append(URLActionRule -                                    (action.toLatin1(), _baseURL.scheme(), _baseURL.host(), basePath, -                                     _destURL.scheme(), _destURL.host(), destPath, true)); +    d->urlActionRestrictions.append( +        URLActionRule(action.toLatin1(), _baseURL.scheme(), _baseURL.host(), basePath, _destURL.scheme(), _destURL.host(), destPath, true));  }  /**   * Helper for KAuthorized::authorizeUrlAction in KIO   * @private   */ -KCONFIGCORE_EXPORT bool authorizeUrlActionInternal(const QString &action, const QUrl &_baseURL, const QUrl &_destURL, const QString &baseClass, const QString &destClass) +KCONFIGCORE_EXPORT bool +authorizeUrlActionInternal(const QString &action, const QUrl &_baseURL, const QUrl &_destURL, const QString &baseClass, const QString &destClass)  { -    MY_D -    QMutexLocker locker(&(d->mutex)); +    MY_D QMutexLocker locker(&(d->mutex));      if (d->blockEverything) {          return false;      } @@ -380,9 +373,8 @@ KCONFIGCORE_EXPORT bool authorizeUrlActionInternal(const QString &action, const      for (const URLActionRule &rule : qAsConst(d->urlActionRestrictions)) {          if ((result != rule.permission) && // No need to check if it doesn't make a difference -                (action == QLatin1String(rule.action.constData())) && -                rule.baseMatch(baseURL, baseClass) && -                rule.destMatch(destURL, destClass, baseURL, baseClass)) { +            (action == QLatin1String(rule.action.constData())) && rule.baseMatch(baseURL, baseClass) +            && rule.destMatch(destURL, destClass, baseURL, baseClass)) {              result = rule.permission;          }      } diff --git a/src/core/kauthorized.h b/src/core/kauthorized.h index 57a99e23..ac3cfa7e 100644 --- a/src/core/kauthorized.h +++ b/src/core/kauthorized.h @@ -16,13 +16,13 @@ class QUrl;  class QString;  /** -* The functions in this namespace provide the core of the Kiosk action -* restriction system; the KIO and KXMLGui frameworks build on this. -* -* The relevant settings are read from the application's KSharedConfig -* instance, so actions can be disabled on a per-application or global -* basis (by using the kdeglobals file). -*/ + * The functions in this namespace provide the core of the Kiosk action + * restriction system; the KIO and KXMLGui frameworks build on this. + * + * The relevant settings are read from the application's KSharedConfig + * instance, so actions can be disabled on a per-application or global + * basis (by using the kdeglobals file). + */  namespace KAuthorized  {  /** diff --git a/src/core/kconfig.cpp b/src/core/kconfig.cpp index ed389ea3..2da1dd48 100644 --- a/src/core/kconfig.cpp +++ b/src/core/kconfig.cpp @@ -19,20 +19,19 @@  #include "kconfigbackend_p.h"  #include "kconfiggroup.h" -#include <QCoreApplication> -#include <QProcess> +#include <QBasicMutex>  #include <QByteArray> +#include <QCoreApplication> +#include <QDir>  #include <QFile>  #include <QLocale> -#include <QDir> +#include <QMutexLocker>  #include <QProcess>  #include <QSet> -#include <QBasicMutex> -#include <QMutexLocker>  #if KCONFIG_USE_DBUS -#include <QDBusMessage>  #include <QDBusConnection> +#include <QDBusMessage>  #include <QDBusMetaType>  #endif @@ -51,12 +50,17 @@ static const Qt::CaseSensitivity sPathCaseSensitivity = Qt::CaseSensitive;  static const Qt::CaseSensitivity sPathCaseSensitivity = Qt::CaseInsensitive;  #endif -KConfigPrivate::KConfigPrivate(KConfig::OpenFlags flags, -                               QStandardPaths::StandardLocation resourceType) -    : openFlags(flags), resourceType(resourceType), mBackend(nullptr), -      bDynamicBackend(true),  bDirty(false), bReadDefaults(false), -      bFileImmutable(false), bForceGlobal(false), bSuppressGlobal(false), -      configState(KConfigBase::NoAccess) +KConfigPrivate::KConfigPrivate(KConfig::OpenFlags flags, QStandardPaths::StandardLocation resourceType) +    : openFlags(flags) +    , resourceType(resourceType) +    , mBackend(nullptr) +    , bDynamicBackend(true) +    , bDirty(false) +    , bReadDefaults(false) +    , bFileImmutable(false) +    , bForceGlobal(false) +    , bSuppressGlobal(false) +    , configState(KConfigBase::NoAccess)  {      const bool isTestMode = QStandardPaths::isTestModeEnabled();      // If sGlobalFileName was initialised and testMode has been toggled, @@ -68,7 +72,7 @@ KConfigPrivate::KConfigPrivate(KConfig::OpenFlags flags,      static QBasicAtomicInt use_etc_kderc = Q_BASIC_ATOMIC_INITIALIZER(-1);      if (use_etc_kderc.loadRelaxed() < 0) { -        use_etc_kderc.storeRelaxed( !qEnvironmentVariableIsSet("KDE_SKIP_KDERC"));    // for unit tests +        use_etc_kderc.storeRelaxed(!qEnvironmentVariableIsSet("KDE_SKIP_KDERC")); // for unit tests      }      if (use_etc_kderc.loadRelaxed()) {          etc_kderc = @@ -83,20 +87,20 @@ KConfigPrivate::KConfigPrivate(KConfig::OpenFlags flags,          }      } -//    if (!mappingsRegistered) { -//        KEntryMap tmp; -//        if (!etc_kderc.isEmpty()) { -//            QExplicitlySharedDataPointer<KConfigBackend> backend = KConfigBackend::create(etc_kderc, QLatin1String("INI")); -//            backend->parseConfig( "en_US", tmp, KConfigBackend::ParseDefaults); -//        } -//        const QString kde5rc(QDir::home().filePath(".kde5rc")); -//        if (KStandardDirs::checkAccess(kde5rc, R_OK)) { -//            QExplicitlySharedDataPointer<KConfigBackend> backend = KConfigBackend::create(kde5rc, QLatin1String("INI")); -//            backend->parseConfig( "en_US", tmp, KConfigBackend::ParseOptions()); -//        } -//        KConfigBackend::registerMappings(tmp); -//        mappingsRegistered = true; -//    } +    //    if (!mappingsRegistered) { +    //        KEntryMap tmp; +    //        if (!etc_kderc.isEmpty()) { +    //            QExplicitlySharedDataPointer<KConfigBackend> backend = KConfigBackend::create(etc_kderc, QLatin1String("INI")); +    //            backend->parseConfig( "en_US", tmp, KConfigBackend::ParseDefaults); +    //        } +    //        const QString kde5rc(QDir::home().filePath(".kde5rc")); +    //        if (KStandardDirs::checkAccess(kde5rc, R_OK)) { +    //            QExplicitlySharedDataPointer<KConfigBackend> backend = KConfigBackend::create(kde5rc, QLatin1String("INI")); +    //            backend->parseConfig( "en_US", tmp, KConfigBackend::ParseOptions()); +    //        } +    //        KConfigBackend::registerMappings(tmp); +    //        mappingsRegistered = true; +    //    }      setLocale(QLocale().name());  } @@ -110,8 +114,7 @@ bool KConfigPrivate::lockLocal()      return true;  } -void KConfigPrivate::copyGroup(const QByteArray &source, const QByteArray &destination, -                               KConfigGroup *otherGroup, KConfigBase::WriteConfigFlags flags) const +void KConfigPrivate::copyGroup(const QByteArray &source, const QByteArray &destination, KConfigGroup *otherGroup, KConfigBase::WriteConfigFlags flags) const  {      KEntryMap &otherMap = otherGroup->config()->d_ptr->entryMap;      const int len = source.length(); @@ -144,7 +147,7 @@ void KConfigPrivate::copyGroup(const QByteArray &source, const QByteArray &desti              newKey.mGroup.replace(0, len, destination);          } -        KEntry entry = entryMap[ entryMapIt.key() ]; +        KEntry entry = entryMap[entryMapIt.key()];          dirtied = entry.bDirty = flags & KConfigBase::Persistent;          if (flags & KConfigBase::Global) { @@ -182,10 +185,7 @@ QString KConfigPrivate::expandString(const QString &value)                  ++nEndPos;                  aVarName = aValue.midRef(nDollarPos + 2, nEndPos - nDollarPos - 3);              } else { -                while (nEndPos < aValue.length() && -                        (aValue[nEndPos].isNumber() || -                         aValue[nEndPos].isLetter() || -                         aValue[nEndPos] == QLatin1Char('_'))) { +                while (nEndPos < aValue.length() && (aValue[nEndPos].isNumber() || aValue[nEndPos].isLetter() || aValue[nEndPos] == QLatin1Char('_'))) {                      ++nEndPos;                  }                  aVarName = aValue.midRef(nDollarPos + 1, nEndPos - nDollarPos - 1); @@ -227,8 +227,7 @@ QString KConfigPrivate::expandString(const QString &value)      return aValue;  } -KConfig::KConfig(const QString &file, OpenFlags mode, -                 QStandardPaths::StandardLocation resourceType) +KConfig::KConfig(const QString &file, OpenFlags mode, QStandardPaths::StandardLocation resourceType)      : d_ptr(new KConfigPrivate(mode, resourceType))  {      d_ptr->changeFileName(file); // set the local file name @@ -298,7 +297,7 @@ QStringList KConfigPrivate::groupList(const QByteArray &group) const  static bool isGroupOrSubGroupMatch(const QByteArray &potentialGroup, const QByteArray &group)  {      if (!potentialGroup.startsWith(group)) { -      return false; +        return false;      }      return potentialGroup.length() == group.length() || potentialGroup[group.length()] == '\x1d';  } @@ -441,7 +440,7 @@ bool KConfig::sync()              if (d->configState == ReadWrite && !tmp->lock()) {                  qCWarning(KCONFIG_CORE_LOG) << "couldn't lock global file"; -                //unlock the local config if we're returning early +                // unlock the local config if we're returning early                  if (d->mBackend->isLocked()) {                      d->mBackend->unlock();                  } @@ -484,9 +483,7 @@ void KConfigPrivate::notifyClients(const QHash<QString, QByteArrayList> &changes      qDBusRegisterMetaType<QHash<QString, QByteArrayList>>(); -    QDBusMessage message = QDBusMessage::createSignal(path, -                                                                                                QStringLiteral("org.kde.kconfig.notify"), -                                                                                                QStringLiteral("ConfigChanged")); +    QDBusMessage message = QDBusMessage::createSignal(path, QStringLiteral("org.kde.kconfig.notify"), QStringLiteral("ConfigChanged"));      message.setArguments({QVariant::fromValue(changes)});      QDBusConnection::sessionBus().send(message);  #else @@ -520,7 +517,7 @@ void KConfig::checkUpdate(const QString &id, const QString &updateFile)      const QString cfg_id = updateFile + QLatin1Char(':') + id;      const QStringList ids = cg.readEntry("update_info", QStringList());      if (!ids.contains(cfg_id)) { -        QProcess::execute(QStringLiteral(KCONF_UPDATE_INSTALL_LOCATION), QStringList { QStringLiteral("--check"), updateFile }); +        QProcess::execute(QStringLiteral(KCONF_UPDATE_INSTALL_LOCATION), QStringList{QStringLiteral("--check"), updateFile});          reparseConfiguration();      }  } @@ -550,15 +547,13 @@ QString KConfig::name() const      return d->fileName;  } -  KConfig::OpenFlags KConfig::openFlags() const  {      Q_D(const KConfig);      return d->openFlags;  } -struct KConfigStaticData -{ +struct KConfigStaticData {      QString globalMainConfigName;      // Keep a copy so we can use it in global dtors, after qApp is gone      QStringList appArgs; @@ -572,7 +567,7 @@ void KConfig::setMainConfigName(const QString &str)  QString KConfig::mainConfigName()  { -    KConfigStaticData* data = globalData(); +    KConfigStaticData *data = globalData();      if (data->appArgs.isEmpty())          data->appArgs = QCoreApplication::arguments(); @@ -690,7 +685,7 @@ QStringList KConfigPrivate::getGlobalFiles() const  void KConfigPrivate::parseGlobalFiles()  {      const QStringList globalFiles = getGlobalFiles(); -//    qDebug() << "parsing global files" << globalFiles; +    //    qDebug() << "parsing global files" << globalFiles;      // TODO: can we cache the values in etc_kderc / other global files      //       on a per-application basis? @@ -712,7 +707,6 @@ void KConfigPrivate::parseConfigFiles()  {      // can only read the file if there is a backend and a file name      if (mBackend && !fileName.isEmpty()) { -          bFileImmutable = false;          QList<QString> files; @@ -745,7 +739,7 @@ void KConfigPrivate::parseConfigFiles()              files = QList<QString>(extraFiles.cbegin(), extraFiles.cend()) + files;          } -//        qDebug() << "parsing local files" << files; +        //        qDebug() << "parsing local files" << files;          const QByteArray utf8Locale = locale.toUtf8();          for (const QString &file : qAsConst(files)) { @@ -762,8 +756,7 @@ void KConfigPrivate::parseConfigFiles()                  }              } else {                  QExplicitlySharedDataPointer<KConfigBackend> backend = KConfigBackend::create(file); -                bFileImmutable = (backend->parseConfig(utf8Locale, entryMap, -                                                       KConfigBackend::ParseDefaults | KConfigBackend::ParseExpansions) +                bFileImmutable = (backend->parseConfig(utf8Locale, entryMap, KConfigBackend::ParseDefaults | KConfigBackend::ParseExpansions)                                    == KConfigBackend::ParseImmutable);              } @@ -844,7 +837,7 @@ bool KConfig::isImmutable() const  bool KConfig::isGroupImmutableImpl(const QByteArray &aGroup) const  {      Q_D(const KConfig); -    return isImmutable() || d->entryMap.getEntryOption(aGroup, {},{}, KEntryMap::EntryImmutable); +    return isImmutable() || d->entryMap.getEntryOption(aGroup, {}, {}, KEntryMap::EntryImmutable);  }  #if KCONFIGCORE_BUILD_DEPRECATED_SINCE(4, 0) @@ -925,13 +918,12 @@ bool KConfig::isConfigWritable(bool warnUser)          errorMsg += QCoreApplication::translate("KConfig", "Please contact your system administrator.");          QString cmdToExec = QStandardPaths::findExecutable(QStringLiteral("kdialog"));          if (!cmdToExec.isEmpty()) { -            QProcess::execute(cmdToExec, QStringList() -                              << QStringLiteral("--title") << QCoreApplication::applicationName() -                              << QStringLiteral("--msgbox") << errorMsg); +            QProcess::execute(cmdToExec, +                              QStringList() << QStringLiteral("--title") << QCoreApplication::applicationName() << QStringLiteral("--msgbox") << errorMsg);          }      } -    d->configState = allWritable ?  ReadWrite : ReadOnly; // update the read/write status +    d->configState = allWritable ? ReadWrite : ReadOnly; // update the read/write status      return allWritable;  } @@ -948,15 +940,13 @@ bool KConfig::hasGroupImpl(const QByteArray &aGroup) const  bool KConfigPrivate::canWriteEntry(const QByteArray &group, const char *key, bool isDefault) const  { -    if (bFileImmutable || -            entryMap.getEntryOption(group, key, KEntryMap::SearchLocalized, KEntryMap::EntryImmutable)) { +    if (bFileImmutable || entryMap.getEntryOption(group, key, KEntryMap::SearchLocalized, KEntryMap::EntryImmutable)) {          return isDefault;      }      return true;  } -void KConfigPrivate::putData(const QByteArray &group, const char *key, -                             const QByteArray &value, KConfigBase::WriteConfigFlags flags, bool expand) +void KConfigPrivate::putData(const QByteArray &group, const char *key, const QByteArray &value, KConfigBase::WriteConfigFlags flags, bool expand)  {      KEntryMap::EntryOptions options = convertToOptions(flags); @@ -987,8 +977,7 @@ void KConfigPrivate::revertEntry(const QByteArray &group, const char *key, KConf      }  } -QByteArray KConfigPrivate::lookupData(const QByteArray &group, const char *key, -                                      KEntryMap::SearchFlags flags) const +QByteArray KConfigPrivate::lookupData(const QByteArray &group, const char *key, KEntryMap::SearchFlags flags) const  {      if (bReadDefaults) {          flags |= KEntryMap::SearchDefaults; @@ -1000,8 +989,7 @@ QByteArray KConfigPrivate::lookupData(const QByteArray &group, const char *key,      return it->mValue;  } -QString KConfigPrivate::lookupData(const QByteArray &group, const char *key, -                                   KEntryMap::SearchFlags flags, bool *expand) const +QString KConfigPrivate::lookupData(const QByteArray &group, const char *key, KEntryMap::SearchFlags flags, bool *expand) const  {      if (bReadDefaults) {          flags |= KEntryMap::SearchDefaults; diff --git a/src/core/kconfig.h b/src/core/kconfig.h index 4b652059..792a9a6b 100644 --- a/src/core/kconfig.h +++ b/src/core/kconfig.h @@ -15,11 +15,11 @@  #include <kconfigcore_export.h> -#include <QString> -#include <QVariant>  #include <QByteArray>  #include <QList>  #include <QStandardPaths> +#include <QString> +#include <QVariant>  class KConfigGroup;  class KEntryMap; @@ -80,13 +80,13 @@ public:       * @see OpenFlags       */      enum OpenFlag { -        IncludeGlobals  = 0x01, ///< Blend kdeglobals into the config object. -        CascadeConfig   = 0x02, ///< Cascade to system-wide config files. +        IncludeGlobals = 0x01, ///< Blend kdeglobals into the config object. +        CascadeConfig = 0x02, ///< Cascade to system-wide config files. -        SimpleConfig    = 0x00, ///< Just a single config file. -        NoCascade       = IncludeGlobals, ///< Include user's globals, but omit system settings. -        NoGlobals       = CascadeConfig, ///< Cascade to system settings, but omit user's globals. -        FullConfig      = IncludeGlobals | CascadeConfig, ///< Fully-fledged config, including globals and cascading to system settings +        SimpleConfig = 0x00, ///< Just a single config file. +        NoCascade = IncludeGlobals, ///< Include user's globals, but omit system settings. +        NoGlobals = CascadeConfig, ///< Cascade to system settings, but omit user's globals. +        FullConfig = IncludeGlobals | CascadeConfig, ///< Fully-fledged config, including globals and cascading to system settings      };      /**       * Stores a combination of #OpenFlag values. @@ -121,7 +121,8 @@ public:       *       * @sa KSharedConfig::openConfig(const QString&, OpenFlags, QStandardPaths::StandardLocation)       */ -    explicit KConfig(const QString &file = QString(), OpenFlags mode = FullConfig, +    explicit KConfig(const QString &file = QString(), +                     OpenFlags mode = FullConfig,                       QStandardPaths::StandardLocation type = QStandardPaths::GenericConfigLocation);      /** diff --git a/src/core/kconfig_p.h b/src/core/kconfig_p.h index 917872f3..b201df17 100644 --- a/src/core/kconfig_p.h +++ b/src/core/kconfig_p.h @@ -11,18 +11,19 @@  #ifndef KCONFIG_P_H  #define KCONFIG_P_H -#include "kconfigdata.h"  #include "kconfigbackend_p.h" +#include "kconfigdata.h"  #include "kconfiggroup.h" -#include <QStringList> -#include <QStack> -#include <QFile>  #include <QDir> +#include <QFile> +#include <QStack> +#include <QStringList>  class KConfigPrivate  {      friend class KConfig; +  public:      KConfig::OpenFlags openFlags;      QStandardPaths::StandardLocation resourceType; @@ -31,19 +32,15 @@ public:      // functions for KConfigGroup      bool canWriteEntry(const QByteArray &group, const char *key, bool isDefault = false) const; -    QString lookupData(const QByteArray &group, const char *key, KEntryMap::SearchFlags flags, -                       bool *expand) const; +    QString lookupData(const QByteArray &group, const char *key, KEntryMap::SearchFlags flags, bool *expand) const;      QByteArray lookupData(const QByteArray &group, const char *key, KEntryMap::SearchFlags flags) const; -    void putData(const QByteArray &group, const char *key, const QByteArray &value, -                 KConfigBase::WriteConfigFlags flags, bool expand = false); -    void revertEntry(const QByteArray &group, const char *key, -                     KConfigBase::WriteConfigFlags flags); +    void putData(const QByteArray &group, const char *key, const QByteArray &value, KConfigBase::WriteConfigFlags flags, bool expand = false); +    void revertEntry(const QByteArray &group, const char *key, KConfigBase::WriteConfigFlags flags);      QStringList groupList(const QByteArray &group) const;      // copies the entries from @p source to @p otherGroup changing all occurrences      // of @p source with @p destination -    void copyGroup(const QByteArray &source, const QByteArray &destination, -                   KConfigGroup *otherGroup, KConfigBase::WriteConfigFlags flags) const; +    void copyGroup(const QByteArray &source, const QByteArray &destination, KConfigGroup *otherGroup, KConfigBase::WriteConfigFlags flags) const;      QStringList keyListImpl(const QByteArray &theGroup) const;      QSet<QByteArray> allSubGroups(const QByteArray &parentGroup) const;      bool hasNonDeletedEntries(const QByteArray &group) const; @@ -55,20 +52,19 @@ public:  protected:      QExplicitlySharedDataPointer<KConfigBackend> mBackend; -    KConfigPrivate(KConfig::OpenFlags flags, -                   QStandardPaths::StandardLocation type); +    KConfigPrivate(KConfig::OpenFlags flags, QStandardPaths::StandardLocation type);      virtual ~KConfigPrivate()      {      } -    bool bDynamicBackend: 1; // do we own the backend? +    bool bDynamicBackend : 1; // do we own the backend?  private: -    bool bDirty: 1; -    bool bReadDefaults: 1; -    bool bFileImmutable: 1; -    bool bForceGlobal: 1; -    bool bSuppressGlobal: 1; +    bool bDirty : 1; +    bool bReadDefaults : 1; +    bool bFileImmutable : 1; +    bool bForceGlobal : 1; +    bool bSuppressGlobal : 1;      static bool mappingsRegistered; diff --git a/src/core/kconfigbackend.cpp b/src/core/kconfigbackend.cpp index 0f95a5f6..13455dbd 100644 --- a/src/core/kconfigbackend.cpp +++ b/src/core/kconfigbackend.cpp @@ -10,14 +10,14 @@  #include "kconfigbackend_p.h"  #include <QDateTime> -#include <QStringList> +#include <QDebug>  #include <QDir>  #include <QFileInfo>  #include <QHash> -#include <QDebug> +#include <QStringList> -#include "kconfigini_p.h"  #include "kconfigdata.h" +#include "kconfigini_p.h"  typedef QExplicitlySharedDataPointer<KConfigBackend> BackendPtr; @@ -38,7 +38,7 @@ void KConfigBackend::registerMappings(const KEntryMap & /*entryMap*/)  BackendPtr KConfigBackend::create(const QString &file, const QString &sys)  { -    //qDebug() << "creating a backend for file" << file << "with system" << sys; +    // qDebug() << "creating a backend for file" << file << "with system" << sys;      KConfigBackend *backend = nullptr;  #if 0 // TODO port to Qt5 plugin loading @@ -61,7 +61,7 @@ BackendPtr KConfigBackend::create(const QString &file, const QString &sys)      Q_UNUSED(sys);  #endif -    //qDebug() << "default creation of the Ini backend"; +    // qDebug() << "default creation of the Ini backend";      backend = new KConfigIniBackend;      backend->setFilePath(file);      return BackendPtr(backend); diff --git a/src/core/kconfigbackend_p.h b/src/core/kconfigbackend_p.h index 7eb1774e..5b38634f 100644 --- a/src/core/kconfigbackend_p.h +++ b/src/core/kconfigbackend_p.h @@ -10,12 +10,12 @@  #ifndef KCONFIGBACKEND_H  #define KCONFIGBACKEND_H +#include <QExplicitlySharedDataPointer>  #include <QObject>  #include <QString> -#include <QExplicitlySharedDataPointer> -#include <kconfigcore_export.h>  #include <kconfigbase.h> +#include <kconfigcore_export.h>  class KConfigBackendPrivate;  class KEntryMap; @@ -48,8 +48,7 @@ public:       * @param system        the configuration system to use       * @return a KConfigBackend object to be used with KConfig       */ -    static QExplicitlySharedDataPointer<KConfigBackend> create(const QString &fileName = QString(), -            const QString &system = QString()); +    static QExplicitlySharedDataPointer<KConfigBackend> create(const QString &fileName = QString(), const QString &system = QString());      /**       * Registers mappings from directories/files to configuration systems @@ -99,9 +98,7 @@ public:       * @param options See ParseOptions       * @return See ParseInfo       */ -    virtual ParseInfo parseConfig(const QByteArray &locale, -                                  KEntryMap &pWriteBackMap, -                                  ParseOptions options = ParseOptions()) = 0; +    virtual ParseInfo parseConfig(const QByteArray &locale, KEntryMap &pWriteBackMap, ParseOptions options = ParseOptions()) = 0;      /**       * Write the @em dirty entries to permanent storage @@ -112,8 +109,7 @@ public:       *       * @return @c true if the write was successful, @c false if writing the configuration failed       */ -    virtual bool writeConfig(const QByteArray &locale, KEntryMap &entryMap, -                             WriteOptions options) = 0; +    virtual bool writeConfig(const QByteArray &locale, KEntryMap &entryMap, WriteOptions options) = 0;      /**       * If isWritable() returns false, writeConfig() will always fail. @@ -185,8 +181,7 @@ Q_DECLARE_OPERATORS_FOR_FLAGS(KConfigBackend::WriteOptions)  /**   * Register a KConfig backend when it is contained in a loadable module   */ -#define K_EXPORT_KCONFIGBACKEND(libname, classname) \ -    K_PLUGIN_FACTORY(factory, registerPlugin<classname>();) +#define K_EXPORT_KCONFIGBACKEND(libname, classname) K_PLUGIN_FACTORY(factory, registerPlugin<classname>();)  #endif  #endif // KCONFIGBACKEND_H diff --git a/src/core/kconfigbase.cpp b/src/core/kconfigbase.cpp index 6bae0e25..9eee6420 100644 --- a/src/core/kconfigbase.cpp +++ b/src/core/kconfigbase.cpp @@ -89,10 +89,13 @@ bool KConfigBase::isGroupImmutable(const char *aGroup) const  }  KConfigBase::~KConfigBase() -{} +{ +}  KConfigBase::KConfigBase() -{} +{ +}  void KConfigBase::virtual_hook(int, void *) -{} +{ +} diff --git a/src/core/kconfigbase.h b/src/core/kconfigbase.h index a7693275..79af8854 100644 --- a/src/core/kconfigbase.h +++ b/src/core/kconfigbase.h @@ -56,9 +56,9 @@ public:           */          Normal = Persistent,          /**< -        * Save the entry to the application specific config file without -        * a locale tag. This is the default. -        */ +         * Save the entry to the application specific config file without +         * a locale tag. This is the default. +         */      };      /** diff --git a/src/core/kconfigdata.cpp b/src/core/kconfigdata.cpp index 5ead8167..accf869b 100644 --- a/src/core/kconfigdata.cpp +++ b/src/core/kconfigdata.cpp @@ -11,28 +11,26 @@  QDebug operator<<(QDebug dbg, const KEntryKey &key)  { -    dbg.nospace() << "[" << key.mGroup << ", " << key.mKey << (key.bLocal ? " localized" : "") << -                  (key.bDefault ? " default" : "") << (key.bRaw ? " raw" : "") << "]"; +    dbg.nospace() << "[" << key.mGroup << ", " << key.mKey << (key.bLocal ? " localized" : "") << (key.bDefault ? " default" : "") << (key.bRaw ? " raw" : "") +                  << "]";      return dbg.space();  }  QDebug operator<<(QDebug dbg, const KEntry &entry)  { -    dbg.nospace() << "[" << entry.mValue << (entry.bDirty ? " dirty" : "") << -                  (entry.bGlobal ? " global" : "") << (entry.bImmutable ? " immutable" : "") << -                  (entry.bDeleted ? " deleted" : "") << (entry.bReverted ? " reverted" : "") << -                  (entry.bExpand ? " expand" : "") << "]"; +    dbg.nospace() << "[" << entry.mValue << (entry.bDirty ? " dirty" : "") << (entry.bGlobal ? " global" : "") << (entry.bImmutable ? " immutable" : "") +                  << (entry.bDeleted ? " deleted" : "") << (entry.bReverted ? " reverted" : "") << (entry.bExpand ? " expand" : "") << "]";      return dbg.space();  } -QMap< KEntryKey, KEntry >::Iterator KEntryMap::findExactEntry(const QByteArray &group, const QByteArray &key, KEntryMap::SearchFlags flags) +QMap<KEntryKey, KEntry>::Iterator KEntryMap::findExactEntry(const QByteArray &group, const QByteArray &key, KEntryMap::SearchFlags flags)  {      KEntryKey theKey(group, key, bool(flags & SearchLocalized), bool(flags & SearchDefaults));      return find(theKey);  } -QMap< KEntryKey, KEntry >::Iterator KEntryMap::findEntry(const QByteArray &group, const QByteArray &key, KEntryMap::SearchFlags flags) +QMap<KEntryKey, KEntry>::Iterator KEntryMap::findEntry(const QByteArray &group, const QByteArray &key, KEntryMap::SearchFlags flags)  {      KEntryKey theKey(group, key, false, bool(flags & SearchDefaults)); @@ -50,7 +48,7 @@ QMap< KEntryKey, KEntry >::Iterator KEntryMap::findEntry(const QByteArray &group      return find(theKey);  } -QMap< KEntryKey, KEntry >::ConstIterator KEntryMap::findEntry(const QByteArray &group, const QByteArray &key, KEntryMap::SearchFlags flags) const +QMap<KEntryKey, KEntry>::ConstIterator KEntryMap::findEntry(const QByteArray &group, const QByteArray &key, KEntryMap::SearchFlags flags) const  {      KEntryKey theKey(group, key, false, bool(flags & SearchDefaults)); @@ -95,11 +93,11 @@ bool KEntryMap::setEntry(const QByteArray &group, const QByteArray &key, const Q      if (it != end()) {          if (it->bImmutable) { -            return false;    // we cannot change this entry. Inherits group immutability. +            return false; // we cannot change this entry. Inherits group immutability.          }          k = it.key();          e = *it; -        //qDebug() << "found existing entry for key" << k; +        // qDebug() << "found existing entry for key" << k;          // If overridden entry is global and not default. And it's overridden by a non global          if (e.bGlobal && !(options & EntryGlobal) && !k.bDefault) {              e.bOverridesGlobal = true; @@ -111,7 +109,7 @@ bool KEntryMap::setEntry(const QByteArray &group, const QByteArray &key, const Q          if (cit == constEnd()) {              insert(KEntryKey(group), KEntry());          } else if (cit->bImmutable) { -            return false;    // this group is immutable, so we cannot change this entry. +            return false; // this group is immutable, so we cannot change this entry.          }          k = KEntryKey(group, key); @@ -127,14 +125,14 @@ bool KEntryMap::setEntry(const QByteArray &group, const QByteArray &key, const Q      e.bDirty = e.bDirty || (options & EntryDirty);      e.bNotify = e.bNotify || (options & EntryNotify); -    e.bGlobal = (options & EntryGlobal); //we can't use || here, because changes to entries in -    //kdeglobals would be written to kdeglobals instead -    //of the local config file, regardless of the globals flag +    e.bGlobal = (options & EntryGlobal); // we can't use || here, because changes to entries in +    // kdeglobals would be written to kdeglobals instead +    // of the local config file, regardless of the globals flag      e.bImmutable = e.bImmutable || (options & EntryImmutable);      if (value.isNull()) {          e.bDeleted = e.bDeleted || (options & EntryDeleted);      } else { -        e.bDeleted = false;    // setting a value to a previously deleted entry +        e.bDeleted = false; // setting a value to a previously deleted entry      }      e.bExpand = (options & EntryExpansion);      e.bReverted = false; @@ -145,17 +143,17 @@ bool KEntryMap::setEntry(const QByteArray &group, const QByteArray &key, const Q      }      if (newKey) { -        //qDebug() << "inserting" << k << "=" << value; +        // qDebug() << "inserting" << k << "=" << value;          insert(k, e);          if (k.bDefault) {              k.bDefault = false; -            //qDebug() << "also inserting" << k << "=" << value; +            // qDebug() << "also inserting" << k << "=" << value;              insert(k, e);          }          // TODO check for presence of unlocalized key          return true;      } else { -//                KEntry e2 = it.value(); +        //                KEntry e2 = it.value();          if (options & EntryLocalized) {              // fast exit checks for cases where the existing entry is more specific              const KEntry &e2 = it.value(); @@ -165,7 +163,7 @@ bool KEntryMap::setEntry(const QByteArray &group, const QByteArray &key, const Q              }          }          if (it.value() != e) { -            //qDebug() << "changing" << k << "from" << e.mValue << "to" << value; +            // qDebug() << "changing" << k << "from" << e.mValue << "to" << value;              it.value() = e;              if (k.bDefault) {                  KEntryKey nonDefaultKey(k); @@ -174,7 +172,7 @@ bool KEntryMap::setEntry(const QByteArray &group, const QByteArray &key, const Q              }              if (!(options & EntryLocalized)) {                  KEntryKey theKey(group, key, true, false); -                //qDebug() << "non-localized entry, remove localized one:" << theKey; +                // qDebug() << "non-localized entry, remove localized one:" << theKey;                  remove(theKey);                  if (k.bDefault) {                      theKey.bDefault = true; @@ -183,9 +181,9 @@ bool KEntryMap::setEntry(const QByteArray &group, const QByteArray &key, const Q              }              return true;          } else { -            //qDebug() << k << "was already set to" << e.mValue; +            // qDebug() << k << "was already set to" << e.mValue;              if (!(options & EntryLocalized)) { -                //qDebug() << "unchanged non-localized entry, remove localized one."; +                // qDebug() << "unchanged non-localized entry, remove localized one.";                  KEntryKey theKey(group, key, true, false);                  bool ret = false;                  Iterator cit = find(theKey); @@ -203,7 +201,7 @@ bool KEntryMap::setEntry(const QByteArray &group, const QByteArray &key, const Q                  }                  return ret;              } -            //qDebug() << "localized entry, unchanged, return false"; +            // qDebug() << "localized entry, unchanged, return false";              // When we are writing a default, we know that the non-              // default is the same as the default, so we can simply              // use the same branch. @@ -246,7 +244,7 @@ bool KEntryMap::hasEntry(const QByteArray &group, const QByteArray &key, KEntryM      return true;  } -bool KEntryMap::getEntryOption(const QMap< KEntryKey, KEntry >::ConstIterator &it, KEntryMap::EntryOption option) const +bool KEntryMap::getEntryOption(const QMap<KEntryKey, KEntry>::ConstIterator &it, KEntryMap::EntryOption option) const  {      if (it != constEnd()) {          switch (option) { @@ -272,7 +270,7 @@ bool KEntryMap::getEntryOption(const QMap< KEntryKey, KEntry >::ConstIterator &i      return false;  } -void KEntryMap::setEntryOption(QMap< KEntryKey, KEntry >::Iterator it, KEntryMap::EntryOption option, bool bf) +void KEntryMap::setEntryOption(QMap<KEntryKey, KEntry>::Iterator it, KEntryMap::EntryOption option, bool bf)  {      if (it != end()) {          switch (option) { @@ -305,18 +303,18 @@ bool KEntryMap::revertEntry(const QByteArray &group, const QByteArray &key, KEnt      Q_ASSERT((flags & KEntryMap::SearchDefaults) == 0);      Iterator entry = findEntry(group, key, flags);      if (entry != end()) { -        //qDebug() << "reverting" << entry.key() << " = " << entry->mValue; +        // qDebug() << "reverting" << entry.key() << " = " << entry->mValue;          if (entry->bReverted) { // already done before              return false;          }          KEntryKey defaultKey(entry.key());          defaultKey.bDefault = true; -        //qDebug() << "looking up default entry with key=" << defaultKey; +        // qDebug() << "looking up default entry with key=" << defaultKey;          const ConstIterator defaultEntry = constFind(defaultKey);          if (defaultEntry != constEnd()) {              Q_ASSERT(defaultEntry.key().bDefault); -            //qDebug() << "found, update entry"; +            // qDebug() << "found, update entry";              *entry = *defaultEntry; // copy default value, for subsequent lookups          } else {              entry->mValue = QByteArray(); @@ -325,7 +323,7 @@ bool KEntryMap::revertEntry(const QByteArray &group, const QByteArray &key, KEnt          entry->bDirty = true;          entry->bReverted = true; // skip it when writing out to disk -        //qDebug() << "Here's what we have now:" << *this; +        // qDebug() << "Here's what we have now:" << *this;          return true;      }      return false; diff --git a/src/core/kconfigdata.h b/src/core/kconfigdata.h index 36d90335..bb9ee717 100644 --- a/src/core/kconfigdata.h +++ b/src/core/kconfigdata.h @@ -11,9 +11,9 @@  #define KCONFIGDATA_H  #include <QByteArray> -#include <QString> -#include <QMap>  #include <QDebug> +#include <QMap> +#include <QString>  /**   * map/dict/list config node entry. @@ -22,60 +22,67 @@  struct KEntry {      /** Constructor. @internal */      KEntry() -        : mValue(), bDirty(false), -          bGlobal(false), bImmutable(false), bDeleted(false), bExpand(false), bReverted(false), -          bLocalizedCountry(false), bNotify(false), bOverridesGlobal(false) {} +        : mValue() +        , bDirty(false) +        , bGlobal(false) +        , bImmutable(false) +        , bDeleted(false) +        , bExpand(false) +        , bReverted(false) +        , bLocalizedCountry(false) +        , bNotify(false) +        , bOverridesGlobal(false) +    { +    }      /** @internal */      QByteArray mValue;      /**       * Must the entry be written back to disk?       */ -    bool    bDirty : 1; +    bool bDirty : 1;      /**       * Entry should be written to the global config file       */ -    bool    bGlobal: 1; +    bool bGlobal : 1;      /**       * Entry can not be modified.       */ -    bool    bImmutable: 1; +    bool bImmutable : 1;      /**       * Entry has been deleted.       */ -    bool    bDeleted: 1; +    bool bDeleted : 1;      /**       * Whether to apply dollar expansion or not.       */ -    bool    bExpand: 1; +    bool bExpand : 1;      /**       * Entry has been reverted to its default value (from a more global file).       */ -    bool    bReverted: 1; +    bool bReverted : 1;      /**       * Entry is for a localized key. If @c false the value references just language e.g. "de",       * if @c true the value references language and country, e.g. "de_DE".       **/ -    bool    bLocalizedCountry: 1; +    bool bLocalizedCountry : 1; -    bool     bNotify: 1; +    bool bNotify : 1;      /**       * Entry will need to be written on a non global file even if it matches default value       */ -    bool     bOverridesGlobal: 1; +    bool bOverridesGlobal : 1;  };  // These operators are used to check whether an entry which is about  // to be written equals the previous value. As such, this intentionally  // omits the dirty/notify flag from the comparison. -inline bool operator ==(const KEntry &k1, const KEntry &k2) +inline bool operator==(const KEntry &k1, const KEntry &k2)  { -    return k1.bGlobal == k2.bGlobal && k1.bImmutable == k2.bImmutable -           && k1.bDeleted == k2.bDeleted && k1.bExpand == k2.bExpand -           && k1.mValue == k2.mValue; +    return k1.bGlobal == k2.bGlobal && k1.bImmutable == k2.bImmutable && k1.bDeleted == k2.bDeleted && k1.bExpand == k2.bExpand && k1.mValue == k2.mValue;  } -inline bool operator !=(const KEntry &k1, const KEntry &k2) +inline bool operator!=(const KEntry &k1, const KEntry &k2)  {      return !(k1 == k2);  } @@ -87,9 +94,12 @@ inline bool operator !=(const KEntry &k1, const KEntry &k2)   */  struct KEntryKey {      /** Constructor. @internal */ -    KEntryKey(const QByteArray &_group = QByteArray(), -              const QByteArray &_key = QByteArray(), bool isLocalized = false, bool isDefault = false) -        : mGroup(_group), mKey(_key), bLocal(isLocalized), bDefault(isDefault), bRaw(false) +    KEntryKey(const QByteArray &_group = QByteArray(), const QByteArray &_key = QByteArray(), bool isLocalized = false, bool isDefault = false) +        : mGroup(_group) +        , mKey(_key) +        , bLocal(isLocalized) +        , bDefault(isDefault) +        , bRaw(false)      {          ;      } @@ -104,16 +114,16 @@ struct KEntryKey {      /**       * Entry is localised or not       */ -    bool    bLocal  : 1; +    bool bLocal : 1;      /**       * Entry indicates if this is a default value.       */ -    bool    bDefault: 1; +    bool bDefault : 1;      /** @internal       * Key is a raw unprocessed key.       * @warning this should only be set during merging, never for normal use.       */ -    bool    bRaw: 1; +    bool bRaw : 1;  };  /** @@ -121,7 +131,7 @@ struct KEntryKey {   * non-localized, non-localized-default   * @internal   */ -inline bool operator <(const KEntryKey &k1, const KEntryKey &k2) +inline bool operator<(const KEntryKey &k1, const KEntryKey &k2)  {      int result = qstrcmp(k1.mGroup, k2.mGroup);      if (result != 0) { @@ -172,45 +182,38 @@ public:      };      Q_DECLARE_FLAGS(EntryOptions, EntryOption) -    Iterator findExactEntry(const QByteArray &group, const QByteArray &key = QByteArray(), -                            SearchFlags flags = SearchFlags()); +    Iterator findExactEntry(const QByteArray &group, const QByteArray &key = QByteArray(), SearchFlags flags = SearchFlags()); -    Iterator findEntry(const QByteArray &group, const QByteArray &key = QByteArray(), -                       SearchFlags flags = SearchFlags()); +    Iterator findEntry(const QByteArray &group, const QByteArray &key = QByteArray(), SearchFlags flags = SearchFlags()); -    ConstIterator findEntry(const QByteArray &group, const QByteArray &key = QByteArray(), -                            SearchFlags flags = SearchFlags()) const; +    ConstIterator findEntry(const QByteArray &group, const QByteArray &key = QByteArray(), SearchFlags flags = SearchFlags()) const;      /**       * Returns true if the entry gets dirtied or false in other case       */ -    bool setEntry(const QByteArray &group, const QByteArray &key, -                  const QByteArray &value, EntryOptions options); +    bool setEntry(const QByteArray &group, const QByteArray &key, const QByteArray &value, EntryOptions options); -    void setEntry(const QByteArray &group, const QByteArray &key, -                  const QString &value, EntryOptions options) +    void setEntry(const QByteArray &group, const QByteArray &key, const QString &value, EntryOptions options)      {          setEntry(group, key, value.toUtf8(), options);      } -    QString getEntry(const QByteArray &group, const QByteArray &key, +    QString getEntry(const QByteArray &group, +                     const QByteArray &key,                       const QString &defaultValue = QString(),                       SearchFlags flags = SearchFlags(),                       bool *expand = nullptr) const; -    bool hasEntry(const QByteArray &group, const QByteArray &key = QByteArray(), -                  SearchFlags flags = SearchFlags()) const; +    bool hasEntry(const QByteArray &group, const QByteArray &key = QByteArray(), SearchFlags flags = SearchFlags()) const;      bool getEntryOption(const ConstIterator &it, EntryOption option) const; -    bool getEntryOption(const QByteArray &group, const QByteArray &key, -                        SearchFlags flags, EntryOption option) const +    bool getEntryOption(const QByteArray &group, const QByteArray &key, SearchFlags flags, EntryOption option) const      {          return getEntryOption(findEntry(group, key, flags), option);      }      void setEntryOption(Iterator it, EntryOption option, bool bf); -    void setEntryOption(const QByteArray &group, const QByteArray &key, SearchFlags flags, -                        EntryOption option, bool bf) +    void setEntryOption(const QByteArray &group, const QByteArray &key, SearchFlags flags, EntryOption option, bool bf)      {          setEntryOption(findEntry(group, key, flags), option, bf);      } diff --git a/src/core/kconfiggroup.cpp b/src/core/kconfiggroup.cpp index d900458f..8fcfafe7 100644 --- a/src/core/kconfiggroup.cpp +++ b/src/core/kconfiggroup.cpp @@ -11,41 +11,50 @@  #include "kconfiggroup_p.h"  #include "kconfig.h" -#include "kconfig_p.h"  #include "kconfig_core_log_settings.h" -#include "ksharedconfig.h" +#include "kconfig_p.h"  #include "kconfigdata.h" +#include "ksharedconfig.h"  #include <QDate> -#include <QSharedData> +#include <QDir>  #include <QFile>  #include <QPoint>  #include <QRect> +#include <QSharedData>  #include <QString>  #include <QTextStream> -#include <QDir>  #include <QUrl> -#include <stdlib.h>  #include <math.h> +#include <stdlib.h>  class KConfigGroupPrivate : public QSharedData  {  public:      KConfigGroupPrivate(KConfig *owner, bool isImmutable, bool isConst, const QByteArray &name) -        : mOwner(owner), mName(name), bImmutable(isImmutable), bConst(isConst) +        : mOwner(owner) +        , mName(name) +        , bImmutable(isImmutable) +        , bConst(isConst)      {      }      KConfigGroupPrivate(const KSharedConfigPtr &owner, const QByteArray &name) -        : sOwner(owner), mOwner(sOwner.data()), mName(name), -          bImmutable(name.isEmpty() ? owner->isImmutable() : owner->isGroupImmutable(name)), bConst(false) +        : sOwner(owner) +        , mOwner(sOwner.data()) +        , mName(name) +        , bImmutable(name.isEmpty() ? owner->isImmutable() : owner->isGroupImmutable(name)) +        , bConst(false)      {      }      KConfigGroupPrivate(KConfigGroup *parent, bool isImmutable, bool isConst, const QByteArray &name) -        : sOwner(parent->d->sOwner), mOwner(parent->d->mOwner), mName(name), -          bImmutable(isImmutable), bConst(isConst) +        : sOwner(parent->d->sOwner) +        , mOwner(parent->d->mOwner) +        , mName(name) +        , bImmutable(isImmutable) +        , bConst(isConst)      {          if (!parent->d->mName.isEmpty()) {              mParent = parent->d; @@ -53,8 +62,11 @@ public:      }      KConfigGroupPrivate(const KConfigGroupPrivate *other, bool isImmutable, const QByteArray &name) -        : sOwner(other->sOwner), mOwner(other->mOwner), mName(name), -          bImmutable(isImmutable), bConst(other->bConst) +        : sOwner(other->sOwner) +        , mOwner(other->mOwner) +        , mName(name) +        , bImmutable(isImmutable) +        , bConst(other->bConst)      {          if (!other->mName.isEmpty()) {              mParent = const_cast<KConfigGroupPrivate *>(other); @@ -67,8 +79,8 @@ public:      QByteArray mName;      /* bitfield */ -    const bool bImmutable: 1; // is this group immutable? -    const bool bConst: 1; // is this group read-only? +    const bool bImmutable : 1; // is this group immutable? +    const bool bConst : 1; // is this group read-only?      QByteArray fullName() const      { @@ -94,10 +106,7 @@ public:          return fullName() + '\x1d' + aGroup;      } -    static QExplicitlySharedDataPointer<KConfigGroupPrivate> create(KConfigBase *master, -            const QByteArray &name, -            bool isImmutable, -            bool isConst) +    static QExplicitlySharedDataPointer<KConfigGroupPrivate> create(KConfigBase *master, const QByteArray &name, bool isImmutable, bool isConst)      {          QExplicitlySharedDataPointer<KConfigGroupPrivate> data;          if (dynamic_cast<KConfigGroup *>(master)) { @@ -198,9 +207,7 @@ static QVector<qreal> asRealList(const QByteArray &string)  static QString errString(const char *pKey, const QByteArray &value, const QVariant &aDefault)  {      return QStringLiteral("\"%1\" - conversion of \"%3\" to %2 failed") -           .arg( QString::fromLatin1(pKey), -                 QString::fromLatin1(QVariant::typeToName(aDefault.type())), -                 QString::fromLatin1(value) ); +        .arg(QString::fromLatin1(pKey), QString::fromLatin1(QVariant::typeToName(aDefault.type())), QString::fromLatin1(value));  }  static QString formatError(int expected, int got) @@ -249,8 +256,7 @@ QVariant KConfigGroup::convertToQVariant(const char *pKey, const QByteArray &val          const auto list = asIntList(value);          if (list.count() != 2) { -            qCWarning(KCONFIG_CORE_LOG) << errString(pKey, value, aDefault) -                       << formatError(2, list.count()); +            qCWarning(KCONFIG_CORE_LOG) << errString(pKey, value, aDefault) << formatError(2, list.count());              return aDefault;          }          return QPoint(list.at(0), list.at(1)); @@ -259,8 +265,7 @@ QVariant KConfigGroup::convertToQVariant(const char *pKey, const QByteArray &val          const auto list = asRealList(value);          if (list.count() != 2) { -            qCWarning(KCONFIG_CORE_LOG) << errString(pKey, value, aDefault) -                       << formatError(2, list.count()); +            qCWarning(KCONFIG_CORE_LOG) << errString(pKey, value, aDefault) << formatError(2, list.count());              return aDefault;          }          return QPointF(list.at(0), list.at(1)); @@ -269,8 +274,7 @@ QVariant KConfigGroup::convertToQVariant(const char *pKey, const QByteArray &val          const auto list = asIntList(value);          if (list.count() != 4) { -            qCWarning(KCONFIG_CORE_LOG) << errString(pKey, value, aDefault) -                       << formatError(4, list.count()); +            qCWarning(KCONFIG_CORE_LOG) << errString(pKey, value, aDefault) << formatError(4, list.count());              return aDefault;          }          const QRect rect(list.at(0), list.at(1), list.at(2), list.at(3)); @@ -284,8 +288,7 @@ QVariant KConfigGroup::convertToQVariant(const char *pKey, const QByteArray &val          const auto list = asRealList(value);          if (list.count() != 4) { -            qCWarning(KCONFIG_CORE_LOG) << errString(pKey, value, aDefault) -                       << formatError(4, list.count()); +            qCWarning(KCONFIG_CORE_LOG) << errString(pKey, value, aDefault) << formatError(4, list.count());              return aDefault;          }          const QRectF rect(list.at(0), list.at(1), list.at(2), list.at(3)); @@ -299,8 +302,7 @@ QVariant KConfigGroup::convertToQVariant(const char *pKey, const QByteArray &val          const auto list = asIntList(value);          if (list.count() != 2) { -            qCWarning(KCONFIG_CORE_LOG) << errString(pKey, value, aDefault) -                       << formatError(2, list.count()); +            qCWarning(KCONFIG_CORE_LOG) << errString(pKey, value, aDefault) << formatError(2, list.count());              return aDefault;          }          const QSize size(list.at(0), list.at(1)); @@ -314,8 +316,7 @@ QVariant KConfigGroup::convertToQVariant(const char *pKey, const QByteArray &val          const auto list = asRealList(value);          if (list.count() != 2) { -            qCWarning(KCONFIG_CORE_LOG) << errString(pKey, value, aDefault) -                       << formatError(2, list.count()); +            qCWarning(KCONFIG_CORE_LOG) << errString(pKey, value, aDefault) << formatError(2, list.count());              return aDefault;          }          const QSizeF size(list.at(0), list.at(1)); @@ -328,8 +329,7 @@ QVariant KConfigGroup::convertToQVariant(const char *pKey, const QByteArray &val      case QMetaType::QDateTime: {          const auto list = asRealList(value);          if (list.count() < 6) { -            qCWarning(KCONFIG_CORE_LOG) << errString(pKey, value, aDefault) -                       << formatError(6, list.count()); +            qCWarning(KCONFIG_CORE_LOG) << errString(pKey, value, aDefault) << formatError(6, list.count());              return aDefault;          }          const QDate date(list.at(0), list.at(1), list.at(2)); @@ -348,11 +348,10 @@ QVariant KConfigGroup::convertToQVariant(const char *pKey, const QByteArray &val      case QMetaType::QDate: {          auto list = asIntList(value);          if (list.count() == 6) { -            list = list.mid(0, 3);    // don't break config files that stored QDate as QDateTime +            list = list.mid(0, 3); // don't break config files that stored QDate as QDateTime          }          if (list.count() != 3) { -            qCWarning(KCONFIG_CORE_LOG) << errString(pKey, value, aDefault) -                       << formatError(3, list.count()); +            qCWarning(KCONFIG_CORE_LOG) << errString(pKey, value, aDefault) << formatError(3, list.count());              return aDefault;          }          const QDate date(list.at(0), list.at(1), list.at(2)); @@ -364,10 +363,9 @@ QVariant KConfigGroup::convertToQVariant(const char *pKey, const QByteArray &val      }      case QMetaType::QColor:      case QMetaType::QFont: -        qCWarning(KCONFIG_CORE_LOG) << "KConfigGroup::readEntry was passed GUI type '" -                   << aDefault.typeName() -                   << "' but KConfigGui isn't linked! If it is linked to your program, " -                   "this is a platform bug. Please inform the KDE developers"; +        qCWarning(KCONFIG_CORE_LOG) << "KConfigGroup::readEntry was passed GUI type '" << aDefault.typeName() +                                    << "' but KConfigGui isn't linked! If it is linked to your program, " +                                       "this is a platform bug. Please inform the KDE developers";          break;      case QMetaType::QUrl:          return QUrl(QString::fromUtf8(value)); @@ -381,12 +379,12 @@ QVariant KConfigGroup::convertToQVariant(const char *pKey, const QByteArray &val  }  #ifdef Q_OS_WIN -# include <QDir> +#include <QDir>  #endif  static bool cleanHomeDirPath(QString &path, const QString &homeDir)  { -#ifdef Q_OS_WIN //safer +#ifdef Q_OS_WIN // safer      if (!QDir::toNativeSeparators(path).startsWith(QDir::toNativeSeparators(homeDir))) {          return false;      } @@ -406,7 +404,7 @@ static bool cleanHomeDirPath(QString &path, const QString &homeDir)      return false;  } -static QString translatePath(QString path)   // krazy:exclude=passbyvalue +static QString translatePath(QString path) // krazy:exclude=passbyvalue  {      if (path.isEmpty()) {          return path; @@ -429,9 +427,7 @@ static QString translatePath(QString path)   // krazy:exclude=passbyvalue      const QString homeDir0 = QFile::decodeName(qgetenv("HOME"));      const QString homeDir1 = QDir::homePath();      const QString homeDir2 = QDir(homeDir1).canonicalPath(); -    if (cleanHomeDirPath(path, homeDir0) || -            cleanHomeDirPath(path, homeDir1) || -            cleanHomeDirPath(path, homeDir2)) { +    if (cleanHomeDirPath(path, homeDir0) || cleanHomeDirPath(path, homeDir1) || cleanHomeDirPath(path, homeDir2)) {          // qDebug() << "Path was replaced\n";      } @@ -442,7 +438,8 @@ static QString translatePath(QString path)   // krazy:exclude=passbyvalue      return path;  } -KConfigGroup::KConfigGroup() : d() +KConfigGroup::KConfigGroup() +    : d()  {  } @@ -452,8 +449,7 @@ bool KConfigGroup::isValid() const  }  KConfigGroupGui _kde_internal_KConfigGroupGui; -static inline bool readEntryGui(const QByteArray &data, const char *key, const QVariant &input, -                                QVariant &output) +static inline bool readEntryGui(const QByteArray &data, const char *key, const QVariant &input, QVariant &output)  {      if (_kde_internal_KConfigGroupGui.readEntryGui) {          return _kde_internal_KConfigGroupGui.readEntryGui(data, key, input, output); @@ -461,8 +457,7 @@ static inline bool readEntryGui(const QByteArray &data, const char *key, const Q      return false;  } -static inline bool writeEntryGui(KConfigGroup *cg, const char *key, const QVariant &input, -                                 KConfigGroup::WriteConfigFlags flags) +static inline bool writeEntryGui(KConfigGroup *cg, const char *key, const QVariant &input, KConfigGroup::WriteConfigFlags flags)  {      if (_kde_internal_KConfigGroupGui.writeEntryGui) {          return _kde_internal_KConfigGroupGui.writeEntryGui(cg, key, input, flags); @@ -535,8 +530,7 @@ const KConfigGroup KConfigGroup::groupImpl(const QByteArray &aGroup) const      KConfigGroup newGroup; -    newGroup.d = new KConfigGroupPrivate(const_cast<KConfigGroup *>(this), isGroupImmutableImpl(aGroup), -                                         true, aGroup); +    newGroup.d = new KConfigGroupPrivate(const_cast<KConfigGroup *>(this), isGroupImmutableImpl(aGroup), true, aGroup);      return newGroup;  } @@ -634,8 +628,7 @@ bool KConfigGroup::isEntryImmutable(const char *key) const  {      Q_ASSERT_X(isValid(), "KConfigGroup::isEntryImmutable", "accessing an invalid group"); -    return (isImmutable() || -            !config()->d_func()->canWriteEntry(d->fullName(), key, config()->readDefaults())); +    return (isImmutable() || !config()->d_func()->canWriteEntry(d->fullName(), key, config()->readDefaults()));  }  bool KConfigGroup::isEntryImmutable(const QString &key) const @@ -676,8 +669,7 @@ QString KConfigGroup::readEntry(const char *key, const QString &aDefault) const      bool expand = false;      // read value from the entry map -    QString aValue = config()->d_func()->lookupData(d->fullName(), key, KEntryMap::SearchLocalized, -                     &expand); +    QString aValue = config()->d_func()->lookupData(d->fullName(), key, KEntryMap::SearchLocalized, &expand);      if (aValue.isNull()) {          aValue = aDefault;      } @@ -809,8 +801,7 @@ QString KConfigGroup::readPathEntry(const char *key, const QString &aDefault) co      bool expand = false; -    QString aValue = config()->d_func()->lookupData(d->fullName(), key, KEntryMap::SearchLocalized, -                     &expand); +    QString aValue = config()->d_func()->lookupData(d->fullName(), key, KEntryMap::SearchLocalized, &expand);      if (aValue.isNull()) {          aValue = aDefault;      } @@ -861,8 +852,7 @@ void KConfigGroup::writeEntry(const char *key, const char *value, WriteConfigFla      writeEntry(key, QVariant(QString::fromLatin1(value)), pFlags);  } -void KConfigGroup::writeEntry(const char *key, const QByteArray &value, -                              WriteConfigFlags flags) +void KConfigGroup::writeEntry(const char *key, const QByteArray &value, WriteConfigFlags flags)  {      Q_ASSERT_X(isValid(), "KConfigGroup::writeEntry", "accessing an invalid group");      Q_ASSERT_X(!d->bConst, "KConfigGroup::writeEntry", "writing to a read-only group"); @@ -870,8 +860,7 @@ void KConfigGroup::writeEntry(const char *key, const QByteArray &value,      config()->d_func()->putData(d->fullName(), key, value.isNull() ? QByteArray("") : value, flags);  } -void KConfigGroup::writeEntry(const QString &key, const QByteArray &value, -                              WriteConfigFlags pFlags) +void KConfigGroup::writeEntry(const QString &key, const QByteArray &value, WriteConfigFlags pFlags)  {      writeEntry(key.toUtf8().constData(), value, pFlags);  } @@ -915,14 +904,13 @@ void KConfigGroup::writeEntry(const char *key, const QVariantList &list, WriteCo      writeEntry(key, KConfigGroupPrivate::serializeList(data), flags);  } -void KConfigGroup::writeEntry(const char *key, const QVariant &value, -                              WriteConfigFlags flags) +void KConfigGroup::writeEntry(const char *key, const QVariant &value, WriteConfigFlags flags)  {      Q_ASSERT_X(isValid(), "KConfigGroup::writeEntry", "accessing an invalid group");      Q_ASSERT_X(!d->bConst, "KConfigGroup::writeEntry", "writing to a read-only group");      if (writeEntryGui(this, key, value, flags)) { -        return;    // GUI type that was handled +        return; // GUI type that was handled      }      QByteArray data; @@ -948,8 +936,9 @@ void KConfigGroup::writeEntry(const char *key, const QVariant &value,          break;      case QMetaType::QVariantList:          if (!value.canConvert(QMetaType::QStringList)) -            qCWarning(KCONFIG_CORE_LOG) << "not all types in \"" << key << "\" can convert to QString," -                       " information will be lost"; +            qCWarning(KCONFIG_CORE_LOG) << "not all types in \"" << key +                                        << "\" can convert to QString," +                                           " information will be lost";          Q_FALLTHROUGH();      case QMetaType::QStringList:          writeEntry(key, value.toList(), flags); @@ -957,10 +946,7 @@ void KConfigGroup::writeEntry(const char *key, const QVariant &value,      case QMetaType::QPoint: {          const QPoint rPoint = value.toPoint(); -        const QVariantList list{ -            rPoint.x(), -            rPoint.y() -        }; +        const QVariantList list{rPoint.x(), rPoint.y()};          writeEntry(key, list, flags);          return; @@ -968,10 +954,7 @@ void KConfigGroup::writeEntry(const char *key, const QVariant &value,      case QMetaType::QPointF: {          const QPointF point = value.toPointF(); -        const QVariantList list{ -            point.x(), -            point.y() -        }; +        const QVariantList list{point.x(), point.y()};          writeEntry(key, list, flags);          return; @@ -979,12 +962,7 @@ void KConfigGroup::writeEntry(const char *key, const QVariant &value,      case QMetaType::QRect: {          const QRect rRect = value.toRect(); -        const QVariantList list{ -            rRect.left(), -            rRect.top(), -            rRect.width(), -            rRect.height() -        }; +        const QVariantList list{rRect.left(), rRect.top(), rRect.width(), rRect.height()};          writeEntry(key, list, flags);          return; @@ -992,12 +970,7 @@ void KConfigGroup::writeEntry(const char *key, const QVariant &value,      case QMetaType::QRectF: {          const QRectF rRectF = value.toRectF(); -        const QVariantList list{ -            rRectF.left(), -            rRectF.top(), -            rRectF.width(), -            rRectF.height() -        }; +        const QVariantList list{rRectF.left(), rRectF.top(), rRectF.width(), rRectF.height()};          writeEntry(key, list, flags);          return; @@ -1005,10 +978,7 @@ void KConfigGroup::writeEntry(const char *key, const QVariant &value,      case QMetaType::QSize: {          const QSize rSize = value.toSize(); -        const QVariantList list{ -            rSize.width(), -            rSize.height() -        }; +        const QVariantList list{rSize.width(), rSize.height()};          writeEntry(key, list, flags);          return; @@ -1016,10 +986,7 @@ void KConfigGroup::writeEntry(const char *key, const QVariant &value,      case QMetaType::QSizeF: {          const QSizeF rSizeF = value.toSizeF(); -        const QVariantList list{ -            rSizeF.width(), -            rSizeF.height() -        }; +        const QVariantList list{rSizeF.width(), rSizeF.height()};          writeEntry(key, list, flags);          return; @@ -1027,11 +994,7 @@ void KConfigGroup::writeEntry(const char *key, const QVariant &value,      case QMetaType::QDate: {          const QDate date = value.toDate(); -        const QVariantList list{ -            date.year(), -            date.month(), -            date.day() -        }; +        const QVariantList list{date.year(), date.month(), date.day()};          writeEntry(key, list, flags);          return; @@ -1049,7 +1012,7 @@ void KConfigGroup::writeEntry(const char *key, const QVariant &value,              time.hour(),              time.minute(), -            time.second() + time.msec()/1000.0, +            time.second() + time.msec() / 1000.0,          };          writeEntry(key, list, flags); @@ -1058,10 +1021,9 @@ void KConfigGroup::writeEntry(const char *key, const QVariant &value,      case QMetaType::QColor:      case QMetaType::QFont: -        qCWarning(KCONFIG_CORE_LOG) << "KConfigGroup::writeEntry was passed GUI type '" -                   << value.typeName() -                   << "' but KConfigGui isn't linked! If it is linked to your program, this is a platform bug. " -                   "Please inform the KDE developers"; +        qCWarning(KCONFIG_CORE_LOG) << "KConfigGroup::writeEntry was passed GUI type '" << value.typeName() +                                    << "' but KConfigGui isn't linked! If it is linked to your program, this is a platform bug. " +                                       "Please inform the KDE developers";          break;      case QMetaType::QUrl:          data = QUrl(value.toUrl()).toString().toUtf8(); @@ -1260,7 +1222,7 @@ bool KConfigGroup::isGroupImmutableImpl(const QByteArray &b) const      Q_ASSERT_X(isValid(), "KConfigGroup::isGroupImmutableImpl", "accessing an invalid group");      if (!hasGroupImpl(b)) { // group doesn't exist yet -        return d->bImmutable;    // child groups are immutable if the parent is immutable. +        return d->bImmutable; // child groups are immutable if the parent is immutable.      }      return config()->isGroupImmutable(d->fullName(b)); diff --git a/src/core/kconfiggroup.h b/src/core/kconfiggroup.h index 620f04c0..5c125dd2 100644 --- a/src/core/kconfiggroup.h +++ b/src/core/kconfiggroup.h @@ -16,8 +16,8 @@  #include <kconfigcore_export.h>  #include <QExplicitlySharedDataPointer> -#include <QVariant>  #include <QStringList> +#include <QVariant>  class KConfig;  class KConfigGroupPrivate; @@ -246,7 +246,7 @@ public:       *       * @see writeEntry(), deleteEntry(), hasKey()       */ -    template <typename T> +    template<typename T>      T readEntry(const QString &key, const T &aDefault) const      {          return readEntry(key.toUtf8().constData(), aDefault); @@ -255,7 +255,7 @@ public:       * Overload for readEntry<T>(const QString&, const T&) const       * @param key name of key, encoded in UTF-8       */ -    template <typename T> +    template<typename T>      T readEntry(const char *key, const T &aDefault) const;      /** @@ -414,14 +414,12 @@ public:       * @param aDefault a default value returned if the key was not found       * @return the value for this key, or @p aDefault if the key does not exist       */ -    QString readEntryUntranslated(const QString &pKey, -                                  const QString &aDefault = QString()) const; +    QString readEntryUntranslated(const QString &pKey, const QString &aDefault = QString()) const;      /**       * Overload for readEntryUntranslated(const QString&, const QString&) const       * @param key name of key, encoded in UTF-8       */ -    QString readEntryUntranslated(const char *key, -                                  const QString &aDefault = QString()) const; +    QString readEntryUntranslated(const char *key, const QString &aDefault = QString()) const;      /**       * Writes a value to the configuration object. @@ -432,34 +430,28 @@ public:       *       * @see readEntry(), writeXdgListEntry(), deleteEntry()       */ -    void writeEntry(const QString &key, const QVariant &value, -                    WriteConfigFlags pFlags = Normal); +    void writeEntry(const QString &key, const QVariant &value, WriteConfigFlags pFlags = Normal);      /**       * Overload for writeEntry(const QString&, const QVariant&, WriteConfigFlags)       * @param key name of key, encoded in UTF-8       */ -    void writeEntry(const char *key, const QVariant &value, -                    WriteConfigFlags pFlags = Normal); +    void writeEntry(const char *key, const QVariant &value, WriteConfigFlags pFlags = Normal);      /** Overload for writeEntry(const QString&, const QVariant&, WriteConfigFlags) */ -    void writeEntry(const QString &key, const QString &value, -                    WriteConfigFlags pFlags = Normal); +    void writeEntry(const QString &key, const QString &value, WriteConfigFlags pFlags = Normal);      /**       * Overload for writeEntry(const QString&, const QVariant&, WriteConfigFlags)       * @param key name of key, encoded in UTF-8       */ -    void writeEntry(const char *key, const QString &value, -                    WriteConfigFlags pFlags = Normal); +    void writeEntry(const char *key, const QString &value, WriteConfigFlags pFlags = Normal);      /** Overload for writeEntry(const QString&, const QVariant&, WriteConfigFlags) */ -    void writeEntry(const QString &key, const QByteArray &value, -                    WriteConfigFlags pFlags = Normal); +    void writeEntry(const QString &key, const QByteArray &value, WriteConfigFlags pFlags = Normal);      /**       * Overload for writeEntry(const QString&, const QVariant&, WriteConfigFlags)       * @param key name of key, encoded in UTF-8       */ -    void writeEntry(const char *key, const QByteArray &value, -                    WriteConfigFlags pFlags = Normal); +    void writeEntry(const char *key, const QByteArray &value, WriteConfigFlags pFlags = Normal);      /** Overload for writeEntry(const QString&, const QVariant&, WriteConfigFlags) */      void writeEntry(const QString &key, const char *value, WriteConfigFlags pFlags = Normal); @@ -473,37 +465,33 @@ public:       * Overload for writeEntry(const QString&, const QVariant&, WriteConfigFlags)       * @param key name of key, encoded in UTF-8       */ -    template <typename T> +    template<typename T>      void writeEntry(const char *key, const T &value, WriteConfigFlags pFlags = Normal);      /** Overload for writeEntry(const QString&, const QVariant&, WriteConfigFlags) */ -    template <typename T> +    template<typename T>      void writeEntry(const QString &key, const T &value, WriteConfigFlags pFlags = Normal)      {          writeEntry(key.toUtf8().constData(), value, pFlags);      }      /** Overload for writeEntry(const QString&, const QVariant&, WriteConfigFlags) */ -    void writeEntry(const QString &key, const QStringList &value, -                    WriteConfigFlags pFlags = Normal); +    void writeEntry(const QString &key, const QStringList &value, WriteConfigFlags pFlags = Normal);      /**       * Overload for writeEntry(const QString&, const QVariant&, WriteConfigFlags)       * @param key name of key, encoded in UTF-8       */ -    void writeEntry(const char *key, const QStringList &value, -                    WriteConfigFlags pFlags = Normal); +    void writeEntry(const char *key, const QStringList &value, WriteConfigFlags pFlags = Normal);      /** Overload for writeEntry(const QString&, const QVariant&, WriteConfigFlags) */ -    void writeEntry(const QString &key, const QVariantList &value, -                    WriteConfigFlags pFlags = Normal); +    void writeEntry(const QString &key, const QVariantList &value, WriteConfigFlags pFlags = Normal);      /**       * Overload for writeEntry(const QString&, const QVariant&, WriteConfigFlags)       * @param key name of key, encoded in UTF-8       */ -    void writeEntry(const char *key, const QVariantList &value, -                    WriteConfigFlags pFlags = Normal); +    void writeEntry(const char *key, const QVariantList &value, WriteConfigFlags pFlags = Normal);      /** Overload for writeEntry(const QString&, const QVariant&, WriteConfigFlags) */ -    template <typename T> +    template<typename T>      void writeEntry(const QString &key, const QList<T> &value, WriteConfigFlags pFlags = Normal)      {          writeEntry(key.toUtf8().constData(), value, pFlags); @@ -512,7 +500,7 @@ public:       * Overload for writeEntry(const QString&, const QVariant&, WriteConfigFlags)       * @param key name of key, encoded in UTF-8       */ -    template <typename T> +    template<typename T>      void writeEntry(const char *key, const QList<T> &value, WriteConfigFlags pFlags = Normal);      /** @@ -525,14 +513,12 @@ public:       *       * @see writeEntry(), readXdgListEntry()       */ -    void writeXdgListEntry(const QString &pKey, const QStringList &value, -                           WriteConfigFlags pFlags = Normal); +    void writeXdgListEntry(const QString &pKey, const QStringList &value, WriteConfigFlags pFlags = Normal);      /**       * Overload for writeXdgListEntry(const QString&, const QStringList&, WriteConfigFlags)       * @param key name of key, encoded in UTF-8       */ -    void writeXdgListEntry(const char *key, const QStringList &value, -                           WriteConfigFlags pFlags = Normal); +    void writeXdgListEntry(const char *key, const QStringList &value, WriteConfigFlags pFlags = Normal);      /**       * Writes a file path to the configuration @@ -547,14 +533,12 @@ public:       *       * @see writeEntry(), readPathEntry()       */ -    void writePathEntry(const QString &pKey, const QString &path, -                        WriteConfigFlags pFlags = Normal); +    void writePathEntry(const QString &pKey, const QString &path, WriteConfigFlags pFlags = Normal);      /**       * Overload for writePathEntry(const QString&, const QString&, WriteConfigFlags)       * @param key name of key, encoded in UTF-8       */ -    void writePathEntry(const char *Key, const QString &path, -                        WriteConfigFlags pFlags = Normal); +    void writePathEntry(const char *Key, const QString &path, WriteConfigFlags pFlags = Normal);      /**       * Writes a list of paths to the configuration @@ -569,14 +553,12 @@ public:       *       * @see writeEntry(), readPathEntry()       */ -    void writePathEntry(const QString &pKey, const QStringList &value, -                        WriteConfigFlags pFlags = Normal); +    void writePathEntry(const QString &pKey, const QStringList &value, WriteConfigFlags pFlags = Normal);      /**       * Overload for writePathEntry(const QString&, const QStringList&, WriteConfigFlags)       * @param key name of key, encoded in UTF-8       */ -    void writePathEntry(const char *key, const QStringList &value, -                        WriteConfigFlags pFlags = Normal); +    void writePathEntry(const char *key, const QStringList &value, WriteConfigFlags pFlags = Normal);      /**       * Deletes the entry specified by @p pKey in the current group @@ -742,9 +724,7 @@ private:      friend class KServicePrivate; // XXX yeah, ugly^5  }; -#define KCONFIGGROUP_ENUMERATOR_ERROR(ENUM) \ -    "The Qt MetaObject system does not seem to know about \"" ENUM \ -    "\" please use Q_ENUM or Q_FLAG to register it." +#define KCONFIGGROUP_ENUMERATOR_ERROR(ENUM) "The Qt MetaObject system does not seem to know about \"" ENUM "\" please use Q_ENUM or Q_FLAG to register it."  /**   * To add support for your own enums in KConfig, you can declare them with Q_ENUM() @@ -754,70 +734,88 @@ private:   * <code>KCONFIGGROUP_DECLARE_ENUM_QOBJECT(MyClass, MyEnum)</code>   *   */ -#define KCONFIGGROUP_DECLARE_ENUM_QOBJECT(Class, Enum)                             \ -    template<>                                                                     \ -    Class::Enum KConfigGroup::readEntry(const char* key, const Class::Enum& def) const\ -    {                                                                              \ -        const QMetaObject* M_obj = &Class::staticMetaObject;                       \ -        const int M_index = M_obj->indexOfEnumerator(#Enum);                       \ -        if(M_index == -1) qFatal(KCONFIGGROUP_ENUMERATOR_ERROR(#Enum));            \ -        const QMetaEnum M_enum = M_obj->enumerator(M_index);                       \ -        const QByteArray M_data = readEntry(key, QByteArray(M_enum.valueToKey(def)));\ -        return static_cast<Class::Enum>(M_enum.keyToValue(M_data.constData()));    \ -    }                                                                              \ -    inline Class::Enum Q_DECL_DEPRECATED readEntry(const KConfigGroup& group, const char* key, const Class::Enum& def)\ -    { return group.readEntry(key, def); }                                          \ -    template<>                                                                     \ -    void KConfigGroup::writeEntry(const char* key, const Class::Enum& value, KConfigBase::WriteConfigFlags flags)\ -    {                                                                              \ -        const QMetaObject* M_obj = &Class::staticMetaObject;                       \ -        const int M_index = M_obj->indexOfEnumerator(#Enum);                       \ -        if(M_index == -1) qFatal(KCONFIGGROUP_ENUMERATOR_ERROR(#Enum));            \ -        const QMetaEnum M_enum = M_obj->enumerator(M_index);                       \ -        writeEntry(key, QByteArray(M_enum.valueToKey(value)), flags);              \ -    }                                                                              \ -    inline void Q_DECL_DEPRECATED writeEntry(KConfigGroup& group, const char* key, const Class::Enum& value, KConfigBase::WriteConfigFlags flags = KConfigBase::Normal)\ -    { group.writeEntry(key, value, flags); } +#define KCONFIGGROUP_DECLARE_ENUM_QOBJECT(Class, Enum)                                                                                                         \ +    template<>                                                                                                                                                 \ +    Class::Enum KConfigGroup::readEntry(const char *key, const Class::Enum &def) const                                                                         \ +    {                                                                                                                                                          \ +        const QMetaObject *M_obj = &Class::staticMetaObject;                                                                                                   \ +        const int M_index = M_obj->indexOfEnumerator(#Enum);                                                                                                   \ +        if (M_index == -1)                                                                                                                                     \ +            qFatal(KCONFIGGROUP_ENUMERATOR_ERROR(#Enum));                                                                                                      \ +        const QMetaEnum M_enum = M_obj->enumerator(M_index);                                                                                                   \ +        const QByteArray M_data = readEntry(key, QByteArray(M_enum.valueToKey(def)));                                                                          \ +        return static_cast<Class::Enum>(M_enum.keyToValue(M_data.constData()));                                                                                \ +    }                                                                                                                                                          \ +    inline Class::Enum Q_DECL_DEPRECATED readEntry(const KConfigGroup &group, const char *key, const Class::Enum &def)                                         \ +    {                                                                                                                                                          \ +        return group.readEntry(key, def);                                                                                                                      \ +    }                                                                                                                                                          \ +    template<>                                                                                                                                                 \ +    void KConfigGroup::writeEntry(const char *key, const Class::Enum &value, KConfigBase::WriteConfigFlags flags)                                              \ +    {                                                                                                                                                          \ +        const QMetaObject *M_obj = &Class::staticMetaObject;                                                                                                   \ +        const int M_index = M_obj->indexOfEnumerator(#Enum);                                                                                                   \ +        if (M_index == -1)                                                                                                                                     \ +            qFatal(KCONFIGGROUP_ENUMERATOR_ERROR(#Enum));                                                                                                      \ +        const QMetaEnum M_enum = M_obj->enumerator(M_index);                                                                                                   \ +        writeEntry(key, QByteArray(M_enum.valueToKey(value)), flags);                                                                                          \ +    }                                                                                                                                                          \ +    inline void Q_DECL_DEPRECATED writeEntry(KConfigGroup &group,                                                                                              \ +                                             const char *key,                                                                                                  \ +                                             const Class::Enum &value,                                                                                         \ +                                             KConfigBase::WriteConfigFlags flags = KConfigBase::Normal)                                                        \ +    {                                                                                                                                                          \ +        group.writeEntry(key, value, flags);                                                                                                                   \ +    }  /**   * Similar to KCONFIGGROUP_DECLARE_ENUM_QOBJECT but for flags declared with Q_FLAG()   * (where multiple values can be set at the same time)   */ -#define KCONFIGGROUP_DECLARE_FLAGS_QOBJECT(Class, Flags)                            \ -    template<>                                                                      \ -    Class::Flags KConfigGroup::readEntry(const char* key, const Class::Flags& def) const\ -    {                                                                               \ -        const QMetaObject* M_obj = &Class::staticMetaObject;                        \ -        const int M_index = M_obj->indexOfEnumerator(#Flags);                       \ -        if(M_index == -1) qFatal(KCONFIGGROUP_ENUMERATOR_ERROR(#Flags));            \ -        const QMetaEnum M_enum = M_obj->enumerator(M_index);                        \ -        const QByteArray M_data = readEntry(key, QByteArray(M_enum.valueToKeys(def)));\ -        return static_cast<Class::Flags>(M_enum.keysToValue(M_data.constData()));   \ -    }                                                                               \ -    inline Class::Flags Q_DECL_DEPRECATED readEntry(const KConfigGroup& group, const char* key, const Class::Flags& def)\ -    { return group.readEntry(key, def);}                                            \ -    template<>                                                                      \ -    void KConfigGroup::writeEntry(const char* key, const Class::Flags& value, KConfigBase::WriteConfigFlags flags)\ -    {                                                                               \ -        const QMetaObject* M_obj = &Class::staticMetaObject;                        \ -        const int M_index = M_obj->indexOfEnumerator(#Flags);                       \ -        if(M_index == -1) qFatal(KCONFIGGROUP_ENUMERATOR_ERROR(#Flags));            \ -        const QMetaEnum M_enum = M_obj->enumerator(M_index);                        \ -        writeEntry(key, QByteArray(M_enum.valueToKeys(value)), flags);              \ -    }                                                                               \ -    inline void Q_DECL_DEPRECATED writeEntry(KConfigGroup& group, const char* key, const Class::Flags& value, KConfigBase::WriteConfigFlags flags = KConfigBase::Normal)\ -    { group.writeEntry(key, value, flags); } +#define KCONFIGGROUP_DECLARE_FLAGS_QOBJECT(Class, Flags)                                                                                                       \ +    template<>                                                                                                                                                 \ +    Class::Flags KConfigGroup::readEntry(const char *key, const Class::Flags &def) const                                                                       \ +    {                                                                                                                                                          \ +        const QMetaObject *M_obj = &Class::staticMetaObject;                                                                                                   \ +        const int M_index = M_obj->indexOfEnumerator(#Flags);                                                                                                  \ +        if (M_index == -1)                                                                                                                                     \ +            qFatal(KCONFIGGROUP_ENUMERATOR_ERROR(#Flags));                                                                                                     \ +        const QMetaEnum M_enum = M_obj->enumerator(M_index);                                                                                                   \ +        const QByteArray M_data = readEntry(key, QByteArray(M_enum.valueToKeys(def)));                                                                         \ +        return static_cast<Class::Flags>(M_enum.keysToValue(M_data.constData()));                                                                              \ +    }                                                                                                                                                          \ +    inline Class::Flags Q_DECL_DEPRECATED readEntry(const KConfigGroup &group, const char *key, const Class::Flags &def)                                       \ +    {                                                                                                                                                          \ +        return group.readEntry(key, def);                                                                                                                      \ +    }                                                                                                                                                          \ +    template<>                                                                                                                                                 \ +    void KConfigGroup::writeEntry(const char *key, const Class::Flags &value, KConfigBase::WriteConfigFlags flags)                                             \ +    {                                                                                                                                                          \ +        const QMetaObject *M_obj = &Class::staticMetaObject;                                                                                                   \ +        const int M_index = M_obj->indexOfEnumerator(#Flags);                                                                                                  \ +        if (M_index == -1)                                                                                                                                     \ +            qFatal(KCONFIGGROUP_ENUMERATOR_ERROR(#Flags));                                                                                                     \ +        const QMetaEnum M_enum = M_obj->enumerator(M_index);                                                                                                   \ +        writeEntry(key, QByteArray(M_enum.valueToKeys(value)), flags);                                                                                         \ +    }                                                                                                                                                          \ +    inline void Q_DECL_DEPRECATED writeEntry(KConfigGroup &group,                                                                                              \ +                                             const char *key,                                                                                                  \ +                                             const Class::Flags &value,                                                                                        \ +                                             KConfigBase::WriteConfigFlags flags = KConfigBase::Normal)                                                        \ +    {                                                                                                                                                          \ +        group.writeEntry(key, value, flags);                                                                                                                   \ +    }  #include "conversioncheck.h" -template <typename T> +template<typename T>  T KConfigGroup::readEntry(const char *key, const T &defaultValue) const  {      ConversionCheck::to_QVariant<T>();      return qvariant_cast<T>(readEntry(key, QVariant::fromValue(defaultValue)));  } -template <typename T> +template<typename T>  QList<T> KConfigGroup::readEntry(const char *key, const QList<T> &defaultValue) const  {      ConversionCheck::to_QVariant<T>(); @@ -839,14 +837,14 @@ QList<T> KConfigGroup::readEntry(const char *key, const QList<T> &defaultValue)      return list;  } -template <typename T> +template<typename T>  void KConfigGroup::writeEntry(const char *key, const T &value, WriteConfigFlags pFlags)  {      ConversionCheck::to_QVariant<T>();      writeEntry(key, QVariant::fromValue(value), pFlags);  } -template <typename T> +template<typename T>  void KConfigGroup::writeEntry(const char *key, const QList<T> &list, WriteConfigFlags pFlags)  {      ConversionCheck::to_QVariant<T>(); diff --git a/src/core/kconfiggroup_p.h b/src/core/kconfiggroup_p.h index 923387e7..2744c153 100644 --- a/src/core/kconfiggroup_p.h +++ b/src/core/kconfiggroup_p.h @@ -8,16 +8,14 @@  #ifndef KCONFIGGROUP_P_H  #define KCONFIGGROUP_P_H -#include <QVariant>  #include "kconfiggroup.h" +#include <QVariant>  class KConfigGroup;  struct KConfigGroupGui { -    typedef bool (*kReadEntryGui)(const QByteArray &data, const char *key, const QVariant &input, -                                  QVariant &output); -    typedef bool (*kWriteEntryGui)(KConfigGroup *, const char *key, const QVariant &input, -                                   KConfigGroup::WriteConfigFlags flags); +    typedef bool (*kReadEntryGui)(const QByteArray &data, const char *key, const QVariant &input, QVariant &output); +    typedef bool (*kWriteEntryGui)(KConfigGroup *, const char *key, const QVariant &input, KConfigGroup::WriteConfigFlags flags);      kReadEntryGui readEntryGui;      kWriteEntryGui writeEntryGui; diff --git a/src/core/kconfigini.cpp b/src/core/kconfigini.cpp index 96cd3763..6271bcd5 100644 --- a/src/core/kconfigini.cpp +++ b/src/core/kconfigini.cpp @@ -9,26 +9,26 @@  #include "kconfigini_p.h" +#include "bufferfragment_p.h"  #include "kconfig.h" +#include "kconfig_core_log_settings.h"  #include "kconfigbackend_p.h" -#include "bufferfragment_p.h"  #include "kconfigdata.h" -#include "kconfig_core_log_settings.h" -#include <QSaveFile> -#include <QLockFile>  #include <QDateTime> +#include <QDebug>  #include <QDir>  #include <QFile>  #include <QFileInfo> -#include <QDebug> +#include <QLockFile> +#include <QSaveFile>  #include <qplatformdefs.h>  #ifndef Q_OS_WIN  #include <unistd.h> // getuid, close  #endif -#include <sys/types.h> // uid_t  #include <fcntl.h> // open +#include <sys/types.h> // uid_t  KCONFIGCORE_EXPORT bool kde_kiosk_exception = false; // flag to disable kiosk restrictions @@ -44,12 +44,12 @@ static QByteArray lookup(const KConfigIniBackend::BufferFragment fragment, QHash  QString KConfigIniBackend::warningProlog(const QFile &file, int line)  { -    return QStringLiteral("KConfigIni: In file %2, line %1: ") -           .arg(line).arg(file.fileName()); +    return QStringLiteral("KConfigIni: In file %2, line %1: ").arg(line).arg(file.fileName());  }  KConfigIniBackend::KConfigIniBackend() -    : KConfigBackend(), lockFile(nullptr) +    : KConfigBackend() +    , lockFile(nullptr)  {  } @@ -57,18 +57,14 @@ KConfigIniBackend::~KConfigIniBackend()  {  } -KConfigBackend::ParseInfo -KConfigIniBackend::parseConfig(const QByteArray ¤tLocale, KEntryMap &entryMap, -                               ParseOptions options) +KConfigBackend::ParseInfo KConfigIniBackend::parseConfig(const QByteArray ¤tLocale, KEntryMap &entryMap, ParseOptions options)  {      return parseConfig(currentLocale, entryMap, options, false);  }  // merging==true is the merging that happens at the beginning of writeConfig:  // merge changes in the on-disk file with the changes in the KConfig object. -KConfigBackend::ParseInfo -KConfigIniBackend::parseConfig(const QByteArray ¤tLocale, KEntryMap &entryMap, -                               ParseOptions options, bool merging) +KConfigBackend::ParseInfo KConfigIniBackend::parseConfig(const QByteArray ¤tLocale, KEntryMap &entryMap, ParseOptions options, bool merging)  {      if (filePath().isEmpty() || !QFile::exists(filePath())) {          return ParseOk; @@ -137,8 +133,7 @@ KConfigIniBackend::parseConfig(const QByteArray ¤tLocale, KEntryMap &entry                      }                      ++end;                  } -                if (end + 1 == line.length() && start + 2 == end && -                        line.at(start) == '$' && line.at(start + 1) == 'i') { +                if (end + 1 == line.length() && start + 2 == end && line.at(start) == '$' && line.at(start + 1) == 'i') {                      if (newGroup.isEmpty()) {                          fileOptionImmutable = !kde_kiosk_exception;                      } else { @@ -162,14 +157,14 @@ KConfigIniBackend::parseConfig(const QByteArray ¤tLocale, KEntryMap &entry              }              if (groupOptionImmutable) -                // Do not make the groups immutable until the entries from -                // this file have been added. +            // Do not make the groups immutable until the entries from +            // this file have been added.              {                  immutableGroups.append(currentGroup);              }          } else {              if (groupSkip && !bDefault) { -                continue;    // skip entry +                continue; // skip entry              }              BufferFragment aKey; @@ -199,8 +194,7 @@ KConfigIniBackend::parseConfig(const QByteArray ¤tLocale, KEntryMap &entry              while ((start = aKey.lastIndexOf('[')) >= 0) {                  int end = aKey.indexOf(']', start);                  if (end < 0) { -                    qCWarning(KCONFIG_CORE_LOG) << warningProlog(file, lineNo) -                               << "Invalid entry (missing ']')"; +                    qCWarning(KCONFIG_CORE_LOG) << warningProlog(file, lineNo) << "Invalid entry (missing ']')";                      goto next_line;                  } else if (end > start + 1 && aKey.at(start + 1) == '$') { // found option(s)                      int i = start + 2; @@ -229,8 +223,7 @@ KConfigIniBackend::parseConfig(const QByteArray ¤tLocale, KEntryMap &entry                      }                  } else { // found a locale                      if (!locale.isNull()) { -                        qCWarning(KCONFIG_CORE_LOG) << warningProlog(file, lineNo) -                                   << "Invalid entry (second locale!?)"; +                        qCWarning(KCONFIG_CORE_LOG) << warningProlog(file, lineNo) << "Invalid entry (second locale!?)";                          goto next_line;                      } @@ -250,7 +243,7 @@ KConfigIniBackend::parseConfig(const QByteArray ¤tLocale, KEntryMap &entry                          if (merging) {                              entryOptions |= KEntryMap::EntryRawKey;                          } else { -                            goto next_line;    // skip this entry if we're not merging +                            goto next_line; // skip this entry if we're not merging                          }                      }                  } @@ -295,8 +288,7 @@ KConfigIniBackend::parseConfig(const QByteArray ¤tLocale, KEntryMap &entry      return fileOptionImmutable ? ParseImmutable : ParseOk;  } -void KConfigIniBackend::writeEntries(const QByteArray &locale, QIODevice &file, -                                     const KEntryMap &map, bool defaultGroup, bool &firstEntry) +void KConfigIniBackend::writeEntries(const QByteArray &locale, QIODevice &file, const KEntryMap &map, bool defaultGroup, bool &firstEntry)  {      QByteArray currentGroup;      bool groupIsImmutable = false; @@ -306,7 +298,7 @@ void KConfigIniBackend::writeEntries(const QByteArray &locale, QIODevice &file,          // Either process the default group or all others          if ((key.mGroup != "<default>") == defaultGroup) { -            continue;    // skip +            continue; // skip          }          // the only thing we care about groups is, is it immutable? @@ -366,9 +358,9 @@ void KConfigIniBackend::writeEntries(const QByteArray &locale, QIODevice &file,          }          if (currentEntry.bDeleted) {              if (currentEntry.bImmutable) { -                file.write("[$di]", 5);    // Deleted + immutable +                file.write("[$di]", 5); // Deleted + immutable              } else { -                file.write("[$d]", 4);    // Deleted +                file.write("[$d]", 4); // Deleted              }          } else {              if (currentEntry.bImmutable || currentEntry.bExpand) { @@ -399,8 +391,7 @@ void KConfigIniBackend::writeEntries(const QByteArray &locale, QIODevice &file,      writeEntries(locale, file, map, false, firstEntry);  } -bool KConfigIniBackend::writeConfig(const QByteArray &locale, KEntryMap &entryMap, -                                    WriteOptions options) +bool KConfigIniBackend::writeConfig(const QByteArray &locale, KEntryMap &entryMap, WriteOptions options)  {      Q_ASSERT(!filePath().isEmpty()); @@ -442,10 +433,10 @@ bool KConfigIniBackend::writeConfig(const QByteArray &locale, KEntryMap &entryMa                  defaultKey.bDefault = true;                  if (!entryMap.contains(defaultKey)) {                      writeMap.remove(key); // remove the deleted entry if there is no default -                    //qDebug() << "Detected as deleted=>removed:" << key.mGroup << key.mKey << "global=" << bGlobal; +                    // qDebug() << "Detected as deleted=>removed:" << key.mGroup << key.mKey << "global=" << bGlobal;                  } else {                      writeMap[key] = *it; // otherwise write an explicitly deleted entry -                    //qDebug() << "Detected as deleted=>[$d]:" << key.mGroup << key.mKey << "global=" << bGlobal; +                    // qDebug() << "Detected as deleted=>[$d]:" << key.mGroup << key.mKey << "global=" << bGlobal;                  }              }              it->bDirty = false; @@ -462,7 +453,7 @@ bool KConfigIniBackend::writeConfig(const QByteArray &locale, KEntryMap &entryMa      QFileInfo fi(filePath());      if (fi.exists()) {  #ifdef Q_OS_WIN -        //TODO: getuid does not exist on windows, use GetSecurityInfo and GetTokenInformation instead +        // TODO: getuid does not exist on windows, use GetSecurityInfo and GetTokenInformation instead          createNew = false;  #else          if (fi.ownerId() == ::getuid()) { @@ -574,7 +565,7 @@ void KConfigIniBackend::createEnclosing()  {      const QString file = filePath();      if (file.isEmpty()) { -        return;    // nothing to do +        return; // nothing to do      }      // Create the containing dir, maybe it wasn't there @@ -639,106 +630,112 @@ bool KConfigIniBackend::isLocked() const      return lockFile && lockFile->isLocked();  } -namespace { -    // serialize an escaped byte at the end of @param data -    // @param data should have room for 4 bytes -    char* escapeByte(char* data, unsigned char s) { -        static const char nibbleLookup[] = { -            '0', '1', '2', '3', '4', '5', '6', '7', -            '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' -        }; -        *data++ = '\\'; -        *data++ = 'x'; -        *data++ = nibbleLookup[s >> 4]; -        *data++ = nibbleLookup[s & 0x0f]; -        return data; -    } +namespace +{ +// serialize an escaped byte at the end of @param data +// @param data should have room for 4 bytes +char *escapeByte(char *data, unsigned char s) +{ +    static const char nibbleLookup[] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'}; +    *data++ = '\\'; +    *data++ = 'x'; +    *data++ = nibbleLookup[s >> 4]; +    *data++ = nibbleLookup[s & 0x0f]; +    return data; +} -    // Struct that represents a multi-byte UTF-8 character. -    // This struct is used to keep track of bytes that seem to be valid -    // UTF-8. -    struct Utf8Char { -    public: -        unsigned char bytes[4]; -        unsigned char count; -        unsigned char charLength; - -        Utf8Char() { -            clear(); -            charLength = 0; -        } -        void clear() { -            count = 0; -        } -        // Add a byte to the UTF8 character. -        // When an additional byte leads to an invalid character, return false. -        bool addByte(unsigned char b) { -            if (count == 0) { -                if (b > 0xc1 && (b & 0xe0) == 0xc0) { -                    charLength = 2; -                } else if ((b & 0xf0) == 0xe0) { -                    charLength = 3; -                } else if (b < 0xf5 && (b & 0xf8) == 0xf0) { -                    charLength = 4; -                } else { -                    return false; +// Struct that represents a multi-byte UTF-8 character. +// This struct is used to keep track of bytes that seem to be valid +// UTF-8. +struct Utf8Char { +public: +    unsigned char bytes[4]; +    unsigned char count; +    unsigned char charLength; + +    Utf8Char() +    { +        clear(); +        charLength = 0; +    } +    void clear() +    { +        count = 0; +    } +    // Add a byte to the UTF8 character. +    // When an additional byte leads to an invalid character, return false. +    bool addByte(unsigned char b) +    { +        if (count == 0) { +            if (b > 0xc1 && (b & 0xe0) == 0xc0) { +                charLength = 2; +            } else if ((b & 0xf0) == 0xe0) { +                charLength = 3; +            } else if (b < 0xf5 && (b & 0xf8) == 0xf0) { +                charLength = 4; +            } else { +                return false; +            } +            bytes[0] = b; +            count = 1; +        } else if (count < 4 && (b & 0xc0) == 0x80) { +            if (count == 1) { +                if (charLength == 3 && bytes[0] == 0xe0 && b < 0xa0) { +                    return false; // overlong 3 byte sequence                  } -                bytes[0] = b; -                count = 1; -            } else if (count < 4 && (b & 0xc0) == 0x80) { -                if (count == 1) { -                    if (charLength == 3 && bytes[0] == 0xe0 && b < 0xa0) { -                        return false; // overlong 3 byte sequence +                if (charLength == 4) { +                    if (bytes[0] == 0xf0 && b < 0x90) { +                        return false; // overlong 4 byte sequence                      } -                    if (charLength == 4) { -                        if (bytes[0] == 0xf0 && b < 0x90) { -                            return false; // overlong 4 byte sequence -                        } -                        if (bytes[0] == 0xf4 && b > 0x8f) { -                            return false; // Unicode value larger than U+10FFFF -                        } +                    if (bytes[0] == 0xf4 && b > 0x8f) { +                        return false; // Unicode value larger than U+10FFFF                      }                  } -                bytes[count++] = b; -            } else { -                return false;              } -            return true; -        } -        // Return true if Utf8Char contains one valid character. -        bool isComplete() { -            return count > 0 && count == charLength; +            bytes[count++] = b; +        } else { +            return false;          } -        // Add the bytes in this UTF8 character in escaped form to data. -        char* escapeBytes(char* data) { -            for (unsigned char i = 0; i < count; ++i) { -                data = escapeByte(data, bytes[i]); -            } -            clear(); -            return data; +        return true; +    } +    // Return true if Utf8Char contains one valid character. +    bool isComplete() +    { +        return count > 0 && count == charLength; +    } +    // Add the bytes in this UTF8 character in escaped form to data. +    char *escapeBytes(char *data) +    { +        for (unsigned char i = 0; i < count; ++i) { +            data = escapeByte(data, bytes[i]);          } -        // Add the bytes of the UTF8 character to a buffer. -        // Only call this if isComplete() returns true. -        char* writeUtf8(char* data) { -            for (unsigned char i = 0; i < count; ++i) { -                *data++ = bytes[i]; -            } -            clear(); -            return data; +        clear(); +        return data; +    } +    // Add the bytes of the UTF8 character to a buffer. +    // Only call this if isComplete() returns true. +    char *writeUtf8(char *data) +    { +        for (unsigned char i = 0; i < count; ++i) { +            *data++ = bytes[i];          } -        // Write the bytes in the UTF8 character literally, or, if the -        // character is not complete, write the escaped bytes. -        // This is useful to handle the state that remains after handling -        // all bytes in a buffer. -        char* write(char* data) { -            if (isComplete()) { -                data = writeUtf8(data); -            } else { -                data = escapeBytes(data); -            } -            return data; +        clear(); +        return data; +    } +    // Write the bytes in the UTF8 character literally, or, if the +    // character is not complete, write the escaped bytes. +    // This is useful to handle the state that remains after handling +    // all bytes in a buffer. +    char *write(char *data) +    { +        if (isComplete()) { +            data = writeUtf8(data); +        } else { +            data = escapeBytes(data);          } -    }; +        return data; +    } +};  }  QByteArray KConfigIniBackend::stringToPrintable(const QByteArray &aString, StringType type) @@ -763,7 +760,7 @@ QByteArray KConfigIniBackend::stringToPrintable(const QByteArray &aString, Strin      }      Utf8Char utf8; -    for (; i < l; ++i/*, r++*/) { +    for (; i < l; ++i /*, r++*/) {          switch (s[i]) {          default:              if (utf8.addByte(s[i])) { @@ -847,8 +844,8 @@ char KConfigIniBackend::charFromHex(const char *str, const QFile &file, int line          } else {              QByteArray e(str, 2);              e.prepend("\\x"); -            qCWarning(KCONFIG_CORE_LOG) << warningProlog(file, line) << "Invalid hex character " << c -                       << " in \\x<nn>-type escape sequence \"" << e.constData() << "\"."; +            qCWarning(KCONFIG_CORE_LOG) << warningProlog(file, line) << "Invalid hex character " << c << " in \\x<nn>-type escape sequence \"" << e.constData() +                                        << "\".";              return 'x';          }      } @@ -915,8 +912,7 @@ void KConfigIniBackend::printableToString(BufferFragment *aString, const QFile &                  break;              default:                  *r = '\\'; -                qCWarning(KCONFIG_CORE_LOG) << warningProlog(file, line) -                           << QStringLiteral("Invalid escape sequence \"\\%1\".").arg(str[i]); +                qCWarning(KCONFIG_CORE_LOG) << warningProlog(file, line) << QStringLiteral("Invalid escape sequence \"\\%1\".").arg(str[i]);              }          }      } diff --git a/src/core/kconfigini_p.h b/src/core/kconfigini_p.h index d760170d..3397857c 100644 --- a/src/core/kconfigini_p.h +++ b/src/core/kconfigini_p.h @@ -10,15 +10,15 @@  #ifndef KCONFIGINI_P_H  #define KCONFIGINI_P_H -#include <kconfigcore_export.h>  #include <kconfigbackend_p.h> +#include <kconfigcore_export.h>  class QLockFile;  class QIODevice;  class KConfigIniBackend : public KConfigBackend  { -Q_OBJECT +    Q_OBJECT  private:      QLockFile *lockFile; @@ -28,15 +28,9 @@ public:      KConfigIniBackend();      ~KConfigIniBackend() override; -    ParseInfo parseConfig(const QByteArray &locale, -                          KEntryMap &entryMap, -                          ParseOptions options) override; -    ParseInfo parseConfig(const QByteArray &locale, -                          KEntryMap &entryMap, -                          ParseOptions options, -                          bool merging); -    bool writeConfig(const QByteArray &locale, KEntryMap &entryMap, -                     WriteOptions options) override; +    ParseInfo parseConfig(const QByteArray &locale, KEntryMap &entryMap, ParseOptions options) override; +    ParseInfo parseConfig(const QByteArray &locale, KEntryMap &entryMap, ParseOptions options, bool merging); +    bool writeConfig(const QByteArray &locale, KEntryMap &entryMap, WriteOptions options) override;      bool isWritable() const override;      QString nonWritableErrorMessage() const override; @@ -48,7 +42,6 @@ public:      bool isLocked() const override;  protected: -      enum StringType {          GroupString = 0,          KeyString = 1, @@ -62,8 +55,7 @@ protected:      static QString warningProlog(const QFile &file, int line);      void writeEntries(const QByteArray &locale, QIODevice &file, const KEntryMap &map); -    void writeEntries(const QByteArray &locale, QIODevice &file, const KEntryMap &map, -                      bool defaultGroup, bool &firstEntry); +    void writeEntries(const QByteArray &locale, QIODevice &file, const KEntryMap &map, bool defaultGroup, bool &firstEntry);  };  #endif // KCONFIGINI_P_H diff --git a/src/core/kconfigwatcher.cpp b/src/core/kconfigwatcher.cpp index c5aa6205..3da2d535 100644 --- a/src/core/kconfigwatcher.cpp +++ b/src/core/kconfigwatcher.cpp @@ -16,17 +16,18 @@  #endif  #include <QDebug> -#include <QThreadStorage>  #include <QHash> +#include <QThreadStorage> -class KConfigWatcherPrivate { +class KConfigWatcherPrivate +{  public:      KSharedConfig::Ptr m_config;  };  KConfigWatcher::Ptr KConfigWatcher::create(const KSharedConfig::Ptr &config)  { -    static QThreadStorage<QHash<KSharedConfig*, QWeakPointer<KConfigWatcher>>> watcherList; +    static QThreadStorage<QHash<KSharedConfig *, QWeakPointer<KConfigWatcher>>> watcherList;      auto c = config.data();      KConfigWatcher::Ptr watcher; @@ -43,9 +44,9 @@ KConfigWatcher::Ptr KConfigWatcher::create(const KSharedConfig::Ptr &config)      return watcherList.localData().value(c).toStrongRef();  } -KConfigWatcher::KConfigWatcher(const KSharedConfig::Ptr &config): -    QObject (nullptr), -    d(new KConfigWatcherPrivate) +KConfigWatcher::KConfigWatcher(const KSharedConfig::Ptr &config) +    : QObject(nullptr) +    , d(new KConfigWatcherPrivate)  {      Q_ASSERT(config);  #if KCONFIG_USE_DBUS @@ -65,13 +66,13 @@ KConfigWatcher::KConfigWatcher(const KSharedConfig::Ptr &config):          watchedPaths << QStringLiteral("/kdeglobals");      } -    for(const QString &path: qAsConst(watchedPaths)) { +    for (const QString &path : qAsConst(watchedPaths)) {          QDBusConnection::sessionBus().connect(QString(),                                                path,                                                QStringLiteral("org.kde.kconfig.notify"),                                                QStringLiteral("ConfigChanged"),                                                this, -                                              SLOT(onConfigChangeNotification(QHash<QString,QByteArrayList>))); +                                              SLOT(onConfigChangeNotification(QHash<QString, QByteArrayList>)));      }  #else      qCWarning(KCONFIG_CORE_LOG) << "Use of KConfigWatcher without DBus support. You will not receive updates"; @@ -87,17 +88,16 @@ KSharedConfig::Ptr KConfigWatcher::config() const  void KConfigWatcher::onConfigChangeNotification(const QHash<QString, QByteArrayList> &changes)  { -    //should we ever need it we can determine the file changed with  QDbusContext::message().path(), but it doesn't seem too useful +    // should we ever need it we can determine the file changed with  QDbusContext::message().path(), but it doesn't seem too useful      d->m_config->reparseConfiguration(); -    for(auto it = changes.constBegin(); it != changes.constEnd(); it++) { -        KConfigGroup group = d->m_config->group(QString());//top level group -        const auto parts = it.key().split(QLatin1Char('\x1d')); //magic char, see KConfig -        for(const QString &groupName: parts) { +    for (auto it = changes.constBegin(); it != changes.constEnd(); it++) { +        KConfigGroup group = d->m_config->group(QString()); // top level group +        const auto parts = it.key().split(QLatin1Char('\x1d')); // magic char, see KConfig +        for (const QString &groupName : parts) {              group = group.group(groupName);          }          Q_EMIT configChanged(group, it.value());      }  } - diff --git a/src/core/kconfigwatcher.h b/src/core/kconfigwatcher.h index 28576bb4..76418c9b 100644 --- a/src/core/kconfigwatcher.h +++ b/src/core/kconfigwatcher.h @@ -10,8 +10,8 @@  #include <QObject>  #include <QSharedPointer> -#include <KSharedConfig>  #include <KConfigGroup> +#include <KSharedConfig>  #include <kconfigcore_export.h> @@ -23,7 +23,7 @@ class KConfigWatcherPrivate;   * Notifies when another client has updated this config file with the Notify flag set.   * @since 5.51   */ -class KCONFIGCORE_EXPORT KConfigWatcher: public QObject +class KCONFIGCORE_EXPORT KConfigWatcher : public QObject  {      Q_OBJECT  public: diff --git a/src/core/kcoreconfigskeleton.cpp b/src/core/kcoreconfigskeleton.cpp index d5af41e4..669e0ce5 100644 --- a/src/core/kcoreconfigskeleton.cpp +++ b/src/core/kcoreconfigskeleton.cpp @@ -18,16 +18,14 @@ static QString obscuredString(const QString &str)      for (int i = 0; i < str.length(); ++i)          // yes, no typo. can't encode ' ' or '!' because          // they're the unicode BOM. stupid scrambling. stupid. -        result += (unicode[ i ].unicode() <= 0x21) ? unicode[ i ] -                  : QChar(0x1001F - unicode[ i ].unicode()); +        result += (unicode[i].unicode() <= 0x21) ? unicode[i] : QChar(0x1001F - unicode[i].unicode());      return result;  }  KConfigSkeletonItemPrivate::~KConfigSkeletonItemPrivate() = default; -KConfigSkeletonItem::KConfigSkeletonItem(const QString &_group, -        const QString &_key) +KConfigSkeletonItem::KConfigSkeletonItem(const QString &_group, const QString &_key)      : mGroup(_group)      , mKey(_key)      , d_ptr(new KConfigSkeletonItemPrivate) @@ -179,19 +177,19 @@ void KConfigSkeletonItem::readImmutability(const KConfigGroup &group)      d->mIsImmutable = group.isEntryImmutable(mKey);  } -void KConfigSkeletonItem::setIsDefaultImpl(const std::function<bool ()> &impl) +void KConfigSkeletonItem::setIsDefaultImpl(const std::function<bool()> &impl)  {      Q_D(KConfigSkeletonItem);      d->mIsDefaultImpl = impl;  } -void KConfigSkeletonItem::setIsSaveNeededImpl(const std::function<bool ()> &impl) +void KConfigSkeletonItem::setIsSaveNeededImpl(const std::function<bool()> &impl)  {      Q_D(KConfigSkeletonItem);      d->mIsSaveNeededImpl = impl;  } -void KConfigSkeletonItem::setGetDefaultImpl(const std::function<QVariant ()> &impl) +void KConfigSkeletonItem::setGetDefaultImpl(const std::function<QVariant()> &impl)  {      Q_D(KConfigSkeletonItem);      d->mGetDefaultImpl = impl; @@ -276,18 +274,15 @@ void KPropertySkeletonItem::swapDefault()      }  } -void KPropertySkeletonItem::setNotifyFunction(const std::function<void ()> &impl) +void KPropertySkeletonItem::setNotifyFunction(const std::function<void()> &impl)  {      Q_D(KPropertySkeletonItem);      d->mNotifyFunction = impl;  } -KCoreConfigSkeleton::ItemString::ItemString(const QString &_group, const QString &_key, -        QString &reference, -        const QString &defaultValue, -        Type type) -    : KConfigSkeletonGenericItem<QString>(_group, _key, reference, defaultValue), -      mType(type) +KCoreConfigSkeleton::ItemString::ItemString(const QString &_group, const QString &_key, QString &reference, const QString &defaultValue, Type type) +    : KConfigSkeletonGenericItem<QString>(_group, _key, reference, defaultValue) +    , mType(type)  {  } @@ -341,23 +336,17 @@ QVariant KCoreConfigSkeleton::ItemString::property() const      return QVariant(mReference);  } -KCoreConfigSkeleton::ItemPassword::ItemPassword(const QString &_group, const QString &_key, -        QString &reference, -        const QString &defaultValue) +KCoreConfigSkeleton::ItemPassword::ItemPassword(const QString &_group, const QString &_key, QString &reference, const QString &defaultValue)      : ItemString(_group, _key, reference, defaultValue, Password)  {  } -KCoreConfigSkeleton::ItemPath::ItemPath(const QString &_group, const QString &_key, -                                        QString &reference, -                                        const QString &defaultValue) +KCoreConfigSkeleton::ItemPath::ItemPath(const QString &_group, const QString &_key, QString &reference, const QString &defaultValue)      : ItemString(_group, _key, reference, defaultValue, Path)  {  } -KCoreConfigSkeleton::ItemUrl::ItemUrl(const QString &_group, const QString &_key, -                                      QUrl &reference, -                                      const QUrl &defaultValue) +KCoreConfigSkeleton::ItemUrl::ItemUrl(const QString &_group, const QString &_key, QUrl &reference, const QUrl &defaultValue)      : KConfigSkeletonGenericItem<QUrl>(_group, _key, reference, defaultValue)  {  } @@ -400,10 +389,7 @@ QVariant KCoreConfigSkeleton::ItemUrl::property() const      return QVariant::fromValue<QUrl>(mReference);  } -KCoreConfigSkeleton::ItemProperty::ItemProperty(const QString &_group, -        const QString &_key, -        QVariant &reference, -        const QVariant &defaultValue) +KCoreConfigSkeleton::ItemProperty::ItemProperty(const QString &_group, const QString &_key, QVariant &reference, const QVariant &defaultValue)      : KConfigSkeletonGenericItem<QVariant>(_group, _key, reference, defaultValue)  {  } @@ -424,7 +410,7 @@ void KCoreConfigSkeleton::ItemProperty::setProperty(const QVariant &p)  bool KCoreConfigSkeleton::ItemProperty::isEqual(const QVariant &v) const  { -    //this might cause problems if the QVariants are not of default types +    // this might cause problems if the QVariants are not of default types      return mReference == v;  } @@ -433,8 +419,7 @@ QVariant KCoreConfigSkeleton::ItemProperty::property() const      return mReference;  } -KCoreConfigSkeleton::ItemBool::ItemBool(const QString &_group, const QString &_key, -                                        bool &reference, bool defaultValue) +KCoreConfigSkeleton::ItemBool::ItemBool(const QString &_group, const QString &_key, bool &reference, bool defaultValue)      : KConfigSkeletonGenericItem<bool>(_group, _key, reference, defaultValue)  {  } @@ -463,10 +448,10 @@ QVariant KCoreConfigSkeleton::ItemBool::property() const      return QVariant(mReference);  } -KCoreConfigSkeleton::ItemInt::ItemInt(const QString &_group, const QString &_key, -                                      qint32 &reference, qint32 defaultValue) +KCoreConfigSkeleton::ItemInt::ItemInt(const QString &_group, const QString &_key, qint32 &reference, qint32 defaultValue)      : KConfigSkeletonGenericItem<qint32>(_group, _key, reference, defaultValue) -    , mHasMin(false), mHasMax(false) +    , mHasMin(false) +    , mHasMax(false)  {  } @@ -528,10 +513,10 @@ void KCoreConfigSkeleton::ItemInt::setMaxValue(qint32 v)      mMax = v;  } -KCoreConfigSkeleton::ItemLongLong::ItemLongLong(const QString &_group, const QString &_key, -        qint64 &reference, qint64 defaultValue) +KCoreConfigSkeleton::ItemLongLong::ItemLongLong(const QString &_group, const QString &_key, qint64 &reference, qint64 defaultValue)      : KConfigSkeletonGenericItem<qint64>(_group, _key, reference, defaultValue) -    , mHasMin(false), mHasMax(false) +    , mHasMin(false) +    , mHasMax(false)  {  } @@ -606,11 +591,9 @@ void KCoreConfigSkeleton::ItemEnum::setValueForChoice(const QString &name, const      d_ptr->mValues.insert(name, value);  } -KCoreConfigSkeleton::ItemEnum::ItemEnum(const QString &_group, const QString &_key, -                                        qint32 &reference, -                                        const QList<Choice> &choices, -                                        qint32 defaultValue) -    : ItemInt(_group, _key, reference, defaultValue), mChoices(choices) +KCoreConfigSkeleton::ItemEnum::ItemEnum(const QString &_group, const QString &_key, qint32 &reference, const QList<Choice> &choices, qint32 defaultValue) +    : ItemInt(_group, _key, reference, defaultValue) +    , mChoices(choices)  {  } @@ -623,8 +606,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 (QList<Choice>::ConstIterator it = mChoices.constBegin(); it != mChoices.constEnd(); ++it, ++i) {              QString choiceName = (*it).name;              if (valueForChoice(choiceName).toLower() == tmp) {                  mReference = i; @@ -665,11 +647,10 @@ QList<KCoreConfigSkeleton::ItemEnum::Choice> KCoreConfigSkeleton::ItemEnum::choi      return mChoices;  } -KCoreConfigSkeleton::ItemUInt::ItemUInt(const QString &_group, const QString &_key, -                                        quint32 &reference, -                                        quint32 defaultValue) +KCoreConfigSkeleton::ItemUInt::ItemUInt(const QString &_group, const QString &_key, quint32 &reference, quint32 defaultValue)      : KConfigSkeletonGenericItem<quint32>(_group, _key, reference, defaultValue) -    , mHasMin(false), mHasMax(false) +    , mHasMin(false) +    , mHasMax(false)  {  } @@ -731,10 +712,10 @@ void KCoreConfigSkeleton::ItemUInt::setMaxValue(quint32 v)      mMax = v;  } -KCoreConfigSkeleton::ItemULongLong::ItemULongLong(const QString &_group, const QString &_key, -        quint64 &reference, quint64 defaultValue) +KCoreConfigSkeleton::ItemULongLong::ItemULongLong(const QString &_group, const QString &_key, quint64 &reference, quint64 defaultValue)      : KConfigSkeletonGenericItem<quint64>(_group, _key, reference, defaultValue) -    , mHasMin(false), mHasMax(false) +    , mHasMin(false) +    , mHasMax(false)  {  } @@ -796,10 +777,10 @@ void KCoreConfigSkeleton::ItemULongLong::setMaxValue(quint64 v)      mMax = v;  } -KCoreConfigSkeleton::ItemDouble::ItemDouble(const QString &_group, const QString &_key, -        double &reference, double defaultValue) +KCoreConfigSkeleton::ItemDouble::ItemDouble(const QString &_group, const QString &_key, double &reference, double defaultValue)      : KConfigSkeletonGenericItem<double>(_group, _key, reference, defaultValue) -    , mHasMin(false), mHasMax(false) +    , mHasMin(false) +    , mHasMax(false)  {  } @@ -861,9 +842,7 @@ void KCoreConfigSkeleton::ItemDouble::setMaxValue(double v)      mMax = v;  } -KCoreConfigSkeleton::ItemRect::ItemRect(const QString &_group, const QString &_key, -                                        QRect &reference, -                                        const QRect &defaultValue) +KCoreConfigSkeleton::ItemRect::ItemRect(const QString &_group, const QString &_key, QRect &reference, const QRect &defaultValue)      : KConfigSkeletonGenericItem<QRect>(_group, _key, reference, defaultValue)  {  } @@ -892,9 +871,7 @@ QVariant KCoreConfigSkeleton::ItemRect::property() const      return QVariant(mReference);  } -KCoreConfigSkeleton::ItemPoint::ItemPoint(const QString &_group, const QString &_key, -        QPoint &reference, -        const QPoint &defaultValue) +KCoreConfigSkeleton::ItemPoint::ItemPoint(const QString &_group, const QString &_key, QPoint &reference, const QPoint &defaultValue)      : KConfigSkeletonGenericItem<QPoint>(_group, _key, reference, defaultValue)  {  } @@ -923,9 +900,7 @@ QVariant KCoreConfigSkeleton::ItemPoint::property() const      return QVariant(mReference);  } -KCoreConfigSkeleton::ItemSize::ItemSize(const QString &_group, const QString &_key, -                                        QSize &reference, -                                        const QSize &defaultValue) +KCoreConfigSkeleton::ItemSize::ItemSize(const QString &_group, const QString &_key, QSize &reference, const QSize &defaultValue)      : KConfigSkeletonGenericItem<QSize>(_group, _key, reference, defaultValue)  {  } @@ -954,9 +929,7 @@ QVariant KCoreConfigSkeleton::ItemSize::property() const      return QVariant(mReference);  } -KCoreConfigSkeleton::ItemDateTime::ItemDateTime(const QString &_group, const QString &_key, -        QDateTime &reference, -        const QDateTime &defaultValue) +KCoreConfigSkeleton::ItemDateTime::ItemDateTime(const QString &_group, const QString &_key, QDateTime &reference, const QDateTime &defaultValue)      : KConfigSkeletonGenericItem<QDateTime>(_group, _key, reference, defaultValue)  {  } @@ -985,9 +958,7 @@ QVariant KCoreConfigSkeleton::ItemDateTime::property() const      return QVariant(mReference);  } -KCoreConfigSkeleton::ItemStringList::ItemStringList(const QString &_group, const QString &_key, -        QStringList &reference, -        const QStringList &defaultValue) +KCoreConfigSkeleton::ItemStringList::ItemStringList(const QString &_group, const QString &_key, QStringList &reference, const QStringList &defaultValue)      : KConfigSkeletonGenericItem<QStringList>(_group, _key, reference, defaultValue)  {  } @@ -1020,9 +991,7 @@ QVariant KCoreConfigSkeleton::ItemStringList::property() const      return QVariant(mReference);  } -KCoreConfigSkeleton::ItemPathList::ItemPathList(const QString &_group, const QString &_key, -        QStringList &reference, -        const QStringList &defaultValue) +KCoreConfigSkeleton::ItemPathList::ItemPathList(const QString &_group, const QString &_key, QStringList &reference, const QStringList &defaultValue)      : ItemStringList(_group, _key, reference, defaultValue)  {  } @@ -1054,10 +1023,8 @@ void KCoreConfigSkeleton::ItemPathList::writeConfig(KConfig *config)      }  } -KCoreConfigSkeleton::ItemUrlList::ItemUrlList(const QString &_group, const QString &_key, -        QList<QUrl> &reference, -        const QList<QUrl> &defaultValue) -    : KConfigSkeletonGenericItem<QList<QUrl> >(_group, _key, reference, defaultValue) +KCoreConfigSkeleton::ItemUrlList::ItemUrlList(const QString &_group, const QString &_key, QList<QUrl> &reference, const QList<QUrl> &defaultValue) +    : KConfigSkeletonGenericItem<QList<QUrl>>(_group, _key, reference, defaultValue)  {  } @@ -1101,23 +1068,21 @@ void KCoreConfigSkeleton::ItemUrlList::writeConfig(KConfig *config)  void KCoreConfigSkeleton::ItemUrlList::setProperty(const QVariant &p)  { -    mReference = qvariant_cast<QList<QUrl> >(p); +    mReference = qvariant_cast<QList<QUrl>>(p);  }  bool KCoreConfigSkeleton::ItemUrlList::isEqual(const QVariant &v) const  { -    return mReference == qvariant_cast<QList<QUrl> >(v); +    return mReference == qvariant_cast<QList<QUrl>>(v);  }  QVariant KCoreConfigSkeleton::ItemUrlList::property() const  { -    return QVariant::fromValue<QList<QUrl> >(mReference); +    return QVariant::fromValue<QList<QUrl>>(mReference);  } -KCoreConfigSkeleton::ItemIntList::ItemIntList(const QString &_group, const QString &_key, -        QList<int> &reference, -        const QList<int> &defaultValue) -    : KConfigSkeletonGenericItem<QList<int> >(_group, _key, reference, defaultValue) +KCoreConfigSkeleton::ItemIntList::ItemIntList(const QString &_group, const QString &_key, QList<int> &reference, const QList<int> &defaultValue) +    : KConfigSkeletonGenericItem<QList<int>>(_group, _key, reference, defaultValue)  {  } @@ -1136,35 +1101,35 @@ void KCoreConfigSkeleton::ItemIntList::readConfig(KConfig *config)  void KCoreConfigSkeleton::ItemIntList::setProperty(const QVariant &p)  { -    mReference = qvariant_cast< QList<int> >(p); +    mReference = qvariant_cast<QList<int>>(p);  }  bool KCoreConfigSkeleton::ItemIntList::isEqual(const QVariant &v) const  { -    return mReference == qvariant_cast< QList<int> >(v); +    return mReference == qvariant_cast<QList<int>>(v);  }  QVariant KCoreConfigSkeleton::ItemIntList::property() const  { -    return QVariant::fromValue< QList<int> >(mReference); +    return QVariant::fromValue<QList<int>>(mReference);  } -//static int kCoreConfigSkeletionDebugArea() { static int s_area = KDebug::registerArea("kdecore (KConfigSkeleton)"); return s_area; } +// static int kCoreConfigSkeletionDebugArea() { static int s_area = KDebug::registerArea("kdecore (KConfigSkeleton)"); return s_area; }  KCoreConfigSkeleton::KCoreConfigSkeleton(const QString &configname, QObject *parent) -    : QObject(parent), -      d(new KCoreConfigSkeletonPrivate) +    : QObject(parent) +    , d(new KCoreConfigSkeletonPrivate)  { -    //qDebug() << "Creating KCoreConfigSkeleton (" << (void *)this << ")"; +    // qDebug() << "Creating KCoreConfigSkeleton (" << (void *)this << ")";      d->mConfig = KSharedConfig::openConfig(configname, KConfig::FullConfig);  }  KCoreConfigSkeleton::KCoreConfigSkeleton(KSharedConfig::Ptr pConfig, QObject *parent) -    : QObject(parent), -      d(new KCoreConfigSkeletonPrivate) +    : QObject(parent) +    , d(new KCoreConfigSkeletonPrivate)  { -    //qDebug() << "Creating KCoreConfigSkeleton (" << (void *)this << ")"; +    // qDebug() << "Creating KCoreConfigSkeleton (" << (void *)this << ")";      d->mConfig = std::move(pConfig);  } @@ -1271,7 +1236,7 @@ bool KCoreConfigSkeleton::isSaveNeeded() const  bool KCoreConfigSkeleton::save()  { -    //qDebug(); +    // qDebug();      KConfigSkeletonItem::List::ConstIterator it;      for (it = d->mItems.constBegin(); it != d->mItems.constEnd(); ++it) {          (*it)->writeConfig(d->mConfig.data()); @@ -1330,8 +1295,7 @@ bool KCoreConfigSkeleton::usrWriteConfig()  void KCoreConfigSkeleton::addItem(KConfigSkeletonItem *item, const QString &name)  {      if (d->mItems.contains(item)) { -        if (item->name() == name || -                (name.isEmpty() && item->name() == item->key())) { +        if (item->name() == name || (name.isEmpty() && item->name() == item->key())) {              // nothing to do -> it is already in our collection              // and the name isn't changing              return; @@ -1366,185 +1330,149 @@ void KCoreConfigSkeleton::clearItems()      qDeleteAll(items);  } -KCoreConfigSkeleton::ItemString *KCoreConfigSkeleton::addItemString(const QString &name, QString &reference, -        const QString &defaultValue, const QString &key) +KCoreConfigSkeleton::ItemString *KCoreConfigSkeleton::addItemString(const QString &name, QString &reference, const QString &defaultValue, const QString &key)  {      KCoreConfigSkeleton::ItemString *item; -    item = new KCoreConfigSkeleton::ItemString(d->mCurrentGroup, key.isEmpty() ? name : key, -            reference, defaultValue, -            KCoreConfigSkeleton::ItemString::Normal); +    item = new KCoreConfigSkeleton::ItemString(d->mCurrentGroup, key.isEmpty() ? name : key, reference, defaultValue, KCoreConfigSkeleton::ItemString::Normal);      addItem(item, name);      return item;  } -KCoreConfigSkeleton::ItemPassword *KCoreConfigSkeleton::addItemPassword(const QString &name, QString &reference, -        const QString &defaultValue, const QString &key) +KCoreConfigSkeleton::ItemPassword * +KCoreConfigSkeleton::addItemPassword(const QString &name, QString &reference, const QString &defaultValue, const QString &key)  {      KCoreConfigSkeleton::ItemPassword *item; -    item = new KCoreConfigSkeleton::ItemPassword(d->mCurrentGroup, key.isNull() ? name : key, -            reference, defaultValue); +    item = new KCoreConfigSkeleton::ItemPassword(d->mCurrentGroup, key.isNull() ? name : key, reference, defaultValue);      addItem(item, name);      return item;  } -KCoreConfigSkeleton::ItemPath *KCoreConfigSkeleton::addItemPath(const QString &name, QString &reference, -        const QString &defaultValue, const QString &key) +KCoreConfigSkeleton::ItemPath *KCoreConfigSkeleton::addItemPath(const QString &name, QString &reference, const QString &defaultValue, const QString &key)  {      KCoreConfigSkeleton::ItemPath *item; -    item = new KCoreConfigSkeleton::ItemPath(d->mCurrentGroup, key.isNull() ? name : key, -            reference, defaultValue); +    item = new KCoreConfigSkeleton::ItemPath(d->mCurrentGroup, key.isNull() ? name : key, reference, defaultValue);      addItem(item, name);      return item;  } -KCoreConfigSkeleton::ItemProperty *KCoreConfigSkeleton::addItemProperty(const QString &name, QVariant &reference, -        const QVariant &defaultValue, const QString &key) +KCoreConfigSkeleton::ItemProperty * +KCoreConfigSkeleton::addItemProperty(const QString &name, QVariant &reference, const QVariant &defaultValue, const QString &key)  {      KCoreConfigSkeleton::ItemProperty *item; -    item = new KCoreConfigSkeleton::ItemProperty(d->mCurrentGroup, key.isNull() ? name : key, -            reference, defaultValue); +    item = new KCoreConfigSkeleton::ItemProperty(d->mCurrentGroup, key.isNull() ? name : key, reference, defaultValue);      addItem(item, name);      return item;  } -KCoreConfigSkeleton::ItemBool *KCoreConfigSkeleton::addItemBool(const QString &name, bool &reference, -        bool defaultValue, const QString &key) +KCoreConfigSkeleton::ItemBool *KCoreConfigSkeleton::addItemBool(const QString &name, bool &reference, bool defaultValue, const QString &key)  {      KCoreConfigSkeleton::ItemBool *item; -    item = new KCoreConfigSkeleton::ItemBool(d->mCurrentGroup, key.isNull() ? name : key, -            reference, defaultValue); +    item = new KCoreConfigSkeleton::ItemBool(d->mCurrentGroup, key.isNull() ? name : key, reference, defaultValue);      addItem(item, name);      return item;  } -KCoreConfigSkeleton::ItemInt *KCoreConfigSkeleton::addItemInt(const QString &name, qint32 &reference, -        qint32 defaultValue, const QString &key) +KCoreConfigSkeleton::ItemInt *KCoreConfigSkeleton::addItemInt(const QString &name, qint32 &reference, qint32 defaultValue, const QString &key)  {      KCoreConfigSkeleton::ItemInt *item; -    item = new KCoreConfigSkeleton::ItemInt(d->mCurrentGroup, key.isNull() ? name : key, -                                            reference, defaultValue); +    item = new KCoreConfigSkeleton::ItemInt(d->mCurrentGroup, key.isNull() ? name : key, reference, defaultValue);      addItem(item, name);      return item;  } -KCoreConfigSkeleton::ItemUInt *KCoreConfigSkeleton::addItemUInt(const QString &name, quint32 &reference, -        quint32 defaultValue, const QString &key) +KCoreConfigSkeleton::ItemUInt *KCoreConfigSkeleton::addItemUInt(const QString &name, quint32 &reference, quint32 defaultValue, const QString &key)  {      KCoreConfigSkeleton::ItemUInt *item; -    item = new KCoreConfigSkeleton::ItemUInt(d->mCurrentGroup, key.isNull() ? name : key, -            reference, defaultValue); +    item = new KCoreConfigSkeleton::ItemUInt(d->mCurrentGroup, key.isNull() ? name : key, reference, defaultValue);      addItem(item, name);      return item;  } -KCoreConfigSkeleton::ItemLongLong *KCoreConfigSkeleton::addItemLongLong(const QString &name, qint64 &reference, -        qint64 defaultValue, const QString &key) +KCoreConfigSkeleton::ItemLongLong *KCoreConfigSkeleton::addItemLongLong(const QString &name, qint64 &reference, qint64 defaultValue, const QString &key)  {      KCoreConfigSkeleton::ItemLongLong *item; -    item = new KCoreConfigSkeleton::ItemLongLong(d->mCurrentGroup, key.isNull() ? name : key, -            reference, defaultValue); +    item = new KCoreConfigSkeleton::ItemLongLong(d->mCurrentGroup, key.isNull() ? name : key, reference, defaultValue);      addItem(item, name);      return item;  }  #if KCONFIGCORE_BUILD_DEPRECATED_SINCE(5, 0) -KCoreConfigSkeleton::ItemLongLong *KCoreConfigSkeleton::addItemInt64( -    const QString &name, -    qint64 &reference, -    qint64 defaultValue, -    const QString &key) +KCoreConfigSkeleton::ItemLongLong *KCoreConfigSkeleton::addItemInt64(const QString &name, qint64 &reference, qint64 defaultValue, const QString &key)  {      return addItemLongLong(name, reference, defaultValue, key);  }  #endif -KCoreConfigSkeleton::ItemULongLong *KCoreConfigSkeleton::addItemULongLong(const QString &name, quint64 &reference, -        quint64 defaultValue, const QString &key) +KCoreConfigSkeleton::ItemULongLong *KCoreConfigSkeleton::addItemULongLong(const QString &name, quint64 &reference, quint64 defaultValue, const QString &key)  {      KCoreConfigSkeleton::ItemULongLong *item; -    item = new KCoreConfigSkeleton::ItemULongLong(d->mCurrentGroup, key.isNull() ? name : key, -            reference, defaultValue); +    item = new KCoreConfigSkeleton::ItemULongLong(d->mCurrentGroup, key.isNull() ? name : key, reference, defaultValue);      addItem(item, name);      return item;  }  #if KCONFIGCORE_BUILD_DEPRECATED_SINCE(5, 0) -KCoreConfigSkeleton::ItemULongLong *KCoreConfigSkeleton::addItemUInt64( -    const QString &name, -    quint64 &reference, -    quint64 defaultValue, -    const QString &key) +KCoreConfigSkeleton::ItemULongLong *KCoreConfigSkeleton::addItemUInt64(const QString &name, quint64 &reference, quint64 defaultValue, const QString &key)  {      return addItemULongLong(name, reference, defaultValue, key);  }  #endif -KCoreConfigSkeleton::ItemDouble *KCoreConfigSkeleton::addItemDouble(const QString &name, double &reference, -        double defaultValue, const QString &key) +KCoreConfigSkeleton::ItemDouble *KCoreConfigSkeleton::addItemDouble(const QString &name, double &reference, double defaultValue, const QString &key)  {      KCoreConfigSkeleton::ItemDouble *item; -    item = new KCoreConfigSkeleton::ItemDouble(d->mCurrentGroup, key.isNull() ? name : key, -            reference, defaultValue); +    item = new KCoreConfigSkeleton::ItemDouble(d->mCurrentGroup, key.isNull() ? name : key, reference, defaultValue);      addItem(item, name);      return item;  } -KCoreConfigSkeleton::ItemRect *KCoreConfigSkeleton::addItemRect(const QString &name, QRect &reference, -        const QRect &defaultValue, const QString &key) +KCoreConfigSkeleton::ItemRect *KCoreConfigSkeleton::addItemRect(const QString &name, QRect &reference, const QRect &defaultValue, const QString &key)  {      KCoreConfigSkeleton::ItemRect *item; -    item = new KCoreConfigSkeleton::ItemRect(d->mCurrentGroup, key.isNull() ? name : key, -            reference, defaultValue); +    item = new KCoreConfigSkeleton::ItemRect(d->mCurrentGroup, key.isNull() ? name : key, reference, defaultValue);      addItem(item, name);      return item;  } -KCoreConfigSkeleton::ItemPoint *KCoreConfigSkeleton::addItemPoint(const QString &name, QPoint &reference, -        const QPoint &defaultValue, const QString &key) +KCoreConfigSkeleton::ItemPoint *KCoreConfigSkeleton::addItemPoint(const QString &name, QPoint &reference, const QPoint &defaultValue, const QString &key)  {      KCoreConfigSkeleton::ItemPoint *item; -    item = new KCoreConfigSkeleton::ItemPoint(d->mCurrentGroup, key.isNull() ? name : key, -            reference, defaultValue); +    item = new KCoreConfigSkeleton::ItemPoint(d->mCurrentGroup, key.isNull() ? name : key, reference, defaultValue);      addItem(item, name);      return item;  } -KCoreConfigSkeleton::ItemSize *KCoreConfigSkeleton::addItemSize(const QString &name, QSize &reference, -        const QSize &defaultValue, const QString &key) +KCoreConfigSkeleton::ItemSize *KCoreConfigSkeleton::addItemSize(const QString &name, QSize &reference, const QSize &defaultValue, const QString &key)  {      KCoreConfigSkeleton::ItemSize *item; -    item = new KCoreConfigSkeleton::ItemSize(d->mCurrentGroup, key.isNull() ? name : key, -            reference, defaultValue); +    item = new KCoreConfigSkeleton::ItemSize(d->mCurrentGroup, key.isNull() ? name : key, reference, defaultValue);      addItem(item, name);      return item;  } -KCoreConfigSkeleton::ItemDateTime *KCoreConfigSkeleton::addItemDateTime(const QString &name, QDateTime &reference, -        const QDateTime &defaultValue, const QString &key) +KCoreConfigSkeleton::ItemDateTime * +KCoreConfigSkeleton::addItemDateTime(const QString &name, QDateTime &reference, const QDateTime &defaultValue, const QString &key)  {      KCoreConfigSkeleton::ItemDateTime *item; -    item = new KCoreConfigSkeleton::ItemDateTime(d->mCurrentGroup, key.isNull() ? name : key, -            reference, defaultValue); +    item = new KCoreConfigSkeleton::ItemDateTime(d->mCurrentGroup, key.isNull() ? name : key, reference, defaultValue);      addItem(item, name);      return item;  } -KCoreConfigSkeleton::ItemStringList *KCoreConfigSkeleton::addItemStringList(const QString &name, QStringList &reference, -        const QStringList &defaultValue, const QString &key) +KCoreConfigSkeleton::ItemStringList * +KCoreConfigSkeleton::addItemStringList(const QString &name, QStringList &reference, const QStringList &defaultValue, const QString &key)  {      KCoreConfigSkeleton::ItemStringList *item; -    item = new KCoreConfigSkeleton::ItemStringList(d->mCurrentGroup, key.isNull() ? name : key, -            reference, defaultValue); +    item = new KCoreConfigSkeleton::ItemStringList(d->mCurrentGroup, key.isNull() ? name : key, reference, defaultValue);      addItem(item, name);      return item;  } -KCoreConfigSkeleton::ItemIntList *KCoreConfigSkeleton::addItemIntList(const QString &name, QList<int> &reference, -        const QList<int> &defaultValue, const QString &key) +KCoreConfigSkeleton::ItemIntList * +KCoreConfigSkeleton::addItemIntList(const QString &name, QList<int> &reference, const QList<int> &defaultValue, const QString &key)  {      KCoreConfigSkeleton::ItemIntList *item; -    item = new KCoreConfigSkeleton::ItemIntList(d->mCurrentGroup, key.isNull() ? name : key, -            reference, defaultValue); +    item = new KCoreConfigSkeleton::ItemIntList(d->mCurrentGroup, key.isNull() ? name : key, reference, defaultValue);      addItem(item, name);      return item;  } @@ -1560,25 +1488,36 @@ KConfigSkeletonItem *KCoreConfigSkeleton::findItem(const QString &name) const      return d->mItemDict.value(name);  } -KConfigCompilerSignallingItem::KConfigCompilerSignallingItem(KConfigSkeletonItem* item, QObject* object, -        KConfigCompilerSignallingItem::NotifyFunction targetFunction, quint64 userData) -    : KConfigSkeletonItem(item->group(), item->key()), mItem(item), mTargetFunction(targetFunction), -    mObject(object), mUserData(userData) +KConfigCompilerSignallingItem::KConfigCompilerSignallingItem(KConfigSkeletonItem *item, +                                                             QObject *object, +                                                             KConfigCompilerSignallingItem::NotifyFunction targetFunction, +                                                             quint64 userData) +    : KConfigSkeletonItem(item->group(), item->key()) +    , mItem(item) +    , mTargetFunction(targetFunction) +    , mObject(object) +    , mUserData(userData)  {      Q_ASSERT(mTargetFunction);      Q_ASSERT(mItem);      Q_ASSERT(mObject); -    setIsDefaultImpl([this] { return mItem->isDefault(); }); -    setIsSaveNeededImpl([this] { return mItem->isSaveNeeded(); }); -    setGetDefaultImpl([this] {return mItem->getDefault(); }); +    setIsDefaultImpl([this] { +        return mItem->isDefault(); +    }); +    setIsSaveNeededImpl([this] { +        return mItem->isSaveNeeded(); +    }); +    setGetDefaultImpl([this] { +        return mItem->getDefault(); +    });  }  KConfigCompilerSignallingItem::~KConfigCompilerSignallingItem()  {  } -bool KConfigCompilerSignallingItem::isEqual(const QVariant& p) const +bool KConfigCompilerSignallingItem::isEqual(const QVariant &p) const  {      return mItem->isEqual(p);  } @@ -1588,11 +1527,11 @@ QVariant KConfigCompilerSignallingItem::property() const      return mItem->property();  } -void KConfigCompilerSignallingItem::readConfig(KConfig* c) +void KConfigCompilerSignallingItem::readConfig(KConfig *c)  {      QVariant oldValue = mItem->property();      mItem->readConfig(c); -    //readConfig() changes mIsImmutable, update it here as well +    // readConfig() changes mIsImmutable, update it here as well      KConfigGroup cg = configGroup(c);      readImmutability(cg);      if (!mItem->isEqual(oldValue)) { @@ -1600,15 +1539,15 @@ void KConfigCompilerSignallingItem::readConfig(KConfig* c)      }  } -void KConfigCompilerSignallingItem::readDefault(KConfig* c) +void KConfigCompilerSignallingItem::readDefault(KConfig *c)  {      mItem->readDefault(c); -    //readDefault() changes mIsImmutable, update it here as well +    // readDefault() changes mIsImmutable, update it here as well      KConfigGroup cg = configGroup(c);      readImmutability(cg);  } -void KConfigCompilerSignallingItem::writeConfig(KConfig* c) +void KConfigCompilerSignallingItem::writeConfig(KConfig *c)  {      mItem->writeConfig(c);  } @@ -1622,7 +1561,7 @@ void KConfigCompilerSignallingItem::setDefault()      }  } -void KConfigCompilerSignallingItem::setProperty(const QVariant& p) +void KConfigCompilerSignallingItem::setProperty(const QVariant &p)  {      if (!mItem->isEqual(p)) {          mItem->setProperty(p); diff --git a/src/core/kcoreconfigskeleton.h b/src/core/kcoreconfigskeleton.h index e7b814e8..aafc417c 100644 --- a/src/core/kcoreconfigskeleton.h +++ b/src/core/kcoreconfigskeleton.h @@ -12,15 +12,15 @@  #include <kconfigcore_export.h> -#include <ksharedconfig.h>  #include <kconfiggroup.h> +#include <ksharedconfig.h>  #include <QDate>  #include <QHash>  #include <QRect>  #include <QStringList> -#include <QVariant>  #include <QUrl> +#include <QVariant>  class KCoreConfigSkeletonPrivate; @@ -42,9 +42,9 @@ class KCONFIGCORE_EXPORT KConfigSkeletonItem  {      Q_DECLARE_PRIVATE(KConfigSkeletonItem)  public: -    typedef QList < KConfigSkeletonItem * >List; -    typedef QHash < QString, KConfigSkeletonItem * > Dict; -    typedef QHash < QString, KConfigSkeletonItem * >::Iterator DictIterator; +    typedef QList<KConfigSkeletonItem *> List; +    typedef QHash<QString, KConfigSkeletonItem *> Dict; +    typedef QHash<QString, KConfigSkeletonItem *>::Iterator DictIterator;      /**       * Constructor. @@ -310,29 +310,35 @@ public:       * Set a notify function, it will be invoked when the value of the property changes.       * @since 5.68       */ -    void setNotifyFunction(const std::function<void ()> &impl); +    void setNotifyFunction(const std::function<void()> &impl);  }; -  /**   * \class KConfigSkeletonGenericItem kcoreconfigskeleton.h <KConfigSkeletonGenericItem>   */ -template < typename T > class KConfigSkeletonGenericItem: public KConfigSkeletonItem +template<typename T> +class KConfigSkeletonGenericItem : public KConfigSkeletonItem  {  public:      /** @copydoc KConfigSkeletonItem(const QString&, const QString&)           @param reference The initial value to hold in the item           @param defaultValue The default value for the item       */ -    KConfigSkeletonGenericItem(const QString &_group, const QString &_key, T &reference, -                               T defaultValue) -        : KConfigSkeletonItem(_group, _key), mReference(reference), -          mDefault(defaultValue), mLoadedValue(defaultValue) +    KConfigSkeletonGenericItem(const QString &_group, const QString &_key, T &reference, T defaultValue) +        : KConfigSkeletonItem(_group, _key) +        , mReference(reference) +        , mDefault(defaultValue) +        , mLoadedValue(defaultValue)      { -        setIsDefaultImpl([this] { return mReference == mDefault; }); -        setIsSaveNeededImpl([this] { return mReference != mLoadedValue; }); -        setGetDefaultImpl([this] { return QVariant::fromValue(mDefault); }); - +        setIsDefaultImpl([this] { +            return mReference == mDefault; +        }); +        setIsSaveNeededImpl([this] { +            return mReference != mLoadedValue; +        }); +        setGetDefaultImpl([this] { +            return QVariant::fromValue(mDefault); +        });      }      /** @@ -407,7 +413,7 @@ public:      }  protected: -    T &mReference;  ///< Stores the value for this item +    T &mReference; ///< Stores the value for this item      T mDefault; ///< The default value for this item      T mLoadedValue;  }; @@ -428,17 +434,16 @@ protected:  class KCONFIGCORE_EXPORT KConfigCompilerSignallingItem : public KConfigSkeletonItem  {  public: -    typedef void (QObject::* NotifyFunction)(quint64 arg); -    /** -    * Constructor. -    * -    * @param item the KConfigSkeletonItem to wrap -    * @param targetFunction the method to invoke whenever the value of @p item changes -    * @param object The object on which the method is invoked. -    * @param userData This data will be passed to @p targetFunction on every property change -    */ -    KConfigCompilerSignallingItem(KConfigSkeletonItem *item, QObject* object, -            NotifyFunction targetFunction, quint64 userData); +    typedef void (QObject::*NotifyFunction)(quint64 arg); +    /** +     * Constructor. +     * +     * @param item the KConfigSkeletonItem to wrap +     * @param targetFunction the method to invoke whenever the value of @p item changes +     * @param object The object on which the method is invoked. +     * @param userData This data will be passed to @p targetFunction on every property change +     */ +    KConfigCompilerSignallingItem(KConfigSkeletonItem *item, QObject *object, NotifyFunction targetFunction, quint64 userData);      ~KConfigCompilerSignallingItem() override;      void readConfig(KConfig *) override; @@ -466,14 +471,14 @@ private:          // call the pointer to member function using the strange ->* operator          (mObject->*mTargetFunction)(mUserData);      } +  private:      QScopedPointer<KConfigSkeletonItem> mItem;      NotifyFunction mTargetFunction; -    QObject* mObject; +    QObject *mObject;      quint64 mUserData;  }; -  /**   * \class KCoreConfigSkeleton kcoreconfigskeleton.h <KCoreConfigSkeleton>   * @@ -540,7 +545,7 @@ public:      /**       * Class for handling a string preferences item.       */ -    class KCONFIGCORE_EXPORT ItemString: public KConfigSkeletonGenericItem < QString > +    class KCONFIGCORE_EXPORT ItemString : public KConfigSkeletonGenericItem<QString>      {      public:          enum Type { @@ -565,9 +570,10 @@ public:          /** @copydoc KConfigSkeletonGenericItem::KConfigSkeletonGenericItem              @param type The type of string held by the item           */ -        ItemString(const QString &_group, const QString &_key, +        ItemString(const QString &_group, +                   const QString &_key,                     QString &reference, -                   const QString &defaultValue = QLatin1String(""),  // NOT QString() !! +                   const QString &defaultValue = QLatin1String(""), // NOT QString() !!                     Type type = Normal);          /** @copydoc KConfigSkeletonItem::writeConfig(KConfig*) */ @@ -592,39 +598,33 @@ public:      /**       * Class for handling a password preferences item.       */ -    class KCONFIGCORE_EXPORT ItemPassword: public ItemString +    class KCONFIGCORE_EXPORT ItemPassword : public ItemString      {      public:          /** @copydoc KConfigSkeletonGenericItem::KConfigSkeletonGenericItem */ -        ItemPassword(const QString &_group, const QString &_key, -                     QString &reference, -                     const QString &defaultValue = QLatin1String(""));  // NOT QString() !! +        ItemPassword(const QString &_group, const QString &_key, QString &reference, +                     const QString &defaultValue = QLatin1String("")); // NOT QString() !!      };      /**       * Class for handling a path preferences item.       */ -    class KCONFIGCORE_EXPORT ItemPath: public ItemString +    class KCONFIGCORE_EXPORT ItemPath : public ItemString      {      public:          /** @copydoc KConfigSkeletonGenericItem::KConfigSkeletonGenericItem */ -        ItemPath(const QString &_group, const QString &_key, -                 QString &reference, -                 const QString &defaultValue = QString()); +        ItemPath(const QString &_group, const QString &_key, QString &reference, const QString &defaultValue = QString());      };      /**       * Class for handling a url preferences item.       */ -    class KCONFIGCORE_EXPORT ItemUrl: public KConfigSkeletonGenericItem < QUrl > +    class KCONFIGCORE_EXPORT ItemUrl : public KConfigSkeletonGenericItem<QUrl>      {      public: -          /** @copydoc KConfigSkeletonGenericItem::KConfigSkeletonGenericItem           */ -        ItemUrl(const QString &_group, const QString &_key, -                QUrl &reference, -                const QUrl &defaultValue = QUrl()); +        ItemUrl(const QString &_group, const QString &_key, QUrl &reference, const QUrl &defaultValue = QUrl());          /** @copydoc KConfigSkeletonItem::writeConfig(KConfig*) */          void writeConfig(KConfig *config) override; @@ -645,12 +645,11 @@ public:      /**       * Class for handling a QVariant preferences item.       */ -    class KCONFIGCORE_EXPORT ItemProperty: public KConfigSkeletonGenericItem < QVariant > +    class KCONFIGCORE_EXPORT ItemProperty : public KConfigSkeletonGenericItem<QVariant>      {      public:          /** @copydoc KConfigSkeletonGenericItem::KConfigSkeletonGenericItem */ -        ItemProperty(const QString &_group, const QString &_key, -                     QVariant &reference, const QVariant &defaultValue = QVariant()); +        ItemProperty(const QString &_group, const QString &_key, QVariant &reference, const QVariant &defaultValue = QVariant());          void readConfig(KConfig *config) override;          void setProperty(const QVariant &p) override; @@ -665,12 +664,11 @@ public:      /**       * Class for handling a bool preferences item.       */ -    class KCONFIGCORE_EXPORT ItemBool: public KConfigSkeletonGenericItem < bool > +    class KCONFIGCORE_EXPORT ItemBool : public KConfigSkeletonGenericItem<bool>      {      public:          /** @copydoc KConfigSkeletonGenericItem::KConfigSkeletonGenericItem */ -        ItemBool(const QString &_group, const QString &_key, bool &reference, -                 bool defaultValue = true); +        ItemBool(const QString &_group, const QString &_key, bool &reference, bool defaultValue = true);          /** @copydoc KConfigSkeletonItem::readConfig(KConfig*) */          void readConfig(KConfig *config) override; @@ -688,12 +686,11 @@ public:      /**       * Class for handling a 32-bit integer preferences item.       */ -    class KCONFIGCORE_EXPORT ItemInt: public KConfigSkeletonGenericItem < qint32 > +    class KCONFIGCORE_EXPORT ItemInt : public KConfigSkeletonGenericItem<qint32>      {      public:          /** @copydoc KConfigSkeletonGenericItem::KConfigSkeletonGenericItem */ -        ItemInt(const QString &_group, const QString &_key, qint32 &reference, -                qint32 defaultValue = 0); +        ItemInt(const QString &_group, const QString &_key, qint32 &reference, qint32 defaultValue = 0);          /** @copydoc KConfigSkeletonItem::readConfig(KConfig*) */          void readConfig(KConfig *config) override; @@ -733,12 +730,11 @@ public:      /**       * Class for handling a 64-bit integer preferences item.       */ -    class KCONFIGCORE_EXPORT ItemLongLong: public KConfigSkeletonGenericItem < qint64 > +    class KCONFIGCORE_EXPORT ItemLongLong : public KConfigSkeletonGenericItem<qint64>      {      public:          /** @copydoc KConfigSkeletonGenericItem::KConfigSkeletonGenericItem */ -        ItemLongLong(const QString &_group, const QString &_key, qint64 &reference, -                     qint64 defaultValue = 0); +        ItemLongLong(const QString &_group, const QString &_key, qint64 &reference, qint64 defaultValue = 0);          /** @copydoc KConfigSkeletonItem::readConfig(KConfig*) */          void readConfig(KConfig *config) override; @@ -777,7 +773,7 @@ public:      /**       * Class for handling enums.       */ -    class KCONFIGCORE_EXPORT ItemEnum: public ItemInt +    class KCONFIGCORE_EXPORT ItemEnum : public ItemInt      {      public:          struct Choice { @@ -790,8 +786,7 @@ public:          /** @copydoc KConfigSkeletonGenericItem::KConfigSkeletonGenericItem              @param choices The list of enums that can be stored in this item            */ -        ItemEnum(const QString &_group, const QString &_key, qint32 &reference, -                 const QList<Choice> &choices, qint32 defaultValue = 0); +        ItemEnum(const QString &_group, const QString &_key, qint32 &reference, const QList<Choice> &choices, qint32 defaultValue = 0);          QList<Choice> choices() const; @@ -823,12 +818,11 @@ public:      /**       * Class for handling an unsigned 32-bit integer preferences item.       */ -    class KCONFIGCORE_EXPORT ItemUInt: public KConfigSkeletonGenericItem < quint32 > +    class KCONFIGCORE_EXPORT ItemUInt : public KConfigSkeletonGenericItem<quint32>      {      public:          /** @copydoc KConfigSkeletonGenericItem::KConfigSkeletonGenericItem */ -        ItemUInt(const QString &_group, const QString &_key, -                 quint32 &reference, quint32 defaultValue = 0); +        ItemUInt(const QString &_group, const QString &_key, quint32 &reference, quint32 defaultValue = 0);          /** @copydoc KConfigSkeletonItem::readConfig(KConfig*) */          void readConfig(KConfig *config) override; @@ -864,12 +858,11 @@ public:      /**       * Class for handling unsigned 64-bit integer preferences item.       */ -    class KCONFIGCORE_EXPORT ItemULongLong: public KConfigSkeletonGenericItem < quint64 > +    class KCONFIGCORE_EXPORT ItemULongLong : public KConfigSkeletonGenericItem<quint64>      {      public:          /** @copydoc KConfigSkeletonGenericItem::KConfigSkeletonGenericItem */ -        ItemULongLong(const QString &_group, const QString &_key, quint64 &reference, -                      quint64 defaultValue = 0); +        ItemULongLong(const QString &_group, const QString &_key, quint64 &reference, quint64 defaultValue = 0);          /** @copydoc KConfigSkeletonItem::readConfig(KConfig*) */          void readConfig(KConfig *config) override; @@ -908,12 +901,11 @@ public:      /**       * Class for handling a floating point preference item.       */ -    class KCONFIGCORE_EXPORT ItemDouble: public KConfigSkeletonGenericItem < double > +    class KCONFIGCORE_EXPORT ItemDouble : public KConfigSkeletonGenericItem<double>      {      public:          /** @copydoc KConfigSkeletonGenericItem::KConfigSkeletonGenericItem */ -        ItemDouble(const QString &_group, const QString &_key, -                   double &reference, double defaultValue = 0); +        ItemDouble(const QString &_group, const QString &_key, double &reference, double defaultValue = 0);          /** @copydoc KConfigSkeletonItem::readConfig(KConfig*) */          void readConfig(KConfig *config) override; @@ -949,12 +941,11 @@ public:      /**       * Class for handling a QRect preferences item.       */ -    class KCONFIGCORE_EXPORT ItemRect: public KConfigSkeletonGenericItem < QRect > +    class KCONFIGCORE_EXPORT ItemRect : public KConfigSkeletonGenericItem<QRect>      {      public:          /** @copydoc KConfigSkeletonGenericItem::KConfigSkeletonGenericItem */ -        ItemRect(const QString &_group, const QString &_key, QRect &reference, -                 const QRect &defaultValue = QRect()); +        ItemRect(const QString &_group, const QString &_key, QRect &reference, const QRect &defaultValue = QRect());          /** @copydoc KConfigSkeletonItem::readConfig(KConfig*) */          void readConfig(KConfig *config) override; @@ -972,12 +963,11 @@ public:      /**       * Class for handling a QPoint preferences item.       */ -    class KCONFIGCORE_EXPORT ItemPoint: public KConfigSkeletonGenericItem < QPoint > +    class KCONFIGCORE_EXPORT ItemPoint : public KConfigSkeletonGenericItem<QPoint>      {      public:          /** @copydoc KConfigSkeletonGenericItem::KConfigSkeletonGenericItem */ -        ItemPoint(const QString &_group, const QString &_key, QPoint &reference, -                  const QPoint &defaultValue = QPoint()); +        ItemPoint(const QString &_group, const QString &_key, QPoint &reference, const QPoint &defaultValue = QPoint());          /** @copydoc KConfigSkeletonItem::readConfig(KConfig*) */          void readConfig(KConfig *config) override; @@ -995,12 +985,11 @@ public:      /**       * Class for handling a QSize preferences item.       */ -    class KCONFIGCORE_EXPORT ItemSize: public KConfigSkeletonGenericItem < QSize > +    class KCONFIGCORE_EXPORT ItemSize : public KConfigSkeletonGenericItem<QSize>      {      public:          /** @copydoc KConfigSkeletonGenericItem::KConfigSkeletonGenericItem */ -        ItemSize(const QString &_group, const QString &_key, QSize &reference, -                 const QSize &defaultValue = QSize()); +        ItemSize(const QString &_group, const QString &_key, QSize &reference, const QSize &defaultValue = QSize());          /** @copydoc KConfigSkeletonItem::readConfig(KConfig*) */          void readConfig(KConfig *config) override; @@ -1018,13 +1007,11 @@ public:      /**       * Class for handling a QDateTime preferences item.       */ -    class KCONFIGCORE_EXPORT ItemDateTime: public KConfigSkeletonGenericItem < QDateTime > +    class KCONFIGCORE_EXPORT ItemDateTime : public KConfigSkeletonGenericItem<QDateTime>      {      public:          /** @copydoc KConfigSkeletonGenericItem::KConfigSkeletonGenericItem */ -        ItemDateTime(const QString &_group, const QString &_key, -                     QDateTime &reference, -                     const QDateTime &defaultValue = QDateTime()); +        ItemDateTime(const QString &_group, const QString &_key, QDateTime &reference, const QDateTime &defaultValue = QDateTime());          /** @copydoc KConfigSkeletonItem::readConfig(KConfig*) */          void readConfig(KConfig *config) override; @@ -1042,13 +1029,11 @@ public:      /**       * Class for handling a string list preferences item.       */ -    class KCONFIGCORE_EXPORT ItemStringList: public KConfigSkeletonGenericItem < QStringList > +    class KCONFIGCORE_EXPORT ItemStringList : public KConfigSkeletonGenericItem<QStringList>      {      public:          /** @copydoc KConfigSkeletonGenericItem::KConfigSkeletonGenericItem */ -        ItemStringList(const QString &_group, const QString &_key, -                       QStringList &reference, -                       const QStringList &defaultValue = QStringList()); +        ItemStringList(const QString &_group, const QString &_key, QStringList &reference, const QStringList &defaultValue = QStringList());          /** @copydoc KConfigSkeletonItem::readConfig(KConfig*) */          void readConfig(KConfig *config) override; @@ -1066,13 +1051,11 @@ public:      /**       * Class for handling a path list preferences item.       */ -    class KCONFIGCORE_EXPORT ItemPathList: public ItemStringList +    class KCONFIGCORE_EXPORT ItemPathList : public ItemStringList      {      public:          /** @copydoc KConfigSkeletonGenericItem::KConfigSkeletonGenericItem */ -        ItemPathList(const QString &_group, const QString &_key, -                     QStringList &reference, -                     const QStringList &defaultValue = QStringList()); +        ItemPathList(const QString &_group, const QString &_key, QStringList &reference, const QStringList &defaultValue = QStringList());          /** @copydoc KConfigSkeletonItem::readConfig */          void readConfig(KConfig *config) override; @@ -1083,13 +1066,11 @@ public:      /**       * Class for handling a url list preferences item.       */ -    class KCONFIGCORE_EXPORT ItemUrlList: public KConfigSkeletonGenericItem < QList<QUrl> > +    class KCONFIGCORE_EXPORT ItemUrlList : public KConfigSkeletonGenericItem<QList<QUrl>>      {      public:          /** @copydoc KConfigSkeletonGenericItem::KConfigSkeletonGenericItem */ -        ItemUrlList(const QString &_group, const QString &_key, -                    QList<QUrl> &reference, -                    const QList<QUrl> &defaultValue = QList<QUrl>()); +        ItemUrlList(const QString &_group, const QString &_key, QList<QUrl> &reference, const QList<QUrl> &defaultValue = QList<QUrl>());          /** @copydoc KConfigSkeletonItem::readConfig(KConfig*) */          void readConfig(KConfig *config) override; @@ -1110,13 +1091,11 @@ public:      /**       * Class for handling an integer list preferences item.       */ -    class KCONFIGCORE_EXPORT ItemIntList: public KConfigSkeletonGenericItem < QList < int > > +    class KCONFIGCORE_EXPORT ItemIntList : public KConfigSkeletonGenericItem<QList<int>>      {      public:          /** @copydoc KConfigSkeletonGenericItem::KConfigSkeletonGenericItem */ -        ItemIntList(const QString &_group, const QString &_key, -                    QList < int > &reference, -                    const QList < int > &defaultValue = QList < int >()); +        ItemIntList(const QString &_group, const QString &_key, QList<int> &reference, const QList<int> &defaultValue = QList<int>());          /** @copydoc KConfigSkeletonItem::readConfig(KConfig*) */          void readConfig(KConfig *config) override; @@ -1246,8 +1225,9 @@ public:       * @param key Key used in config file. If key is null, name is used as key.       * @return The created item       */ -    ItemString *addItemString(const QString &name, QString &reference, -                              const QString &defaultValue = QLatin1String(""),  // NOT QString() !! +    ItemString *addItemString(const QString &name, +                              QString &reference, +                              const QString &defaultValue = QLatin1String(""), // NOT QString() !!                                const QString &key = QString());      /** @@ -1263,9 +1243,7 @@ public:       * @param key Key used in config file. If key is null, name is used as key.       * @return The created item       */ -    ItemPassword *addItemPassword(const QString &name, QString &reference, -                                  const QString &defaultValue = QLatin1String(""), -                                  const QString &key = QString()); +    ItemPassword *addItemPassword(const QString &name, QString &reference, const QString &defaultValue = QLatin1String(""), const QString &key = QString());      /**       * Register a path item of type QString. The string value is interpreted @@ -1280,9 +1258,7 @@ public:       * @param key Key used in config file. If key is null, name is used as key.       * @return The created item       */ -    ItemPath *addItemPath(const QString &name, QString &reference, -                          const QString &defaultValue = QLatin1String(""), -                          const QString &key = QString()); +    ItemPath *addItemPath(const QString &name, QString &reference, const QString &defaultValue = QLatin1String(""), const QString &key = QString());      /**       * Register a property item of type QVariant. Note that only the following @@ -1297,9 +1273,7 @@ public:       * @param key Key used in config file. If key is null, name is used as key.       * @return The created item       */ -    ItemProperty *addItemProperty(const QString &name, QVariant &reference, -                                  const QVariant &defaultValue = QVariant(), -                                  const QString &key = QString()); +    ItemProperty *addItemProperty(const QString &name, QVariant &reference, const QVariant &defaultValue = QVariant(), const QString &key = QString());      /**       * Register an item of type bool.       * @@ -1311,9 +1285,7 @@ public:       * @param key Key used in config file. If key is null, name is used as key.       * @return The created item       */ -    ItemBool *addItemBool(const QString &name, bool &reference, -                          bool defaultValue = false, -                          const QString &key = QString()); +    ItemBool *addItemBool(const QString &name, bool &reference, bool defaultValue = false, const QString &key = QString());      /**       * Register an item of type qint32. @@ -1326,8 +1298,7 @@ public:       * @param key Key used in config file. If key is null, name is used as key.       * @return The created item       */ -    ItemInt *addItemInt(const QString &name, qint32 &reference, qint32 defaultValue = 0, -                        const QString &key = QString()); +    ItemInt *addItemInt(const QString &name, qint32 &reference, qint32 defaultValue = 0, const QString &key = QString());      /**       * Register an item of type quint32. @@ -1340,9 +1311,7 @@ public:       * @param key Key used in config file. If key is null, name is used as key.       * @return The created item       */ -    ItemUInt *addItemUInt(const QString &name, quint32 &reference, -                          quint32 defaultValue = 0, -                          const QString &key = QString()); +    ItemUInt *addItemUInt(const QString &name, quint32 &reference, quint32 defaultValue = 0, const QString &key = QString());      /**       * Register an item of type qint64. @@ -1355,18 +1324,14 @@ public:       * @param key Key used in config file. If key is null, name is used as key.       * @return The created item       */ -    ItemLongLong *addItemLongLong(const QString &name, qint64 &reference, -                                  qint64 defaultValue = 0, -                                  const QString &key = QString()); +    ItemLongLong *addItemLongLong(const QString &name, qint64 &reference, qint64 defaultValue = 0, const QString &key = QString());  #if KCONFIGCORE_ENABLE_DEPRECATED_SINCE(5, 0)      /**       * @deprecated Since 5.0, use addItemLongLong().       */      KCONFIGCORE_DEPRECATED_VERSION(5, 0, "Use KCoreConfigSkeleton::addItemLongLong(...)") -    ItemLongLong *addItemInt64(const QString &name, qint64 &reference, -            qint64 defaultValue = 0, -            const QString &key = QString()); +    ItemLongLong *addItemInt64(const QString &name, qint64 &reference, qint64 defaultValue = 0, const QString &key = QString());  #endif      /** @@ -1380,18 +1345,14 @@ public:       * @param key Key used in config file. If key is null, name is used as key.       * @return The created item       */ -    ItemULongLong *addItemULongLong(const QString &name, quint64 &reference, -                                    quint64 defaultValue = 0, -                                    const QString &key = QString()); +    ItemULongLong *addItemULongLong(const QString &name, quint64 &reference, quint64 defaultValue = 0, const QString &key = QString());  #if KCONFIGCORE_ENABLE_DEPRECATED_SINCE(5, 0)      /**       * @deprecated Since 5.0, use addItemULongLong().       */      KCONFIGCORE_DEPRECATED_VERSION(5, 0, "Use KCoreConfigSkeleton::addItemULongLong(...)") -    ItemULongLong *addItemUInt64(const QString &name, quint64 &reference, -            quint64 defaultValue = 0, -            const QString &key = QString()); +    ItemULongLong *addItemUInt64(const QString &name, quint64 &reference, quint64 defaultValue = 0, const QString &key = QString());  #endif      /** @@ -1405,9 +1366,7 @@ public:       * @param key Key used in config file. If key is null, name is used as key.       * @return The created item       */ -    ItemDouble *addItemDouble(const QString &name, double &reference, -                              double defaultValue = 0.0, -                              const QString &key = QString()); +    ItemDouble *addItemDouble(const QString &name, double &reference, double defaultValue = 0.0, const QString &key = QString());      /**       * Register an item of type QRect. @@ -1420,9 +1379,7 @@ public:       * @param key Key used in config file. If key is null, name is used as key.       * @return The created item       */ -    ItemRect *addItemRect(const QString &name, QRect &reference, -                          const QRect &defaultValue = QRect(), -                          const QString &key = QString()); +    ItemRect *addItemRect(const QString &name, QRect &reference, const QRect &defaultValue = QRect(), const QString &key = QString());      /**       * Register an item of type QPoint. @@ -1435,9 +1392,7 @@ public:       * @param key Key used in config file. If key is null, name is used as key.       * @return The created item       */ -    ItemPoint *addItemPoint(const QString &name, QPoint &reference, -                            const QPoint &defaultValue = QPoint(), -                            const QString &key = QString()); +    ItemPoint *addItemPoint(const QString &name, QPoint &reference, const QPoint &defaultValue = QPoint(), const QString &key = QString());      /**       * Register an item of type QSize. @@ -1450,9 +1405,7 @@ public:       * @param key Key used in config file. If key is null, name is used as key.       * @return The created item       */ -    ItemSize *addItemSize(const QString &name, QSize &reference, -                          const QSize &defaultValue = QSize(), -                          const QString &key = QString()); +    ItemSize *addItemSize(const QString &name, QSize &reference, const QSize &defaultValue = QSize(), const QString &key = QString());      /**       * Register an item of type QDateTime. @@ -1465,9 +1418,7 @@ public:       * @param key Key used in config file. If key is null, name is used as key.       * @return The created item       */ -    ItemDateTime *addItemDateTime(const QString &name, QDateTime &reference, -                                  const QDateTime &defaultValue = QDateTime(), -                                  const QString &key = QString()); +    ItemDateTime *addItemDateTime(const QString &name, QDateTime &reference, const QDateTime &defaultValue = QDateTime(), const QString &key = QString());      /**       * Register an item of type QStringList. @@ -1480,9 +1431,8 @@ public:       * @param key Key used in config file. If key is null, name is used as key.       * @return The created item       */ -    ItemStringList *addItemStringList(const QString &name, QStringList &reference, -                                      const QStringList &defaultValue = QStringList(), -                                      const QString &key = QString()); +    ItemStringList * +    addItemStringList(const QString &name, QStringList &reference, const QStringList &defaultValue = QStringList(), const QString &key = QString());      /**       * Register an item of type QList<int>. @@ -1495,10 +1445,7 @@ public:       * @param key Key used in config file. If key is null, name is used as key.       * @return The created item       */ -    ItemIntList *addItemIntList(const QString &name, QList < int > &reference, -                                const QList < int > &defaultValue = -                                    QList < int >(), -                                const QString &key = QString()); +    ItemIntList *addItemIntList(const QString &name, QList<int> &reference, const QList<int> &defaultValue = QList<int>(), const QString &key = QString());      /**       * Return the @ref KConfig object used for reading and writing the settings. @@ -1623,7 +1570,7 @@ protected:      virtual bool usrSave();  #if KCONFIGCORE_BUILD_DEPRECATED_SINCE(5, 0) -   /** +    /**       * @deprecated since 5.0, override usrRead instead.  This method is still called from usrRead       * for compatibility.       */ @@ -1632,7 +1579,7 @@ protected:  #endif  #if KCONFIGCORE_BUILD_DEPRECATED_SINCE(5, 0) -   /** +    /**       * @deprecated since 5.0, override usrSave instead.  This method is still called from usrSave       * for compatibility.       */ @@ -1643,7 +1590,6 @@ protected:  private:      KCoreConfigSkeletonPrivate *const d;      friend class KConfigSkeleton; -  };  #endif diff --git a/src/core/kcoreconfigskeleton_p.h b/src/core/kcoreconfigskeleton_p.h index 006bd45f..d854cc43 100644 --- a/src/core/kcoreconfigskeleton_p.h +++ b/src/core/kcoreconfigskeleton_p.h @@ -15,8 +15,10 @@ class KCoreConfigSkeletonPrivate  {  public:      KCoreConfigSkeletonPrivate() -        : mCurrentGroup(QStringLiteral("No Group")), mUseDefaults(false) -    {} +        : mCurrentGroup(QStringLiteral("No Group")) +        , mUseDefaults(false) +    { +    }      ~KCoreConfigSkeletonPrivate()      {          KConfigSkeletonItem::List::ConstIterator it; @@ -40,7 +42,8 @@ public:      KConfigSkeletonItemPrivate()          : mIsImmutable(true)          , mWriteFlags(KConfigBase::Normal) -    {} +    { +    }      virtual ~KConfigSkeletonItemPrivate();      bool mIsImmutable; ///< Indicates this item is immutable      KConfigBase::WriteConfigFlags mWriteFlags; ///< The flags to pass to calls of writeEntry() and revertToDefault() @@ -79,5 +82,4 @@ public:      std::function<void()> mNotifyFunction;  }; -  #endif diff --git a/src/core/kdesktopfile.cpp b/src/core/kdesktopfile.cpp index 0dccd2d2..d5029ffe 100644 --- a/src/core/kdesktopfile.cpp +++ b/src/core/kdesktopfile.cpp @@ -14,14 +14,14 @@  #include <QDir>  #include <QFileInfo> -#include <QUrl>  #include <QStandardPaths> +#include <QUrl>  #include "kauthorized.h" +#include "kconfig_core_log_settings.h"  #include "kconfig_p.h"  #include "kconfiggroup.h"  #include "kconfigini_p.h" -#include "kconfig_core_log_settings.h"  class KDesktopFilePrivate : public KConfigPrivate  { @@ -71,9 +71,8 @@ QString KDesktopFile::locateLocal(const QString &path)      // Relative to config? (e.g. for autostart)      const QStringList lstGenericConfigLocation = QStandardPaths::standardLocations(QStandardPaths::GenericConfigLocation);      // Iterate from the last item since some items may be subfolders of others. -    for (QStringList::const_reverse_iterator constIterator = lstGenericConfigLocation.crbegin();  -            constIterator != lstGenericConfigLocation.crend(); -            ++constIterator) { +    for (QStringList::const_reverse_iterator constIterator = lstGenericConfigLocation.crbegin(); constIterator != lstGenericConfigLocation.crend(); +         ++constIterator) {          const QString &dir = (*constIterator);          if (path.startsWith(dir + plus)) {              relativePath = path.mid(dir.length() + 1); @@ -102,16 +101,16 @@ bool KDesktopFile::isDesktopFile(const QString &path)  bool KDesktopFile::isAuthorizedDesktopFile(const QString &path)  {      if (path.isEmpty()) { -        return false;    // Empty paths are not ok. +        return false; // Empty paths are not ok.      }      if (QDir::isRelativePath(path)) { -        return true;    // Relative paths are ok. +        return true; // Relative paths are ok.      }      const QString realPath = QFileInfo(path).canonicalFilePath();      if (realPath.isEmpty()) { -        return false;    // File doesn't exist. +        return false; // File doesn't exist.      }  #ifndef Q_OS_WIN @@ -284,9 +283,7 @@ 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) { +        for (QStringList::ConstIterator it = list.begin(); it != list.end(); ++it) {              if (!KAuthorized::authorize((*it).trimmed())) {                  return false;              } @@ -314,24 +311,23 @@ bool KDesktopFile::tryExec() const  /**   * @return the filename as passed to the constructor.   */ -//QString KDesktopFile::fileName() const { return backEnd->fileName(); } +// QString KDesktopFile::fileName() const { return backEnd->fileName(); }  /**   * @return the resource type as passed to the constructor.   */ -//QString -//KDesktopFile::resource() const { return backEnd->resource(); } +// QString +// KDesktopFile::resource() const { return backEnd->resource(); }  #if KCONFIGCORE_BUILD_DEPRECATED_SINCE(5, 42) -QStringList -KDesktopFile::sortOrder() const +QStringList KDesktopFile::sortOrder() const  {      Q_D(const KDesktopFile);      return d->desktopGroup.readXdgListEntry("SortOrder");  }  #endif -//void KDesktopFile::virtual_hook( int id, void* data ) +// void KDesktopFile::virtual_hook( int id, void* data )  //{ KConfig::virtual_hook( id, data ); }  QString KDesktopFile::readDocPath() const @@ -344,7 +340,7 @@ KDesktopFile *KDesktopFile::copyTo(const QString &file) const  {      KDesktopFile *config = new KDesktopFile(QString());      this->KConfig::copyTo(file, config); -//  config->setDesktopGroup(); +    //  config->setDesktopGroup();      return config;  } diff --git a/src/core/kdesktopfile.h b/src/core/kdesktopfile.h index 4d817181..c98bf1bb 100644 --- a/src/core/kdesktopfile.h +++ b/src/core/kdesktopfile.h @@ -241,9 +241,8 @@ protected:      /** Virtual hook, used to add new "virtual" functions while maintaining          binary compatibility. Unused in this class.      */ -//  virtual void virtual_hook( int id, void* data ); +    //  virtual void virtual_hook( int id, void* data );  private: -      Q_DISABLE_COPY(KDesktopFile)      Q_DECLARE_PRIVATE(KDesktopFile) diff --git a/src/core/kemailsettings.cpp b/src/core/kemailsettings.cpp index ed4255b5..cfebe2a8 100644 --- a/src/core/kemailsettings.cpp +++ b/src/core/kemailsettings.cpp @@ -12,7 +12,10 @@  class KEMailSettingsPrivate  {  public: -    KEMailSettingsPrivate() : m_pConfig(nullptr) {} +    KEMailSettingsPrivate() +        : m_pConfig(nullptr) +    { +    }      ~KEMailSettingsPrivate()      {          delete m_pConfig; @@ -97,7 +100,7 @@ QString KEMailSettings::getSetting(KEMailSettings::Setting s) const      };      return QString();  } -void KEMailSettings::setSetting(KEMailSettings::Setting s, const QString  &v) +void KEMailSettings::setSetting(KEMailSettings::Setting s, const QString &v)  {      KConfigGroup cg(p->m_pConfig, QLatin1String("PROFILE_") + p->m_sCurrentProfile);      switch (s) { @@ -191,7 +194,6 @@ void KEMailSettings::setDefault(const QString &s)      p->m_pConfig->group("Defaults").writeEntry("Profile", s);      p->m_pConfig->sync();      p->m_sDefaultProfile = s; -  }  void KEMailSettings::setProfile(const QString &s) diff --git a/src/core/kemailsettings.h b/src/core/kemailsettings.h index 30f9942c..eb701f8c 100644 --- a/src/core/kemailsettings.h +++ b/src/core/kemailsettings.h @@ -15,29 +15,29 @@  class KEMailSettingsPrivate;  /** -  * \class KEMailSettings kemailsettings.h <KEMailSettings> -  * -  * This is just a small class to facilitate accessing e-mail settings in -  * a sane way, and allowing any program to manage multiple e-mail -  * profiles effortlessly -  * -  * The default profile is automatically selected in the constructor. -  * -  * @author Alex Zepeda zipzippy@sonic.net -  **/ + * \class KEMailSettings kemailsettings.h <KEMailSettings> + * + * This is just a small class to facilitate accessing e-mail settings in + * a sane way, and allowing any program to manage multiple e-mail + * profiles effortlessly + * + * The default profile is automatically selected in the constructor. + * + * @author Alex Zepeda zipzippy@sonic.net + **/  class KCONFIGCORE_EXPORT KEMailSettings  {      Q_DECLARE_TR_FUNCTIONS(KEMailSettings)  public:      /** -      * The list of settings that I thought of when I wrote this -      * class.  Any extra settings thought of later can be accessed -      * easily with getExtendedSetting and setExtendedSetting. -      * @see getSetting() -      * @see setSetting() -      * @see getExtendedSetting() -      * @see setExtendedSetting() -      **/ +     * The list of settings that I thought of when I wrote this +     * class.  Any extra settings thought of later can be accessed +     * easily with getExtendedSetting and setExtendedSetting. +     * @see getSetting() +     * @see setSetting() +     * @see getExtendedSetting() +     * @see setExtendedSetting() +     **/      enum Setting {          ClientProgram,          ClientTerminal, @@ -86,8 +86,8 @@ public:      };      /** -      * The various extensions allowed. -      **/ +     * The various extensions allowed. +     **/      enum Extension {          POP3,          SMTP, @@ -95,40 +95,40 @@ public:      };      /** -      * Default constructor, just sets things up and sets the default profile -      * as the current profile -      **/ +     * Default constructor, just sets things up and sets the default profile +     * as the current profile +     **/      KEMailSettings();      KEMailSettings(const KEMailSettings &) = delete; -    KEMailSettings& operator=(const KEMailSettings &) = delete; +    KEMailSettings &operator=(const KEMailSettings &) = delete;      /** -      * Default destructor, nothing to see here. -      **/ +     * Default destructor, nothing to see here. +     **/      ~KEMailSettings();      /** -      * List of profiles available. -      * @return the list of profiles -      **/ +     * List of profiles available. +     * @return the list of profiles +     **/      QStringList profiles() const;  #if KCONFIGCORE_ENABLE_DEPRECATED_SINCE(5, 0)      /** -      * Returns the name of the current profile. -      * @returns what profile we're currently using -      * @deprecated Since 5.0 -      **/ +     * Returns the name of the current profile. +     * @returns what profile we're currently using +     * @deprecated Since 5.0 +     **/      KCONFIGCORE_DEPRECATED_VERSION(5, 0, "API planned to be changed")      QString currentProfileName() const;      // see https://git.reviewboard.kde.org/r/111910/  #endif      /** -      * Change the current profile. -      * @param s the name of the new profile -      **/ +     * Change the current profile. +     * @param s the name of the new profile +     **/      void setProfile(const QString &s);      /** @@ -138,25 +138,25 @@ public:      QString defaultProfileName() const;      /** -      * Sets a new default. -      * @param def the new default -      **/ +     * Sets a new default. +     * @param def the new default +     **/      void setDefault(const QString &def);      /** -      * Get one of the predefined "basic" settings. -      * @param s the setting to get -      * @return the value of the setting, or QString() if not -      *         set -      **/ +     * Get one of the predefined "basic" settings. +     * @param s the setting to get +     * @return the value of the setting, or QString() if not +     *         set +     **/      QString getSetting(KEMailSettings::Setting s) const;      /** -      * Set one of the predefined "basic" settings. -      * @param s the setting to set -      * @param v the new value of the setting, or QString() to -      *         unset -      **/ +     * Set one of the predefined "basic" settings. +     * @param s the setting to set +     * @param v the new value of the setting, or QString() to +     *         unset +     **/      void setSetting(KEMailSettings::Setting s, const QString &v);  private: diff --git a/src/core/ksharedconfig.cpp b/src/core/ksharedconfig.cpp index cc6adeb9..98aa4c5e 100644 --- a/src/core/ksharedconfig.cpp +++ b/src/core/ksharedconfig.cpp @@ -7,9 +7,9 @@  */  #include "ksharedconfig.h" +#include "kconfig_p.h"  #include "kconfigbackend_p.h"  #include "kconfiggroup.h" -#include "kconfig_p.h"  #include <QCoreApplication>  #include <QThread>  #include <QThreadStorage> @@ -40,8 +40,8 @@ public:  };  static QThreadStorage<GlobalSharedConfigList *> s_storage; -template <typename T> -T * perThreadGlobalStatic() +template<typename T> +T *perThreadGlobalStatic()  {      if (!s_storage.hasLocalData()) {          s_storage.setLocalData(new T); @@ -50,7 +50,10 @@ T * perThreadGlobalStatic()  }  // Q_GLOBAL_STATIC(GlobalSharedConfigList, globalSharedConfigList), but per thread: -static GlobalSharedConfigList *globalSharedConfigList() { return perThreadGlobalStatic<GlobalSharedConfigList>(); } +static GlobalSharedConfigList *globalSharedConfigList() +{ +    return perThreadGlobalStatic<GlobalSharedConfigList>(); +}  void _k_globalMainConfigSync()  { @@ -60,9 +63,7 @@ void _k_globalMainConfigSync()      }  } -KSharedConfigPtr KSharedConfig::openConfig(const QString &_fileName, -        OpenFlags flags, -        QStandardPaths::StandardLocation resType) +KSharedConfigPtr KSharedConfig::openConfig(const QString &_fileName, OpenFlags flags, QStandardPaths::StandardLocation resType)  {      QString fileName(_fileName);      GlobalSharedConfigList *list = globalSharedConfigList(); @@ -78,11 +79,9 @@ KSharedConfigPtr KSharedConfig::openConfig(const QString &_fileName,      }      for (auto *cfg : qAsConst(*list)) { -        if (cfg->name() == fileName && -                cfg->d_ptr->openFlags == flags && -                cfg->locationType() == resType -//                cfg->backend()->type() == backend -           ) { +        if (cfg->name() == fileName && cfg->d_ptr->openFlags == flags && cfg->locationType() == resType +            //                cfg->backend()->type() == backend +        ) {              return KSharedConfigPtr(cfg);          }      } @@ -121,9 +120,7 @@ KSharedConfig::Ptr KSharedConfig::openStateConfig(const QString &_fileName)      return openConfig(fileName, SimpleConfig, QStandardPaths::AppDataLocation);  } -KSharedConfig::KSharedConfig(const QString &fileName, -                             OpenFlags flags, -                             QStandardPaths::StandardLocation resType) +KSharedConfig::KSharedConfig(const QString &fileName, OpenFlags flags, QStandardPaths::StandardLocation resType)      : KConfig(fileName, flags, resType)  {      globalSharedConfigList()->append(this); diff --git a/src/core/ksharedconfig.h b/src/core/ksharedconfig.h index be01401c..e23d17c6 100644 --- a/src/core/ksharedconfig.h +++ b/src/core/ksharedconfig.h @@ -9,8 +9,8 @@  #ifndef KSHAREDCONFIG_H  #define KSHAREDCONFIG_H -#include <kconfig.h>  #include <QExplicitlySharedDataPointer> +#include <kconfig.h>  /**   * \class KSharedConfig ksharedconfig.h <KSharedConfig> @@ -28,7 +28,7 @@   * using reparseConfiguration after a manual change notification, just like you have   * to do between processes.   */ -class KCONFIGCORE_EXPORT KSharedConfig : public KConfig, public QSharedData //krazy:exclude=dpointer (only for refcounting) +class KCONFIGCORE_EXPORT KSharedConfig : public KConfig, public QSharedData // krazy:exclude=dpointer (only for refcounting)  {  public:      typedef QExplicitlySharedDataPointer<KSharedConfig> Ptr; @@ -58,9 +58,8 @@ public:       *       * @sa KConfig       */ -    static KSharedConfig::Ptr openConfig(const QString &fileName = QString(), -                                         OpenFlags mode = FullConfig, -                                         QStandardPaths::StandardLocation type = QStandardPaths::GenericConfigLocation); +    static KSharedConfig::Ptr +    openConfig(const QString &fileName = QString(), OpenFlags mode = FullConfig, QStandardPaths::StandardLocation type = QStandardPaths::GenericConfigLocation);      /**       * Creates a KSharedConfig object to manipulate a configuration file suitable @@ -91,9 +90,7 @@ private:      KConfigGroup groupImpl(const QByteArray &aGroup) override;      const KConfigGroup groupImpl(const QByteArray &aGroup) const override; -    KSharedConfig(const QString &file, OpenFlags mode, -                  QStandardPaths::StandardLocation resourceType); - +    KSharedConfig(const QString &file, OpenFlags mode, QStandardPaths::StandardLocation resourceType);  };  typedef KSharedConfig::Ptr KSharedConfigPtr; diff --git a/src/gui/kconfiggroupgui.cpp b/src/gui/kconfiggroupgui.cpp index 96b042af..5fbdbfad 100644 --- a/src/gui/kconfiggroupgui.cpp +++ b/src/gui/kconfiggroupgui.cpp @@ -21,14 +21,11 @@   * @returns true if something was handled (even if output was set to clear or default)   *          or false if nothing was handled (e.g., Core type)   */ -static bool readEntryGui(const QByteArray &data, const char *key, const QVariant &input, -                         QVariant &output) +static bool readEntryGui(const QByteArray &data, const char *key, const QVariant &input, QVariant &output)  {      const auto errString = [&]() {          return QStringLiteral("\"%1\" - conversion from \"%3\" to %2 failed") -                              .arg(QLatin1String(key), -                                   QLatin1String(QVariant::typeToName(input.type())), -                                   QLatin1String(data.constData()) ); +            .arg(QLatin1String(key), QLatin1String(QVariant::typeToName(input.type())), QLatin1String(data.constData()));      };      // set in case of failure @@ -37,7 +34,7 @@ static bool readEntryGui(const QByteArray &data, const char *key, const QVariant      switch (static_cast<QMetaType::Type>(input.type())) {      case QMetaType::QColor: {          if (data.isEmpty() || data == "invalid") { -            output = QColor();  // return what was stored +            output = QColor(); // return what was stored              return true;          } else if (data.at(0) == '#') {              QColor col; @@ -59,7 +56,7 @@ static bool readEntryGui(const QByteArray &data, const char *key, const QVariant              if (count != 3 && count != 4) {                  const QString formatError = QStringLiteral(" (wrong format: expected '%1' items, read '%2')");                  qCritical() << qPrintable(errString()) << qPrintable(formatError.arg(QStringLiteral("3' or '4")).arg(count)); -                return true;    // return default +                return true; // return default              }              int temp[4]; @@ -72,9 +69,7 @@ static bool readEntryGui(const QByteArray &data, const char *key, const QVariant                      return true; // return default                  }                  if (j < 0 || j > 255) { -                    static const char *const components[] = { -                        "red", "green", "blue", "alpha" -                    }; +                    static const char *const components[] = {"red", "green", "blue", "alpha"};                      const QString boundsError = QStringLiteral(" (bounds error: %1 component %2)");                      qCritical() << qPrintable(errString())                                  << qPrintable(boundsError.arg(QLatin1String(components[i])).arg(j < 0 ? QStringLiteral("< 0") : QStringLiteral("> 255"))); @@ -114,13 +109,13 @@ static bool readEntryGui(const QByteArray &data, const char *key, const QVariant      case QMetaType::QCursor:      case QMetaType::QSizePolicy:      case QMetaType::QPen: -    // we may want to handle these in the future +        // we may want to handle these in the future      default:          break;      } -    return false;               // not handled +    return false; // not handled  }  /** @@ -129,8 +124,7 @@ static bool readEntryGui(const QByteArray &data, const char *key, const QVariant   * @returns true if something was handled (even if an empty value was written)   *          or false if nothing was handled (e.g., Core type)   */ -static bool writeEntryGui(KConfigGroup *cg, const char *key, const QVariant &prop, -                          KConfigGroup::WriteConfigFlags pFlags) +static bool writeEntryGui(KConfigGroup *cg, const char *key, const QVariant &prop, KConfigGroup::WriteConfigFlags pFlags)  {      switch (static_cast<QMetaType::Type>(prop.type())) {      case QMetaType::QColor: { @@ -161,10 +155,8 @@ static bool writeEntryGui(KConfigGroup *cg, const char *key, const QVariant &pro          // https://bugreports.qt.io/browse/QTBUG-63792          // https://bugs.kde.org/show_bug.cgi?id=378523          if (f.weight() == QFont::Normal -            && (f.styleName() == QLatin1String("Regular") -            || f.styleName() == QLatin1String("Normal") -            || f.styleName() == QLatin1String("Book") -            || f.styleName() == QLatin1String("Roman"))) { +            && (f.styleName() == QLatin1String("Regular") || f.styleName() == QLatin1String("Normal") || f.styleName() == QLatin1String("Book") +                || f.styleName() == QLatin1String("Roman"))) {              f.setStyleName(QString());          }          cg->writeEntry(key, f.toString().toUtf8(), pFlags); @@ -194,7 +186,7 @@ static int initKConfigGroupGui()  {      _kde_internal_KConfigGroupGui.readEntryGui = readEntryGui;      _kde_internal_KConfigGroupGui.writeEntryGui = writeEntryGui; -    return 42;                  // because 42 is nicer than 1 or 0 +    return 42; // because 42 is nicer than 1 or 0  }  #ifdef Q_CONSTRUCTOR_FUNCTION diff --git a/src/gui/kconfiggui.cpp b/src/gui/kconfiggui.cpp index 1daeec45..938fbd93 100644 --- a/src/gui/kconfiggui.cpp +++ b/src/gui/kconfiggui.cpp @@ -13,9 +13,7 @@  static QString configName(const QString &id, const QString &key)  { -    return(QLatin1String("session/") + QGuiApplication::applicationName() + -           QLatin1Char('_')          + id                                 + -           QLatin1Char('_')          + key); +    return (QLatin1String("session/") + QGuiApplication::applicationName() + QLatin1Char('_') + id + QLatin1Char('_') + key);  }  static KConfig *s_sessionConfig = nullptr; @@ -28,9 +26,7 @@ KConfig *KConfigGui::sessionConfig()      if (!hasSessionConfig() && qApp->isSessionRestored()) {          // create the default instance specific config object          // from applications' -session command line parameter -        s_sessionConfig = new KConfig(configName(qApp->sessionId(), -                                                 qApp->sessionKey()), -                                      KConfig::SimpleConfig); +        s_sessionConfig = new KConfig(configName(qApp->sessionId(), qApp->sessionKey()), KConfig::SimpleConfig);      }      return s_sessionConfig; @@ -44,8 +40,7 @@ void KConfigGui::setSessionConfig(const QString &id, const QString &key)      }      // create a new instance specific config object from supplied id & key -    s_sessionConfig = new KConfig(configName(id, key), -                                  KConfig::SimpleConfig); +    s_sessionConfig = new KConfig(configName(id, key), KConfig::SimpleConfig);  }  bool KConfigGui::hasSessionConfig() diff --git a/src/gui/kconfigloader.cpp b/src/gui/kconfigloader.cpp index 538a38ff..bc1751f4 100644 --- a/src/gui/kconfigloader.cpp +++ b/src/gui/kconfigloader.cpp @@ -27,8 +27,8 @@ void ConfigLoaderPrivate::parse(KConfigLoader *loader, QIODevice *xml)  }  ConfigLoaderHandler::ConfigLoaderHandler(KConfigLoader *config, ConfigLoaderPrivate *d) -    : m_config(config), -      d(d) +    : m_config(config) +    , d(d)  {      resetState();  } @@ -86,7 +86,7 @@ bool ConfigLoaderHandler::startElement(const QStringRef &localName, const QXmlSt          for (const auto &attr : attrs) {              const QStringRef name = attr.name();              if (name.compare(QLatin1String("name"), Qt::CaseInsensitive) == 0) { -                //qDebug() << "set group to" << attrs.value(i); +                // qDebug() << "set group to" << attrs.value(i);                  group = attr.value().toString();              }          } @@ -137,7 +137,7 @@ bool ConfigLoaderHandler::characters(const QStringRef &ch)  bool ConfigLoaderHandler::endElement(const QStringRef &localName)  { -//     qDebug() << "ConfigLoaderHandler::endElement(" << localName << qName; +    //     qDebug() << "ConfigLoaderHandler::endElement(" << localName << qName;      const QStringRef tag = localName;      if (tag.compare(QLatin1String("entry"), Qt::CaseInsensitive) == 0) {          addItem(); @@ -189,22 +189,16 @@ void ConfigLoaderHandler::addItem()      } else if (m_type == QLatin1String("color")) {          item = m_config->addItemColor(m_name, *d->newColor(), QColor(m_default), m_key);      } else if (m_type == QLatin1String("datetime")) { -        item = m_config->addItemDateTime(m_name, *d->newDateTime(), -                                         QDateTime::fromString(m_default), m_key); +        item = m_config->addItemDateTime(m_name, *d->newDateTime(), QDateTime::fromString(m_default), m_key);      } else if (m_type == QLatin1String("enum")) {          m_key = (m_key.isEmpty()) ? m_name : m_key; -        KConfigSkeleton::ItemEnum *enumItem = -            new KConfigSkeleton::ItemEnum(m_config->currentGroup(), -                                          m_key, *d->newInt(), -                                          m_enumChoices, -                                          m_default.toUInt()); +        KConfigSkeleton::ItemEnum *enumItem = new KConfigSkeleton::ItemEnum(m_config->currentGroup(), m_key, *d->newInt(), m_enumChoices, m_default.toUInt());          m_config->addItem(enumItem, m_name);          item = enumItem;      } else if (m_type == QLatin1String("font")) {          item = m_config->addItemFont(m_name, *d->newFont(), QFont(m_default), m_key);      } else if (m_type == QLatin1String("int")) { -        KConfigSkeleton::ItemInt *intItem = m_config->addItemInt(m_name, *d->newInt(), -                                            m_default.toInt(), m_key); +        KConfigSkeleton::ItemInt *intItem = m_config->addItemInt(m_name, *d->newInt(), m_default.toInt(), m_key);          if (m_haveMin) {              intItem->setMinValue(m_min); @@ -222,13 +216,11 @@ void ConfigLoaderHandler::addItem()      } else if (m_type == QLatin1String("string")) {          item = m_config->addItemString(m_name, *d->newString(), m_default, m_key);      } else if (m_type == QLatin1String("stringlist")) { -        //FIXME: the split() is naive and will break on lists with ,'s in them -        //empty parts are not wanted in this case -        item = m_config->addItemStringList(m_name, *d->newStringList(), -                                           m_default.split(QLatin1Char(','), Qt::SkipEmptyParts), m_key); +        // FIXME: the split() is naive and will break on lists with ,'s in them +        // empty parts are not wanted in this case +        item = m_config->addItemStringList(m_name, *d->newStringList(), m_default.split(QLatin1Char(','), Qt::SkipEmptyParts), m_key);      } else if (m_type == QLatin1String("uint")) { -        KConfigSkeleton::ItemUInt *uintItem = -            m_config->addItemUInt(m_name, *d->newUint(), m_default.toUInt(), m_key); +        KConfigSkeleton::ItemUInt *uintItem = m_config->addItemUInt(m_name, *d->newUint(), m_default.toUInt(), m_key);          if (m_haveMin) {              uintItem->setMinValue(m_min);          } @@ -238,15 +230,11 @@ void ConfigLoaderHandler::addItem()          item = uintItem;      } else if (m_type == QLatin1String("url")) {          m_key = (m_key.isEmpty()) ? m_name : m_key; -        KConfigSkeleton::ItemUrl *urlItem = -            new KConfigSkeleton::ItemUrl(m_config->currentGroup(), -                                         m_key, *d->newUrl(), -                                         QUrl::fromUserInput(m_default)); +        KConfigSkeleton::ItemUrl *urlItem = new KConfigSkeleton::ItemUrl(m_config->currentGroup(), m_key, *d->newUrl(), QUrl::fromUserInput(m_default));          m_config->addItem(urlItem, m_name);          item = urlItem;      } else if (m_type == QLatin1String("double")) { -        KConfigSkeleton::ItemDouble *doubleItem = m_config->addItemDouble(m_name, -                *d->newDouble(), m_default.toDouble(), m_key); +        KConfigSkeleton::ItemDouble *doubleItem = m_config->addItemDouble(m_name, *d->newDouble(), m_default.toDouble(), m_key);          if (m_haveMin) {              doubleItem->setMinValue(m_min);          } @@ -262,8 +250,7 @@ void ConfigLoaderHandler::addItem()          }          item = m_config->addItemIntList(m_name, *d->newIntList(), defaultList, m_key);      } else if (m_type == QLatin1String("longlong")) { -        KConfigSkeleton::ItemLongLong *longlongItem = m_config->addItemLongLong(m_name, -                *d->newLongLong(), m_default.toLongLong(), m_key); +        KConfigSkeleton::ItemLongLong *longlongItem = m_config->addItemLongLong(m_name, *d->newLongLong(), m_default.toLongLong(), m_key);          if (m_haveMin) {              longlongItem->setMinValue(m_min);          } @@ -288,8 +275,7 @@ void ConfigLoaderHandler::addItem()          QRect defaultRect;          const QStringList tmpList = m_default.split(QLatin1Char(','));          if (tmpList.size() >= 4) { -            defaultRect.setCoords(tmpList[0].toInt(), tmpList[1].toInt(), -                                  tmpList[2].toInt(), tmpList[3].toInt()); +            defaultRect.setCoords(tmpList[0].toInt(), tmpList[1].toInt(), tmpList[2].toInt(), tmpList[3].toInt());          }          item = m_config->addItemRect(m_name, *d->newRect(), defaultRect, m_key);      } else if (m_type == QLatin1String("size")) { @@ -301,8 +287,7 @@ void ConfigLoaderHandler::addItem()          }          item = m_config->addItemSize(m_name, *d->newSize(), defaultSize, m_key);      } else if (m_type == QLatin1String("ulonglong")) { -        KConfigSkeleton::ItemULongLong *ulonglongItem = -            m_config->addItemULongLong(m_name, *d->newULongLong(), m_default.toULongLong(), m_key); +        KConfigSkeleton::ItemULongLong *ulonglongItem = m_config->addItemULongLong(m_name, *d->newULongLong(), m_default.toULongLong(), m_key);          if (m_haveMin) {              ulonglongItem->setMinValue(m_min);          } @@ -345,25 +330,25 @@ void ConfigLoaderHandler::resetState()  }  KConfigLoader::KConfigLoader(const QString &configFile, QIODevice *xml, QObject *parent) -    : KConfigSkeleton(configFile, parent), -      d(new ConfigLoaderPrivate) +    : KConfigSkeleton(configFile, parent) +    , d(new ConfigLoaderPrivate)  {      d->parse(this, xml);  }  KConfigLoader::KConfigLoader(KSharedConfigPtr config, QIODevice *xml, QObject *parent) -    : KConfigSkeleton(std::move(config), parent), -      d(new ConfigLoaderPrivate) +    : KConfigSkeleton(std::move(config), parent) +    , d(new ConfigLoaderPrivate)  {      d->parse(this, xml);  } -//FIXME: obviously this is broken and should be using the group as the root, +// FIXME: obviously this is broken and should be using the group as the root,  //       but KConfigSkeleton does not currently support this. it will eventually though,  //       at which point this can be addressed properly  KConfigLoader::KConfigLoader(const KConfigGroup &config, QIODevice *xml, QObject *parent) -    : KConfigSkeleton(KSharedConfig::openConfig(config.config()->name(), config.config()->openFlags(), config.config()->locationType()), parent), -      d(new ConfigLoaderPrivate) +    : KConfigSkeleton(KSharedConfig::openConfig(config.config()->name(), config.config()->openFlags(), config.config()->locationType()), parent) +    , d(new ConfigLoaderPrivate)  {      KConfigGroup group = config.parent();      d->baseGroup = config.name(); @@ -418,7 +403,7 @@ bool KConfigLoader::usrSave()  {      if (d->saveDefaults) {          const auto listItems = items(); -        for (const auto& item : listItems) { +        for (const auto &item : listItems) {              config()->group(item->group()).writeEntry(item->key(), "");          }      } diff --git a/src/gui/kconfigloader.h b/src/gui/kconfigloader.h index 2e97ccd8..e40b68cb 100644 --- a/src/gui/kconfigloader.h +++ b/src/gui/kconfigloader.h @@ -166,4 +166,4 @@ private:      ConfigLoaderPrivate *const d;  }; -#endif //multiple inclusion guard +#endif // multiple inclusion guard diff --git a/src/gui/kconfigloaderhandler_p.h b/src/gui/kconfigloaderhandler_p.h index cf9b7081..bc199e0e 100644 --- a/src/gui/kconfigloaderhandler_p.h +++ b/src/gui/kconfigloaderhandler_p.h @@ -44,4 +44,3 @@ private:  };  #endif - diff --git a/src/gui/kconfigskeleton.cpp b/src/gui/kconfigskeleton.cpp index 031c7fbb..c3881c3b 100644 --- a/src/gui/kconfigskeleton.cpp +++ b/src/gui/kconfigskeleton.cpp @@ -20,9 +20,7 @@ KConfigSkeleton::KConfigSkeleton(KSharedConfig::Ptr pConfig, QObject *parent)  {  } -KConfigSkeleton::ItemColor::ItemColor(const QString &_group, const QString &_key, -                                      QColor &reference, -                                      const QColor &defaultValue) +KConfigSkeleton::ItemColor::ItemColor(const QString &_group, const QString &_key, QColor &reference, const QColor &defaultValue)      : KConfigSkeletonGenericItem<QColor>(_group, _key, reference, defaultValue)  {  } @@ -51,9 +49,7 @@ QVariant KConfigSkeleton::ItemColor::property() const      return QVariant(mReference);  } -KConfigSkeleton::ItemFont::ItemFont(const QString &_group, const QString &_key, -                                    QFont &reference, -                                    const QFont &defaultValue) +KConfigSkeleton::ItemFont::ItemFont(const QString &_group, const QString &_key, QFont &reference, const QFont &defaultValue)      : KConfigSkeletonGenericItem<QFont>(_group, _key, reference, defaultValue)  {  } @@ -82,23 +78,18 @@ QVariant KConfigSkeleton::ItemFont::property() const      return QVariant(mReference);  } -KConfigSkeleton::ItemColor *KConfigSkeleton::addItemColor(const QString &name, QColor &reference, -        const QColor &defaultValue, const QString &key) +KConfigSkeleton::ItemColor *KConfigSkeleton::addItemColor(const QString &name, QColor &reference, const QColor &defaultValue, const QString &key)  {      KConfigSkeleton::ItemColor *item; -    item = new KConfigSkeleton::ItemColor(d->mCurrentGroup, key.isNull() ? name : key, -                                          reference, defaultValue); +    item = new KConfigSkeleton::ItemColor(d->mCurrentGroup, key.isNull() ? name : key, reference, defaultValue);      addItem(item, name);      return item;  } -KConfigSkeleton::ItemFont *KConfigSkeleton::addItemFont(const QString &name, QFont &reference, -        const QFont &defaultValue, const QString &key) +KConfigSkeleton::ItemFont *KConfigSkeleton::addItemFont(const QString &name, QFont &reference, const QFont &defaultValue, const QString &key)  {      KConfigSkeleton::ItemFont *item; -    item = new KConfigSkeleton::ItemFont(d->mCurrentGroup, key.isNull() ? name : key, -                                         reference, defaultValue); +    item = new KConfigSkeleton::ItemFont(d->mCurrentGroup, key.isNull() ? name : key, reference, defaultValue);      addItem(item, name);      return item;  } - diff --git a/src/gui/kconfigskeleton.h b/src/gui/kconfigskeleton.h index 8e88e8d8..3f0aec87 100644 --- a/src/gui/kconfigskeleton.h +++ b/src/gui/kconfigskeleton.h @@ -32,13 +32,11 @@ public:      /**       * Class for handling a color preferences item.       */ -    class KCONFIGGUI_EXPORT ItemColor: public KConfigSkeletonGenericItem < QColor > +    class KCONFIGGUI_EXPORT ItemColor : public KConfigSkeletonGenericItem<QColor>      {      public:          /** @copydoc KConfigSkeletonGenericItem::KConfigSkeletonGenericItem */ -        ItemColor(const QString &_group, const QString &_key, -                  QColor &reference, -                  const QColor &defaultValue = QColor(128, 128, 128)); +        ItemColor(const QString &_group, const QString &_key, QColor &reference, const QColor &defaultValue = QColor(128, 128, 128));          /** @copydoc KConfigSkeletonItem::readConfig(KConfig*) */          void readConfig(KConfig *config) override; @@ -56,12 +54,11 @@ public:      /**       * Class for handling a font preferences item.       */ -    class KCONFIGGUI_EXPORT ItemFont: public KConfigSkeletonGenericItem < QFont > +    class KCONFIGGUI_EXPORT ItemFont : public KConfigSkeletonGenericItem<QFont>      {      public:          /** @copydoc KConfigSkeletonGenericItem::KConfigSkeletonGenericItem */ -        ItemFont(const QString &_group, const QString &_key, QFont &reference, -                 const QFont &defaultValue = QFont()); +        ItemFont(const QString &_group, const QString &_key, QFont &reference, const QFont &defaultValue = QFont());          /** @copydoc KConfigSkeletonItem::readConfig(KConfig*) */          void readConfig(KConfig *config) override; @@ -103,9 +100,7 @@ public:       * @param key Key used in config file. If key is null, name is used as key.       * @return The created item       */ -    ItemColor *addItemColor(const QString &name, QColor &reference, -                            const QColor &defaultValue = QColor(128, 128, 128), -                            const QString &key = QString()); +    ItemColor *addItemColor(const QString &name, QColor &reference, const QColor &defaultValue = QColor(128, 128, 128), const QString &key = QString());      /**       * Register an item of type QFont. @@ -118,10 +113,7 @@ public:       * @param key Key used in config file. If key is null, name is used as key.       * @return The created item       */ -    ItemFont *addItemFont(const QString &name, QFont &reference, -                          const QFont &defaultValue = QFont(), -                          const QString &key = QString()); - +    ItemFont *addItemFont(const QString &name, QFont &reference, const QFont &defaultValue = QFont(), const QString &key = QString());  };  #endif diff --git a/src/gui/kstandardshortcut.cpp b/src/gui/kstandardshortcut.cpp index c55d71c3..ac8431df 100644 --- a/src/gui/kstandardshortcut.cpp +++ b/src/gui/kstandardshortcut.cpp @@ -19,7 +19,6 @@  namespace KStandardShortcut  { -  struct KStandardShortcutInfo {      //! The standard shortcut id. @see StandardShortcut      StandardShortcut id; @@ -32,7 +31,10 @@ struct KStandardShortcutInfo {      const char *name;      //! Localized label for user-visible display, including translation context. -    struct { const char *text; const char *context; } description; +    struct { +        const char *text; +        const char *context; +    } description;      //! The keys for this shortcut      int cutDefault, cutDefault2; @@ -47,11 +49,11 @@ struct KStandardShortcutInfo {      Category category;  }; -#define CTRL(x) Qt::CTRL|Qt::Key_##x -#define SHIFT(x) Qt::SHIFT|Qt::Key_##x -#define CTRLSHIFT(x) Qt::CTRL|Qt::SHIFT|Qt::Key_##x -#define ALT(x) Qt::ALT|Qt::Key_##x -#define ALTSHIFT(x) Qt::ALT|Qt::SHIFT|Qt::Key_##x +#define CTRL(x) Qt::CTRL | Qt::Key_##x +#define SHIFT(x) Qt::SHIFT | Qt::Key_##x +#define CTRLSHIFT(x) Qt::CTRL | Qt::SHIFT | Qt::Key_##x +#define ALT(x) Qt::ALT | Qt::Key_##x +#define ALTSHIFT(x) Qt::ALT | Qt::SHIFT | Qt::Key_##x  /** Array of predefined KStandardShortcutInfo objects, which cover all      the "standard" accelerators. Each enum value from StandardShortcut @@ -60,129 +62,351 @@ struct KStandardShortcutInfo {  // STUFF WILL BREAK IF YOU DON'T READ THIS!!!  // Read the comments of the big enum in kstandardshortcut.h before you change anything!  static KStandardShortcutInfo g_infoStandardShortcut[] = { -//Group File, -    { AccelNone, nullptr, {nullptr, nullptr}, 0, 0, QList<QKeySequence>(), false, Category::InvalidCategory }, -    { Open, "Open", QT_TRANSLATE_NOOP3("KStandardShortcut", "Open", "@action"), CTRL(O), 0, QList<QKeySequence>(), false, Category::File }, -    { New, "New", QT_TRANSLATE_NOOP3("KStandardShortcut", "New", "@action"), CTRL(N), 0, QList<QKeySequence>(), false, Category::File }, -    { Close, "Close", QT_TRANSLATE_NOOP3("KStandardShortcut", "Close", "@action"), CTRL(W), CTRL(Escape), QList<QKeySequence>(), false, Category::File }, -    { Save, "Save", QT_TRANSLATE_NOOP3("KStandardShortcut", "Save", "@action"), CTRL(S), 0, QList<QKeySequence>(), false, Category::File }, -    { Print, "Print", QT_TRANSLATE_NOOP3("KStandardShortcut", "Print", "@action"), CTRL(P), 0, QList<QKeySequence>(), false, Category::File }, -    { Quit, "Quit", QT_TRANSLATE_NOOP3("KStandardShortcut", "Quit", "@action"), CTRL(Q), 0, QList<QKeySequence>(), false, Category::Navigation }, - -//Group Edit -    { Undo, "Undo", QT_TRANSLATE_NOOP3("KStandardShortcut", "Undo", "@action"), CTRL(Z), 0, QList<QKeySequence>(), false, Category::Edit }, -    { Redo, "Redo", QT_TRANSLATE_NOOP3("KStandardShortcut", "Redo", "@action"), CTRLSHIFT(Z), 0, QList<QKeySequence>(), false, Category::Edit }, +    // Group File, +    {AccelNone, nullptr, {nullptr, nullptr}, 0, 0, QList<QKeySequence>(), false, Category::InvalidCategory}, +    {Open, "Open", QT_TRANSLATE_NOOP3("KStandardShortcut", "Open", "@action"), CTRL(O), 0, QList<QKeySequence>(), false, Category::File}, +    {New, "New", QT_TRANSLATE_NOOP3("KStandardShortcut", "New", "@action"), CTRL(N), 0, QList<QKeySequence>(), false, Category::File}, +    {Close, "Close", QT_TRANSLATE_NOOP3("KStandardShortcut", "Close", "@action"), CTRL(W), CTRL(Escape), QList<QKeySequence>(), false, Category::File}, +    {Save, "Save", QT_TRANSLATE_NOOP3("KStandardShortcut", "Save", "@action"), CTRL(S), 0, QList<QKeySequence>(), false, Category::File}, +    {Print, "Print", QT_TRANSLATE_NOOP3("KStandardShortcut", "Print", "@action"), CTRL(P), 0, QList<QKeySequence>(), false, Category::File}, +    {Quit, "Quit", QT_TRANSLATE_NOOP3("KStandardShortcut", "Quit", "@action"), CTRL(Q), 0, QList<QKeySequence>(), false, Category::Navigation}, + +    // Group Edit +    {Undo, "Undo", QT_TRANSLATE_NOOP3("KStandardShortcut", "Undo", "@action"), CTRL(Z), 0, QList<QKeySequence>(), false, Category::Edit}, +    {Redo, "Redo", QT_TRANSLATE_NOOP3("KStandardShortcut", "Redo", "@action"), CTRLSHIFT(Z), 0, QList<QKeySequence>(), false, Category::Edit},      // Both "Cut" and "Delete" use Shift+Delete, but this is okay; see      // https://commits.kde.org/kxmlgui/8eabbf6725386e716b7536c71a9181dfe5d959f0 -    { Cut, "Cut", QT_TRANSLATE_NOOP3("KStandardShortcut", "Cut", "@action"), CTRL(X), SHIFT(Delete), QList<QKeySequence>(), false, Category::Edit }, -    { Copy, "Copy", QT_TRANSLATE_NOOP3("KStandardShortcut", "Copy", "@action"), CTRL(C), CTRL(Insert), QList<QKeySequence>(), false, Category::Edit}, -    { Paste, "Paste", QT_TRANSLATE_NOOP3("KStandardShortcut", "Paste", "@action"), CTRL(V), SHIFT(Insert), QList<QKeySequence>(), false, Category::Edit }, -    { PasteSelection, "Paste Selection", QT_TRANSLATE_NOOP3("KStandardShortcut", "Paste Selection", "@action"), CTRLSHIFT(Insert), 0, QList<QKeySequence>(), false, Category::Edit }, - -    { SelectAll, "SelectAll", QT_TRANSLATE_NOOP3("KStandardShortcut", "Select All", "@action"), CTRL(A), 0, QList<QKeySequence>(), false, Category::Edit }, -    { Deselect, "Deselect", QT_TRANSLATE_NOOP3("KStandardShortcut", "Deselect", "@action"), CTRLSHIFT(A), 0, QList<QKeySequence>(), false, Category::Edit }, -    { DeleteWordBack, "DeleteWordBack", QT_TRANSLATE_NOOP3("KStandardShortcut", "Delete Word Backwards", "@action"), CTRL(Backspace), 0, QList<QKeySequence>(), false, Category::Edit }, -    { DeleteWordForward, "DeleteWordForward", QT_TRANSLATE_NOOP3("KStandardShortcut", "Delete Word Forward", "@action"), CTRL(Delete), 0, QList<QKeySequence>(), false, Category::Edit }, - -    { Find, "Find", QT_TRANSLATE_NOOP3("KStandardShortcut", "Find", "@action"), CTRL(F), 0, QList<QKeySequence>(), false, Category::Edit }, -    { FindNext, "FindNext", QT_TRANSLATE_NOOP3("KStandardShortcut", "Find Next", "@action"), Qt::Key_F3, 0, QList<QKeySequence>(), false, Category::Edit }, -    { FindPrev, "FindPrev", QT_TRANSLATE_NOOP3("KStandardShortcut", "Find Prev", "@action"), SHIFT(F3), 0, QList<QKeySequence>(), false, Category::Edit }, -    { Replace, "Replace", QT_TRANSLATE_NOOP3("KStandardShortcut", "Replace", "@action"), CTRL(R), 0, QList<QKeySequence>(), false, Category::Edit }, - -//Group Navigation -    { Home, "Home", QT_TRANSLATE_NOOP3("KStandardShortcut", "Home", "@action Go to main page"), ALT(Home), Qt::Key_HomePage, QList<QKeySequence>(), false, Category::Navigation }, -    { Begin, "Begin", QT_TRANSLATE_NOOP3("KStandardShortcut", "Begin", "@action Beginning of document"), CTRL(Home), 0, QList<QKeySequence>(), false, Category::Navigation }, -    { End, "End", QT_TRANSLATE_NOOP3("KStandardShortcut", "End", "@action End of document"), CTRL(End), 0, QList<QKeySequence>(), false, Category::Navigation }, -    { Prior, "Prior", QT_TRANSLATE_NOOP3("KStandardShortcut", "Prior", "@action"), Qt::Key_PageUp, 0, QList<QKeySequence>(), false, Category::Navigation }, -    { Next, "Next", QT_TRANSLATE_NOOP3("KStandardShortcut", "Next", "@action Opposite to Prior"), Qt::Key_PageDown, 0, QList<QKeySequence>(), false, Category::Navigation }, - -    { Up, "Up", QT_TRANSLATE_NOOP3("KStandardShortcut", "Up", "@action"), ALT(Up), 0, QList<QKeySequence>(), false, Category::Navigation }, -    { Back, "Back", QT_TRANSLATE_NOOP3("KStandardShortcut", "Back", "@action"), ALT(Left), Qt::Key_Back, QList<QKeySequence>(), false, Category::Navigation }, -    { Forward, "Forward", QT_TRANSLATE_NOOP3("KStandardShortcut", "Forward", "@action"), ALT(Right), Qt::Key_Forward, QList<QKeySequence>(), false, Category::Navigation }, -    { Reload, "Reload", QT_TRANSLATE_NOOP3("KStandardShortcut", "Reload", "@action"), Qt::Key_F5, Qt::Key_Refresh, QList<QKeySequence>(), false, Category::Navigation }, - -    { BeginningOfLine, "BeginningOfLine", QT_TRANSLATE_NOOP3("KStandardShortcut", "Beginning of Line", "@action"), Qt::Key_Home, 0, QList<QKeySequence>(), false, Category::Navigation }, -    { EndOfLine, "EndOfLine", QT_TRANSLATE_NOOP3("KStandardShortcut", "End of Line", "@action"), Qt::Key_End, 0, QList<QKeySequence>(), false, Category::Navigation }, -    { GotoLine, "GotoLine", QT_TRANSLATE_NOOP3("KStandardShortcut", "Go to Line", "@action"), CTRL(G), 0, QList<QKeySequence>(), false, Category::Navigation }, -    { BackwardWord, "BackwardWord", QT_TRANSLATE_NOOP3("KStandardShortcut", "Backward Word", "@action"), CTRL(Left), 0, QList<QKeySequence>(), false, Category::Navigation }, -    { ForwardWord, "ForwardWord", QT_TRANSLATE_NOOP3("KStandardShortcut", "Forward Word", "@action"), CTRL(Right), 0, QList<QKeySequence>(), false, Category::Navigation }, - -    { AddBookmark, "AddBookmark", QT_TRANSLATE_NOOP3("KStandardShortcut", "Add Bookmark", "@action"), CTRL(B), 0, QList<QKeySequence>(), false, Category::Navigation }, -    { ZoomIn, "ZoomIn", QT_TRANSLATE_NOOP3("KStandardShortcut", "Zoom In", "@action"), CTRL(Plus), CTRL(Equal), QList<QKeySequence>(), false, Category::View }, -    { ZoomOut, "ZoomOut", QT_TRANSLATE_NOOP3("KStandardShortcut", "Zoom Out", "@action"), CTRL(Minus), 0, QList<QKeySequence>(), false, Category::View }, -    { FullScreen, "FullScreen", QT_TRANSLATE_NOOP3("KStandardShortcut", "Full Screen Mode", "@action"), CTRLSHIFT(F), 0, QList<QKeySequence>(), false, Category::View }, - -    { ShowMenubar, "ShowMenubar", QT_TRANSLATE_NOOP3("KStandardShortcut", "Show Menu Bar", "@action"), CTRL(M), 0, QList<QKeySequence>(), false, Category::View }, -    { TabNext, "Activate Next Tab", QT_TRANSLATE_NOOP3("KStandardShortcut", "Activate Next Tab", "@action"), CTRL(PageDown), CTRL(BracketRight), QList<QKeySequence>(), false, Category::Navigation  }, -    { TabPrev, "Activate Previous Tab", QT_TRANSLATE_NOOP3("KStandardShortcut", "Activate Previous Tab", "@action"), CTRL(PageUp), CTRL(BracketLeft), QList<QKeySequence>(), false, Category::Navigation  }, - -    //Group Help -    { Help, "Help", QT_TRANSLATE_NOOP3("KStandardShortcut", "Help", "@action"), Qt::Key_F1, 0, QList<QKeySequence>(), false, Category::Help }, -    { WhatsThis, "WhatsThis", QT_TRANSLATE_NOOP3("KStandardShortcut", "What's This", "@action"), SHIFT(F1), 0, QList<QKeySequence>(), false, Category::Help }, - -//Group TextCompletion -    { TextCompletion, "TextCompletion", QT_TRANSLATE_NOOP3("KStandardShortcut", "Text Completion", "@action"), CTRL(E), 0, QList<QKeySequence>(), false, Category::Edit }, -    { PrevCompletion, "PrevCompletion", QT_TRANSLATE_NOOP3("KStandardShortcut", "Previous Completion Match", "@action"), CTRL(Up), 0, QList<QKeySequence>(), false, Category::Edit }, -    { NextCompletion, "NextCompletion", QT_TRANSLATE_NOOP3("KStandardShortcut", "Next Completion Match", "@action"), CTRL(Down), 0, QList<QKeySequence>(), false, Category::Edit }, -    { SubstringCompletion, "SubstringCompletion", QT_TRANSLATE_NOOP3("KStandardShortcut", "Substring Completion", "@action"), CTRL(T), 0, QList<QKeySequence>(), false, Category::Edit }, - -    { RotateUp, "RotateUp", QT_TRANSLATE_NOOP3("KStandardShortcut", "Previous Item in List", "@action"), Qt::Key_Up, 0, QList<QKeySequence>(), false, Category::Navigation }, -    { RotateDown, "RotateDown", QT_TRANSLATE_NOOP3("KStandardShortcut", "Next Item in List", "@action"), Qt::Key_Down, 0, QList<QKeySequence>(), false, Category::Navigation }, - -    { OpenRecent, "OpenRecent", QT_TRANSLATE_NOOP3("KStandardShortcut", "Open Recent", "@action"), 0, 0, QList<QKeySequence>(), false, Category::File }, -    { SaveAs, "SaveAs", QT_TRANSLATE_NOOP3("KStandardShortcut", "Save As", "@action"), CTRLSHIFT(S), 0, QList<QKeySequence>(), false, Category::File }, -    { Revert, "Revert", QT_TRANSLATE_NOOP3("KStandardShortcut", "Revert", "@action"), 0, 0, QList<QKeySequence>(), false, Category::Edit }, -    { PrintPreview, "PrintPreview", QT_TRANSLATE_NOOP3("KStandardShortcut", "Print Preview", "@action"), 0, 0, QList<QKeySequence>(), false, Category::File }, -    { Mail, "Mail", QT_TRANSLATE_NOOP3("KStandardShortcut", "Mail", "@action"), 0, 0, QList<QKeySequence>(), false, Category::Help }, -    { Clear, "Clear", QT_TRANSLATE_NOOP3("KStandardShortcut", "Clear", "@action"), 0, 0, QList<QKeySequence>(), false, Category::Edit }, -    { ActualSize, "ActualSize", QT_TRANSLATE_NOOP3("KStandardShortcut", "Actual Size", "@action"), CTRL(0), 0, QList<QKeySequence>(), false, Category::View }, -    { FitToPage, "FitToPage", QT_TRANSLATE_NOOP3("KStandardShortcut", "Fit To Page", "@action"), 0, 0, QList<QKeySequence>(), false, Category::View }, -    { FitToWidth, "FitToWidth", QT_TRANSLATE_NOOP3("KStandardShortcut", "Fit To Width", "@action"), 0, 0, QList<QKeySequence>(), false, Category::View }, -    { FitToHeight, "FitToHeight", QT_TRANSLATE_NOOP3("KStandardShortcut", "Fit To Height", "@action"), 0, 0, QList<QKeySequence>(), false, Category::View }, -    { Zoom, "Zoom", QT_TRANSLATE_NOOP3("KStandardShortcut", "Zoom", "@action"), 0, 0, QList<QKeySequence>(), false, Category::View }, -    { Goto, "Goto", QT_TRANSLATE_NOOP3("KStandardShortcut", "Goto", "@action"), 0, 0, QList<QKeySequence>(), false, Category::Navigation }, -    { GotoPage, "GotoPage", QT_TRANSLATE_NOOP3("KStandardShortcut", "Goto Page", "@action"), 0, 0, QList<QKeySequence>(), false, Category::Navigation }, -    { DocumentBack, "DocumentBack", QT_TRANSLATE_NOOP3("KStandardShortcut", "Document Back", "@action"), ALTSHIFT(Left), 0, QList<QKeySequence>(), false, Category::Navigation }, -    { DocumentForward, "DocumentForward", QT_TRANSLATE_NOOP3("KStandardShortcut", "Document Forward", "@action"), ALTSHIFT(Right), 0, QList<QKeySequence>(), false, Category::Navigation }, -    { EditBookmarks, "EditBookmarks", QT_TRANSLATE_NOOP3("KStandardShortcut", "Edit Bookmarks", "@action"), 0, 0, QList<QKeySequence>(), false, Category::Navigation }, -    { Spelling, "Spelling", QT_TRANSLATE_NOOP3("KStandardShortcut", "Spelling", "@action"), 0, 0, QList<QKeySequence>(), false, Category::Edit }, -    { ShowToolbar, "ShowToolbar", QT_TRANSLATE_NOOP3("KStandardShortcut", "Show Toolbar", "@action"), 0, 0, QList<QKeySequence>(), false, Category::View }, -    { ShowStatusbar, "ShowStatusbar", QT_TRANSLATE_NOOP3("KStandardShortcut", "Show Statusbar", "@action"), 0, 0, QList<QKeySequence>(), false, Category::View }, +    {Cut, "Cut", QT_TRANSLATE_NOOP3("KStandardShortcut", "Cut", "@action"), CTRL(X), SHIFT(Delete), QList<QKeySequence>(), false, Category::Edit}, +    {Copy, "Copy", QT_TRANSLATE_NOOP3("KStandardShortcut", "Copy", "@action"), CTRL(C), CTRL(Insert), QList<QKeySequence>(), false, Category::Edit}, +    {Paste, "Paste", QT_TRANSLATE_NOOP3("KStandardShortcut", "Paste", "@action"), CTRL(V), SHIFT(Insert), QList<QKeySequence>(), false, Category::Edit}, +    {PasteSelection, +     "Paste Selection", +     QT_TRANSLATE_NOOP3("KStandardShortcut", "Paste Selection", "@action"), +     CTRLSHIFT(Insert), +     0, +     QList<QKeySequence>(), +     false, +     Category::Edit}, + +    {SelectAll, "SelectAll", QT_TRANSLATE_NOOP3("KStandardShortcut", "Select All", "@action"), CTRL(A), 0, QList<QKeySequence>(), false, Category::Edit}, +    {Deselect, "Deselect", QT_TRANSLATE_NOOP3("KStandardShortcut", "Deselect", "@action"), CTRLSHIFT(A), 0, QList<QKeySequence>(), false, Category::Edit}, +    {DeleteWordBack, +     "DeleteWordBack", +     QT_TRANSLATE_NOOP3("KStandardShortcut", "Delete Word Backwards", "@action"), +     CTRL(Backspace), +     0, +     QList<QKeySequence>(), +     false, +     Category::Edit}, +    {DeleteWordForward, +     "DeleteWordForward", +     QT_TRANSLATE_NOOP3("KStandardShortcut", "Delete Word Forward", "@action"), +     CTRL(Delete), +     0, +     QList<QKeySequence>(), +     false, +     Category::Edit}, + +    {Find, "Find", QT_TRANSLATE_NOOP3("KStandardShortcut", "Find", "@action"), CTRL(F), 0, QList<QKeySequence>(), false, Category::Edit}, +    {FindNext, "FindNext", QT_TRANSLATE_NOOP3("KStandardShortcut", "Find Next", "@action"), Qt::Key_F3, 0, QList<QKeySequence>(), false, Category::Edit}, +    {FindPrev, "FindPrev", QT_TRANSLATE_NOOP3("KStandardShortcut", "Find Prev", "@action"), SHIFT(F3), 0, QList<QKeySequence>(), false, Category::Edit}, +    {Replace, "Replace", QT_TRANSLATE_NOOP3("KStandardShortcut", "Replace", "@action"), CTRL(R), 0, QList<QKeySequence>(), false, Category::Edit}, + +    // Group Navigation +    {Home, +     "Home", +     QT_TRANSLATE_NOOP3("KStandardShortcut", "Home", "@action Go to main page"), +     ALT(Home), +     Qt::Key_HomePage, +     QList<QKeySequence>(), +     false, +     Category::Navigation}, +    {Begin, +     "Begin", +     QT_TRANSLATE_NOOP3("KStandardShortcut", "Begin", "@action Beginning of document"), +     CTRL(Home), +     0, +     QList<QKeySequence>(), +     false, +     Category::Navigation}, +    {End, "End", QT_TRANSLATE_NOOP3("KStandardShortcut", "End", "@action End of document"), CTRL(End), 0, QList<QKeySequence>(), false, Category::Navigation}, +    {Prior, "Prior", QT_TRANSLATE_NOOP3("KStandardShortcut", "Prior", "@action"), Qt::Key_PageUp, 0, QList<QKeySequence>(), false, Category::Navigation}, +    {Next, +     "Next", +     QT_TRANSLATE_NOOP3("KStandardShortcut", "Next", "@action Opposite to Prior"), +     Qt::Key_PageDown, +     0, +     QList<QKeySequence>(), +     false, +     Category::Navigation}, + +    {Up, "Up", QT_TRANSLATE_NOOP3("KStandardShortcut", "Up", "@action"), ALT(Up), 0, QList<QKeySequence>(), false, Category::Navigation}, +    {Back, "Back", QT_TRANSLATE_NOOP3("KStandardShortcut", "Back", "@action"), ALT(Left), Qt::Key_Back, QList<QKeySequence>(), false, Category::Navigation}, +    {Forward, +     "Forward", +     QT_TRANSLATE_NOOP3("KStandardShortcut", "Forward", "@action"), +     ALT(Right), +     Qt::Key_Forward, +     QList<QKeySequence>(), +     false, +     Category::Navigation}, +    {Reload, +     "Reload", +     QT_TRANSLATE_NOOP3("KStandardShortcut", "Reload", "@action"), +     Qt::Key_F5, +     Qt::Key_Refresh, +     QList<QKeySequence>(), +     false, +     Category::Navigation}, + +    {BeginningOfLine, +     "BeginningOfLine", +     QT_TRANSLATE_NOOP3("KStandardShortcut", "Beginning of Line", "@action"), +     Qt::Key_Home, +     0, +     QList<QKeySequence>(), +     false, +     Category::Navigation}, +    {EndOfLine, +     "EndOfLine", +     QT_TRANSLATE_NOOP3("KStandardShortcut", "End of Line", "@action"), +     Qt::Key_End, +     0, +     QList<QKeySequence>(), +     false, +     Category::Navigation}, +    {GotoLine, "GotoLine", QT_TRANSLATE_NOOP3("KStandardShortcut", "Go to Line", "@action"), CTRL(G), 0, QList<QKeySequence>(), false, Category::Navigation}, +    {BackwardWord, +     "BackwardWord", +     QT_TRANSLATE_NOOP3("KStandardShortcut", "Backward Word", "@action"), +     CTRL(Left), +     0, +     QList<QKeySequence>(), +     false, +     Category::Navigation}, +    {ForwardWord, +     "ForwardWord", +     QT_TRANSLATE_NOOP3("KStandardShortcut", "Forward Word", "@action"), +     CTRL(Right), +     0, +     QList<QKeySequence>(), +     false, +     Category::Navigation}, + +    {AddBookmark, +     "AddBookmark", +     QT_TRANSLATE_NOOP3("KStandardShortcut", "Add Bookmark", "@action"), +     CTRL(B), +     0, +     QList<QKeySequence>(), +     false, +     Category::Navigation}, +    {ZoomIn, "ZoomIn", QT_TRANSLATE_NOOP3("KStandardShortcut", "Zoom In", "@action"), CTRL(Plus), CTRL(Equal), QList<QKeySequence>(), false, Category::View}, +    {ZoomOut, "ZoomOut", QT_TRANSLATE_NOOP3("KStandardShortcut", "Zoom Out", "@action"), CTRL(Minus), 0, QList<QKeySequence>(), false, Category::View}, +    {FullScreen, +     "FullScreen", +     QT_TRANSLATE_NOOP3("KStandardShortcut", "Full Screen Mode", "@action"), +     CTRLSHIFT(F), +     0, +     QList<QKeySequence>(), +     false, +     Category::View}, + +    {ShowMenubar, "ShowMenubar", QT_TRANSLATE_NOOP3("KStandardShortcut", "Show Menu Bar", "@action"), CTRL(M), 0, QList<QKeySequence>(), false, Category::View}, +    {TabNext, +     "Activate Next Tab", +     QT_TRANSLATE_NOOP3("KStandardShortcut", "Activate Next Tab", "@action"), +     CTRL(PageDown), +     CTRL(BracketRight), +     QList<QKeySequence>(), +     false, +     Category::Navigation}, +    {TabPrev, +     "Activate Previous Tab", +     QT_TRANSLATE_NOOP3("KStandardShortcut", "Activate Previous Tab", "@action"), +     CTRL(PageUp), +     CTRL(BracketLeft), +     QList<QKeySequence>(), +     false, +     Category::Navigation}, + +    // Group Help +    {Help, "Help", QT_TRANSLATE_NOOP3("KStandardShortcut", "Help", "@action"), Qt::Key_F1, 0, QList<QKeySequence>(), false, Category::Help}, +    {WhatsThis, "WhatsThis", QT_TRANSLATE_NOOP3("KStandardShortcut", "What's This", "@action"), SHIFT(F1), 0, QList<QKeySequence>(), false, Category::Help}, + +    // Group TextCompletion +    {TextCompletion, +     "TextCompletion", +     QT_TRANSLATE_NOOP3("KStandardShortcut", "Text Completion", "@action"), +     CTRL(E), +     0, +     QList<QKeySequence>(), +     false, +     Category::Edit}, +    {PrevCompletion, +     "PrevCompletion", +     QT_TRANSLATE_NOOP3("KStandardShortcut", "Previous Completion Match", "@action"), +     CTRL(Up), +     0, +     QList<QKeySequence>(), +     false, +     Category::Edit}, +    {NextCompletion, +     "NextCompletion", +     QT_TRANSLATE_NOOP3("KStandardShortcut", "Next Completion Match", "@action"), +     CTRL(Down), +     0, +     QList<QKeySequence>(), +     false, +     Category::Edit}, +    {SubstringCompletion, +     "SubstringCompletion", +     QT_TRANSLATE_NOOP3("KStandardShortcut", "Substring Completion", "@action"), +     CTRL(T), +     0, +     QList<QKeySequence>(), +     false, +     Category::Edit}, + +    {RotateUp, +     "RotateUp", +     QT_TRANSLATE_NOOP3("KStandardShortcut", "Previous Item in List", "@action"), +     Qt::Key_Up, +     0, +     QList<QKeySequence>(), +     false, +     Category::Navigation}, +    {RotateDown, +     "RotateDown", +     QT_TRANSLATE_NOOP3("KStandardShortcut", "Next Item in List", "@action"), +     Qt::Key_Down, +     0, +     QList<QKeySequence>(), +     false, +     Category::Navigation}, + +    {OpenRecent, "OpenRecent", QT_TRANSLATE_NOOP3("KStandardShortcut", "Open Recent", "@action"), 0, 0, QList<QKeySequence>(), false, Category::File}, +    {SaveAs, "SaveAs", QT_TRANSLATE_NOOP3("KStandardShortcut", "Save As", "@action"), CTRLSHIFT(S), 0, QList<QKeySequence>(), false, Category::File}, +    {Revert, "Revert", QT_TRANSLATE_NOOP3("KStandardShortcut", "Revert", "@action"), 0, 0, QList<QKeySequence>(), false, Category::Edit}, +    {PrintPreview, "PrintPreview", QT_TRANSLATE_NOOP3("KStandardShortcut", "Print Preview", "@action"), 0, 0, QList<QKeySequence>(), false, Category::File}, +    {Mail, "Mail", QT_TRANSLATE_NOOP3("KStandardShortcut", "Mail", "@action"), 0, 0, QList<QKeySequence>(), false, Category::Help}, +    {Clear, "Clear", QT_TRANSLATE_NOOP3("KStandardShortcut", "Clear", "@action"), 0, 0, QList<QKeySequence>(), false, Category::Edit}, +    {ActualSize, "ActualSize", QT_TRANSLATE_NOOP3("KStandardShortcut", "Actual Size", "@action"), CTRL(0), 0, QList<QKeySequence>(), false, Category::View}, +    {FitToPage, "FitToPage", QT_TRANSLATE_NOOP3("KStandardShortcut", "Fit To Page", "@action"), 0, 0, QList<QKeySequence>(), false, Category::View}, +    {FitToWidth, "FitToWidth", QT_TRANSLATE_NOOP3("KStandardShortcut", "Fit To Width", "@action"), 0, 0, QList<QKeySequence>(), false, Category::View}, +    {FitToHeight, "FitToHeight", QT_TRANSLATE_NOOP3("KStandardShortcut", "Fit To Height", "@action"), 0, 0, QList<QKeySequence>(), false, Category::View}, +    {Zoom, "Zoom", QT_TRANSLATE_NOOP3("KStandardShortcut", "Zoom", "@action"), 0, 0, QList<QKeySequence>(), false, Category::View}, +    {Goto, "Goto", QT_TRANSLATE_NOOP3("KStandardShortcut", "Goto", "@action"), 0, 0, QList<QKeySequence>(), false, Category::Navigation}, +    {GotoPage, "GotoPage", QT_TRANSLATE_NOOP3("KStandardShortcut", "Goto Page", "@action"), 0, 0, QList<QKeySequence>(), false, Category::Navigation}, +    {DocumentBack, +     "DocumentBack", +     QT_TRANSLATE_NOOP3("KStandardShortcut", "Document Back", "@action"), +     ALTSHIFT(Left), +     0, +     QList<QKeySequence>(), +     false, +     Category::Navigation}, +    {DocumentForward, +     "DocumentForward", +     QT_TRANSLATE_NOOP3("KStandardShortcut", "Document Forward", "@action"), +     ALTSHIFT(Right), +     0, +     QList<QKeySequence>(), +     false, +     Category::Navigation}, +    {EditBookmarks, +     "EditBookmarks", +     QT_TRANSLATE_NOOP3("KStandardShortcut", "Edit Bookmarks", "@action"), +     0, +     0, +     QList<QKeySequence>(), +     false, +     Category::Navigation}, +    {Spelling, "Spelling", QT_TRANSLATE_NOOP3("KStandardShortcut", "Spelling", "@action"), 0, 0, QList<QKeySequence>(), false, Category::Edit}, +    {ShowToolbar, "ShowToolbar", QT_TRANSLATE_NOOP3("KStandardShortcut", "Show Toolbar", "@action"), 0, 0, QList<QKeySequence>(), false, Category::View}, +    {ShowStatusbar, "ShowStatusbar", QT_TRANSLATE_NOOP3("KStandardShortcut", "Show Statusbar", "@action"), 0, 0, QList<QKeySequence>(), false, Category::View},  #if KCONFIGGUI_BUILD_DEPRECATED_SINCE(5, 39) -    { SaveOptions, "SaveOptions", QT_TRANSLATE_NOOP3("KStandardShortcut", "Save Options", "@action"), 0, 0, QList<QKeySequence>(), false, Category::Settings }, +    {SaveOptions, "SaveOptions", QT_TRANSLATE_NOOP3("KStandardShortcut", "Save Options", "@action"), 0, 0, QList<QKeySequence>(), false, Category::Settings},  #else      // dummy entry -    { SaveOptions_DEPRECATED_DO_NOT_USE, nullptr, {nullptr, nullptr}, 0, 0, QList<QKeySequence>(), false, Category::InvalidCategory }, +    {SaveOptions_DEPRECATED_DO_NOT_USE, nullptr, {nullptr, nullptr}, 0, 0, QList<QKeySequence>(), false, Category::InvalidCategory},  #endif -    { KeyBindings, "KeyBindings", QT_TRANSLATE_NOOP3("KStandardShortcut", "Key Bindings", "@action"), 0, 0, QList<QKeySequence>(), false, Category::Settings }, -    { Preferences, "Preferences", QT_TRANSLATE_NOOP3("KStandardShortcut", "Configure Application", "@action"), CTRLSHIFT(Comma), 0, QList<QKeySequence>(), false, Category::Settings }, -    { ConfigureToolbars, "ConfigureToolbars", QT_TRANSLATE_NOOP3("KStandardShortcut", "Configure Toolbars", "@action"), 0, 0, QList<QKeySequence>(), false, Category::Settings }, -    { ConfigureNotifications, "ConfigureNotifications", QT_TRANSLATE_NOOP3("KStandardShortcut", "Configure Notifications", "@action"), 0, 0, QList<QKeySequence>(), false, Category::Settings }, -    { TipofDay, "TipofDay", QT_TRANSLATE_NOOP3("KStandardShortcut", "Tip Of Day", "@action"), 0, 0, QList<QKeySequence>(), false, Category::Help }, -    { ReportBug, "ReportBug", QT_TRANSLATE_NOOP3("KStandardShortcut", "Report Bug", "@action"), 0, 0, QList<QKeySequence>(), false, Category::Help }, -    { SwitchApplicationLanguage, "SwitchApplicationLanguage", QT_TRANSLATE_NOOP3("KStandardShortcut", "Configure Language...", "@action"), 0, 0, QList<QKeySequence>(), false, Category::Settings }, -    { AboutApp, "AboutApp", QT_TRANSLATE_NOOP3("KStandardShortcut", "About Application", "@action"), 0, 0, QList<QKeySequence>(), false, Category::Help }, -    { AboutKDE, "AboutKDE", QT_TRANSLATE_NOOP3("KStandardShortcut", "About KDE", "@action"), 0, 0, QList<QKeySequence>(), false, Category::Help }, +    {KeyBindings, "KeyBindings", QT_TRANSLATE_NOOP3("KStandardShortcut", "Key Bindings", "@action"), 0, 0, QList<QKeySequence>(), false, Category::Settings}, +    {Preferences, +     "Preferences", +     QT_TRANSLATE_NOOP3("KStandardShortcut", "Configure Application", "@action"), +     CTRLSHIFT(Comma), +     0, +     QList<QKeySequence>(), +     false, +     Category::Settings}, +    {ConfigureToolbars, +     "ConfigureToolbars", +     QT_TRANSLATE_NOOP3("KStandardShortcut", "Configure Toolbars", "@action"), +     0, +     0, +     QList<QKeySequence>(), +     false, +     Category::Settings}, +    {ConfigureNotifications, +     "ConfigureNotifications", +     QT_TRANSLATE_NOOP3("KStandardShortcut", "Configure Notifications", "@action"), +     0, +     0, +     QList<QKeySequence>(), +     false, +     Category::Settings}, +    {TipofDay, "TipofDay", QT_TRANSLATE_NOOP3("KStandardShortcut", "Tip Of Day", "@action"), 0, 0, QList<QKeySequence>(), false, Category::Help}, +    {ReportBug, "ReportBug", QT_TRANSLATE_NOOP3("KStandardShortcut", "Report Bug", "@action"), 0, 0, QList<QKeySequence>(), false, Category::Help}, +    {SwitchApplicationLanguage, +     "SwitchApplicationLanguage", +     QT_TRANSLATE_NOOP3("KStandardShortcut", "Configure Language...", "@action"), +     0, +     0, +     QList<QKeySequence>(), +     false, +     Category::Settings}, +    {AboutApp, "AboutApp", QT_TRANSLATE_NOOP3("KStandardShortcut", "About Application", "@action"), 0, 0, QList<QKeySequence>(), false, Category::Help}, +    {AboutKDE, "AboutKDE", QT_TRANSLATE_NOOP3("KStandardShortcut", "About KDE", "@action"), 0, 0, QList<QKeySequence>(), false, Category::Help},      // Both "Cut" and "Delete" use Shift+Delete, but this is okay; see      // https://commits.kde.org/kxmlgui/8eabbf6725386e716b7536c71a9181dfe5d959f0 -    { DeleteFile, "DeleteFile", QT_TRANSLATE_NOOP3("KStandardShortcut", "Delete", "@action"), SHIFT(Delete), 0, QList<QKeySequence>(), false, Category::File }, -    { RenameFile, "RenameFile", QT_TRANSLATE_NOOP3("KStandardShortcut", "Rename", "@action"), Qt::Key_F2, 0, QList<QKeySequence>(), false, Category::File }, -    { MoveToTrash, "MoveToTrash", QT_TRANSLATE_NOOP3("KStandardShortcut", "Move to Trash", "@action"), Qt::Key_Delete, 0, QList<QKeySequence>(), false, Category::File }, -    { Donate, "Donate", QT_TRANSLATE_NOOP3("KStandardShortcut", "Donate", "@action"), 0, 0, QList<QKeySequence>(), false, Category::Help }, -    { ShowHideHiddenFiles, "ShowHideHiddenFiles", QT_TRANSLATE_NOOP3("KStandardShortcut", "Show/Hide Hidden Files", "@action"), CTRL(H), ALT(Period), QList<QKeySequence>(), false, Category::View }, -    { CreateFolder, "CreateFolder", QT_TRANSLATE_NOOP3("KStandardShortcut", "Create Folder", "@action"), Qt::Key_F10, 0, QList<QKeySequence>(), false, Category::File }, - -    //dummy entry to catch simple off-by-one errors. Insert new entries before this line. -    { AccelNone, nullptr, {nullptr, nullptr}, 0, 0, QList<QKeySequence>(), false, Category::InvalidCategory } -}; +    {DeleteFile, "DeleteFile", QT_TRANSLATE_NOOP3("KStandardShortcut", "Delete", "@action"), SHIFT(Delete), 0, QList<QKeySequence>(), false, Category::File}, +    {RenameFile, "RenameFile", QT_TRANSLATE_NOOP3("KStandardShortcut", "Rename", "@action"), Qt::Key_F2, 0, QList<QKeySequence>(), false, Category::File}, +    {MoveToTrash, +     "MoveToTrash", +     QT_TRANSLATE_NOOP3("KStandardShortcut", "Move to Trash", "@action"), +     Qt::Key_Delete, +     0, +     QList<QKeySequence>(), +     false, +     Category::File}, +    {Donate, "Donate", QT_TRANSLATE_NOOP3("KStandardShortcut", "Donate", "@action"), 0, 0, QList<QKeySequence>(), false, Category::Help}, +    {ShowHideHiddenFiles, +     "ShowHideHiddenFiles", +     QT_TRANSLATE_NOOP3("KStandardShortcut", "Show/Hide Hidden Files", "@action"), +     CTRL(H), +     ALT(Period), +     QList<QKeySequence>(), +     false, +     Category::View}, +    {CreateFolder, +     "CreateFolder", +     QT_TRANSLATE_NOOP3("KStandardShortcut", "Create Folder", "@action"), +     Qt::Key_F10, +     0, +     QList<QKeySequence>(), +     false, +     Category::File}, + +    // dummy entry to catch simple off-by-one errors. Insert new entries before this line. +    {AccelNone, nullptr, {nullptr, nullptr}, 0, 0, QList<QKeySequence>(), false, Category::InvalidCategory}};  /** Search for the KStandardShortcutInfo object associated with the given @p id.      Return a dummy entry with no name and an empty shortcut if @p id is invalid.  */  static KStandardShortcutInfo *guardedStandardShortcutInfo(StandardShortcut id)  { -    if (id >= static_cast<int>(sizeof(g_infoStandardShortcut) / sizeof(KStandardShortcutInfo)) || -            id < 0) { +    if (id >= static_cast<int>(sizeof(g_infoStandardShortcut) / sizeof(KStandardShortcutInfo)) || id < 0) {          qWarning() << "KStandardShortcut: id not found!";          return &g_infoStandardShortcut[AccelNone];      } else { @@ -190,7 +414,6 @@ static KStandardShortcutInfo *guardedStandardShortcutInfo(StandardShortcut id)      }  } -  // Sanitize the list for duplicates. For some reason some  // people have kdeglobals entries like  //   Close=Ctrl+W; Ctrl+Esc; Ctrl+W; Ctrl+Esc; @@ -278,18 +501,16 @@ QString name(StandardShortcut id)  QString label(StandardShortcut id)  {      KStandardShortcutInfo *info = guardedStandardShortcutInfo(id); -    return QCoreApplication::translate("KStandardShortcut", -                                       info->description.text, -                                       info->description.context); +    return QCoreApplication::translate("KStandardShortcut", info->description.text, info->description.context);  }  // TODO: Add psWhatsThis entry to KStandardShortcutInfo  QString whatsThis(StandardShortcut /*id*/)  { -//  KStandardShortcutInfo* info = guardedStandardShortcutInfo( id ); -//  if( info && info->whatsThis ) -//      return i18n(info->whatsThis); -//  else +    //  KStandardShortcutInfo* info = guardedStandardShortcutInfo( id ); +    //  if( info && info->whatsThis ) +    //      return i18n(info->whatsThis); +    //  else      return QString();  } @@ -326,7 +547,6 @@ StandardShortcut find(const QKeySequence &seq)      return AccelNone;  } -  #if KCONFIGGUI_BUILD_DEPRECATED_SINCE(5, 71)  StandardShortcut find(const char *keyName)  { @@ -342,7 +562,6 @@ StandardShortcut find(const char *keyName)  StandardShortcut findByName(const QString &name)  { -      for (const KStandardShortcutInfo &shortcutInfo : g_infoStandardShortcut) {          if (QString::fromLatin1(shortcutInfo.name) == name) {              return shortcutInfo.id; diff --git a/src/gui/kstandardshortcut.h b/src/gui/kstandardshortcut.h index 3757a593..6ffbeed6 100644 --- a/src/gui/kstandardshortcut.h +++ b/src/gui/kstandardshortcut.h @@ -9,8 +9,8 @@  #ifndef KSTANDARDSHORTCUT_H  #define KSTANDARDSHORTCUT_H -#include <QString>  #include <QKeySequence> +#include <QString>  #include <kconfiggui_export.h> @@ -42,8 +42,8 @@ namespace KStandardShortcut   * Defines the identifier of all standard accelerators.   */  enum StandardShortcut { -    //C++ requires that the value of an enum symbol be one more than the previous one. -    //This means that everything will be well-ordered from here on. +    // C++ requires that the value of an enum symbol be one more than the previous one. +    // This means that everything will be well-ordered from here on.      AccelNone = 0,      // File menu      Open, ///< Open file. diff --git a/src/gui/kwindowconfig.cpp b/src/gui/kwindowconfig.cpp index 4f3ac73a..a7697782 100644 --- a/src/gui/kwindowconfig.cpp +++ b/src/gui/kwindowconfig.cpp @@ -37,7 +37,7 @@ static QString allConnectedScreens()  static QString configFileString(const QRect &desk, const QString &key)  {      // We include resolution data to also save data on a per-resolution basis -    const QString returnString =  QStringLiteral("%1 %2 %3x%4").arg(allConnectedScreens()).arg(key).arg(desk.width()).arg(desk.height()); +    const QString returnString = QStringLiteral("%1 %2 %3x%4").arg(allConnectedScreens()).arg(key).arg(desk.width()).arg(desk.height());      return returnString;  } @@ -67,7 +67,6 @@ static QString windowYPositionString(const QRect &desk)      return configFileString(desk, QStringLiteral("YPosition"));  } -  void KWindowConfig::saveWindowSize(const QWindow *window, KConfigGroup &config, KConfigGroup::WriteConfigFlags options)  {      // QWindow::screen() shouldn't return null, but it sometimes does due to bugs. @@ -97,7 +96,6 @@ void KWindowConfig::saveWindowSize(const QWindow *window, KConfigGroup &config,      } else {          config.writeEntry(screenMaximizedString(desk), isMaximized, options);      } -  }  void KWindowConfig::restoreWindowSize(QWindow *window, const KConfigGroup &config) diff --git a/src/gui/kwindowconfig.h b/src/gui/kwindowconfig.h index 4bb56e12..3c18c0a7 100644 --- a/src/gui/kwindowconfig.h +++ b/src/gui/kwindowconfig.h @@ -54,7 +54,7 @@ KCONFIGGUI_EXPORT void saveWindowSize(const QWindow *window, KConfigGroup &confi   * @param config The config group to read from.   * @since 5.0.   */ -KCONFIGGUI_EXPORT void restoreWindowSize(QWindow *window,  const KConfigGroup &config); +KCONFIGGUI_EXPORT void restoreWindowSize(QWindow *window, const KConfigGroup &config);  /**   * Saves the window's position either to the global or application config file. @@ -81,6 +81,6 @@ KCONFIGGUI_EXPORT void saveWindowPosition(const QWindow *window, KConfigGroup &c   * @param config The config group to read from.   * @since 5.74   */ -KCONFIGGUI_EXPORT void restoreWindowPosition(QWindow *window,  const KConfigGroup &config); +KCONFIGGUI_EXPORT void restoreWindowPosition(QWindow *window, const KConfigGroup &config);  }  #endif // KWINDOWCONFIG_H diff --git a/src/kconf_update/kconf_update.cpp b/src/kconf_update/kconf_update.cpp index c2552c23..defe0b80 100644 --- a/src/kconf_update/kconf_update.cpp +++ b/src/kconf_update/kconf_update.cpp @@ -7,15 +7,15 @@  #include <config-kconf.h> // CMAKE_INSTALL_PREFIX +#include <QCoreApplication>  #include <QDate> +#include <QDebug> +#include <QDir>  #include <QFile> +#include <QProcess> +#include <QTemporaryFile>  #include <QTextStream>  #include <QUrl> -#include <QTemporaryFile> -#include <QCoreApplication> -#include <QDir> -#include <QProcess> -#include <QDebug>  #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)  #include <QTextCodec> @@ -24,17 +24,16 @@  #include <kconfig.h>  #include <kconfiggroup.h> -#include <QStandardPaths> -#include <QCommandLineParser>  #include <QCommandLineOption> +#include <QCommandLineParser> +#include <QStandardPaths>  #include "kconf_update_debug.h"  #include "kconfigutils.h"  // Convenience wrapper around qCDebug to prefix the output with metadata of  // the file. -#define qCDebugFile(CATEGORY) \ -    qCDebug(CATEGORY) << m_currentFilename << ':' << m_lineCount << ":'" << m_line << "': " +#define qCDebugFile(CATEGORY) qCDebug(CATEGORY) << m_currentFilename << ':' << m_lineCount << ":'" << m_line << "': "  class KonfUpdate  { @@ -43,7 +42,7 @@ public:      ~KonfUpdate();      KonfUpdate(const KonfUpdate &) = delete; -    KonfUpdate& operator=(const KonfUpdate &) = delete; +    KonfUpdate &operator=(const KonfUpdate &) = delete;      QStringList findUpdateFiles(bool dirtyOnly); @@ -65,8 +64,7 @@ public:      void gotScriptArguments(const QString &_arguments);      void resetOptions(); -    void copyGroup(const KConfigBase *cfg1, const QString &group1, -                   KConfigBase *cfg2, const QString &group2); +    void copyGroup(const KConfigBase *cfg1, const QString &group1, KConfigBase *cfg2, const QString &group2);      void copyGroup(const KConfigGroup &cg1, KConfigGroup &cg2);      void copyOrMoveKey(const QStringList &srcGroupPath, const QString &srcKey, const QStringList &dstGroupPath, const QString &dstKey);      void copyOrMoveGroup(const QStringList &srcGroupPath, const QStringList &dstGroupPath); @@ -104,9 +102,14 @@ protected:  };  KonfUpdate::KonfUpdate(QCommandLineParser *parser) -    : m_oldConfig1(nullptr), m_oldConfig2(nullptr), m_newConfig(nullptr), -      m_bCopy(false), m_bOverwrite(false), m_textStream(nullptr), -      m_file(nullptr), m_lineCount(-1) +    : m_oldConfig1(nullptr) +    , m_oldConfig2(nullptr) +    , m_newConfig(nullptr) +    , m_bCopy(false) +    , m_bOverwrite(false) +    , m_textStream(nullptr) +    , m_file(nullptr) +    , m_lineCount(-1)  {      bool updateAll = false; @@ -125,8 +128,7 @@ KonfUpdate::KonfUpdate(QCommandLineParser *parser)          QLoggingCategory::setFilterRules(QLatin1String("%1.debug=true").arg(QLatin1String{KCONF_UPDATE_LOG().categoryName()}));          qDebug() << "Automatically enabled the debug logging category" << KCONF_UPDATE_LOG().categoryName();          if (!KCONF_UPDATE_LOG().isDebugEnabled()) { -            qWarning("The debug logging category %s needs to be enabled manually to get debug output", -                     KCONF_UPDATE_LOG().categoryName()); +            qWarning("The debug logging category %s needs to be enabled manually to get debug output", KCONF_UPDATE_LOG().categoryName());          }      } @@ -159,7 +161,7 @@ KonfUpdate::KonfUpdate(QCommandLineParser *parser)          updateAll = true;      } -    for (const QString& file : qAsConst(updateFiles)) { +    for (const QString &file : qAsConst(updateFiles)) {          updateFile(file);      } @@ -167,9 +169,7 @@ KonfUpdate::KonfUpdate(QCommandLineParser *parser)          cg.writeEntry("updateInfoAdded", true);          updateFiles = findUpdateFiles(false); -        for (QStringList::ConstIterator it = updateFiles.constBegin(); -                it != updateFiles.constEnd(); -                ++it) { +        for (QStringList::ConstIterator it = updateFiles.constBegin(); it != updateFiles.constEnd(); ++it) {              checkFile(*it);          }          updateFiles.clear(); @@ -199,9 +199,7 @@ QStringList KonfUpdate::findUpdateFiles(bool dirtyOnly)              KConfigGroup cg(m_config, fileName);              const QDateTime ctime = QDateTime::fromSecsSinceEpoch(cg.readEntry("ctime", 0u));              const QDateTime mtime = QDateTime::fromSecsSinceEpoch(cg.readEntry("mtime", 0u)); -            if (!dirtyOnly || -                    (ctime.isValid() && ctime != info.birthTime()) || -                     mtime != info.lastModified()) { +            if (!dirtyOnly || (ctime.isValid() && ctime != info.birthTime()) || mtime != info.lastModified()) {                  result.append(file);              }          } @@ -243,9 +241,7 @@ bool KonfUpdate::checkFile(const QString &filename)          }          if (line.startsWith(QLatin1String("Id="))) {              if (!foundVersion) { -                qCDebug(KCONF_UPDATE_LOG, -                        "Missing 'Version=5', file '%s' will be skipped.", -                        qUtf8Printable(filename)); +                qCDebug(KCONF_UPDATE_LOG, "Missing 'Version=5', file '%s' will be skipped.", qUtf8Printable(filename));                  return true;              }              id = m_currentFilename + QLatin1Char{':'} + line.mid(3); @@ -267,7 +263,7 @@ void KonfUpdate::checkGotFile(const QString &_file, const QString &id)          file = _file.mid(i + 1).trimmed();      } -//   qDebug("File %s, id %s", file.toLatin1().constData(), id.toLatin1().constData()); +    //   qDebug("File %s, id %s", file.toLatin1().constData(), id.toLatin1().constData());      KConfig cfg(file, KConfig::SimpleConfig);      KConfigGroup cg = cfg.group("$Version"); @@ -334,9 +330,7 @@ bool KonfUpdate::updateFile(const QString &filename)          }          if (m_line.startsWith(QLatin1String("Id="))) {              if (!foundVersion) { -                qCDebug(KCONF_UPDATE_LOG, -                        "Missing 'Version=5', file '%s' will be skipped.", -                        qUtf8Printable(filename)); +                qCDebug(KCONF_UPDATE_LOG, "Missing 'Version=5', file '%s' will be skipped.", qUtf8Printable(filename));                  break;              }              gotId(m_line.mid(3)); @@ -416,7 +410,7 @@ void KonfUpdate::gotId(const QString &_id)      KConfigGroup cg(m_config, m_currentFilename);      QStringList ids = cg.readEntry("done", QStringList());      if (ids.contains(_id) && !m_bUseConfigInfo) { -        //qDebug("Id '%s' was already in done-list", _id.toLatin1().constData()); +        // qDebug("Id '%s' was already in done-list", _id.toLatin1().constData());          m_skip = true;          return;      } @@ -523,8 +517,8 @@ void KonfUpdate::gotFile(const QString &_file)      m_skipFile = false;      if (!m_oldFile.isEmpty()) { // if File= is specified, it doesn't exist, is empty or contains only kconf_update's [$Version] group, skip          if (m_oldConfig1 != nullptr -                && (m_oldConfig1->groupList().isEmpty() -                    || (m_oldConfig1->groupList().count() == 1 && m_oldConfig1->groupList().at(0) == QLatin1String("$Version")))) { +            && (m_oldConfig1->groupList().isEmpty() +                || (m_oldConfig1->groupList().count() == 1 && m_oldConfig1->groupList().at(0) == QLatin1String("$Version")))) {              qCDebug(KCONF_UPDATE_LOG) << m_currentFilename << ": File" << m_oldFile << "does not exist or empty, skipping";              m_skipFile = true;          } @@ -621,9 +615,7 @@ void KonfUpdate::copyOrMoveKey(const QStringList &srcGroupPath, const QString &s      }      // Delete old entry -    if (m_oldConfig2 == m_newConfig -            && srcGroupPath == dstGroupPath -            && srcKey == dstKey) { +    if (m_oldConfig2 == m_newConfig && srcGroupPath == dstGroupPath && srcKey == dstKey) {          return; // Don't delete!      }      KConfigGroup srcCg2 = KConfigUtils::openGroup(m_oldConfig2, srcGroupPath); @@ -695,8 +687,7 @@ void KonfUpdate::gotAllGroups()      }      const QStringList allGroups = m_oldConfig1->groupList(); -    for (QStringList::ConstIterator it = allGroups.begin(); -            it != allGroups.end(); ++it) { +    for (QStringList::ConstIterator it = allGroups.begin(); it != allGroups.end(); ++it) {          m_oldGroup = QStringList() << *it;          m_newGroup = m_oldGroup;          gotAllKeys(); @@ -706,9 +697,7 @@ void KonfUpdate::gotAllGroups()  void KonfUpdate::gotOptions(const QString &_options)  {      const QStringList options = _options.split(QLatin1Char{','}); -    for (QStringList::ConstIterator it = options.begin(); -            it != options.end(); -            ++it) { +    for (QStringList::ConstIterator it = options.begin(); it != options.end(); ++it) {          if ((*it).toLower().trimmed() == QLatin1String("copy")) {              m_bCopy = true;          } @@ -719,8 +708,7 @@ void KonfUpdate::gotOptions(const QString &_options)      }  } -void KonfUpdate::copyGroup(const KConfigBase *cfg1, const QString &group1, -                           KConfigBase *cfg2, const QString &group2) +void KonfUpdate::copyGroup(const KConfigBase *cfg1, const QString &group1, KConfigBase *cfg2, const QString &group2)  {      KConfigGroup cg2 = cfg2->group(group2);      copyGroup(cfg1->group(group1), cg2); @@ -730,8 +718,7 @@ void KonfUpdate::copyGroup(const KConfigGroup &cg1, KConfigGroup &cg2)  {      // Copy keys      QMap<QString, QString> list = cg1.entryMap(); -    for (QMap<QString, QString>::ConstIterator it = list.constBegin(); -            it != list.constEnd(); ++it) { +    for (QMap<QString, QString>::ConstIterator it = list.constBegin(); it != list.constEnd(); ++it) {          if (m_bOverwrite || !cg2.hasKey(it.key())) {              cg2.writeEntry(it.key(), it.value());          } @@ -822,7 +809,7 @@ void KonfUpdate::gotScript(const QString &_script)      proc.setStandardOutputFile(scriptOut.fileName());      if (m_oldConfig1) {          if (m_bDebugOutput) { -            //scriptIn.setAutoRemove(false); +            // scriptIn.setAutoRemove(false);              qCDebug(KCONF_UPDATE_LOG) << "Script input stored in" << scriptIn.fileName();          }          KConfig cfg(scriptIn.fileName(), KConfig::SimpleConfig); @@ -830,9 +817,7 @@ void KonfUpdate::gotScript(const QString &_script)          if (m_oldGroup.isEmpty()) {              // Write all entries to tmpFile;              const QStringList grpList = m_oldConfig1->groupList(); -            for (QStringList::ConstIterator it = grpList.begin(); -                    it != grpList.end(); -                    ++it) { +            for (QStringList::ConstIterator it = grpList.begin(); it != grpList.end(); ++it) {                  copyGroup(m_oldConfig1, *it, &cfg, *it);              }          } else { @@ -883,7 +868,7 @@ void KonfUpdate::gotScript(const QString &_script)      }      if (m_bDebugOutput) { -        //scriptOut.setAutoRemove(false); +        // scriptOut.setAutoRemove(false);          qCDebug(KCONF_UPDATE_LOG) << "Script output stored in" << scriptOut.fileName();          QFile output(scriptOut.fileName());          if (output.open(QIODevice::ReadOnly)) { @@ -966,9 +951,15 @@ int main(int argc, char **argv)      parser.setApplicationDescription(QCoreApplication::translate("main", "KDE Tool for updating user configuration files"));      parser.addHelpOption();      parser.addOption(QCommandLineOption(QStringList() << QStringLiteral("debug"), QCoreApplication::translate("main", "Keep output results from scripts"))); -    parser.addOption(QCommandLineOption(QStringList() << QStringLiteral("testmode"), QCoreApplication::translate("main", "For unit tests only: use test directories to stay away from the user's real files"))); -    parser.addOption(QCommandLineOption(QStringList() << QStringLiteral("check"), QCoreApplication::translate("main", "Check whether config file itself requires updating"), QStringLiteral("update-file"))); -    parser.addPositionalArgument(QStringLiteral("files"), QCoreApplication::translate("main", "File(s) to read update instructions from"), QStringLiteral("[files...]")); +    parser.addOption( +        QCommandLineOption(QStringList() << QStringLiteral("testmode"), +                           QCoreApplication::translate("main", "For unit tests only: use test directories to stay away from the user's real files"))); +    parser.addOption(QCommandLineOption(QStringList() << QStringLiteral("check"), +                                        QCoreApplication::translate("main", "Check whether config file itself requires updating"), +                                        QStringLiteral("update-file"))); +    parser.addPositionalArgument(QStringLiteral("files"), +                                 QCoreApplication::translate("main", "File(s) to read update instructions from"), +                                 QStringLiteral("[files...]"));      // TODO aboutData.addAuthor(ki18n("Waldo Bastian"), KLocalizedString(), "bastian@kde.org"); diff --git a/src/kconf_update/kconfigutils.cpp b/src/kconf_update/kconfigutils.cpp index 56e5cba7..49d5ac3c 100644 --- a/src/kconf_update/kconfigutils.cpp +++ b/src/kconf_update/kconfigutils.cpp @@ -13,7 +13,6 @@  namespace KConfigUtils  { -  bool hasGroup(KConfig *config, const QStringList &lst)  {      KConfigGroup group = openGroup(config, lst); diff --git a/src/kconf_update/kconfigutils.h b/src/kconf_update/kconfigutils.h index 5b07c4fe..9a74d412 100644 --- a/src/kconf_update/kconfigutils.h +++ b/src/kconf_update/kconfigutils.h @@ -18,7 +18,6 @@ class KConfigGroup;  namespace KConfigUtils  { -  bool hasGroup(KConfig *, const QStringList &);  KConfigGroup openGroup(KConfig *, const QStringList &); diff --git a/src/kconfig_compiler/KConfigCodeGeneratorBase.cpp b/src/kconfig_compiler/KConfigCodeGeneratorBase.cpp index 3f308cbb..27a96488 100644 --- a/src/kconfig_compiler/KConfigCodeGeneratorBase.cpp +++ b/src/kconfig_compiler/KConfigCodeGeneratorBase.cpp @@ -13,21 +13,24 @@  #include "KConfigCodeGeneratorBase.h" -#include <QLatin1Char>  #include <QFileInfo> +#include <QLatin1Char> -#include <ostream>  #include <QDebug> +#include <ostream>  #include <iostream> -KConfigCodeGeneratorBase::KConfigCodeGeneratorBase( -    const QString &inputFile, -    const QString &baseDir, -    const QString &fileName, -    const KConfigParameters ¶meters, -    ParseResult &parseResult) -    : parseResult(parseResult), m_inputFile(inputFile), m_baseDir(baseDir), m_fileName(fileName), m_cfg(parameters) +KConfigCodeGeneratorBase::KConfigCodeGeneratorBase(const QString &inputFile, +                                                   const QString &baseDir, +                                                   const QString &fileName, +                                                   const KConfigParameters ¶meters, +                                                   ParseResult &parseResult) +    : parseResult(parseResult) +    , m_inputFile(inputFile) +    , m_baseDir(baseDir) +    , m_fileName(fileName) +    , m_cfg(parameters)  {      m_file.setFileName(m_fileName);      if (!m_file.open(QIODevice::WriteOnly)) { @@ -54,7 +57,7 @@ void KConfigCodeGeneratorBase::save()      m_file.close();  } -//TODO: Remove this weird logic and adapt the testcases +// TODO: Remove this weird logic and adapt the testcases  void KConfigCodeGeneratorBase::indent()  {      if (m_indentLevel >= 4) { @@ -102,7 +105,8 @@ void KConfigCodeGeneratorBase::endScope(ScopeFinalizer finalizer)  void KConfigCodeGeneratorBase::start()  {      const QString m_fileName = QFileInfo(m_inputFile).fileName(); -    m_stream << "// This file is generated by kconfig_compiler_kf5 from " << m_fileName << ".kcfg" << ".\n"; +    m_stream << "// This file is generated by kconfig_compiler_kf5 from " << m_fileName << ".kcfg" +             << ".\n";      m_stream << "// All changes you do to this file will be lost.\n";  } @@ -214,7 +218,6 @@ void KConfigCodeGeneratorBase::createIfSetLogic(const CfgEntry *e, const QString  void KConfigCodeGeneratorBase::memberMutatorBody(const CfgEntry *e)  { -      // HACK: Don't open '{' manually, use startScope / endScope to automatically handle whitespace indentation.      if (!e->min.isEmpty()) {          if (e->min != QLatin1String("0") || !isUnsigned(e->type)) { // skip writing "if uint<0" (#187579) @@ -254,8 +257,7 @@ void KConfigCodeGeneratorBase::memberMutatorBody(const CfgEntry *e)          if (signal.modify) {              m_stream << whitespace() << "  Q_EMIT " << m_this << signal.name << "();\n";          } else { -            m_stream << whitespace() <<  "  " << m_this << varPath(QStringLiteral("settingsChanged"), m_cfg) -                << " |= " << signalEnumName(signal.name) << ";\n"; +            m_stream << whitespace() << "  " << m_this << varPath(QStringLiteral("settingsChanged"), m_cfg) << " |= " << signalEnumName(signal.name) << ";\n";          }      }      if (hasBody) { diff --git a/src/kconfig_compiler/KConfigCodeGeneratorBase.h b/src/kconfig_compiler/KConfigCodeGeneratorBase.h index e9d2a955..4a100518 100644 --- a/src/kconfig_compiler/KConfigCodeGeneratorBase.h +++ b/src/kconfig_compiler/KConfigCodeGeneratorBase.h @@ -14,28 +14,31 @@  #ifndef KCONFIGCODEGENERATORBASE_H  #define KCONFIGCODEGENERATORBASE_H +#include <QFile>  #include <QString>  #include <QTextStream> -#include <QFile>  #include <QVector> -#include "KConfigParameters.h"  #include "KConfigCommonStructs.h" +#include "KConfigParameters.h"  class CfgEntry;  struct ParseResult;  /* This class manages the base of writing a C - Based code */ -class KConfigCodeGeneratorBase { +class KConfigCodeGeneratorBase +{  public: -    enum ScopeFinalizer {None, Semicolon,}; - -    KConfigCodeGeneratorBase( -        const QString &inputFileName,  // The kcfg file -        const QString &baseDir,        // where we should store the generated file -        const QString &fileName,       // the name of the generated file -        const KConfigParameters ¶meters, // parameters passed to the generator -        ParseResult &parseResult // The pre processed configuration entries +    enum ScopeFinalizer { +        None, +        Semicolon, +    }; + +    KConfigCodeGeneratorBase(const QString &inputFileName, // The kcfg file +                             const QString &baseDir, // where we should store the generated file +                             const QString &fileName, // the name of the generated file +                             const KConfigParameters ¶meters, // parameters passed to the generator +                             ParseResult &parseResult // The pre processed configuration entries      );      virtual ~KConfigCodeGeneratorBase(); @@ -87,32 +90,53 @@ protected:      /* reduce the number of spaces for the indentation level */      void unindent(); -    QString inputFile() const { return m_inputFile; } -    QString fileName() const { return m_fileName; } -    QString baseDir() const { return m_baseDir; } -    QString This() const { return m_this; } -    QString Const() const { return m_const; } -    KConfigParameters cfg() const { return m_cfg; } +    QString inputFile() const +    { +        return m_inputFile; +    } +    QString fileName() const +    { +        return m_fileName; +    } +    QString baseDir() const +    { +        return m_baseDir; +    } +    QString This() const +    { +        return m_this; +    } +    QString Const() const +    { +        return m_const; +    } +    KConfigParameters cfg() const +    { +        return m_cfg; +    }      // Can't be const. -    QTextStream& stream() { return m_stream; } +    QTextStream &stream() +    { +        return m_stream; +    }      // HACK: This needs to be accesible because the HeaderGenerator actually modifies      // it while running. Considering that this is a the result of the xml Parse, and not      // the result of generating code, I consider this to be quite wrong - but moving the      // changes away from the header generator only created more problems and I have to      // investigate more. -    ParseResult &parseResult;       // the result of the parsed kcfg file +    ParseResult &parseResult; // the result of the parsed kcfg file  private:      QString m_inputFile; // the base file name, input file is based on this. -    QString m_baseDir;   // Where we are going to save the file -    QString m_fileName;  // The file name +    QString m_baseDir; // Where we are going to save the file +    QString m_fileName; // The file name      KConfigParameters m_cfg; // The parameters passed via the kcfgc file -    QTextStream m_stream;             // the stream that operates in the file to write data. -    QFile m_file;                     // The file handler. +    QTextStream m_stream; // the stream that operates in the file to write data. +    QFile m_file; // The file handler.      // Special access to `this->` and `const` thru the code.      QString m_this; diff --git a/src/kconfig_compiler/KConfigCommonStructs.h b/src/kconfig_compiler/KConfigCommonStructs.h index 8ed1d22f..43e981cb 100644 --- a/src/kconfig_compiler/KConfigCommonStructs.h +++ b/src/kconfig_compiler/KConfigCommonStructs.h @@ -14,20 +14,18 @@  #ifndef KCONFIGCOMMONSTRUCTS_H  #define KCONFIGCOMMONSTRUCTS_H +#include <QList>  #include <QString>  #include <QVector> -#include <QList>  #include "KConfigParameters.h" -struct Param -{ +struct Param {      QString name;      QString type;  }; -struct Signal -{ +struct Signal {      QString name;      QString label;      QList<Param> arguments; @@ -53,9 +51,13 @@ public:      class Choices      {      public: -        Choices() {} +        Choices() +        { +        }          Choices(const QList<Choice> &d, const QString &n, const QString &p) -            : prefix(p), choices(d), mName(n) +            : prefix(p) +            , choices(d) +            , mName(n)          {              int i = n.indexOf(QLatin1String("::"));              if (i >= 0) { @@ -76,6 +78,7 @@ public:          {              return !mExternalQual.isEmpty();          } +      private:          QString mName;          QString mExternalQual; @@ -161,33 +164,18 @@ QString filenameOnly(const QString &path);  QString itemDeclaration(const CfgEntry *e, const KConfigParameters &cfg); -QString translatedString( -    const KConfigParameters &cfg, -    const QString &string, -    const QString &context = QString(), -    const QString ¶m = QString(), -    const QString ¶mValue = QString()); +QString translatedString(const KConfigParameters &cfg, +                         const QString &string, +                         const QString &context = QString(), +                         const QString ¶m = QString(), +                         const QString ¶mValue = QString());  // TODO: Sanitize those functions. -QString newItem( -    const CfgEntry *entry, -    const QString &key, -    const QString &defaultValue, -    const KConfigParameters &cfg, -    const QString ¶m = QString()); - -QString newInnerItem( -    const CfgEntry *entry, -    const QString &key, -    const QString &defaultValue, -    const KConfigParameters &cfg, -    const QString ¶m = QString()); - -QString userTextsFunctions( -    const CfgEntry *e, -    const KConfigParameters &cfg, -    QString itemVarStr = QString(), -    const QString &i = QString()); +QString newItem(const CfgEntry *entry, const QString &key, const QString &defaultValue, const KConfigParameters &cfg, const QString ¶m = QString()); + +QString newInnerItem(const CfgEntry *entry, const QString &key, const QString &defaultValue, const KConfigParameters &cfg, const QString ¶m = QString()); + +QString userTextsFunctions(const CfgEntry *e, const KConfigParameters &cfg, QString itemVarStr = QString(), const QString &i = QString());  QString paramString(const QString &s, const CfgEntry *e, int i);  QString paramString(const QString &group, const QList<Param> ¶meters); diff --git a/src/kconfig_compiler/KConfigHeaderGenerator.cpp b/src/kconfig_compiler/KConfigHeaderGenerator.cpp index 7829ab67..d2c7e6cf 100644 --- a/src/kconfig_compiler/KConfigHeaderGenerator.cpp +++ b/src/kconfig_compiler/KConfigHeaderGenerator.cpp @@ -13,15 +13,11 @@  #include "KConfigHeaderGenerator.h" -#include <QTextStream>  #include <QDebug> +#include <QTextStream>  #include <iostream> -KConfigHeaderGenerator::KConfigHeaderGenerator( -    const QString &inputFile, -    const QString &baseDir, -    const KConfigParameters &cfg, -    ParseResult &result) +KConfigHeaderGenerator::KConfigHeaderGenerator(const QString &inputFile, const QString &baseDir, const KConfigParameters &cfg, ParseResult &result)      : KConfigCodeGeneratorBase(inputFile, baseDir, baseDir + cfg.baseName + QLatin1Char('.') + cfg.headerExtension, cfg, result)  {  } @@ -78,9 +74,7 @@ void KConfigHeaderGenerator::doClassDefinition()      }      // Member variables -    if (!cfg().memberVariables.isEmpty() -        && cfg().memberVariables != QLatin1String("private") -        && cfg().memberVariables != QLatin1String("dpointer")) { +    if (!cfg().memberVariables.isEmpty() && cfg().memberVariables != QLatin1String("private") && cfg().memberVariables != QLatin1String("dpointer")) {          stream() << "  " << cfg().memberVariables << ":\n";      } @@ -212,7 +206,7 @@ void KConfigHeaderGenerator::implementEnums()          implementChoiceEnums(entry, choices);          implementValueEnums(entry, values);      } -   stream() << '\n'; +    stream() << '\n';  }  void KConfigHeaderGenerator::createSignals() @@ -239,19 +233,15 @@ void KConfigHeaderGenerator::createSignals()      // a last comma, as it's valid c++.      for (int i = 0, end = parseResult.signalList.size(); i < end; i++) {          auto signal = parseResult.signalList.at(i); -        stream() << whitespace() << "  " << signalEnumName(signal.name) << " = 0x" -                 << Qt::hex -                 << val; -        if (i != end-1) { +        stream() << whitespace() << "  " << signalEnumName(signal.name) << " = 0x" << Qt::hex << val; +        if (i != end - 1) {              stream() << ",\n";          }          val <<= 1;      }      stream() << '\n'; -    stream() << whitespace() << "};" -             << Qt::dec -             << "\n\n"; +    stream() << whitespace() << "};" << Qt::dec << "\n\n";      stream() << "  Q_SIGNALS:";      for (const Signal &signal : qAsConst(parseResult.signalList)) { @@ -364,7 +354,7 @@ void KConfigHeaderGenerator::createForwardDeclarations()      }  } -void KConfigHeaderGenerator::createProperties(const CfgEntry *entry, const QString& returnType) +void KConfigHeaderGenerator::createProperties(const CfgEntry *entry, const QString &returnType)  {      if (!cfg().generateProperties) {          return; @@ -377,8 +367,8 @@ void KConfigHeaderGenerator::createProperties(const CfgEntry *entry, const QStri          stream() << " WRITE " << setFunction(entry->name);          stream() << " NOTIFY " << signal; -        //If we have the modified signal, we'll also need -        //the changed signal as well +        // If we have the modified signal, we'll also need +        // the changed signal as well          Signal s;          s.name = signal;          s.modify = true; @@ -417,12 +407,10 @@ void KConfigHeaderGenerator::createSetters(const CfgEntry *entry)      stream() << whitespace() << "void " << setFunction(entry->name) << "( ";      if (!entry->param.isEmpty()) { -        stream() <<cppType(entry->paramType) << " i, "; +        stream() << cppType(entry->paramType) << " i, ";      } -    stream() << (cfg().useEnumTypes && entry->type == QLatin1String("Enum") -        ? enumType(entry, cfg().globalEnums) -        : param(entry->type)); +    stream() << (cfg().useEnumTypes && entry->type == QLatin1String("Enum") ? enumType(entry, cfg().globalEnums) : param(entry->type));      stream() << " v )"; @@ -481,7 +469,7 @@ void KConfigHeaderGenerator::createImmutableGetters(const CfgEntry *entry)      stream() << whitespace() << "";      stream() << "bool " << immutableFunction(entry->name) << "(";      if (!entry->param.isEmpty()) { -        stream() << " " << cppType(entry->paramType)<< " i "; +        stream() << " " << cppType(entry->paramType) << " i ";      }      stream() << ")" << Const();      // function body inline only if not using dpointer @@ -506,11 +494,9 @@ void KConfigHeaderGenerator::createItemAcessors(const CfgEntry *entry, const QSt          return;      }      stream() << whitespace() << "/**\n"; -    stream() << whitespace() << "  Get Item object corresponding to " << entry->name << "()" -        << '\n'; +    stream() << whitespace() << "  Get Item object corresponding to " << entry->name << "()" << '\n';      stream() << whitespace() << "*/\n"; -    stream() << whitespace() << "Item" << itemType(entry->type) << " *" -        << getFunction(entry->name) << "Item("; +    stream() << whitespace() << "Item" << itemType(entry->type) << " *" << getFunction(entry->name) << "Item(";      if (!entry->param.isEmpty()) {          stream() << " " << cppType(entry->paramType) << " i ";      } @@ -530,7 +516,7 @@ void KConfigHeaderGenerator::createItemAcessors(const CfgEntry *entry, const QSt  void KConfigHeaderGenerator::createDefaultValueMember(const CfgEntry *entry)  {      // Default value Accessor -    if (! ((cfg().allDefaultGetters || cfg().defaultGetters.contains(entry->name)) && !entry->defaultValue.isEmpty())) { +    if (!((cfg().allDefaultGetters || cfg().defaultGetters.contains(entry->name)) && !entry->defaultValue.isEmpty())) {          return;      }      stream() << whitespace() << "/**\n"; diff --git a/src/kconfig_compiler/KConfigHeaderGenerator.h b/src/kconfig_compiler/KConfigHeaderGenerator.h index b93a47db..4c2e4561 100644 --- a/src/kconfig_compiler/KConfigHeaderGenerator.h +++ b/src/kconfig_compiler/KConfigHeaderGenerator.h @@ -17,23 +17,20 @@  #include "KConfigCodeGeneratorBase.h"  #include "KConfigCommonStructs.h" -#include <QString>  #include <QList> +#include <QString>  class KConfigParameters;  class CfgEntry;  class QTextStream;  struct ParseResult; -class KConfigHeaderGenerator : public KConfigCodeGeneratorBase { +class KConfigHeaderGenerator : public KConfigCodeGeneratorBase +{  public: -    KConfigHeaderGenerator( -        const QString &inputFile, -        const QString &baseDir, -        const KConfigParameters ¶meters, -        ParseResult &parseResult); +    KConfigHeaderGenerator(const QString &inputFile, const QString &baseDir, const KConfigParameters ¶meters, ParseResult &parseResult); -        void start() override; +    void start() override;  private:      void startHeaderGuards(); diff --git a/src/kconfig_compiler/KConfigParameters.h b/src/kconfig_compiler/KConfigParameters.h index f8619b2a..153b68dd 100644 --- a/src/kconfig_compiler/KConfigParameters.h +++ b/src/kconfig_compiler/KConfigParameters.h @@ -33,14 +33,14 @@ public:      };      // These are read from the .kcfgc configuration file -    QString nameSpace;     // The namespace for the class to be generated -    QString className;     // The class name to be generated -    QString inherits;      // The class the generated class inherits (if empty, from KConfigSkeleton) +    QString nameSpace; // The namespace for the class to be generated +    QString className; // The class name to be generated +    QString inherits; // The class the generated class inherits (if empty, from KConfigSkeleton)      QString visibility;      bool parentInConstructor; // The class has the optional parent parameter in its constructor      bool forceStringFilename; -    bool singleton;        // The class will be a singleton -    bool staticAccessors;  // provide or not static accessors +    bool singleton; // The class will be a singleton +    bool staticAccessors; // provide or not static accessors      bool customAddons;      QString memberVariables;      QStringList headerIncludes; diff --git a/src/kconfig_compiler/KConfigSourceGenerator.cpp b/src/kconfig_compiler/KConfigSourceGenerator.cpp index 663a138f..ce6378cd 100644 --- a/src/kconfig_compiler/KConfigSourceGenerator.cpp +++ b/src/kconfig_compiler/KConfigSourceGenerator.cpp @@ -50,7 +50,7 @@ void KConfigSourceGenerator::createHeaders()      // TODO: Make addQuotes return a string instead of replacing it inplace.      addQuotes(headerName); -    addHeaders({ headerName }); +    addHeaders({headerName});      stream() << '\n';      addHeaders(cfg().sourceIncludes); @@ -108,11 +108,10 @@ void KConfigSourceGenerator::createPrivateDPointerImplementation()      // Create Items.      for (const auto *entry : qAsConst(parseResult.entries)) { -        const QString declType = entry->signalList.isEmpty() -                ? QString(cfg().inherits + QStringLiteral("::Item") + itemType(entry->type)) -                : QStringLiteral("KConfigCompilerSignallingItem"); +        const QString declType = entry->signalList.isEmpty() ? QString(cfg().inherits + QStringLiteral("::Item") + itemType(entry->type)) +                                                             : QStringLiteral("KConfigCompilerSignallingItem"); -        stream() << "    " << declType << " *" << itemVar( entry, cfg() ); +        stream() << "    " << declType << " *" << itemVar(entry, cfg());          if (!entry->param.isEmpty()) {              stream() << QStringLiteral("[%1]").arg(entry->paramMax + 1);          } @@ -163,7 +162,7 @@ void KConfigSourceGenerator::createSingletonImplementation()      stream() << "}\n\n";      if (parseResult.cfgFileNameArg) { -        auto instance = [this] (const QString &type, const QString &arg, bool isString) { +        auto instance = [this](const QString &type, const QString &arg, bool isString) {              stream() << "void " << cfg().className << "::instance(" << type << " " << arg << ")\n";              stream() << "{\n";              stream() << "  if (s_global" << cfg().className << "()->q) {\n"; @@ -215,8 +214,7 @@ void KConfigSourceGenerator::createConstructorParameterList()          stream() << (parseResult.parameters.isEmpty() ? "" : ",");      } -    for (QList<Param>::ConstIterator it = parseResult.parameters.constBegin(); -            it != parseResult.parameters.constEnd(); ++it) { +    for (QList<Param>::ConstIterator it = parseResult.parameters.constBegin(); it != parseResult.parameters.constEnd(); ++it) {          if (it != parseResult.parameters.constBegin()) {              stream() << ",";          } @@ -229,7 +227,6 @@ void KConfigSourceGenerator::createConstructorParameterList()          }          stream() << " QObject *parent";      } -  }  void KConfigSourceGenerator::createParentConstructorCall() @@ -239,7 +236,7 @@ void KConfigSourceGenerator::createParentConstructorCall()          stream() << " QStringLiteral( \"" << parseResult.cfgFileName << "\" ";      }      if (parseResult.cfgFileNameArg) { -        if (! cfg().forceStringFilename) { +        if (!cfg().forceStringFilename) {              stream() << " std::move( config ) ";          } else {              stream() << " config "; @@ -275,19 +272,13 @@ void KConfigSourceGenerator::createEnums(const CfgEntry *entry)          stream() << "    choice.name = QStringLiteral(\"" << choice.name << "\");\n";          if (cfg().setUserTexts) {              if (!choice.label.isEmpty()) { -                stream() << "    choice.label = " -                    << translatedString(cfg(), choice.label, choice.context) -                    << ";\n"; +                stream() << "    choice.label = " << translatedString(cfg(), choice.label, choice.context) << ";\n";              }              if (!choice.toolTip.isEmpty()) { -                stream() << "    choice.toolTip = " -                    << translatedString(cfg(), choice.toolTip, choice.context) -                    << ";\n"; +                stream() << "    choice.toolTip = " << translatedString(cfg(), choice.toolTip, choice.context) << ";\n";              }              if (!choice.whatsThis.isEmpty()) { -                stream() << "    choice.whatsThis = " -                    << translatedString(cfg(), choice.whatsThis, choice.context) -                    << ";\n"; +                stream() << "    choice.whatsThis = " << translatedString(cfg(), choice.whatsThis, choice.context) << ";\n";              }          }          stream() << "    values" << entry->name << ".append( choice );\n"; @@ -300,12 +291,10 @@ void KConfigSourceGenerator::createNormalEntry(const CfgEntry *entry, const QStr      const QString itemVarStr = itemPath(entry, cfg());      const QString innerItemVarStr = innerItemVar(entry, cfg());      if (!entry->signalList.isEmpty()) { -        stream() << "  " << innerItemVarStr << " = " -            << newInnerItem(entry, key, entry->defaultValue, cfg()) << '\n'; +        stream() << "  " << innerItemVarStr << " = " << newInnerItem(entry, key, entry->defaultValue, cfg()) << '\n';      } -    stream() << "  " << itemVarStr << " = " -        << newItem(entry, key, entry->defaultValue, cfg()) << '\n'; +    stream() << "  " << itemVarStr << " = " << newItem(entry, key, entry->defaultValue, cfg()) << '\n';      if (!entry->min.isEmpty()) {          stream() << "  " << innerItemVarStr << "->setMinValue(" << entry->min << ");\n"; @@ -353,19 +342,17 @@ void KConfigSourceGenerator::createIndexedEntry(const CfgEntry *entry, const QSt          const QString argBracket = QStringLiteral("[%1]").arg(i);          const QString innerItemVarStr = innerItemVar(entry, cfg()) + argBracket; -        const QString defaultStr = !entry->paramDefaultValues[i].isEmpty() -            ? entry->paramDefaultValues[i] -            : !entry->defaultValue.isEmpty() ? paramString(entry->defaultValue, entry, i) : defaultValue(entry->type); +        const QString defaultStr = !entry->paramDefaultValues[i].isEmpty() ? entry->paramDefaultValues[i] +            : !entry->defaultValue.isEmpty()                               ? paramString(entry->defaultValue, entry, i) +                                                                           : defaultValue(entry->type);          if (!entry->signalList.isEmpty()) { -            stream() << "  " << innerItemVarStr << " = " -                     << newInnerItem(entry, paramString(key, entry, i), defaultStr, cfg(), argBracket) << '\n'; +            stream() << "  " << innerItemVarStr << " = " << newInnerItem(entry, paramString(key, entry, i), defaultStr, cfg(), argBracket) << '\n';          }          const QString itemVarStr = itemPath(entry, cfg()) + argBracket; -        stream() << "  " << itemVarStr << " = " -                 << newItem(entry, paramString(key, entry, i), defaultStr, cfg(), argBracket) << '\n'; +        stream() << "  " << itemVarStr << " = " << newItem(entry, paramString(key, entry, i), defaultStr, cfg(), argBracket) << '\n';          if (!entry->min.isEmpty()) {              stream() << "  " << innerItemVarStr << "->setMinValue(" << entry->min << ");\n"; @@ -376,7 +363,8 @@ void KConfigSourceGenerator::createIndexedEntry(const CfgEntry *entry, const QSt          for (const CfgEntry::Choice &choice : qAsConst(entry->choices.choices)) {              if (!choice.val.isEmpty()) { -                stream() << "  " << itemVarStr << "->setValueForChoice(QStringLiteral( \"" << choice.name << "\" ), QStringLiteral( \"" << choice.val << "\" ));\n"; +                stream() << "  " << itemVarStr << "->setValueForChoice(QStringLiteral( \"" << choice.name << "\" ), QStringLiteral( \"" << choice.val +                         << "\" ));\n";              }          } @@ -419,14 +407,12 @@ void KConfigSourceGenerator::handleCurrentGroupChange(const CfgEntry *entry)      if (!entry->parentGroup.isEmpty()) {          QString parentGroup = QString(entry->parentGroup).remove(QRegularExpression(QStringLiteral("\\W")));          if (!mConfigGroupList.contains(parentGroup)) { -            stream() << "  KConfigGroup cg" << parentGroup -                     << "(this->config(), " << paramString(entry->parentGroup, parseResult.parameters) << ");\n"; +            stream() << "  KConfigGroup cg" << parentGroup << "(this->config(), " << paramString(entry->parentGroup, parseResult.parameters) << ");\n";              mConfigGroupList << parentGroup;          }          QString currentGroup = QString(mCurrentGroup).remove(QRegularExpression(QStringLiteral("\\W")));          if (!mConfigGroupList.contains(currentGroup)) { -            stream() << "  KConfigGroup cg" << currentGroup -                     << " = cg" << QString(entry->parentGroup).remove(QRegularExpression(QStringLiteral("\\W"))) +            stream() << "  KConfigGroup cg" << currentGroup << " = cg" << QString(entry->parentGroup).remove(QRegularExpression(QStringLiteral("\\W")))                       << ".group(" << paramString(mCurrentGroup, parseResult.parameters) << ");\n";              mConfigGroupList << currentGroup;          } @@ -470,8 +456,7 @@ void KConfigSourceGenerator::doConstructor()          // this cast to base-class pointer-to-member is valid C++          // https://stackoverflow.com/questions/4272909/is-it-safe-to-upcast-a-method-pointer-and-use-it-with-base-class-pointer/          stream() << "  KConfigCompilerSignallingItem::NotifyFunction notifyFunction =" -            << " static_cast<KConfigCompilerSignallingItem::NotifyFunction>(&" -            << cfg().className << "::itemChanged);\n"; +                 << " static_cast<KConfigCompilerSignallingItem::NotifyFunction>(&" << cfg().className << "::itemChanged);\n";          stream() << '\n';      } @@ -524,7 +509,8 @@ void KConfigSourceGenerator::createGetterDPointerMode(const CfgEntry *entry)  void KConfigSourceGenerator::createImmutableGetterDPointerMode(const CfgEntry *entry)  {      stream() << whitespace() << ""; -    stream() << "bool " << " " << immutableFunction(entry->name, cfg().className) << "("; +    stream() << "bool " +             << " " << immutableFunction(entry->name, cfg().className) << "(";      if (!entry->param.isEmpty()) {          stream() << " " << cppType(entry->paramType) << " i ";      } @@ -569,8 +555,7 @@ void KConfigSourceGenerator::createItemGetterDPointerMode(const CfgEntry *entry)          return;      }      stream() << '\n'; -    stream() << cfg().inherits << "::Item" << itemType(entry->type) << " *" -        << getFunction(entry->name, cfg().className) << "Item("; +    stream() << cfg().inherits << "::Item" << itemType(entry->type) << " *" << getFunction(entry->name, cfg().className) << "Item(";      if (!entry->param.isEmpty()) {          stream() << " " << cppType(entry->paramType) << " i ";      } @@ -637,7 +622,8 @@ void KConfigSourceGenerator::createNonModifyingSignalsHelper()      if (!parseResult.hasNonModifySignals) {          return;      } -    stream() << "bool " << cfg().className << "::" << "usrSave()\n"; +    stream() << "bool " << cfg().className << "::" +             << "usrSave()\n";      startScope();      stream() << "  const bool res = " << cfg().inherits << "::usrSave();\n";      stream() << "  if (!res) return false;\n\n"; @@ -685,7 +671,8 @@ void KConfigSourceGenerator::createSignalFlagsHandler()      }      stream() << '\n'; -    stream() << "void " << cfg().className << "::" << "itemChanged(quint64 flags) {\n"; +    stream() << "void " << cfg().className << "::" +             << "itemChanged(quint64 flags) {\n";      if (parseResult.hasNonModifySignals)          stream() << "  " << varPath(QStringLiteral("settingsChanged"), cfg()) << " |= flags;\n"; @@ -703,7 +690,8 @@ void KConfigSourceGenerator::createSignalFlagsHandler()      stream() << "}\n";  } -void KConfigSourceGenerator::includeMoc() { +void KConfigSourceGenerator::includeMoc() +{      const QString mocFileName = cfg().baseName + QStringLiteral(".moc");      if (parseResult.signalList.count() || cfg().generateProperties) { diff --git a/src/kconfig_compiler/KConfigSourceGenerator.h b/src/kconfig_compiler/KConfigSourceGenerator.h index db2c8e72..4b3ef96c 100644 --- a/src/kconfig_compiler/KConfigSourceGenerator.h +++ b/src/kconfig_compiler/KConfigSourceGenerator.h @@ -17,21 +17,18 @@  #include "KConfigCodeGeneratorBase.h"  #include "KConfigCommonStructs.h" -#include <QString>  #include <QList> +#include <QString>  class KConfigParameters;  class CfgEntry;  class QTextStream;  struct ParseResult; -class KConfigSourceGenerator : public KConfigCodeGeneratorBase { +class KConfigSourceGenerator : public KConfigCodeGeneratorBase +{  public: -    KConfigSourceGenerator( -        const QString &inputFile, -        const QString &baseDir, -        const KConfigParameters ¶meters, -        ParseResult &parseResult); +    KConfigSourceGenerator(const QString &inputFile, const QString &baseDir, const KConfigParameters ¶meters, ParseResult &parseResult);      void start() override; diff --git a/src/kconfig_compiler/KConfigXmlParser.cpp b/src/kconfig_compiler/KConfigXmlParser.cpp index e1010564..97d61342 100644 --- a/src/kconfig_compiler/KConfigXmlParser.cpp +++ b/src/kconfig_compiler/KConfigXmlParser.cpp @@ -21,13 +21,15 @@  #include <QStringList>  #include <QTextStream>  #include <iostream> -//TODO: Move preprocessDefault to Header / CPP implementation. +// TODO: Move preprocessDefault to Header / CPP implementation.  // it makes no sense for a parser to process those values and generate code. -static void preProcessDefault(QString &defaultValue, const QString &name, +static void preProcessDefault(QString &defaultValue, +                              const QString &name,                                const QString &type,                                const CfgEntry::Choices &choices, -                              QString &code, const KConfigParameters &cfg) +                              QString &code, +                              const KConfigParameters &cfg)  {      if (type == QLatin1String("String") && !defaultValue.isEmpty()) {          defaultValue = literalString(defaultValue); @@ -64,8 +66,7 @@ static void preProcessDefault(QString &defaultValue, const QString &name,          defaultValue = QLatin1String("default") + name;      } else if (type == QLatin1String("Color") && !defaultValue.isEmpty()) { -        const QRegularExpression colorRe(QRegularExpression::anchoredPattern( -                                         QStringLiteral("\\d+,\\s*\\d+,\\s*\\d+(,\\s*\\d+)?"))); +        const QRegularExpression colorRe(QRegularExpression::anchoredPattern(QStringLiteral("\\d+,\\s*\\d+,\\s*\\d+(,\\s*\\d+)?")));          if (colorRe.match(defaultValue).hasMatch()) {              defaultValue = QLatin1String("QColor( ") + defaultValue + QLatin1String(" )"); @@ -124,7 +125,7 @@ void KConfigXmlParser::readParameterFromEntry(CfgEntry &readEntry, const QDomEle      if (readEntry.param.isEmpty()) {          std::cerr << "Parameter must have a name: " << qPrintable(dumpNode(e)) << std::endl; -        exit (1); +        exit(1);      }      if (readEntry.paramType.isEmpty()) { @@ -157,7 +158,7 @@ void KConfigXmlParser::readParameterFromEntry(CfgEntry &readEntry, const QDomEle          readEntry.paramMax = readEntry.paramValues.count() - 1;      } else {          std::cerr << "Parameter '" << qPrintable(readEntry.param) << "' has type " << qPrintable(readEntry.paramType) -            << " but must be of type int, uint or Enum." << std::endl; +                  << " but must be of type int, uint or Enum." << std::endl;          exit(1);      }  } @@ -190,7 +191,8 @@ void KConfigXmlParser::readChoicesFromEntry(CfgEntry &readEntry, const QDomEleme          if (choice.name.isEmpty()) {              std::cerr << "Tag <choice> requires attribute 'name'." << std::endl;          } else if (!choiceNameRegex.match(choice.name).hasMatch()) { -            std::cerr << "Tag <choice> attribute 'name' must be compatible with Enum naming. name was '" << qPrintable(choice.name) << "'. You can use attribute 'value' to pass any string as the choice value." << std::endl; +            std::cerr << "Tag <choice> attribute 'name' must be compatible with Enum naming. name was '" << qPrintable(choice.name) +                      << "'. You can use attribute 'value' to pass any string as the choice value." << std::endl;          }          choice.val = e2.attribute(QStringLiteral("value"));          for (QDomElement e3 = e2.firstChildElement(); !e3.isNull(); e3 = e3.nextSiblingElement()) { @@ -266,7 +268,7 @@ void KConfigXmlParser::validateNameAndKey(CfgEntry &readEntry, const QDomElement      bool nameIsEmpty = readEntry.name.isEmpty();      if (nameIsEmpty && readEntry.key.isEmpty()) {          std::cerr << "Entry must have a name or a key: " << qPrintable(dumpNode(element)) << std::endl; -        exit (1); +        exit(1);      }      if (readEntry.key.isEmpty()) { @@ -284,12 +286,12 @@ void KConfigXmlParser::validateNameAndKey(CfgEntry &readEntry, const QDomElement      if (readEntry.name.contains(QStringLiteral("$("))) {          if (readEntry.param.isEmpty()) {              std::cerr << "Name may not be parameterized: " << qPrintable(readEntry.name) << std::endl; -            exit (1); +            exit(1);          }      } else {          if (!readEntry.param.isEmpty()) {              std::cerr << "Name must contain '$(" << qPrintable(readEntry.param) << ")': " << qPrintable(readEntry.name) << std::endl; -            exit (1); +            exit(1);          }      }  } @@ -324,13 +326,13 @@ void KConfigXmlParser::readParamDefaultValues(CfgEntry &readEntry, const QDomEle              i = readEntry.paramValues.indexOf(index);              if (i == -1) {                  std::cerr << "Index '" << qPrintable(index) << "' for default value is unknown." << std::endl; -                exit (1); +                exit(1);              }          }          if ((i < 0) || (i > readEntry.paramMax)) {              std::cerr << "Index '" << i << "' for default value is out of range [0, " << readEntry.paramMax << "]." << std::endl; -            exit (1); +            exit(1);          }          QString tmpDefaultValue = e.text(); @@ -349,7 +351,8 @@ CfgEntry *KConfigXmlParser::parseEntry(const QString &group, const QString &pare      readEntry.type = element.attribute(QStringLiteral("type"));      readEntry.name = element.attribute(QStringLiteral("name"));      readEntry.key = element.attribute(QStringLiteral("key")); -    readEntry.hidden = element.attribute(QStringLiteral("hidden")) == QLatin1String("true");; +    readEntry.hidden = element.attribute(QStringLiteral("hidden")) == QLatin1String("true"); +    ;      readEntry.group = group;      readEntry.parentGroup = parentGroup; @@ -364,29 +367,33 @@ CfgEntry *KConfigXmlParser::parseEntry(const QString &group, const QString &pare      }      if (readEntry.type.isEmpty()) { -        readEntry.type = QStringLiteral("String");    // XXX : implicit type might be bad +        readEntry.type = QStringLiteral("String"); // XXX : implicit type might be bad      }      readParamDefaultValues(readEntry, element);      if (!mValidNameRegexp.match(readEntry.name).hasMatch()) {          if (nameIsEmpty) -            std::cerr << "The key '" << qPrintable(readEntry.key) << "' can not be used as name for the entry because " -                 "it is not a valid name. You need to specify a valid name for this entry." << std::endl; +            std::cerr << "The key '" << qPrintable(readEntry.key) +                      << "' can not be used as name for the entry because " +                         "it is not a valid name. You need to specify a valid name for this entry." +                      << std::endl;          else {              std::cerr << "The name '" << qPrintable(readEntry.name) << "' is not a valid name for an entry." << std::endl;          } -        exit (1); +        exit(1);      }      if (mAllNames.contains(readEntry.name)) {          if (nameIsEmpty) -            std::cerr << "The key '" << qPrintable(readEntry.key) << "' can not be used as name for the entry because " -                 "it does not result in a unique name. You need to specify a unique name for this entry." << std::endl; +            std::cerr << "The key '" << qPrintable(readEntry.key) +                      << "' can not be used as name for the entry because " +                         "it does not result in a unique name. You need to specify a unique name for this entry." +                      << std::endl;          else {              std::cerr << "The name '" << qPrintable(readEntry.name) << "' is not unique." << std::endl;          } -        exit (1); +        exit(1);      }      mAllNames.append(readEntry.name); @@ -433,7 +440,8 @@ CfgEntry *KConfigXmlParser::parseEntry(const QString &group, const QString &pare  // TODO: Change the name of the config variable.  KConfigXmlParser::KConfigXmlParser(const KConfigParameters &cfg, const QString &inputFileName) -    : cfg(cfg), mInputFileName(inputFileName) +    : cfg(cfg) +    , mInputFileName(inputFileName)  {      mValidNameRegexp.setPattern(QRegularExpression::anchoredPattern(QStringLiteral("[a-zA-Z_][a-zA-Z0-9_]*")));  } @@ -447,14 +455,15 @@ void KConfigXmlParser::start()      int errorCol;      if (!doc.setContent(&input, &errorMsg, &errorRow, &errorCol)) {          std::cerr << "Unable to load document." << std::endl; -        std::cerr << "Parse error in " << qPrintable(mInputFileName) << ", line " << errorRow << ", col " << errorCol << ": " << qPrintable(errorMsg) << std::endl; -        exit (1); +        std::cerr << "Parse error in " << qPrintable(mInputFileName) << ", line " << errorRow << ", col " << errorCol << ": " << qPrintable(errorMsg) +                  << std::endl; +        exit(1);      }      QDomElement cfgElement = doc.documentElement();      if (cfgElement.isNull()) {          std::cerr << "No document in kcfg file" << std::endl; -        exit (1); +        exit(1);      }      for (QDomElement element = cfgElement.firstChildElement(); !element.isNull(); element = element.nextSiblingElement()) { @@ -490,7 +499,7 @@ void KConfigXmlParser::readGroupTag(const QDomElement &e)      QString group = e.attribute(QStringLiteral("name"));      if (group.isEmpty()) {          std::cerr << "Group without name" << std::endl; -        exit (1); +        exit(1);      }      const QString parentGroup = e.attribute(QStringLiteral("parentGroupName")); @@ -504,7 +513,7 @@ void KConfigXmlParser::readGroupTag(const QDomElement &e)              mParseResult.entries.append(entry);          } else {              std::cerr << "Can not parse entry." << std::endl; -            exit (1); +            exit(1);          }      }  } @@ -531,7 +540,7 @@ void KConfigXmlParser::readSignalTag(const QDomElement &e)      QString signalName = e.attribute(QStringLiteral("name"));      if (signalName.isEmpty()) {          std::cerr << "Signal without name." << std::endl; -        exit (1); +        exit(1);      }      Signal theSignal;      theSignal.name = signalName; @@ -542,9 +551,9 @@ void KConfigXmlParser::readSignalTag(const QDomElement &e)              argument.type = e2.attribute(QStringLiteral("type"));              if (argument.type.isEmpty()) {                  std::cerr << "Signal argument without type." << std::endl; -                exit (1); +                exit(1);              } -            argument.name= e2.text(); +            argument.name = e2.text();              theSignal.arguments.append(argument);          } else if (e2.tagName() == QLatin1String("label")) {              theSignal.label = e2.text(); diff --git a/src/kconfig_compiler/KConfigXmlParser.h b/src/kconfig_compiler/KConfigXmlParser.h index 742cb496..58c2ed58 100644 --- a/src/kconfig_compiler/KConfigXmlParser.h +++ b/src/kconfig_compiler/KConfigXmlParser.h @@ -15,8 +15,8 @@  #define KCONFIGXMLPARSER_H  #include <QDomDocument> -#include <QString>  #include <QRegularExpression> +#include <QString>  #include "KConfigCommonStructs.h"  #include "KConfigParameters.h" diff --git a/src/kconfig_compiler/kconfig_compiler.cpp b/src/kconfig_compiler/kconfig_compiler.cpp index dd7b793c..449d437a 100644 --- a/src/kconfig_compiler/kconfig_compiler.cpp +++ b/src/kconfig_compiler/kconfig_compiler.cpp @@ -10,26 +10,26 @@      SPDX-License-Identifier: LGPL-2.0-or-later  */ +#include <QCommandLineOption> +#include <QCommandLineParser>  #include <QCoreApplication> +#include <QDomAttr>  #include <QFile>  #include <QFileInfo> -#include <QSettings> -#include <QTextStream> -#include <QDomAttr>  #include <QRegularExpression> +#include <QSettings>  #include <QStringList> -#include <QCommandLineParser> -#include <QCommandLineOption> +#include <QTextStream> -#include <ostream> +#include <algorithm>  #include <iostream> +#include <ostream>  #include <stdlib.h> -#include <algorithm>  #include "../../kconfig_version.h" -#include "KConfigParameters.h"  #include "KConfigCommonStructs.h"  #include "KConfigHeaderGenerator.h" +#include "KConfigParameters.h"  #include "KConfigSourceGenerator.h"  #include "KConfigXmlParser.h" @@ -114,12 +114,12 @@ QString setFunction(const QString &n, const QString &className)  QString changeSignalName(const QString &n)  { -    return n+QStringLiteral("Changed"); +    return n + QStringLiteral("Changed");  }  QString getDefaultFunction(const QString &n, const QString &className)  { -    QString result = QLatin1String("default") +  n + QLatin1String("Value"); +    QString result = QLatin1String("default") + n + QLatin1String("Value");      result[7] = result.at(7).toUpper();      if (!className.isEmpty()) { @@ -173,7 +173,9 @@ static QString quoteString(const QString &s)  QString literalString(const QString &str)  { -    const bool isAscii = std::none_of(str.cbegin(), str.cend(), [](const QChar ch) { return ch.unicode() > 127; }); +    const bool isAscii = std::none_of(str.cbegin(), str.cend(), [](const QChar ch) { +        return ch.unicode() > 127; +    });      if (isAscii) {          return QLatin1String{"QStringLiteral( "} + quoteString(str) + QLatin1String{" )"}; @@ -246,7 +248,7 @@ QString param(const QString &t)          return QStringLiteral("const QList<QUrl> &");      } else {          std::cerr << "kconfig_compiler_kf5 does not support type \"" << qPrintable(type) << "\"" << std::endl; -        return QStringLiteral("QString"); //For now, but an assert would be better +        return QStringLiteral("QString"); // For now, but an assert would be better      }  } @@ -300,7 +302,7 @@ QString cppType(const QString &t)          return QStringLiteral("QList<QUrl>");      } else {          std::cerr << "kconfig_compiler_kf5 does not support type \"" << qPrintable(type) << "\"" << std::endl; -        return QStringLiteral("QString"); //For now, but an assert would be better +        return QStringLiteral("QString"); // For now, but an assert would be better      }  } @@ -308,7 +310,7 @@ QString defaultValue(const QString &t)  {      const QString type = t.toLower();      if (type == QLatin1String("string")) { -        return QStringLiteral("\"\"");    // Use empty string, not null string! +        return QStringLiteral("\"\""); // Use empty string, not null string!      } else if (type == QLatin1String("stringlist")) {          return QStringLiteral("QStringList()");      } else if (type == QLatin1String("font")) { @@ -340,18 +342,18 @@ QString defaultValue(const QString &t)      } else if (type == QLatin1String("enum")) {          return QStringLiteral("0");      } else if (type == QLatin1String("path")) { -        return QStringLiteral("\"\"");    // Use empty string, not null string! +        return QStringLiteral("\"\""); // Use empty string, not null string!      } else if (type == QLatin1String("pathlist")) {          return QStringLiteral("QStringList()");      } else if (type == QLatin1String("password")) { -        return QStringLiteral("\"\"");    // Use empty string, not null string! +        return QStringLiteral("\"\""); // Use empty string, not null string!      } else if (type == QLatin1String("url")) {          return QStringLiteral("QUrl()");      } else if (type == QLatin1String("urllist")) {          return QStringLiteral("QList<QUrl>()");      } else {          std::cerr << "Error, kconfig_compiler_kf5 does not support the \"" << qPrintable(type) << "\" type!" << std::endl; -        return QStringLiteral("QString"); //For now, but an assert would be better +        return QStringLiteral("QString"); // For now, but an assert would be better      }  } @@ -381,8 +383,8 @@ QString itemDeclaration(const CfgEntry *e, const KConfigParameters &cfg)      QString result;      if (!cfg.itemAccessors && !cfg.dpointer) { -        result += QLatin1String{"  "} + (!e->signalList.isEmpty() ? QStringLiteral("KConfigCompilerSignallingItem") : type) -                  + QLatin1String{"  *item"} + fCap + argSuffix + QLatin1String{";\n"}; +        result += QLatin1String{"  "} + (!e->signalList.isEmpty() ? QStringLiteral("KConfigCompilerSignallingItem") : type) + QLatin1String{"  *item"} + fCap +            + argSuffix + QLatin1String{";\n"};      }      if (!e->signalList.isEmpty()) { @@ -434,8 +436,8 @@ QString itemPath(const CfgEntry *e, const KConfigParameters &cfg)  QString newInnerItem(const CfgEntry *entry, const QString &key, const QString &defaultValue, const KConfigParameters &cfg, const QString ¶m)  { -    QString t = QLatin1String{"new "} + cfg.inherits + QLatin1String{"::Item"} + itemType(entry->type) -                + QLatin1String{"( currentGroup(), "} + key + QLatin1String{", "} + varPath( entry->name, cfg ) + param; +    QString t = QLatin1String{"new "} + cfg.inherits + QLatin1String{"::Item"} + itemType(entry->type) + QLatin1String{"( currentGroup(), "} + key +        + QLatin1String{", "} + varPath(entry->name, cfg) + param;      if (entry->type == QLatin1String("Enum")) {          t += QLatin1String{", values"} + entry->name; @@ -523,8 +525,7 @@ QString translatedString(const KConfigParameters &cfg, const QString &string, co      case KConfigParameters::KdeTranslation:          if (!cfg.translationDomain.isEmpty() && !context.isEmpty()) { -            result += QLatin1String{"i18ndc("} + quoteString(cfg.translationDomain) + QLatin1String{", "} -                      + quoteString(context) + QLatin1String{", "}; +            result += QLatin1String{"i18ndc("} + quoteString(cfg.translationDomain) + QLatin1String{", "} + quoteString(context) + QLatin1String{", "};          } else if (!cfg.translationDomain.isEmpty()) {              result += QLatin1String{"i18nd("} + quoteString(cfg.translationDomain) + QLatin1String{", "};          } else if (!context.isEmpty()) { @@ -573,21 +574,19 @@ QString userTextsFunctions(const CfgEntry *e, const KConfigParameters &cfg, QStr      return txt;  } -  // returns the member mutator implementation  // which should go in the h file if inline  // or the cpp file if not inline -//TODO: Fix add Debug Method, it should also take the debug string. +// TODO: Fix add Debug Method, it should also take the debug string.  void addDebugMethod(QTextStream &out, const KConfigParameters &cfg, const QString &n)  {      if (cfg.qCategoryLoggingName.isEmpty()) { -       out << "  qDebug() << \"" << setFunction(n); +        out << "  qDebug() << \"" << setFunction(n);      } else { -       out << "  qCDebug(" << cfg.qCategoryLoggingName << ") << \"" << setFunction(n); +        out << "  qCDebug(" << cfg.qCategoryLoggingName << ") << \"" << setFunction(n);      }  } -  // returns the member get default implementation  // which should go in the h file if inline  // or the cpp file if not inline @@ -633,7 +632,7 @@ QString itemAccessorBody(const CfgEntry *e, const KConfigParameters &cfg)      return result;  } -//indents text adding X spaces per line +// indents text adding X spaces per line  QString indent(QString text, int spaces)  {      QString result; @@ -651,7 +650,7 @@ QString indent(QString text, int spaces)      return result;  } -bool hasErrors(KConfigXmlParser &parser, const ParseResult& parseResult, const KConfigParameters &cfg) +bool hasErrors(KConfigXmlParser &parser, const ParseResult &parseResult, const KConfigParameters &cfg)  {      Q_UNUSED(parser) @@ -671,18 +670,18 @@ bool hasErrors(KConfigXmlParser &parser, const ParseResult& parseResult, const K      }      /* TODO: For some reason some configuration files prefer to have *no* entries -    * at all in it, and the generated code is mostly bogus as KConfigXT will not -    * handle save / load / properties, etc, nothing. -    * -    * The first of those files that I came across are qmakebuilderconfig.kcfg from the KDevelop -    * project. -    * I think we should remove the possibility of creating configuration classes from configuration -    * files that don't really have configuration in it. but I'm changing this right now to allow -    * kdevelop files to pass. -    * -    * Remove for KDE 6 -    * (to make things more interesting, it failed in a code that's never used within KDevelop... ) -    */ +     * at all in it, and the generated code is mostly bogus as KConfigXT will not +     * handle save / load / properties, etc, nothing. +     * +     * The first of those files that I came across are qmakebuilderconfig.kcfg from the KDevelop +     * project. +     * I think we should remove the possibility of creating configuration classes from configuration +     * files that don't really have configuration in it. but I'm changing this right now to allow +     * kdevelop files to pass. +     * +     * Remove for KDE 6 +     * (to make things more interesting, it failed in a code that's never used within KDevelop... ) +     */      if (parseResult.entries.isEmpty()) {          std::cerr << "No entries." << std::endl;          return false; @@ -699,13 +698,13 @@ int main(int argc, char **argv)      QString inputFilename, codegenFilename; -    QCommandLineOption targetDirectoryOption(QStringList { QStringLiteral("d"), QStringLiteral("directory") }, -            QCoreApplication::translate("main", "Directory to generate files in [.]"), -            QCoreApplication::translate("main", "directory"), QStringLiteral(".")); +    QCommandLineOption targetDirectoryOption(QStringList{QStringLiteral("d"), QStringLiteral("directory")}, +                                             QCoreApplication::translate("main", "Directory to generate files in [.]"), +                                             QCoreApplication::translate("main", "directory"), +                                             QStringLiteral(".")); -    QCommandLineOption licenseOption ( -        QStringList { QStringLiteral("l"), QStringLiteral("license") }, -        QCoreApplication::translate("main", "Display software license.")); +    QCommandLineOption licenseOption(QStringList{QStringLiteral("l"), QStringLiteral("license")}, +                                     QCoreApplication::translate("main", "Display software license."));      QCommandLineParser parser; @@ -713,7 +712,7 @@ int main(int argc, char **argv)      parser.addPositionalArgument(QStringLiteral("file.kcfgc"), QStringLiteral("Code generation options file"));      parser.addOption(targetDirectoryOption); -    parser.addOption (licenseOption); +    parser.addOption(licenseOption);      parser.addVersionOption();      parser.addHelpOption(); @@ -732,7 +731,7 @@ int main(int argc, char **argv)      const QStringList args = parser.positionalArguments();      if (args.count() < 2) {          std::cerr << "Too few arguments." << std::endl; -	    return 1; +        return 1;      }      if (args.count() > 2) { diff --git a/src/kreadconfig/kreadconfig.cpp b/src/kreadconfig/kreadconfig.cpp index 3d26c3b8..444f3bde 100644 --- a/src/kreadconfig/kreadconfig.cpp +++ b/src/kreadconfig/kreadconfig.cpp @@ -38,64 +38,66 @@  int main(int argc, char **argv)  { -	QCoreApplication app(argc, argv); +    QCoreApplication app(argc, argv); -	QCommandLineParser parser; -    parser.addOption(QCommandLineOption(QStringLiteral("file"), QCoreApplication::translate("main", "Use <file> instead of global config"), QStringLiteral("file"))); -    parser.addOption(QCommandLineOption(QStringLiteral("group"), QCoreApplication::translate("main", "Group to look in. Use repeatedly for nested groups."), QStringLiteral("group"), QStringLiteral("KDE"))); +    QCommandLineParser parser; +    parser.addOption( +        QCommandLineOption(QStringLiteral("file"), QCoreApplication::translate("main", "Use <file> instead of global config"), QStringLiteral("file"))); +    parser.addOption(QCommandLineOption(QStringLiteral("group"), +                                        QCoreApplication::translate("main", "Group to look in. Use repeatedly for nested groups."), +                                        QStringLiteral("group"), +                                        QStringLiteral("KDE")));      parser.addOption(QCommandLineOption(QStringLiteral("key"), QCoreApplication::translate("main", "Key to look for"), QStringLiteral("key")));      parser.addOption(QCommandLineOption(QStringLiteral("default"), QCoreApplication::translate("main", "Default value"), QStringLiteral("value")));      parser.addOption(QCommandLineOption(QStringLiteral("type"), QCoreApplication::translate("main", "Type of variable"), QStringLiteral("type"))); -	parser.process(app); +    parser.process(app); -    const QStringList groups=parser.values(QStringLiteral("group")); -    QString key=parser.value(QStringLiteral("key")); -    QString file=parser.value(QStringLiteral("file")); -    QString dflt=parser.value(QStringLiteral("default")); -    QString type=parser.value(QStringLiteral("type")).toLower(); +    const QStringList groups = parser.values(QStringLiteral("group")); +    QString key = parser.value(QStringLiteral("key")); +    QString file = parser.value(QStringLiteral("file")); +    QString dflt = parser.value(QStringLiteral("default")); +    QString type = parser.value(QStringLiteral("type")).toLower();      if (key.isNull() || !parser.positionalArguments().isEmpty()) { -		parser.showHelp(1); -	} +        parser.showHelp(1); +    } -	KSharedConfig::openConfig(); +    KSharedConfig::openConfig(); -	KConfig *konfig; -	bool configMustDeleted = false; -	if (file.isEmpty()) -	   konfig = KSharedConfig::openConfig().data(); -	else -	{ -		konfig = new KConfig( file, KConfig::NoGlobals ); -		configMustDeleted=true; -	} -	KConfigGroup cfgGroup = konfig->group(QString()); +    KConfig *konfig; +    bool configMustDeleted = false; +    if (file.isEmpty()) +        konfig = KSharedConfig::openConfig().data(); +    else { +        konfig = new KConfig(file, KConfig::NoGlobals); +        configMustDeleted = true; +    } +    KConfigGroup cfgGroup = konfig->group(QString());      for (const QString &grp : groups) -		cfgGroup = cfgGroup.group(grp); -    if(type==QStringLiteral("bool")) { -		dflt=dflt.toLower(); -        bool def=(dflt==QStringLiteral("true") || dflt==QStringLiteral("on") || dflt==QStringLiteral("yes") || dflt==QStringLiteral("1")); -		bool retValue = !cfgGroup.readEntry(key, def); -		if ( configMustDeleted ) -			delete konfig; -		return retValue; -    } else if((type==QStringLiteral("num")) || (type==QStringLiteral("int"))) { -		int retValue = cfgGroup.readEntry(key, dflt.toInt()); -		if ( configMustDeleted ) -			delete konfig; -		return retValue; -    } else if (type==QStringLiteral("path")){ -		fprintf(stdout, "%s\n", cfgGroup.readPathEntry(key, dflt).toLocal8Bit().data()); -		if ( configMustDeleted ) -			delete konfig; -		return 0; -	} else { -		/* Assume it's a string... */ -		fprintf(stdout, "%s\n", cfgGroup.readEntry(key, dflt).toLocal8Bit().data()); -		if ( configMustDeleted ) -			delete konfig; -		return 0; -	} +        cfgGroup = cfgGroup.group(grp); +    if (type == QStringLiteral("bool")) { +        dflt = dflt.toLower(); +        bool def = (dflt == QStringLiteral("true") || dflt == QStringLiteral("on") || dflt == QStringLiteral("yes") || dflt == QStringLiteral("1")); +        bool retValue = !cfgGroup.readEntry(key, def); +        if (configMustDeleted) +            delete konfig; +        return retValue; +    } else if ((type == QStringLiteral("num")) || (type == QStringLiteral("int"))) { +        int retValue = cfgGroup.readEntry(key, dflt.toInt()); +        if (configMustDeleted) +            delete konfig; +        return retValue; +    } else if (type == QStringLiteral("path")) { +        fprintf(stdout, "%s\n", cfgGroup.readPathEntry(key, dflt).toLocal8Bit().data()); +        if (configMustDeleted) +            delete konfig; +        return 0; +    } else { +        /* Assume it's a string... */ +        fprintf(stdout, "%s\n", cfgGroup.readEntry(key, dflt).toLocal8Bit().data()); +        if (configMustDeleted) +            delete konfig; +        return 0; +    }  } - diff --git a/src/kreadconfig/kwriteconfig.cpp b/src/kreadconfig/kwriteconfig.cpp index 8befa56d..ba16ec68 100644 --- a/src/kreadconfig/kwriteconfig.cpp +++ b/src/kreadconfig/kwriteconfig.cpp @@ -11,9 +11,9 @@  #include <KConfig>  #include <KConfigGroup> -#include <stdio.h> -#include <QCoreApplication>  #include <QCommandLineParser> +#include <QCoreApplication> +#include <stdio.h>  int main(int argc, char **argv)  { @@ -21,20 +21,27 @@ int main(int argc, char **argv)      QCommandLineParser parser;      parser.addHelpOption(); -    parser.addOption(QCommandLineOption(QStringLiteral("file"), QCoreApplication::translate("main", "Use <file> instead of global config"), QStringLiteral("file"))); -    parser.addOption(QCommandLineOption(QStringLiteral("group"), QCoreApplication::translate("main", "Group to look in. Use repeatedly for nested groups."), QStringLiteral("group"), QStringLiteral("KDE"))); +    parser.addOption( +        QCommandLineOption(QStringLiteral("file"), QCoreApplication::translate("main", "Use <file> instead of global config"), QStringLiteral("file"))); +    parser.addOption(QCommandLineOption(QStringLiteral("group"), +                                        QCoreApplication::translate("main", "Group to look in. Use repeatedly for nested groups."), +                                        QStringLiteral("group"), +                                        QStringLiteral("KDE")));      parser.addOption(QCommandLineOption(QStringLiteral("key"), QCoreApplication::translate("main", "Key to look for"), QStringLiteral("key"))); -    parser.addOption(QCommandLineOption(QStringLiteral("type"), QCoreApplication::translate("main", "Type of variable. Use \"bool\" for a boolean, otherwise it is treated as a string"), QStringLiteral("type"))); +    parser.addOption( +        QCommandLineOption(QStringLiteral("type"), +                           QCoreApplication::translate("main", "Type of variable. Use \"bool\" for a boolean, otherwise it is treated as a string"), +                           QStringLiteral("type")));      parser.addOption(QCommandLineOption(QStringLiteral("delete"), QCoreApplication::translate("main", "Delete the designated key if enabled"))); -    parser.addPositionalArgument(QStringLiteral("value"), QCoreApplication::translate("main",  "The value to write. Mandatory, on a shell use '' for empty" )); +    parser.addPositionalArgument(QStringLiteral("value"), QCoreApplication::translate("main", "The value to write. Mandatory, on a shell use '' for empty"));      parser.process(app); -    const QStringList groups=parser.values(QStringLiteral("group")); -    QString key=parser.value(QStringLiteral("key")); -    QString file=parser.value(QStringLiteral("file")); -    QString type=parser.value(QStringLiteral("type")).toLower(); -    bool del=parser.isSet(QStringLiteral("delete")); +    const QStringList groups = parser.values(QStringLiteral("group")); +    QString key = parser.value(QStringLiteral("key")); +    QString file = parser.value(QStringLiteral("file")); +    QString type = parser.value(QStringLiteral("type")).toLower(); +    bool del = parser.isSet(QStringLiteral("delete"));      QString value;      if (del) { @@ -47,28 +54,28 @@ int main(int argc, char **argv)      KConfig *konfig;      if (file.isEmpty()) -        konfig = new KConfig(QStringLiteral( "kdeglobals"), KConfig::NoGlobals ); +        konfig = new KConfig(QStringLiteral("kdeglobals"), KConfig::NoGlobals);      else -        konfig = new KConfig( file, KConfig::NoGlobals ); +        konfig = new KConfig(file, KConfig::NoGlobals);      KConfigGroup cfgGroup = konfig->group(QString());      for (const QString &grp : groups)          cfgGroup = cfgGroup.group(grp); -    if ( konfig->accessMode() != KConfig::ReadWrite || cfgGroup.isEntryImmutable( key ) ) return 2; +    if (konfig->accessMode() != KConfig::ReadWrite || cfgGroup.isEntryImmutable(key)) +        return 2;      if (del) { -        cfgGroup.deleteEntry( key ); -    } else if (type==QStringLiteral("bool")) { +        cfgGroup.deleteEntry(key); +    } else if (type == QStringLiteral("bool")) {          // For symmetry with kreadconfig we accept a wider range of values as true than Qt -        bool boolvalue=(value==QStringLiteral("true") || value==QStringLiteral("on") || value==QStringLiteral("yes") || value==QStringLiteral("1")); -        cfgGroup.writeEntry( key, boolvalue ); -    } else if (type==QStringLiteral("path")) { -        cfgGroup.writePathEntry( key, value ); +        bool boolvalue = (value == QStringLiteral("true") || value == QStringLiteral("on") || value == QStringLiteral("yes") || value == QStringLiteral("1")); +        cfgGroup.writeEntry(key, boolvalue); +    } else if (type == QStringLiteral("path")) { +        cfgGroup.writePathEntry(key, value);      } else { -        cfgGroup.writeEntry( key, value ); +        cfgGroup.writeEntry(key, value);      }      konfig->sync();      delete konfig;      return 0;  } - | 
