aboutsummaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
authorDavid Faure <faure@kde.org>2013-12-18 09:53:59 +0100
committerDavid Faure <faure@kde.org>2013-12-18 09:53:59 +0100
commit159963832457e6307282308455330acc7b5bd153 (patch)
treece1cc0234d37e9afc75bc86d734beb963ed57d02 /src/core
parent867e7a50e6396338ab4fe9aa22ad141e4cd344d2 (diff)
downloadkconfig-159963832457e6307282308455330acc7b5bd153.tar.gz
kconfig-159963832457e6307282308455330acc7b5bd153.tar.bz2
Code reformatted using kde-dev-scripts/astyle-kdelibs.
Use git blame -w 867e7a5 to show authorship as it was before this commit.
Diffstat (limited to 'src/core')
-rw-r--r--src/core/bufferfragment_p.h110
-rw-r--r--src/core/conversion_check.h50
-rw-r--r--src/core/kauthorized.cpp568
-rw-r--r--src/core/kauthorized.h60
-rw-r--r--src/core/kconfig.cpp303
-rw-r--r--src/core/kconfig.h24
-rw-r--r--src/core/kconfig_p.h73
-rw-r--r--src/core/kconfigbackend.cpp17
-rw-r--r--src/core/kconfigbackend.h21
-rw-r--r--src/core/kconfigbase.cpp19
-rw-r--r--src/core/kconfigbase.h27
-rw-r--r--src/core/kconfigdata.cpp121
-rw-r--r--src/core/kconfigdata.h254
-rw-r--r--src/core/kconfiggroup.cpp904
-rw-r--r--src/core/kconfiggroup.h169
-rw-r--r--src/core/kconfiggroup_p.h7
-rw-r--r--src/core/kconfigini.cpp361
-rw-r--r--src/core/kconfigini_p.h24
-rw-r--r--src/core/kcoreconfigskeleton.cpp1172
-rw-r--r--src/core/kcoreconfigskeleton.h1973
-rw-r--r--src/core/kcoreconfigskeleton_p.h27
-rw-r--r--src/core/kdesktopfile.cpp261
-rw-r--r--src/core/kdesktopfile.h406
-rw-r--r--src/core/kemailsettings.cpp397
-rw-r--r--src/core/kemailsettings.h234
-rw-r--r--src/core/ksharedconfig.cpp34
-rw-r--r--src/core/ksharedconfig.h10
27 files changed, 3891 insertions, 3735 deletions
diff --git a/src/core/bufferfragment_p.h b/src/core/bufferfragment_p.h
index 5a753ad4..117d8db3 100644
--- a/src/core/bufferfragment_p.h
+++ b/src/core/bufferfragment_p.h
@@ -23,158 +23,168 @@
#define bf_isspace(str) ((str == ' ') || (str == '\t') || (str == '\r'))
-// This class provides wrapper around fragment of existing buffer (array of bytes).
+// This class provides wrapper around fragment of existing buffer (array of bytes).
// If underlying buffer gets deleted, all BufferFragment objects referencing it become invalid.
// Use toByteArray() to make deep copy of the buffer fragment.
-//
+//
// API is designed to subset of QByteArray methods with some changes:
// - trim() is like QByteArray.trimmed(), but it modifies current object
// - truncateLeft() provides way to cut off beginning of the buffer
// - split() works more like strtok_r than QByteArray.split()
// - truncateLeft() and mid() require position argument to be valid
-
-class KConfigIniBackend::BufferFragment
+
+class KConfigIniBackend::BufferFragment
{
-
+
public:
- BufferFragment() : d(0), len(0)
+ BufferFragment() : d(0), len(0)
{
}
-
- BufferFragment(char* buf, int size) : d(buf), len(size)
+
+ BufferFragment(char *buf, int size) : d(buf), len(size)
{
}
- int length() const
+ int length() const
{
return len;
}
- char at(unsigned int i) const
+ char at(unsigned int i) const
{
Q_ASSERT(i < len);
return d[i];
}
- void clear()
+ void clear()
{
len = 0;
}
- const char* constData() const
+ const char *constData() const
{
return d;
}
- char* data() const
+ char *data() const
{
return d;
}
- void trim()
+ void trim()
{
while (bf_isspace(*d) && len > 0) {
d++;
len--;
}
- while (len > 0 && bf_isspace(d[len - 1]))
+ while (len > 0 && bf_isspace(d[len - 1])) {
len--;
+ }
}
// similar to strtok_r . On first call variable pointed by start should be set to 0.
- // Each call will update *start to new starting position.
- BufferFragment split(char c, unsigned int* start)
+ // Each call will update *start to new starting position.
+ BufferFragment split(char c, unsigned int *start)
{
while (*start < len) {
int end = indexOf(c, *start);
- if (end == -1) end = len;
+ if (end == -1) {
+ end = len;
+ }
BufferFragment line(d + (*start), end - (*start));
*start = end + 1;
return line;
}
return BufferFragment();
}
-
- bool isEmpty() const
+
+ bool isEmpty() const
{
return (len == 0);
}
- BufferFragment left(unsigned int size) const
+ BufferFragment left(unsigned int size) const
{
- return BufferFragment(d, qMin(size,len));
+ return BufferFragment(d, qMin(size, len));
}
- void truncateLeft(unsigned int size)
+ void truncateLeft(unsigned int size)
{
Q_ASSERT(size <= len);
d += size;
len -= size;
}
- void truncate(unsigned int pos)
+ void truncate(unsigned int pos)
{
- if (pos < len) len = pos;
+ if (pos < len) {
+ len = pos;
+ }
}
- bool isNull() const
+ bool isNull() const
{
return (d == 0);
}
-
- BufferFragment mid(unsigned int pos, int length=-1) const
+
+ BufferFragment mid(unsigned int pos, int length = -1) const
{
Q_ASSERT(pos < len);
int size = length;
- if (length == -1 || (pos + length) > len)
+ if (length == -1 || (pos + length) > len) {
size = len - pos;
+ }
return BufferFragment(d + pos, size);
}
- bool operator==(const QByteArray& other) const
+ bool operator==(const QByteArray &other) const
{
- return (other.size() == (int)len && memcmp(d,other.constData(),len) == 0);
+ return (other.size() == (int)len && memcmp(d, other.constData(), len) == 0);
}
- bool operator!=(const QByteArray& other) const
+ bool operator!=(const QByteArray &other) const
{
- return (other.size() != (int)len || memcmp(d,other.constData(),len) != 0);
+ return (other.size() != (int)len || memcmp(d, other.constData(), len) != 0);
}
-
- int indexOf(char c, unsigned int from = 0) const
+
+ int indexOf(char c, unsigned int from = 0) const
{
- const char* cursor = d + from - 1;
- const char* end = d + len;
- while ( ++cursor < end)
- if (*cursor ==c )
- return cursor - d;
+ const char *cursor = d + from - 1;
+ const char *end = d + len;
+ while (++cursor < end)
+ if (*cursor == c) {
+ return cursor - d;
+ }
return -1;
}
- int lastIndexOf(char c) const
+ int lastIndexOf(char c) const
{
int from = len - 1;
- while (from >= 0)
- if (d[from] == c)
- return from;
- else
+ while (from >= 0)
+ if (d[from] == c) {
+ return from;
+ } else {
from--;
+ }
return -1;
}
- QByteArray toByteArray() const {
- return QByteArray(d,len);
+ QByteArray toByteArray() const
+ {
+ return QByteArray(d, len);
}
-
+
// this is faster than toByteArray, but returned QByteArray becomes invalid
// when buffer for this BufferFragment disappears
- QByteArray toVolatileByteArray() const {
+ QByteArray toVolatileByteArray() const
+ {
return QByteArray::fromRawData(d, len);
}
private:
- char* d;
+ char *d;
unsigned int len;
};
diff --git a/src/core/conversion_check.h b/src/core/conversion_check.h
index 23bdcf04..55bd8826 100644
--- a/src/core/conversion_check.h
+++ b/src/core/conversion_check.h
@@ -18,7 +18,6 @@
Boston, MA 02110-1301, USA.
*/
-
#ifndef CONVERSION_CHECK_H
#define CONVERSION_CHECK_H
@@ -32,7 +31,8 @@
class QColor;
class QFont;
-namespace ConversionCheck {
+namespace ConversionCheck
+{
// used to distinguish between supported/unsupported types
struct supported { };
@@ -40,43 +40,47 @@ struct unsupported { };
// traits type class to define support for constraints
template <typename T>
-struct QVconvertible
-{
- typedef unsupported toQString;
- typedef unsupported toQVariant;
+struct QVconvertible {
+ typedef unsupported toQString;
+ typedef unsupported toQVariant;
};
// constraint classes
template <typename T>
-struct type_toQString
-{
- void constraint() { supported x = y; Q_UNUSED(x); }
- typename QVconvertible<T>::toQString y;
+struct type_toQString {
+ void constraint()
+ {
+ supported x = y;
+ Q_UNUSED(x);
+ }
+ typename QVconvertible<T>::toQString y;
};
template <typename T>
-struct type_toQVariant
-{
- void constraint() { supported x = y; Q_UNUSED(x); }
- typename QVconvertible<T>::toQVariant y;
+struct type_toQVariant {
+ void constraint()
+ {
+ supported x = y;
+ Q_UNUSED(x);
+ }
+ typename QVconvertible<T>::toQVariant y;
};
-
// check if T is convertible to QString thru QVariant
// if not supported can't be used in QList<T> functions
template <typename T>
inline void to_QString()
{
- void (type_toQString<T>::*x)() = &type_toQString<T>::constraint;
- Q_UNUSED(x);
+ void (type_toQString<T>::*x)() = &type_toQString<T>::constraint;
+ Q_UNUSED(x);
}
// check if T is convertible to QVariant & supported in readEntry/writeEntry
template <typename T>
inline void to_QVariant()
{
- void (type_toQVariant<T>::*x)() = &type_toQVariant<T>::constraint;
- Q_UNUSED(x);
+ void (type_toQVariant<T>::*x)() = &type_toQVariant<T>::constraint;
+ Q_UNUSED(x);
}
// define for all types handled in readEntry/writeEntry
@@ -84,10 +88,10 @@ inline void to_QVariant()
// 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;\
-}
+ template <> struct QVconvertible<type> {\
+ typedef string_support toQString;\
+ typedef variant_support toQVariant;\
+ }
// The only types needed here are the types handled in readEntry/writeEntry
// the default QVconvertible will take care of the rest.
diff --git a/src/core/kauthorized.cpp b/src/core/kauthorized.cpp
index abf479ca..c9b14f50 100644
--- a/src/core/kauthorized.cpp
+++ b/src/core/kauthorized.cpp
@@ -40,301 +40,302 @@
extern bool kde_kiosk_exception;
-
class URLActionRule
{
- public:
+public:
#define checkExactMatch(s, b) \
- if (s.isEmpty()) b = true; \
- else if (s[s.length()-1] == QLatin1Char('!')) \
- { b = false; s.truncate(s.length()-1); } \
- else b = true;
+ if (s.isEmpty()) b = true; \
+ else if (s[s.length()-1] == QLatin1Char('!')) \
+ { b = false; s.truncate(s.length()-1); } \
+ else b = true;
#define checkStartWildCard(s, b) \
- if (s.isEmpty()) b = true; \
- else if (s[0] == QLatin1Char('*')) \
- { b = true; s = s.mid(1); } \
- else b = false;
+ if (s.isEmpty()) b = true; \
+ else if (s[0] == QLatin1Char('*')) \
+ { b = true; s = s.mid(1); } \
+ else b = false;
#define checkEqual(s, b) \
- b = (s == QString::fromLatin1("="));
-
- URLActionRule(const QByteArray &act,
- 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)
- {
- checkExactMatch(baseProt, baseProtWildCard);
- checkStartWildCard(baseHost, baseHostWildCard);
- checkExactMatch(basePath, basePathWildCard);
- checkExactMatch(destProt, destProtWildCard);
- checkStartWildCard(destHost, destHostWildCard);
- checkExactMatch(destPath, destPathWildCard);
- checkEqual(destProt, destProtEqual);
- checkEqual(destHost, destHostEqual);
- }
-
- bool baseMatch(const QUrl &url, const QString &protClass) const
- {
- if (baseProtWildCard)
- {
- if ( !baseProt.isEmpty() && !url.scheme().startsWith(baseProt) &&
- (protClass.isEmpty() || (protClass != baseProt)) )
- return false;
- }
- else
- {
- if ( (url.scheme() != baseProt) &&
- (protClass.isEmpty() || (protClass != baseProt)) )
- return false;
- }
- if (baseHostWildCard)
- {
- if (!baseHost.isEmpty() && !url.host().endsWith(baseHost))
- return false;
- }
- else
- {
- if (url.host() != baseHost)
- return false;
+ b = (s == QString::fromLatin1("="));
+
+ URLActionRule(const QByteArray &act,
+ 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)
+ {
+ checkExactMatch(baseProt, baseProtWildCard);
+ checkStartWildCard(baseHost, baseHostWildCard);
+ checkExactMatch(basePath, basePathWildCard);
+ checkExactMatch(destProt, destProtWildCard);
+ checkStartWildCard(destHost, destHostWildCard);
+ checkExactMatch(destPath, destPathWildCard);
+ checkEqual(destProt, destProtEqual);
+ checkEqual(destHost, destHostEqual);
+ }
+
+ bool baseMatch(const QUrl &url, const QString &protClass) const
+ {
+ if (baseProtWildCard) {
+ if (!baseProt.isEmpty() && !url.scheme().startsWith(baseProt) &&
+ (protClass.isEmpty() || (protClass != baseProt))) {
+ return false;
+ }
+ } else {
+ if ((url.scheme() != baseProt) &&
+ (protClass.isEmpty() || (protClass != baseProt))) {
+ return false;
+ }
}
- if (basePathWildCard)
- {
- if (!basePath.isEmpty() && !url.path().startsWith(basePath))
- return false;
+ if (baseHostWildCard) {
+ if (!baseHost.isEmpty() && !url.host().endsWith(baseHost)) {
+ return false;
+ }
+ } else {
+ if (url.host() != baseHost) {
+ return false;
+ }
}
- else
- {
- if (url.path() != basePath)
- return false;
+ if (basePathWildCard) {
+ if (!basePath.isEmpty() && !url.path().startsWith(basePath)) {
+ return false;
+ }
+ } else {
+ if (url.path() != basePath) {
+ return false;
+ }
}
return true;
- }
-
- 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) )
- return false;
- }
- else if (destProtWildCard)
- {
- if ( !destProt.isEmpty() && !url.scheme().startsWith(destProt) &&
- (protClass.isEmpty() || (protClass != destProt)) )
- return false;
- }
- else
- {
- if ( (url.scheme() != destProt) &&
- (protClass.isEmpty() || (protClass != destProt)) )
- return false;
- }
- if (destHostWildCard)
- {
- if (!destHost.isEmpty() && !url.host().endsWith(destHost))
- return false;
- }
- else if (destHostEqual)
- {
- if (url.host() != base.host())
- return false;
- }
- else
- {
- if (url.host() != destHost)
- return false;
+ }
+
+ 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)) {
+ return false;
+ }
+ } else if (destProtWildCard) {
+ if (!destProt.isEmpty() && !url.scheme().startsWith(destProt) &&
+ (protClass.isEmpty() || (protClass != destProt))) {
+ return false;
+ }
+ } else {
+ if ((url.scheme() != destProt) &&
+ (protClass.isEmpty() || (protClass != destProt))) {
+ return false;
+ }
}
- if (destPathWildCard)
- {
- if (!destPath.isEmpty() && !url.path().startsWith(destPath))
- return false;
+ if (destHostWildCard) {
+ if (!destHost.isEmpty() && !url.host().endsWith(destHost)) {
+ return false;
+ }
+ } else if (destHostEqual) {
+ if (url.host() != base.host()) {
+ return false;
+ }
+ } else {
+ if (url.host() != destHost) {
+ return false;
+ }
}
- else
- {
- if (url.path() != destPath)
- return false;
+ if (destPathWildCard) {
+ if (!destPath.isEmpty() && !url.path().startsWith(destPath)) {
+ return false;
+ }
+ } else {
+ if (url.path() != destPath) {
+ return false;
+ }
}
return true;
- }
-
- QByteArray action;
- QString baseProt;
- QString baseHost;
- QString basePath;
- QString destProt;
- QString destHost;
- QString destPath;
- bool baseProtWildCard : 1;
- bool baseHostWildCard : 1;
- bool basePathWildCard : 1;
- bool destProtWildCard : 1;
- bool destHostWildCard : 1;
- bool destPathWildCard : 1;
- bool destProtEqual : 1;
- bool destHostEqual : 1;
- bool permission;
+ }
+
+ QByteArray action;
+ QString baseProt;
+ QString baseHost;
+ QString basePath;
+ QString destProt;
+ QString destHost;
+ QString destPath;
+ bool baseProtWildCard : 1;
+ bool baseHostWildCard : 1;
+ bool basePathWildCard : 1;
+ bool destProtWildCard : 1;
+ bool destHostWildCard : 1;
+ bool destPathWildCard : 1;
+ bool destProtEqual : 1;
+ bool destHostEqual : 1;
+ bool permission;
};
-class KAuthorizedPrivate {
+class KAuthorizedPrivate
+{
public:
- KAuthorizedPrivate()
- : actionRestrictions( false ), blockEverything(false),mutex(QMutex::Recursive)
- {
- Q_ASSERT_X(QCoreApplication::instance(),"KAuthorizedPrivate()","There has to be an existing QCoreApplication::instance() pointer");
+ KAuthorizedPrivate()
+ : actionRestrictions(false), blockEverything(false), mutex(QMutex::Recursive)
+ {
+ Q_ASSERT_X(QCoreApplication::instance(), "KAuthorizedPrivate()", "There has to be an existing QCoreApplication::instance() pointer");
- KSharedConfig::Ptr config = KSharedConfig::openConfig();
+ KSharedConfig::Ptr config = KSharedConfig::openConfig();
- Q_ASSERT_X(config,"KAuthorizedPrivate()","There has to be an existing KSharedConfig::openConfig() pointer");
- if (!config) {
- blockEverything=true;
- return;
+ Q_ASSERT_X(config, "KAuthorizedPrivate()", "There has to be an existing KSharedConfig::openConfig() pointer");
+ if (!config) {
+ blockEverything = true;
+ return;
+ }
+ actionRestrictions = config->hasGroup("KDE Action Restrictions") && !kde_kiosk_exception;
}
- actionRestrictions = config->hasGroup("KDE Action Restrictions" ) && !kde_kiosk_exception;
- }
- ~KAuthorizedPrivate()
- {
- }
+ ~KAuthorizedPrivate()
+ {
+ }
- bool actionRestrictions : 1;
- bool blockEverything : 1;
- QList<URLActionRule> urlActionRestrictions;
- QMutex mutex;
+ bool actionRestrictions : 1;
+ bool blockEverything : 1;
+ QList<URLActionRule> urlActionRestrictions;
+ QMutex mutex;
};
-Q_GLOBAL_STATIC(KAuthorizedPrivate,authPrivate)
+Q_GLOBAL_STATIC(KAuthorizedPrivate, authPrivate)
#define MY_D KAuthorizedPrivate *d=authPrivate();
-
bool KAuthorized::authorize(const QString &genericAction)
{
- MY_D
- if (d->blockEverything) return false;
+ MY_D
+ if (d->blockEverything) {
+ return false;
+ }
- if (!d->actionRestrictions)
- return true;
+ if (!d->actionRestrictions) {
+ return true;
+ }
- KConfigGroup cg(KSharedConfig::openConfig(), "KDE Action Restrictions");
- return cg.readEntry(genericAction, true);
+ KConfigGroup cg(KSharedConfig::openConfig(), "KDE Action Restrictions");
+ return cg.readEntry(genericAction, true);
}
-bool KAuthorized::authorizeKAction(const QString& action)
+bool KAuthorized::authorizeKAction(const QString &action)
{
- MY_D
- if (d->blockEverything) return false;
- if (!d->actionRestrictions || action.isEmpty())
- return true;
+ MY_D
+ if (d->blockEverything) {
+ return false;
+ }
+ if (!d->actionRestrictions || action.isEmpty()) {
+ return true;
+ }
- return authorize(QLatin1String("action/") + action);
+ return authorize(QLatin1String("action/") + action);
}
bool KAuthorized::authorizeControlModule(const QString &menuId)
{
- if (menuId.isEmpty() || kde_kiosk_exception)
- return true;
- KConfigGroup cg(KSharedConfig::openConfig(), "KDE Control Module Restrictions");
- return cg.readEntry(menuId, true);
+ if (menuId.isEmpty() || kde_kiosk_exception) {
+ return true;
+ }
+ KConfigGroup cg(KSharedConfig::openConfig(), "KDE Control Module Restrictions");
+ return cg.readEntry(menuId, true);
}
QStringList KAuthorized::authorizeControlModules(const QStringList &menuIds)
{
- KConfigGroup cg(KSharedConfig::openConfig(), "KDE Control Module Restrictions");
- QStringList result;
- for(QStringList::ConstIterator it = menuIds.begin();
- it != menuIds.end(); ++it)
- {
- if (cg.readEntry(*it, true))
- result.append(*it);
- }
- return result;
+ KConfigGroup cg(KSharedConfig::openConfig(), "KDE Control Module Restrictions");
+ QStringList result;
+ for (QStringList::ConstIterator it = menuIds.begin();
+ it != menuIds.end(); ++it) {
+ if (cg.readEntry(*it, true)) {
+ result.append(*it);
+ }
+ }
+ return result;
}
static void initUrlActionRestrictions()
{
- 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));
+ 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));
+// 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, QLatin1String(":internet"), Any, Any, true));
- d->urlActionRestrictions.append(
- URLActionRule("redirect", Any, Any, Any, QLatin1String(":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, QLatin1String("file"), Any, Any, true));
- d->urlActionRestrictions.append(
- URLActionRule("redirect", QLatin1String(":internet"), Any, Any, QLatin1String("file"), Any, Any, false));
-
- // local protocols may redirect everywhere
- d->urlActionRestrictions.append(
- URLActionRule("redirect", QLatin1String(":local"), Any, Any, Any, Any, Any, true));
-
- // Anyone may redirect to about:
- d->urlActionRestrictions.append(
- URLActionRule("redirect", Any, Any, Any, QLatin1String("about"), Any, Any, true));
-
- // Anyone may redirect to mailto:
- d->urlActionRestrictions.append(
- URLActionRule("redirect", Any, Any, Any, QLatin1String("mailto"), Any, Any, true));
-
- // Anyone may redirect to itself, cq. within it's own group
- d->urlActionRestrictions.append(
- URLActionRule("redirect", Any, Any, Any, QLatin1String("="), Any, Any, true));
-
- d->urlActionRestrictions.append(
- URLActionRule("redirect", QLatin1String("about"), Any, Any, Any, Any, Any, true));
-
-
- KConfigGroup cg(KSharedConfig::openConfig(), "KDE URL Restrictions");
- int count = cg.readEntry("rule_count", 0);
- QString keyFormat = QString::fromLatin1("rule_%1");
- for(int i = 1; i <= count; i++)
- {
- QString key = keyFormat.arg(i);
- const QStringList rule = cg.readEntry(key, QStringList());
- if (rule.count() != 8)
- continue;
- const QByteArray action = rule[0].toLatin1();
- QString refProt = rule[1];
- QString refHost = rule[2];
- QString refPath = rule[3];
- QString urlProt = rule[4];
- QString urlHost = rule[5];
- QString urlPath = rule[6];
- bool bEnabled = (rule[7].toLower() == QLatin1String("true"));
-
- if (refPath.startsWith(QLatin1String("$HOME")))
- refPath.replace(0, 5, QDir::homePath());
- else if (refPath.startsWith(QLatin1Char('~')))
- refPath.replace(0, 1, QDir::homePath());
- if (urlPath.startsWith(QLatin1String("$HOME")))
- urlPath.replace(0, 5, QDir::homePath());
- else if (urlPath.startsWith(QLatin1Char('~')))
- urlPath.replace(0, 1, QDir::homePath());
-
- if (refPath.startsWith(QLatin1String("$TMP")))
- refPath.replace(0, 4, QDir::tempPath());
- if (urlPath.startsWith(QLatin1String("$TMP")))
- urlPath.replace(0, 4, QDir::tempPath());
+// URLActionRule("list", Any, Any, Any, "file", Any, QDir::homePath(), true));
+ d->urlActionRestrictions.append(
+ URLActionRule("link", Any, Any, Any, QLatin1String(":internet"), Any, Any, true));
+ d->urlActionRestrictions.append(
+ URLActionRule("redirect", Any, Any, Any, QLatin1String(":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, QLatin1String("file"), Any, Any, true));
+ d->urlActionRestrictions.append(
+ URLActionRule("redirect", QLatin1String(":internet"), Any, Any, QLatin1String("file"), Any, Any, false));
+
+ // local protocols may redirect everywhere
+ d->urlActionRestrictions.append(
+ URLActionRule("redirect", QLatin1String(":local"), Any, Any, Any, Any, Any, true));
+
+ // Anyone may redirect to about:
+ d->urlActionRestrictions.append(
+ URLActionRule("redirect", Any, Any, Any, QLatin1String("about"), Any, Any, true));
+
+ // Anyone may redirect to mailto:
+ d->urlActionRestrictions.append(
+ URLActionRule("redirect", Any, Any, Any, QLatin1String("mailto"), Any, Any, true));
+
+ // Anyone may redirect to itself, cq. within it's own group
+ d->urlActionRestrictions.append(
+ URLActionRule("redirect", Any, Any, Any, QLatin1String("="), Any, Any, true));
d->urlActionRestrictions.append(
- URLActionRule( action, refProt, refHost, refPath, urlProt, urlHost, urlPath, bEnabled));
- }
+ URLActionRule("redirect", QLatin1String("about"), Any, Any, Any, Any, Any, true));
+
+ KConfigGroup cg(KSharedConfig::openConfig(), "KDE URL Restrictions");
+ int count = cg.readEntry("rule_count", 0);
+ QString keyFormat = QString::fromLatin1("rule_%1");
+ for (int i = 1; i <= count; i++) {
+ QString key = keyFormat.arg(i);
+ const QStringList rule = cg.readEntry(key, QStringList());
+ if (rule.count() != 8) {
+ continue;
+ }
+ const QByteArray action = rule[0].toLatin1();
+ QString refProt = rule[1];
+ QString refHost = rule[2];
+ QString refPath = rule[3];
+ QString urlProt = rule[4];
+ QString urlHost = rule[5];
+ QString urlPath = rule[6];
+ bool bEnabled = (rule[7].toLower() == QLatin1String("true"));
+
+ if (refPath.startsWith(QLatin1String("$HOME"))) {
+ refPath.replace(0, 5, QDir::homePath());
+ } else if (refPath.startsWith(QLatin1Char('~'))) {
+ refPath.replace(0, 1, QDir::homePath());
+ }
+ if (urlPath.startsWith(QLatin1String("$HOME"))) {
+ urlPath.replace(0, 5, QDir::homePath());
+ } else if (urlPath.startsWith(QLatin1Char('~'))) {
+ urlPath.replace(0, 1, QDir::homePath());
+ }
+
+ if (refPath.startsWith(QLatin1String("$TMP"))) {
+ refPath.replace(0, 4, QDir::tempPath());
+ }
+ if (urlPath.startsWith(QLatin1String("$TMP"))) {
+ urlPath.replace(0, 4, QDir::tempPath());
+ }
+
+ d->urlActionRestrictions.append(
+ URLActionRule(action, refProt, refHost, refPath, urlProt, urlHost, urlPath, bEnabled));
+ }
}
namespace KAuthorized
@@ -342,52 +343,55 @@ namespace KAuthorized
// Called by KAuthorized::allowUrlAction in KIO
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));
#if QT_VERSION >= QT_VERSION_CHECK(5, 3, 0)
- const QString basePath = _baseURL.adjusted(QUrl::StripTrailingSlash).path();
- const QString destPath = _destURL.adjusted(QUrl::StripTrailingSlash).path();
+ const QString basePath = _baseURL.adjusted(QUrl::StripTrailingSlash).path();
+ const QString destPath = _destURL.adjusted(QUrl::StripTrailingSlash).path();
#else
- const QString basePath = QUrl(_baseURL.toString(QUrl::StripTrailingSlash)).path();
- const QString destPath = QUrl(_destURL.toString(QUrl::StripTrailingSlash)).path();
+ const QString basePath = QUrl(_baseURL.toString(QUrl::StripTrailingSlash)).path();
+ const QString destPath = QUrl(_destURL.toString(QUrl::StripTrailingSlash)).path();
#endif
- 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));
}
// Called by KAuthorized::authorizeUrlAction in KIO
-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));
- if (d->blockEverything) return false;
-
- if (_destURL.isEmpty())
- return true;
-
- bool result = false;
- if (d->urlActionRestrictions.isEmpty())
- initUrlActionRestrictions();
-
- QUrl baseURL(_baseURL);
- baseURL.setPath(QDir::cleanPath(baseURL.path()));
-
- QUrl destURL(_destURL);
- destURL.setPath(QDir::cleanPath(destURL.path()));
-
- Q_FOREACH(const URLActionRule &rule, 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))
- {
- result = rule.permission;
- }
- }
- return result;
+ MY_D
+ QMutexLocker locker(&(d->mutex));
+ if (d->blockEverything) {
+ return false;
+ }
+
+ if (_destURL.isEmpty()) {
+ return true;
+ }
+
+ bool result = false;
+ if (d->urlActionRestrictions.isEmpty()) {
+ initUrlActionRestrictions();
+ }
+
+ QUrl baseURL(_baseURL);
+ baseURL.setPath(QDir::cleanPath(baseURL.path()));
+
+ QUrl destURL(_destURL);
+ destURL.setPath(QDir::cleanPath(destURL.path()));
+
+ Q_FOREACH (const URLActionRule &rule, 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)) {
+ result = rule.permission;
+ }
+ }
+ return result;
}
} // namespace
diff --git a/src/core/kauthorized.h b/src/core/kauthorized.h
index a16368a8..45dd8284 100644
--- a/src/core/kauthorized.h
+++ b/src/core/kauthorized.h
@@ -34,39 +34,39 @@ class QStringList;
*/
namespace KAuthorized
{
- /**
- * Returns whether a certain action is authorized
- * @param genericAction The name of a generic action
- * @return true if the action is authorized
- * @todo what are the generic actions?
- */
- KCONFIGCORE_EXPORT bool authorize(const QString& genericAction);
+/**
+ * Returns whether a certain action is authorized
+ * @param genericAction The name of a generic action
+ * @return true if the action is authorized
+ * @todo what are the generic actions?
+ */
+KCONFIGCORE_EXPORT bool authorize(const QString &genericAction);
- /**
- * Returns whether a certain KAction is authorized.
- *
- * @param action The name of a KAction action. The name is prepended
- * with "action/" before being passed to authorize()
- * @return true if the KAction is authorized
- */
- KCONFIGCORE_EXPORT bool authorizeKAction(const QString& action);
+/**
+ * Returns whether a certain KAction is authorized.
+ *
+ * @param action The name of a KAction action. The name is prepended
+ * with "action/" before being passed to authorize()
+ * @return true if the KAction is authorized
+ */
+KCONFIGCORE_EXPORT bool authorizeKAction(const QString &action);
- /**
- * Returns whether access to a certain control module is authorized.
- *
- * @param menuId identifying the control module, e.g. kde-mouse.desktop
- * @return true if access to the module is authorized, false otherwise.
- */
- KCONFIGCORE_EXPORT bool authorizeControlModule(const QString& menuId);
+/**
+ * Returns whether access to a certain control module is authorized.
+ *
+ * @param menuId identifying the control module, e.g. kde-mouse.desktop
+ * @return true if access to the module is authorized, false otherwise.
+ */
+KCONFIGCORE_EXPORT bool authorizeControlModule(const QString &menuId);
- /**
- * Returns which control modules from a given list are authorized for access.
- *
- * @param menuIds list of menu-ids of control modules;
- * an example of a menu-id is kde-mouse.desktop.
- * @return Those control modules for which access has been authorized.
- */
- KCONFIGCORE_EXPORT QStringList authorizeControlModules(const QStringList& menuIds);
+/**
+ * Returns which control modules from a given list are authorized for access.
+ *
+ * @param menuIds list of menu-ids of control modules;
+ * an example of a menu-id is kde-mouse.desktop.
+ * @return Those control modules for which access has been authorized.
+ */
+KCONFIGCORE_EXPORT QStringList authorizeControlModules(const QStringList &menuIds);
}
diff --git a/src/core/kconfig.cpp b/src/core/kconfig.cpp
index b311a366..4f5553d5 100644
--- a/src/core/kconfig.cpp
+++ b/src/core/kconfig.cpp
@@ -30,8 +30,14 @@
#include <fcntl.h>
#ifdef Q_OS_WIN
-static inline FILE* popen(const char *cmd, const char *mode) { return _popen(cmd, mode); }
-static inline int pclose(FILE* stream) { return _pclose(stream); }
+static inline FILE *popen(const char *cmd, const char *mode)
+{
+ return _popen(cmd, mode);
+}
+static inline int pclose(FILE *stream)
+{
+ return _pclose(stream);
+}
#else
#include <unistd.h>
#endif
@@ -49,7 +55,7 @@ static inline int pclose(FILE* stream) { return _pclose(stream); }
#include <QtCore/QProcess>
#include <QtCore/QSet>
-bool KConfigPrivate::mappingsRegistered=false;
+bool KConfigPrivate::mappingsRegistered = false;
KConfigPrivate::KConfigPrivate(KConfig::OpenFlags flags,
QStandardPaths::StandardLocation resourceType)
@@ -61,13 +67,14 @@ KConfigPrivate::KConfigPrivate(KConfig::OpenFlags flags,
sGlobalFileName = QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation) + QLatin1String("/kdeglobals");
static int use_etc_kderc = -1;
- if (use_etc_kderc < 0)
- use_etc_kderc = !qEnvironmentVariableIsSet("KDE_SKIP_KDERC"); // for unit tests
+ if (use_etc_kderc < 0) {
+ use_etc_kderc = !qEnvironmentVariableIsSet("KDE_SKIP_KDERC"); // for unit tests
+ }
if (use_etc_kderc) {
etc_kderc =
#ifdef Q_OS_WIN
- QFile::decodeName( qgetenv("WINDIR") + "/kde4rc" );
+ QFile::decodeName(qgetenv("WINDIR") + "/kde4rc");
#else
QLatin1String("/etc/kde4rc");
#endif
@@ -98,7 +105,6 @@ KConfigPrivate::KConfigPrivate(KConfig::OpenFlags flags,
#endif
}
-
bool KConfigPrivate::lockLocal()
{
if (mBackend) {
@@ -108,10 +114,10 @@ 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;
+ KEntryMap &otherMap = otherGroup->config()->d_ptr->entryMap;
const int len = source.length();
const bool sameName = (destination == source);
@@ -120,15 +126,17 @@ void KConfigPrivate::copyGroup(const QByteArray& source, const QByteArray& desti
// as dirty erroneously
bool dirtied = false;
- for (KEntryMap::ConstIterator entryMapIt( entryMap.constBegin() ); entryMapIt != entryMap.constEnd(); ++entryMapIt) {
- const QByteArray& group = entryMapIt.key().mGroup;
+ for (KEntryMap::ConstIterator entryMapIt(entryMap.constBegin()); entryMapIt != entryMap.constEnd(); ++entryMapIt) {
+ const QByteArray &group = entryMapIt.key().mGroup;
- if (!group.startsWith(source)) // nothing to do
+ if (!group.startsWith(source)) { // nothing to do
continue;
+ }
// don't copy groups that start with the same prefix, but are not sub-groups
- if (group.length() > len && group[len] != '\x1d')
+ if (group.length() > len && group[len] != '\x1d') {
continue;
+ }
KEntryKey newKey = entryMapIt.key();
@@ -136,8 +144,9 @@ void KConfigPrivate::copyGroup(const QByteArray& source, const QByteArray& desti
newKey.bLocal = true;
}
- if (!sameName)
+ if (!sameName) {
newKey.mGroup.replace(0, len, destination);
+ }
KEntry entry = entryMap[ entryMapIt.key() ];
dirtied = entry.bDirty = flags & KConfigBase::Persistent;
@@ -154,33 +163,35 @@ void KConfigPrivate::copyGroup(const QByteArray& source, const QByteArray& desti
}
}
-QString KConfigPrivate::expandString(const QString& value)
+QString KConfigPrivate::expandString(const QString &value)
{
QString aValue = value;
// check for environment variables and make necessary translations
- int nDollarPos = aValue.indexOf( QLatin1Char('$') );
- while( nDollarPos != -1 && nDollarPos+1 < aValue.length()) {
+ int nDollarPos = aValue.indexOf(QLatin1Char('$'));
+ while (nDollarPos != -1 && nDollarPos + 1 < aValue.length()) {
// there is at least one $
- if( aValue[nDollarPos+1] == QLatin1Char('(') ) {
- int nEndPos = nDollarPos+1;
+ if (aValue[nDollarPos + 1] == QLatin1Char('(')) {
+ int nEndPos = nDollarPos + 1;
// the next character is not $
- while ( (nEndPos <= aValue.length()) && (aValue[nEndPos]!=QLatin1Char(')')) )
+ while ((nEndPos <= aValue.length()) && (aValue[nEndPos] != QLatin1Char(')'))) {
nEndPos++;
+ }
nEndPos++;
- QString cmd = aValue.mid( nDollarPos+2, nEndPos-nDollarPos-3 );
+ QString cmd = aValue.mid(nDollarPos + 2, nEndPos - nDollarPos - 3);
QString result;
#if 0 // Removed in KDE Frameworks 5. No such concept anymore. Just set your PATH.
- QByteArray oldpath = qgetenv( "PATH" );
+ QByteArray oldpath = qgetenv("PATH");
QByteArray newpath;
if (KComponentData::hasMainComponent()) {
newpath = QFile::encodeName(KGlobal::dirs()->resourceDirs("exe").join(QChar::fromLatin1(KPATH_SEPARATOR)));
- if (!newpath.isEmpty() && !oldpath.isEmpty())
+ if (!newpath.isEmpty() && !oldpath.isEmpty()) {
newpath += KPATH_SEPARATOR;
+ }
}
newpath += oldpath;
- qputenv( "PATH", newpath);
+ qputenv("PATH", newpath);
#endif
// FIXME: wince does not have pipes
@@ -193,58 +204,61 @@ QString KConfigPrivate::expandString(const QString& value)
}
#endif
#if 0 // Removed in KDE Frameworks 5, see above.
- qputenv( "PATH", oldpath);
+ qputenv("PATH", oldpath);
#endif
- aValue.replace( nDollarPos, nEndPos-nDollarPos, result );
+ aValue.replace(nDollarPos, nEndPos - nDollarPos, result);
nDollarPos += result.length();
- } else if( aValue[nDollarPos+1] != QLatin1Char('$') ) {
- int nEndPos = nDollarPos+1;
+ } else if (aValue[nDollarPos + 1] != QLatin1Char('$')) {
+ int nEndPos = nDollarPos + 1;
// the next character is not $
QString aVarName;
- if ( aValue[nEndPos] == QLatin1Char('{') ) {
- while ( (nEndPos <= aValue.length()) && (aValue[nEndPos] != QLatin1Char('}')) )
+ if (aValue[nEndPos] == QLatin1Char('{')) {
+ while ((nEndPos <= aValue.length()) && (aValue[nEndPos] != QLatin1Char('}'))) {
nEndPos++;
+ }
nEndPos++;
- aVarName = aValue.mid( nDollarPos+2, nEndPos-nDollarPos-3 );
+ aVarName = aValue.mid(nDollarPos + 2, nEndPos - nDollarPos - 3);
} else {
- while ( nEndPos <= aValue.length() &&
+ while (nEndPos <= aValue.length() &&
(aValue[nEndPos].isNumber() ||
- aValue[nEndPos].isLetter() ||
- aValue[nEndPos] == QLatin1Char('_') ) )
+ aValue[nEndPos].isLetter() ||
+ aValue[nEndPos] == QLatin1Char('_'))) {
nEndPos++;
- aVarName = aValue.mid( nDollarPos+1, nEndPos-nDollarPos-1 );
+ }
+ aVarName = aValue.mid(nDollarPos + 1, nEndPos - nDollarPos - 1);
}
QString env;
if (!aVarName.isEmpty()) {
#ifdef Q_OS_WIN
- if (aVarName == QLatin1String("HOME"))
+ if (aVarName == QLatin1String("HOME")) {
env = QDir::homePath();
- else
+ } else
#endif
{
QByteArray pEnv = qgetenv(aVarName.toLatin1().constData());
- if( !pEnv.isEmpty() )
+ if (!pEnv.isEmpty()) {
env = QString::fromLocal8Bit(pEnv.constData());
+ }
}
- aValue.replace(nDollarPos, nEndPos-nDollarPos, env);
+ aValue.replace(nDollarPos, nEndPos - nDollarPos, env);
nDollarPos += env.length();
- } else
- aValue.remove( nDollarPos, nEndPos-nDollarPos );
+ } else {
+ aValue.remove(nDollarPos, nEndPos - nDollarPos);
+ }
} else {
// remove one of the dollar signs
- aValue.remove( nDollarPos, 1 );
+ aValue.remove(nDollarPos, 1);
nDollarPos++;
}
- nDollarPos = aValue.indexOf( QLatin1Char('$'), nDollarPos );
+ nDollarPos = aValue.indexOf(QLatin1Char('$'), nDollarPos);
}
return aValue;
}
-
-KConfig::KConfig(const QString& file, OpenFlags mode,
+KConfig::KConfig(const QString &file, OpenFlags mode,
QStandardPaths::StandardLocation resourceType)
- : d_ptr(new KConfigPrivate(mode, resourceType))
+ : d_ptr(new KConfigPrivate(mode, resourceType))
{
d_ptr->changeFileName(file); // set the local file name
@@ -252,7 +266,7 @@ KConfig::KConfig(const QString& file, OpenFlags mode,
reparseConfiguration();
}
-KConfig::KConfig(const QString& file, const QString& backend, QStandardPaths::StandardLocation resourceType)
+KConfig::KConfig(const QString &file, const QString &backend, QStandardPaths::StandardLocation resourceType)
: d_ptr(new KConfigPrivate(SimpleConfig, resourceType))
{
d_ptr->mBackend = KConfigBackend::create(file, backend);
@@ -271,8 +285,9 @@ KConfig::KConfig(KConfigPrivate &d)
KConfig::~KConfig()
{
Q_D(KConfig);
- if (d->bDirty && (d->mBackend && d->mBackend->ref.load() == 1))
+ if (d->bDirty && (d->mBackend && d->mBackend->ref.load() == 1)) {
sync();
+ }
delete d;
}
@@ -281,8 +296,8 @@ QStringList KConfig::groupList() const
Q_D(const KConfig);
QSet<QString> groups;
- for (KEntryMap::ConstIterator entryMapIt( d->entryMap.constBegin() ); entryMapIt != d->entryMap.constEnd(); ++entryMapIt) {
- const KEntryKey& key = entryMapIt.key();
+ for (KEntryMap::ConstIterator entryMapIt(d->entryMap.constBegin()); entryMapIt != d->entryMap.constEnd(); ++entryMapIt) {
+ const KEntryKey &key = entryMapIt.key();
const QByteArray group = key.mGroup;
if (key.mKey.isNull() && !group.isEmpty() && group != "<default>" && group != "$Version") {
const QString groupname = QString::fromUtf8(group);
@@ -293,13 +308,13 @@ QStringList KConfig::groupList() const
return groups.toList();
}
-QStringList KConfigPrivate::groupList(const QByteArray& group) const
+QStringList KConfigPrivate::groupList(const QByteArray &group) const
{
QByteArray theGroup = group + '\x1d';
QSet<QString> groups;
- for (KEntryMap::ConstIterator entryMapIt( entryMap.constBegin() ); entryMapIt != entryMap.constEnd(); ++entryMapIt) {
- const KEntryKey& key = entryMapIt.key();
+ for (KEntryMap::ConstIterator entryMapIt(entryMap.constBegin()); entryMapIt != entryMap.constEnd(); ++entryMapIt) {
+ const KEntryKey &key = entryMapIt.key();
if (key.mKey.isNull() && key.mGroup.startsWith(theGroup)) {
const QString groupname = QString::fromUtf8(key.mGroup.mid(theGroup.length()));
groups << groupname.left(groupname.indexOf(QLatin1Char('\x1d')));
@@ -310,14 +325,14 @@ QStringList KConfigPrivate::groupList(const QByteArray& group) const
}
// List all sub groups, including subsubgroups
-QSet<QByteArray> KConfigPrivate::allSubGroups(const QByteArray& parentGroup) const
+QSet<QByteArray> KConfigPrivate::allSubGroups(const QByteArray &parentGroup) const
{
QSet<QByteArray> groups;
QByteArray theGroup = parentGroup + '\x1d';
groups << parentGroup;
for (KEntryMap::const_iterator entryMapIt = entryMap.begin(); entryMapIt != entryMap.end(); ++entryMapIt) {
- const KEntryKey& key = entryMapIt.key();
+ const KEntryKey &key = entryMapIt.key();
if (key.mKey.isNull() && key.mGroup.startsWith(theGroup)) {
groups << key.mGroup;
}
@@ -325,21 +340,21 @@ QSet<QByteArray> KConfigPrivate::allSubGroups(const QByteArray& parentGroup) con
return groups;
}
-bool KConfigPrivate::hasNonDeletedEntries(const QByteArray& group) const
+bool KConfigPrivate::hasNonDeletedEntries(const QByteArray &group) const
{
const QSet<QByteArray> allGroups = allSubGroups(group);
- Q_FOREACH(const QByteArray& aGroup, allGroups) {
+ Q_FOREACH (const QByteArray &aGroup, allGroups) {
// Could be optimized, let's use the slow way for now
// Check for any non-deleted entry
- if (!keyListImpl(aGroup).isEmpty())
+ if (!keyListImpl(aGroup).isEmpty()) {
return true;
+ }
}
return false;
}
-
-QStringList KConfigPrivate::keyListImpl(const QByteArray& theGroup) const
+QStringList KConfigPrivate::keyListImpl(const QByteArray &theGroup) const
{
QStringList keys;
@@ -350,9 +365,10 @@ QStringList KConfigPrivate::keyListImpl(const QByteArray& theGroup) const
QSet<QString> tmp;
for (; it != theEnd && it.key().mGroup == theGroup; ++it) {
- const KEntryKey& key = it.key();
- if (key.mGroup == theGroup && !key.mKey.isNull() && !it->bDeleted)
+ const KEntryKey &key = it.key();
+ if (key.mGroup == theGroup && !key.mKey.isNull() && !it->bDeleted) {
tmp << QString::fromUtf8(key.mKey);
+ }
}
keys = tmp.toList();
}
@@ -360,14 +376,14 @@ QStringList KConfigPrivate::keyListImpl(const QByteArray& theGroup) const
return keys;
}
-QStringList KConfig::keyList(const QString& aGroup) const
+QStringList KConfig::keyList(const QString &aGroup) const
{
Q_D(const KConfig);
const QByteArray theGroup(aGroup.isEmpty() ? "<default>" : aGroup.toUtf8());
return d->keyListImpl(theGroup);
}
-QMap<QString,QString> KConfig::entryMap(const QString& aGroup) const
+QMap<QString, QString> KConfig::entryMap(const QString &aGroup) const
{
Q_D(const KConfig);
QMap<QString, QString> theMap;
@@ -386,9 +402,9 @@ QMap<QString,QString> KConfig::entryMap(const QString& aGroup) const
// with the non-localized entry
if (!theMap.contains(key)) {
if (it->bExpand) {
- theMap.insert(key,KConfigPrivate::expandString(QString::fromUtf8(it->mValue.constData())));
+ theMap.insert(key, KConfigPrivate::expandString(QString::fromUtf8(it->mValue.constData())));
} else {
- theMap.insert(key,QString::fromUtf8(it->mValue.constData()));
+ theMap.insert(key, QString::fromUtf8(it->mValue.constData()));
}
}
}
@@ -422,7 +438,7 @@ bool KConfig::sync()
// Rewrite global/local config only if there is a dirty entry in it.
bool writeGlobals = false;
bool writeLocals = false;
- Q_FOREACH (const KEntry& e, d->entryMap) {
+ Q_FOREACH (const KEntry &e, d->entryMap) {
if (e.bDirty) {
if (e.bGlobal) {
writeGlobals = true;
@@ -472,8 +488,9 @@ void KConfig::markAsClean()
// clear any dirty flags that entries might have set
const KEntryMapIterator theEnd = d->entryMap.end();
- for (KEntryMapIterator it = d->entryMap.begin(); it != theEnd; ++it)
+ for (KEntryMapIterator it = d->entryMap.begin(); it != theEnd; ++it) {
it->bDirty = false;
+ }
}
bool KConfig::isDirty() const
@@ -485,7 +502,7 @@ bool KConfig::isDirty() const
void KConfig::checkUpdate(const QString &id, const QString &updateFile)
{
const KConfigGroup cg(this, "$Version");
- const QString cfg_id = updateFile+QLatin1Char(':')+id;
+ const QString cfg_id = updateFile + QLatin1Char(':') + id;
const QStringList ids = cg.readEntry("update_info", QStringList());
if (!ids.contains(cfg_id)) {
#if 0
@@ -497,18 +514,20 @@ void KConfig::checkUpdate(const QString &id, const QString &updateFile)
}
}
-KConfig* KConfig::copyTo(const QString &file, KConfig *config) const
+KConfig *KConfig::copyTo(const QString &file, KConfig *config) const
{
Q_D(const KConfig);
- if (!config)
+ if (!config) {
config = new KConfig(QString(), SimpleConfig, d->resourceType);
+ }
config->d_func()->changeFileName(file);
config->d_func()->entryMap = d->entryMap;
config->d_func()->bFileImmutable = false;
const KEntryMapIterator theEnd = config->d_func()->entryMap.end();
- for (KEntryMapIterator it = config->d_func()->entryMap.begin(); it != theEnd; ++it)
+ for (KEntryMapIterator it = config->d_func()->entryMap.begin(); it != theEnd; ++it) {
it->bDirty = true;
+ }
config->d_ptr->bDirty = true;
return config;
@@ -522,7 +541,7 @@ QString KConfig::name() const
Q_GLOBAL_STATIC(QString, globalMainConfigName)
-void KConfig::setMainConfigName(const QString& str)
+void KConfig::setMainConfigName(const QString &str)
{
*globalMainConfigName() = str;
}
@@ -531,20 +550,21 @@ QString KConfig::mainConfigName()
{
// --config on the command line overrides everything else
const QStringList args = QCoreApplication::arguments();
- for (int i = 1; i < args.count() ; ++i) {
- if (args.at(i) == QLatin1String("--config") && i < args.count()-1) {
- return args.at(i+1);
+ for (int i = 1; i < args.count(); ++i) {
+ if (args.at(i) == QLatin1String("--config") && i < args.count() - 1) {
+ return args.at(i + 1);
}
}
const QString globalName = *globalMainConfigName();
- if (!globalName.isEmpty())
+ if (!globalName.isEmpty()) {
return globalName;
+ }
QString appName = QCoreApplication::applicationName();
return appName + QLatin1String("rc");
}
-void KConfigPrivate::changeFileName(const QString& name)
+void KConfigPrivate::changeFileName(const QString &name)
{
fileName = name;
@@ -564,8 +584,9 @@ void KConfigPrivate::changeFileName(const QString& name)
}
} else if (QDir::isAbsolutePath(fileName)) {
fileName = QFileInfo(fileName).canonicalFilePath();
- if (fileName.isEmpty()) // file doesn't exist (yet)
+ if (fileName.isEmpty()) { // file doesn't exist (yet)
fileName = name;
+ }
file = fileName;
} else {
file = QStandardPaths::writableLocation(resourceType) + QLatin1Char('/') + fileName;
@@ -579,10 +600,11 @@ void KConfigPrivate::changeFileName(const QString& name)
bSuppressGlobal = (file.compare(sGlobalFileName, Qt::CaseInsensitive) == 0);
#endif
- if (bDynamicBackend || !mBackend) // allow dynamic changing of backend
+ if (bDynamicBackend || !mBackend) { // allow dynamic changing of backend
mBackend = KConfigBackend::create(file);
- else
+ } else {
mBackend->setFilePath(file);
+ }
configState = mBackend->accessMode();
}
@@ -595,30 +617,34 @@ void KConfig::reparseConfiguration()
}
// Don't lose pending changes
- if (!d->isReadOnly() && d->bDirty)
+ if (!d->isReadOnly() && d->bDirty) {
sync();
+ }
d->entryMap.clear();
d->bFileImmutable = false;
// Parse all desired files from the least to the most specific.
- if (d->wantGlobals())
+ if (d->wantGlobals()) {
d->parseGlobalFiles();
+ }
d->parseConfigFiles();
}
-
QStringList KConfigPrivate::getGlobalFiles() const
{
QStringList globalFiles;
- Q_FOREACH (const QString& dir1, QStandardPaths::locateAll(QStandardPaths::GenericConfigLocation, QLatin1String("kdeglobals")))
+ Q_FOREACH (const QString &dir1, QStandardPaths::locateAll(QStandardPaths::GenericConfigLocation, QLatin1String("kdeglobals"))) {
globalFiles.push_front(dir1);
- Q_FOREACH (const QString& dir2, QStandardPaths::locateAll(QStandardPaths::GenericConfigLocation, QLatin1String("system.kdeglobals")))
+ }
+ Q_FOREACH (const QString &dir2, QStandardPaths::locateAll(QStandardPaths::GenericConfigLocation, QLatin1String("system.kdeglobals"))) {
globalFiles.push_front(dir2);
- if (!etc_kderc.isEmpty())
+ }
+ if (!etc_kderc.isEmpty()) {
globalFiles.push_front(etc_kderc);
+ }
return globalFiles;
}
@@ -630,8 +656,8 @@ void KConfigPrivate::parseGlobalFiles()
// TODO: can we cache the values in etc_kderc / other global files
// on a per-application basis?
const QByteArray utf8Locale = locale.toUtf8();
- Q_FOREACH(const QString& file, globalFiles) {
- KConfigBackend::ParseOptions parseOpts = KConfigBackend::ParseGlobal|KConfigBackend::ParseExpansions;
+ Q_FOREACH (const QString &file, globalFiles) {
+ KConfigBackend::ParseOptions parseOpts = KConfigBackend::ParseGlobal | KConfigBackend::ParseExpansions;
#ifndef Q_OS_WIN
if (file != sGlobalFileName)
#else
@@ -640,8 +666,9 @@ void KConfigPrivate::parseGlobalFiles()
parseOpts |= KConfigBackend::ParseDefaults;
QExplicitlySharedDataPointer<KConfigBackend> backend = KConfigBackend::create(file);
- if ( backend->parseConfig( utf8Locale, entryMap, parseOpts) == KConfigBackend::ParseImmutable)
+ if (backend->parseConfig(utf8Locale, entryMap, parseOpts) == KConfigBackend::ParseImmutable) {
break;
+ }
}
}
@@ -660,20 +687,22 @@ void KConfigPrivate::parseConfigFiles()
if (QDir::isAbsolutePath(fileName)) {
files << fileName;
} else {
- Q_FOREACH (const QString& f, QStandardPaths::locateAll(resourceType, fileName))
+ Q_FOREACH (const QString &f, QStandardPaths::locateAll(resourceType, fileName)) {
files.prepend(f);
+ }
}
}
} else {
files << mBackend->filePath();
}
- if (!isSimple())
+ if (!isSimple()) {
files = extraFiles.toList() + files;
+ }
// qDebug() << "parsing local files" << files;
const QByteArray utf8Locale = locale.toUtf8();
- foreach(const QString& file, files) {
+ foreach (const QString &file, files) {
#ifndef Q_OS_WIN
if (file == mBackend->filePath()) {
#else
@@ -692,17 +721,19 @@ void KConfigPrivate::parseConfigFiles()
} else {
QExplicitlySharedDataPointer<KConfigBackend> backend = KConfigBackend::create(file);
bFileImmutable = (backend->parseConfig(utf8Locale, entryMap,
- KConfigBackend::ParseDefaults|KConfigBackend::ParseExpansions)
+ KConfigBackend::ParseDefaults | KConfigBackend::ParseExpansions)
== KConfigBackend::ParseImmutable);
}
- if (bFileImmutable)
+ if (bFileImmutable) {
break;
+ }
}
#pragma message("TODO: enable kiosk feature again (resource restrictions), but without KStandardDirs... Needs a class in the kconfig framework.")
#if 0
- if (componentData.dirs()->isRestrictedResource(resourceType, fileName))
+ if (componentData.dirs()->isRestrictedResource(resourceType, fileName)) {
bFileImmutable = true;
+ }
#endif
}
}
@@ -713,10 +744,10 @@ KConfig::AccessMode KConfig::accessMode() const
return d->configState;
}
-void KConfig::addConfigSources(const QStringList& files)
+void KConfig::addConfigSources(const QStringList &files)
{
Q_D(KConfig);
- Q_FOREACH(const QString& file, files) {
+ Q_FOREACH (const QString &file, files) {
d->extraFiles.push(file);
}
@@ -731,7 +762,7 @@ QString KConfig::locale() const
return d->locale;
}
-bool KConfigPrivate::setLocale(const QString& aLocale)
+bool KConfigPrivate::setLocale(const QString &aLocale)
{
if (aLocale != locale) {
locale = aLocale;
@@ -740,7 +771,7 @@ bool KConfigPrivate::setLocale(const QString& aLocale)
return false;
}
-bool KConfig::setLocale(const QString& locale)
+bool KConfig::setLocale(const QString &locale)
{
Q_D(KConfig);
if (d->setLocale(locale)) {
@@ -768,7 +799,7 @@ bool KConfig::isImmutable() const
return d->bFileImmutable;
}
-bool KConfig::isGroupImmutableImpl(const QByteArray& aGroup) const
+bool KConfig::isGroupImmutableImpl(const QByteArray &aGroup) const
{
Q_D(const KConfig);
return isImmutable() || d->entryMap.getEntryOption(aGroup, 0, 0, KEntryMap::EntryImmutable);
@@ -802,26 +833,29 @@ const KConfigGroup KConfig::groupImpl(const QByteArray &group) const
KEntryMap::EntryOptions convertToOptions(KConfig::WriteConfigFlags flags)
{
- KEntryMap::EntryOptions options=0;
+ KEntryMap::EntryOptions options = 0;
- if (flags&KConfig::Persistent)
+ if (flags & KConfig::Persistent) {
options |= KEntryMap::EntryDirty;
- if (flags&KConfig::Global)
+ }
+ if (flags & KConfig::Global) {
options |= KEntryMap::EntryGlobal;
- if (flags&KConfig::Localized)
+ }
+ if (flags & KConfig::Localized) {
options |= KEntryMap::EntryLocalized;
+ }
return options;
}
void KConfig::deleteGroupImpl(const QByteArray &aGroup, WriteConfigFlags flags)
{
Q_D(KConfig);
- KEntryMap::EntryOptions options = convertToOptions(flags)|KEntryMap::EntryDeleted;
+ KEntryMap::EntryOptions options = convertToOptions(flags) | KEntryMap::EntryDeleted;
const QSet<QByteArray> groups = d->allSubGroups(aGroup);
- Q_FOREACH (const QByteArray& group, groups) {
+ Q_FOREACH (const QByteArray &group, groups) {
const QStringList keys = d->keyListImpl(group);
- Q_FOREACH (const QString& _key, keys) {
+ Q_FOREACH (const QString &_key, keys) {
const QByteArray &key = _key.toUtf8();
if (d->canWriteEntry(group, key.constData())) {
d->entryMap.setEntry(group, key, QByteArray(), options);
@@ -838,14 +872,14 @@ bool KConfig::isConfigWritable(bool warnUser)
if (warnUser && !allWritable) {
QString errorMsg;
- if (d->mBackend) // TODO how can be it be null? Set errorMsg appropriately
+ if (d->mBackend) { // TODO how can be it be null? Set errorMsg appropriately
errorMsg = d->mBackend->nonWritableErrorMessage();
+ }
// Note: We don't ask the user if we should not ask this question again because we can't save the answer.
errorMsg += QCoreApplication::translate("KConfig", "Please contact your system administrator.");
QString cmdToExec = QStandardPaths::findExecutable(QString::fromLatin1("kdialog"));
- if (!cmdToExec.isEmpty())
- {
+ if (!cmdToExec.isEmpty()) {
QProcess::execute(cmdToExec, QStringList()
<< QString::fromLatin1("--title") << QCoreApplication::applicationName()
<< QString::fromLatin1("--msgbox") << errorMsg);
@@ -857,7 +891,7 @@ bool KConfig::isConfigWritable(bool warnUser)
return allWritable;
}
-bool KConfig::hasGroupImpl(const QByteArray& aGroup) const
+bool KConfig::hasGroupImpl(const QByteArray &aGroup) const
{
Q_D(const KConfig);
@@ -867,55 +901,64 @@ bool KConfig::hasGroupImpl(const QByteArray& aGroup) const
return d->hasNonDeletedEntries(aGroup);
}
-bool KConfigPrivate::canWriteEntry(const QByteArray& group, const char* key, bool isDefault) const
+bool KConfigPrivate::canWriteEntry(const QByteArray &group, const char *key, bool isDefault) const
{
if (bFileImmutable ||
- entryMap.getEntryOption(group, key, KEntryMap::SearchLocalized, KEntryMap::EntryImmutable))
+ 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);
- if (bForceGlobal)
+ if (bForceGlobal) {
options |= KEntryMap::EntryGlobal;
- if (expand)
+ }
+ if (expand) {
options |= KEntryMap::EntryExpansion;
+ }
- if (value.isNull()) // deleting entry
+ if (value.isNull()) { // deleting entry
options |= KEntryMap::EntryDeleted;
+ }
bool dirtied = entryMap.setEntry(group, key, value, options);
- if (dirtied && (flags & KConfigBase::Persistent))
+ if (dirtied && (flags & KConfigBase::Persistent)) {
bDirty = true;
+ }
}
-void KConfigPrivate::revertEntry(const QByteArray& group, const char* key)
+void KConfigPrivate::revertEntry(const QByteArray &group, const char *key)
{
bool dirtied = entryMap.revertEntry(group, key);
- if (dirtied)
+ if (dirtied) {
bDirty = true;
+ }
}
-QByteArray KConfigPrivate::lookupData(const QByteArray& group, const char* key,
+QByteArray KConfigPrivate::lookupData(const QByteArray &group, const char *key,
KEntryMap::SearchFlags flags) const
{
- if (bReadDefaults)
+ if (bReadDefaults) {
flags |= KEntryMap::SearchDefaults;
+ }
const KEntryMapConstIterator it = entryMap.findEntry(group, key, flags);
- if (it == entryMap.constEnd())
+ if (it == entryMap.constEnd()) {
return QByteArray();
+ }
return it->mValue;
}
-QString KConfigPrivate::lookupData(const QByteArray& group, const char* key,
+QString KConfigPrivate::lookupData(const QByteArray &group, const char *key,
KEntryMap::SearchFlags flags, bool *expand) const
{
- if (bReadDefaults)
+ if (bReadDefaults) {
flags |= KEntryMap::SearchDefaults;
+ }
return entryMap.getEntry(group, key, QString(), flags, expand);
}
@@ -925,7 +968,7 @@ QStandardPaths::StandardLocation KConfig::locationType() const
return d->resourceType;
}
-void KConfig::virtual_hook(int /*id*/, void* /*data*/)
+void KConfig::virtual_hook(int /*id*/, void * /*data*/)
{
- /* nothing */
+ /* nothing */
}
diff --git a/src/core/kconfig.h b/src/core/kconfig.h
index 6dbf1d26..d27eebe7 100644
--- a/src/core/kconfig.h
+++ b/src/core/kconfig.h
@@ -95,7 +95,7 @@ public:
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
+ FullConfig = IncludeGlobals | CascadeConfig ///< Fully-fledged config, including globals and cascading to system settings
};
Q_DECLARE_FLAGS(OpenFlags, OpenFlag)
@@ -127,7 +127,7 @@ public:
*
* @sa KSharedConfig::openConfig(const QString&, OpenFlags, const char*)
*/
- explicit KConfig(const QString& file = QString(), OpenFlags mode = FullConfig,
+ explicit KConfig(const QString &file = QString(), OpenFlags mode = FullConfig,
QStandardPaths::StandardLocation type = QStandardPaths::GenericConfigLocation);
/**
@@ -142,7 +142,7 @@ public:
*
* @since 4.1
*/
- KConfig(const QString& file, const QString& backend, QStandardPaths::StandardLocation type = QStandardPaths::GenericConfigLocation);
+ KConfig(const QString &file, const QString &backend, QStandardPaths::StandardLocation type = QStandardPaths::GenericConfigLocation);
virtual ~KConfig();
@@ -210,7 +210,7 @@ public:
*
* @return @p config if it was set, otherwise a new KConfig object
*/
- KConfig* copyTo(const QString &file, KConfig *config = 0) const;
+ KConfig *copyTo(const QString &file, KConfig *config = 0) const;
/**
* Ensures that the configuration file contains a certain update.
@@ -283,7 +283,7 @@ public:
* effect (eg: @p aLocale was already the current locale for this
* object)
*/
- bool setLocale(const QString& aLocale);
+ bool setLocale(const QString &aLocale);
/// @}
/// @{ defaults
@@ -350,20 +350,20 @@ public:
* The returned map may be empty if the group is empty, or not found.
* @see QMap
*/
- QMap<QString, QString> entryMap(const QString &aGroup=QString()) const;
+ QMap<QString, QString> entryMap(const QString &aGroup = QString()) const;
/**
* Sets the name of the application config file.
* @since 5.0
*/
- static void setMainConfigName(const QString& str);
+ static void setMainConfigName(const QString &str);
protected:
virtual bool hasGroupImpl(const QByteArray &group) const;
- virtual KConfigGroup groupImpl( const QByteArray &b);
+ virtual KConfigGroup groupImpl(const QByteArray &b);
virtual const KConfigGroup groupImpl(const QByteArray &b) const;
virtual void deleteGroupImpl(const QByteArray &group, WriteConfigFlags flags = Normal);
- virtual bool isGroupImmutableImpl(const QByteArray& aGroup) const;
+ virtual bool isGroupImmutableImpl(const QByteArray &aGroup) const;
friend class KConfigGroup;
friend class KConfigGroupPrivate;
@@ -372,7 +372,7 @@ 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);
KConfigPrivate *const d_ptr;
@@ -381,7 +381,7 @@ protected:
private:
friend class KConfigTest;
- QStringList keyList(const QString& aGroup=QString()) const;
+ QStringList keyList(const QString &aGroup = QString()) const;
/**
* @internal for KSharedConfig. Could be made public if needed, though.
@@ -392,6 +392,6 @@ private:
Q_DECLARE_PRIVATE(KConfig)
};
-Q_DECLARE_OPERATORS_FOR_FLAGS( KConfig::OpenFlags )
+Q_DECLARE_OPERATORS_FOR_FLAGS(KConfig::OpenFlags)
#endif // KCONFIG_H
diff --git a/src/core/kconfig_p.h b/src/core/kconfig_p.h
index e6fb1ca0..b93c8167 100644
--- a/src/core/kconfig_p.h
+++ b/src/core/kconfig_p.h
@@ -40,27 +40,27 @@ public:
KConfig::OpenFlags openFlags;
QStandardPaths::StandardLocation resourceType;
- void changeFileName(const QString& fileName);
+ void changeFileName(const QString &fileName);
// 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;
- 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);
- QStringList groupList(const QByteArray& group) const;
+ 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;
+ 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);
+ 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,
+ 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;
+ QStringList keyListImpl(const QByteArray &theGroup) const;
+ QSet<QByteArray> allSubGroups(const QByteArray &parentGroup) const;
+ bool hasNonDeletedEntries(const QByteArray &group) const;
- static QString expandString(const QString& value);
+ static QString expandString(const QString &value);
protected:
QExplicitlySharedDataPointer<KConfigBackend> mBackend;
@@ -72,18 +72,17 @@ protected:
{
}
- bool bDynamicBackend:1; // do we own the backend?
+ bool bDynamicBackend: 1; // do we own the backend?
private:
- bool bDirty:1;
- bool bLocaleInitialized:1;
- bool bReadDefaults:1;
- bool bFileImmutable:1;
- bool bForceGlobal:1;
- bool bSuppressGlobal:1;
-
- QString sGlobalFileName;
- static bool mappingsRegistered;
+ bool bDirty: 1;
+ bool bLocaleInitialized: 1;
+ bool bReadDefaults: 1;
+ bool bFileImmutable: 1;
+ bool bForceGlobal: 1;
+ bool bSuppressGlobal: 1;
+ QString sGlobalFileName;
+ static bool mappingsRegistered;
KEntryMap entryMap;
QString backendType;
@@ -94,16 +93,28 @@ private:
QString etc_kderc;
KConfigBase::AccessMode configState;
- bool wantGlobals() const { return openFlags&KConfig::IncludeGlobals && !bSuppressGlobal; }
- bool wantDefaults() const { return openFlags&KConfig::CascadeConfig; }
- bool isSimple() const { return openFlags == KConfig::SimpleConfig; }
- bool isReadOnly() const { return configState == KConfig::ReadOnly; }
+ bool wantGlobals() const
+ {
+ return openFlags & KConfig::IncludeGlobals && !bSuppressGlobal;
+ }
+ bool wantDefaults() const
+ {
+ return openFlags & KConfig::CascadeConfig;
+ }
+ bool isSimple() const
+ {
+ return openFlags == KConfig::SimpleConfig;
+ }
+ bool isReadOnly() const
+ {
+ return configState == KConfig::ReadOnly;
+ }
- bool setLocale(const QString& aLocale);
+ bool setLocale(const QString &aLocale);
QStringList getGlobalFiles() const;
void parseGlobalFiles();
void parseConfigFiles();
- void initCustomized(KConfig*);
+ void initCustomized(KConfig *);
bool lockLocal();
};
diff --git a/src/core/kconfigbackend.cpp b/src/core/kconfigbackend.cpp
index eb92a964..90655fac 100644
--- a/src/core/kconfigbackend.cpp
+++ b/src/core/kconfigbackend.cpp
@@ -42,22 +42,21 @@ public:
QDateTime lastModified;
QString localFileName;
- static QString whatSystem(const QString& /*fileName*/)
+ static QString whatSystem(const QString & /*fileName*/)
{
return QLatin1String("INI");
}
};
-
-void KConfigBackend::registerMappings(const KEntryMap& /*entryMap*/)
+void KConfigBackend::registerMappings(const KEntryMap & /*entryMap*/)
{
}
-BackendPtr KConfigBackend::create(const QString& file, const QString& sys)
+BackendPtr KConfigBackend::create(const QString &file, const QString &sys)
{
//qDebug() << "creating a backend for file" << file << "with system" << sys;
const QString system = (sys.isEmpty() ? Private::whatSystem(file) : sys);
- KConfigBackend* backend = 0;
+ KConfigBackend *backend = 0;
#if 0 // TODO port to Qt5 plugin loading
if (system.compare(QLatin1String("INI"), Qt::CaseInsensitive) != 0) {
@@ -65,7 +64,7 @@ BackendPtr KConfigBackend::create(const QString& file, const QString& sys)
KService::List offers = KServiceTypeTrader::self()->query(QLatin1String("KConfigBackend"), constraint);
//qDebug() << "found" << offers.count() << "offers for KConfigBackend plugins with name" << system;
- foreach (const KService::Ptr& offer, offers) {
+ foreach (const KService::Ptr &offer, offers) {
backend = offer->createInstance<KConfigBackend>(0);
if (backend) {
//qDebug() << "successfully created a backend for" << system;
@@ -83,7 +82,7 @@ BackendPtr KConfigBackend::create(const QString& file, const QString& sys)
}
KConfigBackend::KConfigBackend()
- : d(new Private)
+ : d(new Private)
{
}
@@ -97,7 +96,7 @@ QDateTime KConfigBackend::lastModified() const
return d->lastModified;
}
-void KConfigBackend::setLastModified(const QDateTime& dt)
+void KConfigBackend::setLastModified(const QDateTime &dt)
{
d->lastModified = dt;
}
@@ -117,7 +116,7 @@ QString KConfigBackend::filePath() const
return d->localFileName;
}
-void KConfigBackend::setLocalFilePath(const QString& file)
+void KConfigBackend::setLocalFilePath(const QString &file)
{
d->localFileName = file;
}
diff --git a/src/core/kconfigbackend.h b/src/core/kconfigbackend.h
index 49239e66..550bf396 100644
--- a/src/core/kconfigbackend.h
+++ b/src/core/kconfigbackend.h
@@ -61,8 +61,8 @@ 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
@@ -74,7 +74,7 @@ public:
*
* @param entryMap the KEntryMap to build the mappings from
*/
- static void registerMappings(const KEntryMap& entryMap);
+ static void registerMappings(const KEntryMap &entryMap);
/** Destroys the backend */
virtual ~KConfigBackend();
@@ -110,8 +110,8 @@ public:
* @param options @see ParseOptions
* @return @see ParseInfo
*/
- virtual ParseInfo parseConfig(const QByteArray& locale,
- KEntryMap& pWriteBackMap,
+ virtual ParseInfo parseConfig(const QByteArray &locale,
+ KEntryMap &pWriteBackMap,
ParseOptions options = ParseOptions()) = 0;
/**
@@ -123,7 +123,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,
+ virtual bool writeConfig(const QByteArray &locale, KEntryMap &entryMap,
WriteOptions options) = 0;
/**
@@ -163,7 +163,7 @@ public:
*
* @param path the absolute file path
*/
- virtual void setFilePath(const QString& path) = 0;
+ virtual void setFilePath(const QString &path) = 0;
/**
* Lock the file
@@ -189,9 +189,9 @@ public:
protected:
KConfigBackend();
- void setLastModified(const QDateTime& dt);
+ void setLastModified(const QDateTime &dt);
void setSize(qint64 sz);
- void setLocalFilePath(const QString& file);
+ void setLocalFilePath(const QString &file);
private:
class Private;
@@ -205,7 +205,6 @@ 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>();)
-
+ K_PLUGIN_FACTORY(factory, registerPlugin<classname>();)
#endif // KCONFIGBACKEND_H
diff --git a/src/core/kconfigbase.cpp b/src/core/kconfigbase.cpp
index 4be7ac23..8cda588f 100644
--- a/src/core/kconfigbase.cpp
+++ b/src/core/kconfigbase.cpp
@@ -41,32 +41,32 @@ bool KConfigBase::hasGroup(const QByteArray &group) const
return hasGroupImpl(group);
}
-KConfigGroup KConfigBase::group( const QByteArray &b)
+KConfigGroup KConfigBase::group(const QByteArray &b)
{
return groupImpl(b);
}
-KConfigGroup KConfigBase::group( const QString &str)
+KConfigGroup KConfigBase::group(const QString &str)
{
return groupImpl(str.toUtf8());
}
-KConfigGroup KConfigBase::group( const char *str)
+KConfigGroup KConfigBase::group(const char *str)
{
return groupImpl(QByteArray(str));
}
-const KConfigGroup KConfigBase::group( const QByteArray &b ) const
+const KConfigGroup KConfigBase::group(const QByteArray &b) const
{
return groupImpl(b);
}
-const KConfigGroup KConfigBase::group( const QString &s ) const
+const KConfigGroup KConfigBase::group(const QString &s) const
{
return groupImpl(s.toUtf8());
}
-const KConfigGroup KConfigBase::group( const char *s ) const
+const KConfigGroup KConfigBase::group(const char *s) const
{
return groupImpl(QByteArray(s));
}
@@ -86,17 +86,16 @@ void KConfigBase::deleteGroup(const char *group, WriteConfigFlags flags)
deleteGroupImpl(QByteArray(group), flags);
}
-bool KConfigBase::isGroupImmutable(const QByteArray& aGroup) const
+bool KConfigBase::isGroupImmutable(const QByteArray &aGroup) const
{
return isGroupImmutableImpl(aGroup);
}
-bool KConfigBase::isGroupImmutable(const QString& aGroup) const
+bool KConfigBase::isGroupImmutable(const QString &aGroup) const
{
return isGroupImmutableImpl(aGroup.toUtf8());
}
-
bool KConfigBase::isGroupImmutable(const char *aGroup) const
{
return isGroupImmutableImpl(QByteArray(aGroup));
@@ -108,5 +107,5 @@ KConfigBase::~KConfigBase()
KConfigBase::KConfigBase()
{}
-void KConfigBase::virtual_hook(int , void *)
+void KConfigBase::virtual_hook(int, void *)
{}
diff --git a/src/core/kconfigbase.h b/src/core/kconfigbase.h
index 782ff4b6..3d00d98a 100644
--- a/src/core/kconfigbase.h
+++ b/src/core/kconfigbase.h
@@ -41,8 +41,7 @@ public:
/**
* Flags to control write entry
*/
- enum WriteConfigFlag
- {
+ enum WriteConfigFlag {
Persistent = 0x01,
/**<
* Save this entry when saving the config object.
@@ -56,11 +55,11 @@ public:
/**<
* Add the locale tag to the key when writing it.
*/
- Normal=Persistent
- /**<
- * Save the entry to the application specific config file without
- * a locale tag. This is the default.
- */
+ Normal = Persistent
+ /**<
+ * Save the entry to the application specific config file without
+ * a locale tag. This is the default.
+ */
};
Q_DECLARE_FLAGS(WriteConfigFlags, WriteConfigFlag)
@@ -154,31 +153,29 @@ public:
/**
* Can changes be made to the entries in @p aGroup?
- *
+ *
* @param aGroup The group to check for immutability.
* @return @c false if the entries in @p aGroup can be modified.
*/
- bool isGroupImmutable(const QByteArray& aGroup) const;
- bool isGroupImmutable(const QString& aGroup) const;
+ bool isGroupImmutable(const QByteArray &aGroup) const;
+ bool isGroupImmutable(const QString &aGroup) const;
bool isGroupImmutable(const char *aGroup) const;
protected:
KConfigBase();
virtual bool hasGroupImpl(const QByteArray &group) const = 0;
- virtual KConfigGroup groupImpl( const QByteArray &b) = 0;
+ virtual KConfigGroup groupImpl(const QByteArray &b) = 0;
virtual const KConfigGroup groupImpl(const QByteArray &b) const = 0;
virtual void deleteGroupImpl(const QByteArray &group, WriteConfigFlags flags = Normal) = 0;
- virtual bool isGroupImmutableImpl(const QByteArray& aGroup) const = 0;
+ virtual bool isGroupImmutableImpl(const QByteArray &aGroup) const = 0;
/** 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);
};
Q_DECLARE_OPERATORS_FOR_FLAGS(KConfigBase::WriteConfigFlags)
-
-
#endif // KCONFIG_H
diff --git a/src/core/kconfigdata.cpp b/src/core/kconfigdata.cpp
index 74a068be..109063d6 100644
--- a/src/core/kconfigdata.cpp
+++ b/src/core/kconfigdata.cpp
@@ -22,81 +22,83 @@
#include <kconfigdata.h>
-QDebug operator<<(QDebug dbg, const KEntryKey& key)
+QDebug operator<<(QDebug dbg, const KEntryKey &key)
{
- dbg.nospace() << "[" << key.mGroup << ", " << key.mKey << (key.bLocal?" localized":"") <<
- (key.bDefault?" default":"") << (key.bRaw?" raw":"") << "]";
- return dbg.space();
+ 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)
+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();
+ 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));
+ 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));
+ KEntryKey theKey(group, key, false, bool(flags & SearchDefaults));
// try the localized key first
- if (flags&SearchLocalized) {
+ if (flags & SearchLocalized) {
theKey.bLocal = true;
Iterator it = find(theKey);
- if (it != end())
+ if (it != end()) {
return it;
+ }
theKey.bLocal = false;
}
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));
+ KEntryKey theKey(group, key, false, bool(flags & SearchDefaults));
// try the localized key first
- if (flags&SearchLocalized) {
+ if (flags & SearchLocalized) {
theKey.bLocal = true;
ConstIterator it = find(theKey);
- if (it != constEnd())
+ if (it != constEnd()) {
return it;
+ }
theKey.bLocal = false;
}
return find(theKey);
}
-bool KEntryMap::setEntry(const QByteArray& group, const QByteArray& key, const QByteArray& value, KEntryMap::EntryOptions options)
+bool KEntryMap::setEntry(const QByteArray &group, const QByteArray &key, const QByteArray &value, KEntryMap::EntryOptions options)
{
KEntryKey k;
KEntry e;
bool newKey = false;
- const Iterator it = findExactEntry(group, key, SearchFlags(options>>16));
+ const Iterator it = findExactEntry(group, key, SearchFlags(options >> 16));
if (key.isEmpty()) { // inserting a group marker
k.mGroup = group;
- e.bImmutable = (options&EntryImmutable);
- if (options&EntryDeleted) {
+ e.bImmutable = (options & EntryImmutable);
+ if (options & EntryDeleted) {
qWarning("Internal KConfig error: cannot mark groups as deleted");
}
- if(it == end()) {
+ if (it == end()) {
insert(k, e);
return true;
- } else if(it.value() == e) {
+ } else if (it.value() == e) {
return false;
}
@@ -104,10 +106,10 @@ bool KEntryMap::setEntry(const QByteArray& group, const QByteArray& key, const Q
return true;
}
-
if (it != end()) {
- if (it->bImmutable)
- return false; // we cannot change this entry. Inherits group immutability.
+ if (it->bImmutable) {
+ return false; // we cannot change this entry. Inherits group immutability.
+ }
k = it.key();
e = *it;
//qDebug() << "found existing entry for key" << k;
@@ -115,39 +117,39 @@ bool KEntryMap::setEntry(const QByteArray& group, const QByteArray& key, const Q
// make sure the group marker is in the map
KEntryMap const *that = this;
ConstIterator cit = that->findEntry(group);
- if (cit == constEnd())
+ if (cit == constEnd()) {
insert(KEntryKey(group), KEntry());
- else if (cit->bImmutable)
- return false; // this group is immutable, so we cannot change this entry.
+ } else if (cit->bImmutable) {
+ return false; // this group is immutable, so we cannot change this entry.
+ }
k = KEntryKey(group, key);
newKey = true;
}
// set these here, since we may be changing the type of key from the one we found
- k.bLocal = (options&EntryLocalized);
- k.bDefault = (options&EntryDefault);
- k.bRaw = (options&EntryRawKey);
+ k.bLocal = (options & EntryLocalized);
+ k.bDefault = (options & EntryDefault);
+ k.bRaw = (options & EntryRawKey);
e.mValue = value;
- e.bDirty = e.bDirty || (options&EntryDirty);
- e.bGlobal = (options&EntryGlobal); //we can't use || here, because changes to entries in
+ e.bDirty = e.bDirty || (options & EntryDirty);
+ 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.bExpand = (options&EntryExpansion);
+ 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.bExpand = (options & EntryExpansion);
e.bReverted = false;
- if(newKey)
- {
+ if (newKey) {
//qDebug() << "inserting" << k << "=" << value;
insert(k, e);
- if(k.bDefault)
- {
+ if (k.bDefault) {
k.bDefault = false;
//qDebug() << "also inserting" << k << "=" << value;
insert(k, e);
@@ -156,12 +158,10 @@ bool KEntryMap::setEntry(const QByteArray& group, const QByteArray& key, const Q
return true;
} else {
// KEntry e2 = it.value();
- if(it.value() != e)
- {
+ if (it.value() != e) {
//qDebug() << "changing" << k << "from" << e.mValue << "to" << value;
it.value() = e;
- if(k.bDefault)
- {
+ if (k.bDefault) {
KEntryKey nonDefaultKey(k);
nonDefaultKey.bDefault = false;
insert(nonDefaultKey, e);
@@ -206,30 +206,33 @@ bool KEntryMap::setEntry(const QByteArray& group, const QByteArray& key, const Q
}
}
-QString KEntryMap::getEntry(const QByteArray& group, const QByteArray& key, const QString& defaultValue, KEntryMap::SearchFlags flags, bool* expand) const
+QString KEntryMap::getEntry(const QByteArray &group, const QByteArray &key, const QString &defaultValue, KEntryMap::SearchFlags flags, bool *expand) const
{
const ConstIterator it = findEntry(group, key, flags);
QString theValue = defaultValue;
if (it != constEnd() && !it->bDeleted) {
if (!it->mValue.isNull()) {
- const QByteArray data=it->mValue;
+ const QByteArray data = it->mValue;
theValue = QString::fromUtf8(data.constData(), data.length());
- if (expand)
+ if (expand) {
*expand = it->bExpand;
+ }
}
}
return theValue;
}
-bool KEntryMap::hasEntry(const QByteArray& group, const QByteArray& key, KEntryMap::SearchFlags flags) const
+bool KEntryMap::hasEntry(const QByteArray &group, const QByteArray &key, KEntryMap::SearchFlags flags) const
{
const ConstIterator it = findEntry(group, key, flags);
- if (it == constEnd())
+ if (it == constEnd()) {
return false;
- if (it->bDeleted)
+ }
+ if (it->bDeleted) {
return false;
+ }
if (key.isNull()) { // looking for group marker
return it->mValue.isNull();
}
@@ -237,7 +240,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) {
@@ -286,7 +289,7 @@ void KEntryMap::setEntryOption(QMap< KEntryKey, KEntry >::Iterator it, KEntryMap
}
}
-bool KEntryMap::revertEntry(const QByteArray& group, const QByteArray& key, KEntryMap::SearchFlags flags)
+bool KEntryMap::revertEntry(const QByteArray &group, const QByteArray &key, KEntryMap::SearchFlags flags)
{
Q_ASSERT((flags & KEntryMap::SearchDefaults) == 0);
Iterator entry = findEntry(group, key, flags);
diff --git a/src/core/kconfigdata.h b/src/core/kconfigdata.h
index f7ad81b9..e57becb2 100644
--- a/src/core/kconfigdata.h
+++ b/src/core/kconfigdata.h
@@ -32,38 +32,37 @@
* map/dict/list config node entry.
* @internal
*/
-struct KEntry
-{
- /** Constructor. @internal */
- KEntry()
- : mValue(), bDirty(false),
- bGlobal(false), bImmutable(false), bDeleted(false), bExpand(false), bReverted(false) {}
- /** @internal */
- QByteArray mValue;
- /**
- * Must the entry be written back to disk?
- */
- bool bDirty :1;
- /**
- * Entry should be written to the global config file
- */
- bool bGlobal:1;
- /**
- * Entry can not be modified.
- */
- bool bImmutable:1;
- /**
- * Entry has been deleted.
- */
- bool bDeleted:1;
- /**
- * Whether to apply dollar expansion or not.
- */
- bool bExpand:1;
- /**
- * Entry has been reverted to its default value (from a more global file).
- */
- bool bReverted:1;
+struct KEntry {
+ /** Constructor. @internal */
+ KEntry()
+ : mValue(), bDirty(false),
+ bGlobal(false), bImmutable(false), bDeleted(false), bExpand(false), bReverted(false) {}
+ /** @internal */
+ QByteArray mValue;
+ /**
+ * Must the entry be written back to disk?
+ */
+ bool bDirty : 1;
+ /**
+ * Entry should be written to the global config file
+ */
+ bool bGlobal: 1;
+ /**
+ * Entry can not be modified.
+ */
+ bool bImmutable: 1;
+ /**
+ * Entry has been deleted.
+ */
+ bool bDeleted: 1;
+ /**
+ * Whether to apply dollar expansion or not.
+ */
+ bool bExpand: 1;
+ /**
+ * Entry has been reverted to its default value (from a more global file).
+ */
+ bool bReverted: 1;
};
// These operators are used to check whether an entry which is about
@@ -86,34 +85,35 @@ inline bool operator !=(const KEntry &k1, const KEntry &k2)
* to which it belongs.
* @internal
*/
-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)
- { ; }
- /**
- * The "group" to which this EntryKey belongs
- */
- QByteArray mGroup;
- /**
- * The _actual_ key of the entry in question
- */
- QByteArray mKey;
- /**
- * Entry is localised or not
- */
- bool bLocal :1;
- /**
- * Entry indicates if this is a default value.
- */
- 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;
+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)
+ {
+ ;
+ }
+ /**
+ * The "group" to which this EntryKey belongs
+ */
+ QByteArray mGroup;
+ /**
+ * The _actual_ key of the entry in question
+ */
+ QByteArray mKey;
+ /**
+ * Entry is localised or not
+ */
+ bool bLocal : 1;
+ /**
+ * Entry indicates if this is a default value.
+ */
+ 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;
};
/**
@@ -133,14 +133,14 @@ inline bool operator <(const KEntryKey &k1, const KEntryKey &k2)
return result < 0;
}
- if (k1.bLocal != k2.bLocal)
+ if (k1.bLocal != k2.bLocal) {
return k1.bLocal;
+ }
return (!k1.bDefault && k2.bDefault);
}
-
-QDebug operator<<(QDebug dbg, const KEntryKey& key);
-QDebug operator<<(QDebug dbg, const KEntry& entry);
+QDebug operator<<(QDebug dbg, const KEntryKey &key);
+QDebug operator<<(QDebug dbg, const KEntry &entry);
/**
* \relates KEntry
@@ -151,69 +151,69 @@ QDebug operator<<(QDebug dbg, const KEntry& entry);
*/
class KEntryMap : public QMap<KEntryKey, KEntry>
{
- public:
- enum SearchFlag {
- SearchDefaults=1,
- SearchLocalized=2
- };
- Q_DECLARE_FLAGS(SearchFlags, SearchFlag)
-
- enum EntryOption {
- EntryDirty=1,
- EntryGlobal=2,
- EntryImmutable=4,
- EntryDeleted=8,
- EntryExpansion=16,
- EntryRawKey=32,
- EntryDefault=(SearchDefaults<<16),
- EntryLocalized=(SearchLocalized<<16)
- };
- Q_DECLARE_FLAGS(EntryOptions, EntryOption)
-
- Iterator findExactEntry(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;
-
- /**
- * 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);
-
- 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,
- const QString & defaultValue = QString(),
- SearchFlags flags = SearchFlags(),
- bool * expand=0) 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
- {
- 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)
- {
- setEntryOption(findEntry(group, key, flags), option, bf);
- }
-
- bool revertEntry(const QByteArray& group, const QByteArray& key, SearchFlags flags=SearchFlags());
+public:
+ enum SearchFlag {
+ SearchDefaults = 1,
+ SearchLocalized = 2
+ };
+ Q_DECLARE_FLAGS(SearchFlags, SearchFlag)
+
+ enum EntryOption {
+ EntryDirty = 1,
+ EntryGlobal = 2,
+ EntryImmutable = 4,
+ EntryDeleted = 8,
+ EntryExpansion = 16,
+ EntryRawKey = 32,
+ EntryDefault = (SearchDefaults << 16),
+ EntryLocalized = (SearchLocalized << 16)
+ };
+ Q_DECLARE_FLAGS(EntryOptions, EntryOption)
+
+ Iterator findExactEntry(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;
+
+ /**
+ * 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);
+
+ 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,
+ const QString &defaultValue = QString(),
+ SearchFlags flags = SearchFlags(),
+ bool *expand = 0) 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
+ {
+ 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)
+ {
+ setEntryOption(findEntry(group, key, flags), option, bf);
+ }
+
+ bool revertEntry(const QByteArray &group, const QByteArray &key, SearchFlags flags = SearchFlags());
};
Q_DECLARE_OPERATORS_FOR_FLAGS(KEntryMap::SearchFlags)
Q_DECLARE_OPERATORS_FOR_FLAGS(KEntryMap::EntryOptions)
diff --git a/src/core/kconfiggroup.cpp b/src/core/kconfiggroup.cpp
index ab7d494f..c720cc66 100644
--- a/src/core/kconfiggroup.cpp
+++ b/src/core/kconfiggroup.cpp
@@ -45,32 +45,34 @@
class KConfigGroupPrivate : public QSharedData
{
- public:
- KConfigGroupPrivate(KConfig* owner, bool isImmutable, bool isConst, const QByteArray &name)
+public:
+ KConfigGroupPrivate(KConfig *owner, bool isImmutable, bool isConst, const QByteArray &name)
: mOwner(owner), mName(name), bImmutable(isImmutable), bConst(isConst)
{
}
- KConfigGroupPrivate(const KSharedConfigPtr &owner, const QByteArray& name)
+ KConfigGroupPrivate(const KSharedConfigPtr &owner, const QByteArray &name)
: sOwner(owner), mOwner(sOwner.data()), mName(name),
- bImmutable(name.isEmpty()? owner->isImmutable(): owner->isGroupImmutable(name)), bConst(false)
+ bImmutable(name.isEmpty() ? owner->isImmutable() : owner->isGroupImmutable(name)), bConst(false)
{
}
- KConfigGroupPrivate(KConfigGroup* parent, bool isImmutable, bool isConst, const QByteArray& name)
+ KConfigGroupPrivate(KConfigGroup *parent, bool isImmutable, bool isConst, const QByteArray &name)
: sOwner(parent->d->sOwner), mOwner(parent->d->mOwner), mName(name),
bImmutable(isImmutable), bConst(isConst)
{
- if (!parent->d->mName.isEmpty())
+ if (!parent->d->mName.isEmpty()) {
mParent = parent->d;
+ }
}
- KConfigGroupPrivate(const KConfigGroupPrivate* other, bool isImmutable, const QByteArray &name)
+ KConfigGroupPrivate(const KConfigGroupPrivate *other, bool isImmutable, const QByteArray &name)
: sOwner(other->sOwner), mOwner(other->mOwner), mName(name),
bImmutable(isImmutable), bConst(other->bConst)
{
- if (!other->mName.isEmpty())
+ if (!other->mName.isEmpty()) {
mParent = const_cast<KConfigGroupPrivate *>(other);
+ }
}
KSharedConfig::Ptr sOwner;
@@ -79,8 +81,8 @@ class KConfigGroupPrivate : public QSharedData
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
{
@@ -92,28 +94,31 @@ class KConfigGroupPrivate : public QSharedData
QByteArray name() const
{
- if (mName.isEmpty())
+ if (mName.isEmpty()) {
return "<default>";
+ }
return mName;
}
- QByteArray fullName(const QByteArray& aGroup) const
+ QByteArray fullName(const QByteArray &aGroup) const
{
- if (mName.isEmpty())
+ if (mName.isEmpty()) {
return aGroup;
+ }
return fullName() + '\x1d' + aGroup;
}
static QExplicitlySharedDataPointer<KConfigGroupPrivate> create(KConfigBase *master,
- const QByteArray &name,
- bool isImmutable,
- bool isConst)
+ const QByteArray &name,
+ bool isImmutable,
+ bool isConst)
{
QExplicitlySharedDataPointer<KConfigGroupPrivate> data;
- if (dynamic_cast<KConfigGroup*>(master))
- data = new KConfigGroupPrivate(dynamic_cast<KConfigGroup*>(master), isImmutable, isConst, name);
- else
- data = new KConfigGroupPrivate(dynamic_cast<KConfig*>(master), isImmutable, isConst, name);
+ if (dynamic_cast<KConfigGroup *>(master)) {
+ data = new KConfigGroupPrivate(dynamic_cast<KConfigGroup *>(master), isImmutable, isConst, name);
+ } else {
+ data = new KConfigGroupPrivate(dynamic_cast<KConfig *>(master), isImmutable, isConst, name);
+ }
return data;
}
@@ -141,8 +146,9 @@ QByteArray KConfigGroupPrivate::serializeList(const QList<QByteArray> &list)
}
// To be able to distinguish an empty list from a list with one empty element.
- if (value.isEmpty())
+ if (value.isEmpty()) {
value = "\\0";
+ }
}
return value;
@@ -150,10 +156,12 @@ QByteArray KConfigGroupPrivate::serializeList(const QList<QByteArray> &list)
QStringList KConfigGroupPrivate::deserializeList(const QString &data)
{
- if (data.isEmpty())
+ if (data.isEmpty()) {
return QStringList();
- if (data == QLatin1String("\\0"))
+ }
+ if (data == QLatin1String("\\0")) {
return QStringList(QString());
+ }
QStringList value;
QString val;
val.reserve(data.size());
@@ -177,192 +185,199 @@ QStringList KConfigGroupPrivate::deserializeList(const QString &data)
return value;
}
-static QList<int> asIntList(const QByteArray& string)
+static QList<int> asIntList(const QByteArray &string)
{
QList<int> list;
- Q_FOREACH(const QByteArray& s, string.split(','))
+ Q_FOREACH (const QByteArray &s, string.split(',')) {
list << s.toInt();
+ }
return list;
}
-static QList<qreal> asRealList(const QByteArray& string)
+static QList<qreal> asRealList(const QByteArray &string)
{
QList<qreal> list;
- Q_FOREACH(const QByteArray& s, string.split(','))
+ Q_FOREACH (const QByteArray &s, string.split(',')) {
list << s.toDouble();
+ }
return list;
}
-static QString errString( const char * pKey, const QByteArray & value, const QVariant & aDefault ) {
+static QString errString(const char *pKey, const QByteArray &value, const QVariant &aDefault)
+{
return QString::fromLatin1("\"%1\" - conversion of \"%3\" to %2 failed")
- .arg(QString::fromLatin1(pKey))
- .arg(QString::fromLatin1(QVariant::typeToName(aDefault.type())))
- .arg(QString::fromLatin1(value));
+ .arg(QString::fromLatin1(pKey))
+ .arg(QString::fromLatin1(QVariant::typeToName(aDefault.type())))
+ .arg(QString::fromLatin1(value));
}
-static QString formatError( int expected, int got ) {
- return QString::fromLatin1(" (wrong format: expected %1 items, got %2)").arg( expected ).arg( got );
+static QString formatError(int expected, int got)
+{
+ return QString::fromLatin1(" (wrong format: expected %1 items, got %2)").arg(expected).arg(got);
}
-QVariant KConfigGroup::convertToQVariant(const char *pKey, const QByteArray& value, const QVariant& aDefault)
+QVariant KConfigGroup::convertToQVariant(const char *pKey, const QByteArray &value, const QVariant &aDefault)
{
// if a type handler is added here you must add a QVConversions definition
// to conversion_check.h, or ConversionCheck::to_QVariant will not allow
// readEntry<T> to convert to QVariant.
- switch( aDefault.type() ) {
- case QVariant::Invalid:
- return QVariant();
- case QVariant::String:
- // this should return the raw string not the dollar expanded string.
- // imho if processed string is wanted should call
- // readEntry(key, QString) not readEntry(key, QVariant)
- return QString::fromUtf8(value);
- case QVariant::List:
- case QVariant::StringList:
- return KConfigGroupPrivate::deserializeList(QString::fromUtf8(value));
- case QVariant::ByteArray:
- return value;
- case QVariant::Bool: {
- const QByteArray lower(value.toLower());
- if (lower == "false" || lower == "no" || lower == "off" || lower == "0")
- return false;
- return true;
+ switch (aDefault.type()) {
+ case QVariant::Invalid:
+ return QVariant();
+ case QVariant::String:
+ // this should return the raw string not the dollar expanded string.
+ // imho if processed string is wanted should call
+ // readEntry(key, QString) not readEntry(key, QVariant)
+ return QString::fromUtf8(value);
+ case QVariant::List:
+ case QVariant::StringList:
+ return KConfigGroupPrivate::deserializeList(QString::fromUtf8(value));
+ case QVariant::ByteArray:
+ return value;
+ case QVariant::Bool: {
+ const QByteArray lower(value.toLower());
+ if (lower == "false" || lower == "no" || lower == "off" || lower == "0") {
+ return false;
}
- case QVariant::Double:
- case QMetaType::Float:
- case QVariant::Int:
- case QVariant::UInt:
- case QVariant::LongLong:
- case QVariant::ULongLong: {
- QVariant tmp = value;
- if ( !tmp.convert(aDefault.type()) )
- tmp = aDefault;
- return tmp;
+ return true;
+ }
+ case QVariant::Double:
+ case QMetaType::Float:
+ case QVariant::Int:
+ case QVariant::UInt:
+ case QVariant::LongLong:
+ case QVariant::ULongLong: {
+ QVariant tmp = value;
+ if (!tmp.convert(aDefault.type())) {
+ tmp = aDefault;
}
- case QVariant::Point: {
- const QList<int> list = asIntList(value);
-
- if ( list.count() != 2 ) {
- qWarning() << errString( pKey, value, aDefault )
- << formatError( 2, list.count() );
- return aDefault;
- }
- return QPoint(list.at( 0 ), list.at( 1 ));
+ return tmp;
+ }
+ case QVariant::Point: {
+ const QList<int> list = asIntList(value);
+
+ if (list.count() != 2) {
+ qWarning() << errString(pKey, value, aDefault)
+ << formatError(2, list.count());
+ return aDefault;
}
- case QVariant::PointF: {
- const QList<qreal> list = asRealList(value);
-
- if ( list.count() != 2 ) {
- qWarning() << errString( pKey, value, aDefault )
- << formatError( 2, list.count() );
- return aDefault;
- }
- return QPointF(list.at( 0 ), list.at( 1 ));
+ return QPoint(list.at(0), list.at(1));
+ }
+ case QVariant::PointF: {
+ const QList<qreal> list = asRealList(value);
+
+ if (list.count() != 2) {
+ qWarning() << errString(pKey, value, aDefault)
+ << formatError(2, list.count());
+ return aDefault;
}
- case QVariant::Rect: {
- const QList<int> list = asIntList(value);
-
- if ( list.count() != 4 ) {
- qWarning() << 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 ));
- if ( !rect.isValid() ) {
- qWarning() << errString( pKey, value, aDefault );
- return aDefault;
- }
- return rect;
+ return QPointF(list.at(0), list.at(1));
+ }
+ case QVariant::Rect: {
+ const QList<int> list = asIntList(value);
+
+ if (list.count() != 4) {
+ qWarning() << errString(pKey, value, aDefault)
+ << formatError(4, list.count());
+ return aDefault;
}
- case QVariant::RectF: {
- const QList<qreal> list = asRealList(value);
-
- if ( list.count() != 4 ) {
- qWarning() << 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 ));
- if ( !rect.isValid() ) {
- qWarning() << errString( pKey, value, aDefault );
- return aDefault;
- }
- return rect;
+ const QRect rect(list.at(0), list.at(1), list.at(2), list.at(3));
+ if (!rect.isValid()) {
+ qWarning() << errString(pKey, value, aDefault);
+ return aDefault;
}
- case QVariant::Size: {
- const QList<int> list = asIntList(value);
-
- if ( list.count() != 2 ) {
- qWarning() << errString( pKey, value, aDefault )
- << formatError( 2, list.count() );
- return aDefault;
- }
- const QSize size(list.at( 0 ), list.at( 1 ));
- if ( !size.isValid() ) {
- qWarning() << errString( pKey, value, aDefault );
- return aDefault;
- }
- return size;
+ return rect;
+ }
+ case QVariant::RectF: {
+ const QList<qreal> list = asRealList(value);
+
+ if (list.count() != 4) {
+ qWarning() << errString(pKey, value, aDefault)
+ << formatError(4, list.count());
+ return aDefault;
}
- case QVariant::SizeF: {
- const QList<qreal> list = asRealList(value);
-
- if ( list.count() != 2 ) {
- qWarning() << errString( pKey, value, aDefault )
- << formatError( 2, list.count() );
- return aDefault;
- }
- const QSizeF size(list.at( 0 ), list.at( 1 ));
- if ( !size.isValid() ) {
- qWarning() << errString( pKey, value, aDefault );
- return aDefault;
- }
- return size;
+ const QRectF rect(list.at(0), list.at(1), list.at(2), list.at(3));
+ if (!rect.isValid()) {
+ qWarning() << errString(pKey, value, aDefault);
+ return aDefault;
}
- case QVariant::DateTime: {
- const QList<int> list = asIntList(value);
- if ( list.count() != 6 ) {
- qWarning() << errString( pKey, value, aDefault )
- << formatError( 6, list.count() );
- return aDefault;
- }
- const QDate date( list.at( 0 ), list.at( 1 ), list.at( 2 ) );
- const QTime time( list.at( 3 ), list.at( 4 ), list.at( 5 ) );
- const QDateTime dt( date, time );
- if ( !dt.isValid() ) {
- qWarning() << errString( pKey, value, aDefault );
- return aDefault;
- }
- return dt;
+ return rect;
+ }
+ case QVariant::Size: {
+ const QList<int> list = asIntList(value);
+
+ if (list.count() != 2) {
+ qWarning() << errString(pKey, value, aDefault)
+ << formatError(2, list.count());
+ return aDefault;
}
- case QVariant::Date: {
- QList<int> list = asIntList(value);
- if ( list.count() == 6 )
- list = list.mid(0, 3); // don't break config files that stored QDate as QDateTime
- if ( list.count() != 3 ) {
- qWarning() << errString( pKey, value, aDefault )
- << formatError( 3, list.count() );
- return aDefault;
- }
- const QDate date( list.at( 0 ), list.at( 1 ), list.at( 2 ) );
- if ( !date.isValid() ) {
- qWarning() << errString( pKey, value, aDefault );
- return aDefault;
- }
- return date;
+ const QSize size(list.at(0), list.at(1));
+ if (!size.isValid()) {
+ qWarning() << errString(pKey, value, aDefault);
+ return aDefault;
}
- case QVariant::Color:
- case QVariant::Font:
- qWarning() << "KConfigGroup::readEntry was passed GUI type '"
- << aDefault.typeName()
- << "' but kdeui isn't linked! If it is linked to your program, "
- "this is a platform bug. Please inform the KDE developers";
- break;
- case QVariant::Url:
- return QUrl(QString::fromUtf8(value));
+ return size;
+ }
+ case QVariant::SizeF: {
+ const QList<qreal> list = asRealList(value);
- default:
- break;
+ if (list.count() != 2) {
+ qWarning() << errString(pKey, value, aDefault)
+ << formatError(2, list.count());
+ return aDefault;
+ }
+ const QSizeF size(list.at(0), list.at(1));
+ if (!size.isValid()) {
+ qWarning() << errString(pKey, value, aDefault);
+ return aDefault;
+ }
+ return size;
+ }
+ case QVariant::DateTime: {
+ const QList<int> list = asIntList(value);
+ if (list.count() != 6) {
+ qWarning() << errString(pKey, value, aDefault)
+ << formatError(6, list.count());
+ return aDefault;
+ }
+ const QDate date(list.at(0), list.at(1), list.at(2));
+ const QTime time(list.at(3), list.at(4), list.at(5));
+ const QDateTime dt(date, time);
+ if (!dt.isValid()) {
+ qWarning() << errString(pKey, value, aDefault);
+ return aDefault;
+ }
+ return dt;
+ }
+ case QVariant::Date: {
+ QList<int> list = asIntList(value);
+ if (list.count() == 6) {
+ list = list.mid(0, 3); // don't break config files that stored QDate as QDateTime
+ }
+ if (list.count() != 3) {
+ qWarning() << errString(pKey, value, aDefault)
+ << formatError(3, list.count());
+ return aDefault;
+ }
+ const QDate date(list.at(0), list.at(1), list.at(2));
+ if (!date.isValid()) {
+ qWarning() << errString(pKey, value, aDefault);
+ return aDefault;
+ }
+ return date;
+ }
+ case QVariant::Color:
+ case QVariant::Font:
+ qWarning() << "KConfigGroup::readEntry was passed GUI type '"
+ << aDefault.typeName()
+ << "' but kdeui isn't linked! If it is linked to your program, "
+ "this is a platform bug. Please inform the KDE developers";
+ break;
+ case QVariant::Url:
+ return QUrl(QString::fromUtf8(value));
+
+ default:
+ break;
}
qWarning() << "unhandled type " << aDefault.typeName();
@@ -373,68 +388,75 @@ QVariant KConfigGroup::convertToQVariant(const char *pKey, const QByteArray& val
# include <QtCore/QDir>
#endif
-static bool cleanHomeDirPath( QString &path, const QString &homeDir )
+static bool cleanHomeDirPath(QString &path, const QString &homeDir)
{
#ifdef Q_OS_WIN //safer
- if (!QDir::toNativeSeparators(path).startsWith(QDir::toNativeSeparators(homeDir)))
+ if (!QDir::toNativeSeparators(path).startsWith(QDir::toNativeSeparators(homeDir))) {
return false;
+ }
#else
- if (!path.startsWith(homeDir))
+ if (!path.startsWith(homeDir)) {
return false;
+ }
#endif
- int len = homeDir.length();
- // replace by "$HOME" if possible
- if (len && (path.length() == len || path[len] == QLatin1Char('/'))) {
+ int len = homeDir.length();
+ // replace by "$HOME" if possible
+ if (len && (path.length() == len || path[len] == QLatin1Char('/'))) {
path.replace(0, len, QString::fromLatin1("$HOME"));
return true;
- } else
+ } else {
return false;
+ }
}
-static QString translatePath( QString path ) // krazy:exclude=passbyvalue
+static QString translatePath(QString path) // krazy:exclude=passbyvalue
{
- if (path.isEmpty())
- return path;
+ if (path.isEmpty()) {
+ return path;
+ }
- // only "our" $HOME should be interpreted
- path.replace(QLatin1Char('$'), QLatin1String("$$"));
+ // only "our" $HOME should be interpreted
+ path.replace(QLatin1Char('$'), QLatin1String("$$"));
- bool startsWithFile = path.startsWith(QLatin1String("file:"), Qt::CaseInsensitive);
+ bool startsWithFile = path.startsWith(QLatin1String("file:"), Qt::CaseInsensitive);
- // return original path, if it refers to another type of URL (e.g. http:/), or
- // if the path is already relative to another directory
- if ((!startsWithFile && QFileInfo(path).isRelative()) ||
- (startsWithFile && QFileInfo(path.mid(5)).isRelative()))
- return path;
+ // return original path, if it refers to another type of URL (e.g. http:/), or
+ // if the path is already relative to another directory
+ if ((!startsWithFile && QFileInfo(path).isRelative()) ||
+ (startsWithFile && QFileInfo(path.mid(5)).isRelative())) {
+ return path;
+ }
- if (startsWithFile)
- path.remove(0,5); // strip leading "file:/" off the string
+ if (startsWithFile) {
+ path.remove(0, 5); // strip leading "file:/" off the string
+ }
- // keep only one single '/' at the beginning - needed for cleanHomeDirPath()
- while (path[0] == QLatin1Char('/') && path[1] == QLatin1Char('/'))
- path.remove(0,1);
+ // keep only one single '/' at the beginning - needed for cleanHomeDirPath()
+ while (path[0] == QLatin1Char('/') && path[1] == QLatin1Char('/')) {
+ path.remove(0, 1);
+ }
- // we can not use KGlobal::dirs()->relativeLocation("home", path) here,
- // since it would not recognize paths without a trailing '/'.
- // All of the 3 following functions to return the user's home directory
- // can return different paths. We have to test all them.
- 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) ) {
- // qDebug() << "Path was replaced\n";
- }
+ // we can not use KGlobal::dirs()->relativeLocation("home", path) here,
+ // since it would not recognize paths without a trailing '/'.
+ // All of the 3 following functions to return the user's home directory
+ // can return different paths. We have to test all them.
+ 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)) {
+ // qDebug() << "Path was replaced\n";
+ }
- if (startsWithFile)
- path.prepend(QString::fromLatin1("file://"));
+ if (startsWithFile) {
+ path.prepend(QString::fromLatin1("file://"));
+ }
- return path;
+ return path;
}
-
KConfigGroup::KConfigGroup() : d(0)
{
}
@@ -445,20 +467,22 @@ bool KConfigGroup::isValid() const
}
KConfigGroupGui _kde_internal_KConfigGroupGui;
-static inline bool readEntryGui(const QByteArray& data, const char* key, const QVariant &input,
+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);
- return false;
+ if (_kde_internal_KConfigGroupGui.readEntryGui) {
+ return _kde_internal_KConfigGroupGui.readEntryGui(data, key, input, output);
+ }
+ return false;
}
-static inline bool writeEntryGui(KConfigGroup *cg, const char* key, const QVariant &input,
+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);
- return false;
+ if (_kde_internal_KConfigGroupGui.writeEntryGui) {
+ return _kde_internal_KConfigGroupGui.writeEntryGui(cg, key, input, flags);
+ }
+ return false;
}
KConfigGroup::KConfigGroup(KConfigBase *master, const QString &_group)
@@ -467,17 +491,17 @@ KConfigGroup::KConfigGroup(KConfigBase *master, const QString &_group)
}
KConfigGroup::KConfigGroup(KConfigBase *master, const char *_group)
- : d(KConfigGroupPrivate::create(master, _group, master->isGroupImmutable(_group), false))
+ : d(KConfigGroupPrivate::create(master, _group, master->isGroupImmutable(_group), false))
{
}
KConfigGroup::KConfigGroup(const KConfigBase *master, const QString &_group)
- : d(KConfigGroupPrivate::create(const_cast<KConfigBase*>(master), _group.toUtf8(), master->isGroupImmutable(_group), true))
+ : d(KConfigGroupPrivate::create(const_cast<KConfigBase *>(master), _group.toUtf8(), master->isGroupImmutable(_group), true))
{
}
-KConfigGroup::KConfigGroup(const KConfigBase *master, const char * _group)
- : d(KConfigGroupPrivate::create(const_cast<KConfigBase*>(master), _group, master->isGroupImmutable(_group), true))
+KConfigGroup::KConfigGroup(const KConfigBase *master, const char *_group)
+ : d(KConfigGroupPrivate::create(const_cast<KConfigBase *>(master), _group, master->isGroupImmutable(_group), true))
{
}
@@ -486,7 +510,7 @@ KConfigGroup::KConfigGroup(const KSharedConfigPtr &master, const QString &_group
{
}
-KConfigGroup::KConfigGroup(const KSharedConfigPtr &master, const char * _group)
+KConfigGroup::KConfigGroup(const KSharedConfigPtr &master, const char *_group)
: d(new KConfigGroupPrivate(master, _group))
{
}
@@ -507,7 +531,7 @@ KConfigGroup::~KConfigGroup()
d = 0;
}
-KConfigGroup KConfigGroup::groupImpl(const QByteArray& aGroup)
+KConfigGroup KConfigGroup::groupImpl(const QByteArray &aGroup)
{
Q_ASSERT_X(isValid(), "KConfigGroup::groupImpl", "accessing an invalid group");
Q_ASSERT_X(!aGroup.isEmpty(), "KConfigGroup::groupImpl", "can not have an unnamed child group");
@@ -519,14 +543,14 @@ KConfigGroup KConfigGroup::groupImpl(const QByteArray& aGroup)
return newGroup;
}
-const KConfigGroup KConfigGroup::groupImpl(const QByteArray& aGroup) const
+const KConfigGroup KConfigGroup::groupImpl(const QByteArray &aGroup) const
{
Q_ASSERT_X(isValid(), "KConfigGroup::groupImpl", "accessing an invalid group");
Q_ASSERT_X(!aGroup.isEmpty(), "KConfigGroup::groupImpl", "can not have an unnamed child group");
KConfigGroup newGroup;
- newGroup.d = new KConfigGroupPrivate(const_cast<KConfigGroup*>(this), isGroupImmutableImpl(aGroup),
+ newGroup.d = new KConfigGroupPrivate(const_cast<KConfigGroup *>(this), isGroupImmutableImpl(aGroup),
true, aGroup);
return newGroup;
@@ -558,7 +582,7 @@ void KConfigGroup::deleteGroup(WriteConfigFlags flags)
}
#ifndef KDE_NO_DEPRECATED
-void KConfigGroup::changeGroup( const QString &group )
+void KConfigGroup::changeGroup(const QString &group)
{
Q_ASSERT_X(isValid(), "KConfigGroup::changeGroup", "accessing an invalid group");
d.detach();
@@ -567,7 +591,7 @@ void KConfigGroup::changeGroup( const QString &group )
#endif
#ifndef KDE_NO_DEPRECATED
-void KConfigGroup::changeGroup( const char *group )
+void KConfigGroup::changeGroup(const char *group)
{
Q_ASSERT_X(isValid(), "KConfigGroup::changeGroup", "accessing an invalid group");
d.detach();
@@ -586,15 +610,16 @@ bool KConfigGroup::exists() const
{
Q_ASSERT_X(isValid(), "KConfigGroup::exists", "accessing an invalid group");
- return config()->hasGroup( d->fullName() );
+ return config()->hasGroup(d->fullName());
}
bool KConfigGroup::sync()
{
Q_ASSERT_X(isValid(), "KConfigGroup::sync", "accessing an invalid group");
- if (!d->bConst)
+ if (!d->bConst) {
return config()->sync();
+ }
return false;
}
@@ -606,59 +631,60 @@ QMap<QString, QString> KConfigGroup::entryMap() const
return config()->entryMap(QString::fromUtf8(d->fullName()));
}
-KConfig* KConfigGroup::config()
+KConfig *KConfigGroup::config()
{
Q_ASSERT_X(isValid(), "KConfigGroup::config", "accessing an invalid group");
return d->mOwner;
}
-const KConfig* KConfigGroup::config() const
+const KConfig *KConfigGroup::config() const
{
Q_ASSERT_X(isValid(), "KConfigGroup::config", "accessing an invalid group");
return d->mOwner;
}
-bool KConfigGroup::isEntryImmutable(const char* key) const
+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()));
+ !config()->d_func()->canWriteEntry(d->fullName(), key, config()->readDefaults()));
}
-bool KConfigGroup::isEntryImmutable(const QString& key) const
+bool KConfigGroup::isEntryImmutable(const QString &key) const
{
return isEntryImmutable(key.toUtf8().constData());
}
-QString KConfigGroup::readEntryUntranslated(const QString& pKey, const QString& aDefault) const
+QString KConfigGroup::readEntryUntranslated(const QString &pKey, const QString &aDefault) const
{
return readEntryUntranslated(pKey.toUtf8().constData(), aDefault);
}
-QString KConfigGroup::readEntryUntranslated(const char *key, const QString& aDefault) const
+QString KConfigGroup::readEntryUntranslated(const char *key, const QString &aDefault) const
{
Q_ASSERT_X(isValid(), "KConfigGroup::readEntryUntranslated", "accessing an invalid group");
QString result = config()->d_func()->lookupData(d->fullName(), key, KEntryMap::SearchFlags(), 0);
- if (result.isNull())
+ if (result.isNull()) {
return aDefault;
+ }
return result;
}
-QString KConfigGroup::readEntry(const char *key, const char* aDefault) const
+QString KConfigGroup::readEntry(const char *key, const char *aDefault) const
{
return readEntry(key, QString::fromUtf8(aDefault));
}
-QString KConfigGroup::readEntry(const QString &key, const char* aDefault) const
+QString KConfigGroup::readEntry(const QString &key, const char *aDefault) const
{
return readEntry(key.toUtf8().constData(), aDefault);
}
-QString KConfigGroup::readEntry(const char* key, const QString& aDefault) const
+QString KConfigGroup::readEntry(const char *key, const QString &aDefault) const
{
Q_ASSERT_X(isValid(), "KConfigGroup::readEntry", "accessing an invalid group");
@@ -666,89 +692,97 @@ QString KConfigGroup::readEntry(const char* key, const QString& aDefault) const
// read value from the entry map
QString aValue = config()->d_func()->lookupData(d->fullName(), key, KEntryMap::SearchLocalized,
- &expand);
- if (aValue.isNull())
+ &expand);
+ if (aValue.isNull()) {
aValue = aDefault;
+ }
- if (expand)
+ if (expand) {
return KConfigPrivate::expandString(aValue);
+ }
return aValue;
}
-QString KConfigGroup::readEntry(const QString &key, const QString& aDefault) const
+QString KConfigGroup::readEntry(const QString &key, const QString &aDefault) const
{
return readEntry(key.toUtf8().constData(), aDefault);
}
-QStringList KConfigGroup::readEntry(const char* key, const QStringList& aDefault) const
+QStringList KConfigGroup::readEntry(const char *key, const QStringList &aDefault) const
{
Q_ASSERT_X(isValid(), "KConfigGroup::readEntry", "accessing an invalid group");
const QString data = readEntry(key, QString());
- if (data.isNull())
+ if (data.isNull()) {
return aDefault;
+ }
return KConfigGroupPrivate::deserializeList(data);
}
-QStringList KConfigGroup::readEntry( const QString& key, const QStringList& aDefault) const
+QStringList KConfigGroup::readEntry(const QString &key, const QStringList &aDefault) const
{
- return readEntry( key.toUtf8().constData(), aDefault );
+ return readEntry(key.toUtf8().constData(), aDefault);
}
-QVariant KConfigGroup::readEntry( const char* key, const QVariant &aDefault ) const
+QVariant KConfigGroup::readEntry(const char *key, const QVariant &aDefault) const
{
Q_ASSERT_X(isValid(), "KConfigGroup::readEntry", "accessing an invalid group");
const QByteArray data = config()->d_func()->lookupData(d->fullName(), key, KEntryMap::SearchLocalized);
- if (data.isNull())
+ if (data.isNull()) {
return aDefault;
+ }
QVariant value;
- if (!readEntryGui( data, key, aDefault, value ))
+ if (!readEntryGui(data, key, aDefault, value)) {
return convertToQVariant(key, data, aDefault);
+ }
return value;
}
-QVariant KConfigGroup::readEntry( const QString& key, const QVariant& aDefault) const
+QVariant KConfigGroup::readEntry(const QString &key, const QVariant &aDefault) const
{
- return readEntry( key.toUtf8().constData(), aDefault );
+ return readEntry(key.toUtf8().constData(), aDefault);
}
-QVariantList KConfigGroup::readEntry( const char* key, const QVariantList& aDefault) const
+QVariantList KConfigGroup::readEntry(const char *key, const QVariantList &aDefault) const
{
Q_ASSERT_X(isValid(), "KConfigGroup::readEntry", "accessing an invalid group");
const QString data = readEntry(key, QString());
- if (data.isNull())
+ if (data.isNull()) {
return aDefault;
+ }
QVariantList value;
- Q_FOREACH(const QString& v, KConfigGroupPrivate::deserializeList(data))
+ Q_FOREACH (const QString &v, KConfigGroupPrivate::deserializeList(data)) {
value << v;
+ }
return value;
}
-QVariantList KConfigGroup::readEntry( const QString& key, const QVariantList& aDefault) const
+QVariantList KConfigGroup::readEntry(const QString &key, const QVariantList &aDefault) const
{
- return readEntry( key.toUtf8().constData(), aDefault );
+ return readEntry(key.toUtf8().constData(), aDefault);
}
-QStringList KConfigGroup::readXdgListEntry(const QString& key, const QStringList& aDefault) const
+QStringList KConfigGroup::readXdgListEntry(const QString &key, const QStringList &aDefault) const
{
return readXdgListEntry(key.toUtf8().constData(), aDefault);
}
-QStringList KConfigGroup::readXdgListEntry(const char *key, const QStringList& aDefault) const
+QStringList KConfigGroup::readXdgListEntry(const char *key, const QStringList &aDefault) const
{
Q_ASSERT_X(isValid(), "KConfigGroup::readXdgListEntry", "accessing an invalid group");
const QString data = readEntry(key, QString());
- if (data.isNull())
+ if (data.isNull()) {
return aDefault;
+ }
QStringList value;
QString val;
@@ -777,42 +811,44 @@ QStringList KConfigGroup::readXdgListEntry(const char *key, const QStringList& a
return value;
}
-QString KConfigGroup::readPathEntry(const QString& pKey, const QString & aDefault) const
+QString KConfigGroup::readPathEntry(const QString &pKey, const QString &aDefault) const
{
return readPathEntry(pKey.toUtf8().constData(), aDefault);
}
-QString KConfigGroup::readPathEntry(const char *key, const QString & aDefault) const
+QString KConfigGroup::readPathEntry(const char *key, const QString &aDefault) const
{
Q_ASSERT_X(isValid(), "KConfigGroup::readPathEntry", "accessing an invalid group");
bool expand = false;
QString aValue = config()->d_func()->lookupData(d->fullName(), key, KEntryMap::SearchLocalized,
- &expand);
- if (aValue.isNull())
+ &expand);
+ if (aValue.isNull()) {
aValue = aDefault;
+ }
return KConfigPrivate::expandString(aValue);
}
-QStringList KConfigGroup::readPathEntry(const QString& pKey, const QStringList& aDefault) const
+QStringList KConfigGroup::readPathEntry(const QString &pKey, const QStringList &aDefault) const
{
return readPathEntry(pKey.toUtf8().constData(), aDefault);
}
-QStringList KConfigGroup::readPathEntry(const char *key, const QStringList& aDefault) const
+QStringList KConfigGroup::readPathEntry(const char *key, const QStringList &aDefault) const
{
Q_ASSERT_X(isValid(), "KConfigGroup::readPathEntry", "accessing an invalid group");
const QString data = readPathEntry(key, QString());
- if (data.isNull())
+ if (data.isNull()) {
return aDefault;
+ }
return KConfigGroupPrivate::deserializeList(data);
}
-void KConfigGroup::writeEntry( const char* key, const QString& value, WriteConfigFlags flags )
+void KConfigGroup::writeEntry(const char *key, const QString &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");
@@ -820,7 +856,7 @@ void KConfigGroup::writeEntry( const char* key, const QString& value, WriteConfi
writeEntry(key, value.toUtf8(), flags);
}
-void KConfigGroup::writeEntry( const QString& key, const QString& value, WriteConfigFlags flags )
+void KConfigGroup::writeEntry(const QString &key, const QString &value, WriteConfigFlags flags)
{
writeEntry(key.toUtf8().constData(), value, flags);
}
@@ -838,209 +874,212 @@ 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");
- config()->d_func()->putData(d->fullName(), key, value.isNull()? QByteArray(""): value, flags);
+ config()->d_func()->putData(d->fullName(), key, value.isNull() ? QByteArray("") : value, flags);
}
-void KConfigGroup::writeEntry(const QString& key, const QByteArray& value,
+void KConfigGroup::writeEntry(const QString &key, const QByteArray &value,
WriteConfigFlags pFlags)
{
writeEntry(key.toUtf8().constData(), value, pFlags);
}
-void KConfigGroup::writeEntry(const char* key, const QStringList &list, WriteConfigFlags flags)
+void KConfigGroup::writeEntry(const char *key, const QStringList &list, 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");
QList<QByteArray> balist;
- Q_FOREACH(const QString &entry, list)
+ Q_FOREACH (const QString &entry, list) {
balist.append(entry.toUtf8());
+ }
writeEntry(key, KConfigGroupPrivate::serializeList(balist), flags);
}
-void KConfigGroup::writeEntry(const QString& key, const QStringList &list, WriteConfigFlags flags)
+void KConfigGroup::writeEntry(const QString &key, const QStringList &list, WriteConfigFlags flags)
{
writeEntry(key.toUtf8().constData(), list, flags);
}
-void KConfigGroup::writeEntry( const char* key, const QVariantList& list, WriteConfigFlags flags )
+void KConfigGroup::writeEntry(const char *key, const QVariantList &list, 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");
QList<QByteArray> data;
- Q_FOREACH(const QVariant& v, list) {
- if (v.type() == QVariant::ByteArray)
+ Q_FOREACH (const QVariant &v, list) {
+ if (v.type() == QVariant::ByteArray) {
data << v.toByteArray();
- else
+ } else {
data << v.toString().toUtf8();
+ }
}
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
+ if (writeEntryGui(this, key, value, flags)) {
+ return; // GUI type that was handled
+ }
QByteArray data;
// if a type handler is added here you must add a QVConversions definition
// to conversion_check.h, or ConversionCheck::to_QVariant will not allow
// writeEntry<T> to convert to QVariant.
- switch( value.type() ) {
- case QVariant::Invalid:
- data = "";
- break;
- case QVariant::ByteArray:
- data = value.toByteArray();
- break;
- case QVariant::String:
- case QVariant::Int:
- case QVariant::UInt:
- case QVariant::Double:
- case QMetaType::Float:
- case QVariant::Bool:
- case QVariant::LongLong:
- case QVariant::ULongLong:
- data = value.toString().toUtf8();
- break;
- case QVariant::List:
- if (!value.canConvert(QVariant::StringList))
- qWarning() << "not all types in \"" << key << "\" can convert to QString,"
- " information will be lost";
- case QVariant::StringList:
- writeEntry( key, value.toList(), flags );
- return;
- case QVariant::Point: {
- QVariantList list;
- const QPoint rPoint = value.toPoint();
- list.insert( 0, rPoint.x() );
- list.insert( 1, rPoint.y() );
-
- writeEntry( key, list, flags );
- return;
- }
- case QVariant::PointF: {
- QVariantList list;
- const QPointF point = value.toPointF();
- list.insert( 0, point.x() );
- list.insert( 1, point.y() );
-
- writeEntry( key, list, flags );
- return;
- }
- case QVariant::Rect:{
- QVariantList list;
- const QRect rRect = value.toRect();
- list.insert( 0, rRect.left() );
- list.insert( 1, rRect.top() );
- list.insert( 2, rRect.width() );
- list.insert( 3, rRect.height() );
-
- writeEntry( key, list, flags );
- return;
- }
- case QVariant::RectF:{
- QVariantList list;
- const QRectF rRectF = value.toRectF();
- list.insert(0, rRectF.left());
- list.insert(1, rRectF.top());
- list.insert(2, rRectF.width());
- list.insert(3, rRectF.height());
-
- writeEntry(key, list, flags);
- return;
- }
- case QVariant::Size:{
- QVariantList list;
- const QSize rSize = value.toSize();
- list.insert( 0, rSize.width() );
- list.insert( 1, rSize.height() );
-
- writeEntry( key, list, flags );
- return;
- }
- case QVariant::SizeF:{
- QVariantList list;
- const QSizeF rSizeF = value.toSizeF();
- list.insert(0, rSizeF.width());
- list.insert(1, rSizeF.height());
-
- writeEntry(key, list, flags);
- return;
- }
- case QVariant::Date: {
- QVariantList list;
- const QDate date = value.toDate();
+ switch (value.type()) {
+ case QVariant::Invalid:
+ data = "";
+ break;
+ case QVariant::ByteArray:
+ data = value.toByteArray();
+ break;
+ case QVariant::String:
+ case QVariant::Int:
+ case QVariant::UInt:
+ case QVariant::Double:
+ case QMetaType::Float:
+ case QVariant::Bool:
+ case QVariant::LongLong:
+ case QVariant::ULongLong:
+ data = value.toString().toUtf8();
+ break;
+ case QVariant::List:
+ if (!value.canConvert(QVariant::StringList))
+ qWarning() << "not all types in \"" << key << "\" can convert to QString,"
+ " information will be lost";
+ case QVariant::StringList:
+ writeEntry(key, value.toList(), flags);
+ return;
+ case QVariant::Point: {
+ QVariantList list;
+ const QPoint rPoint = value.toPoint();
+ list.insert(0, rPoint.x());
+ list.insert(1, rPoint.y());
+
+ writeEntry(key, list, flags);
+ return;
+ }
+ case QVariant::PointF: {
+ QVariantList list;
+ const QPointF point = value.toPointF();
+ list.insert(0, point.x());
+ list.insert(1, point.y());
+
+ writeEntry(key, list, flags);
+ return;
+ }
+ case QVariant::Rect: {
+ QVariantList list;
+ const QRect rRect = value.toRect();
+ list.insert(0, rRect.left());
+ list.insert(1, rRect.top());
+ list.insert(2, rRect.width());
+ list.insert(3, rRect.height());
+
+ writeEntry(key, list, flags);
+ return;
+ }
+ case QVariant::RectF: {
+ QVariantList list;
+ const QRectF rRectF = value.toRectF();
+ list.insert(0, rRectF.left());
+ list.insert(1, rRectF.top());
+ list.insert(2, rRectF.width());
+ list.insert(3, rRectF.height());
+
+ writeEntry(key, list, flags);
+ return;
+ }
+ case QVariant::Size: {
+ QVariantList list;
+ const QSize rSize = value.toSize();
+ list.insert(0, rSize.width());
+ list.insert(1, rSize.height());
+
+ writeEntry(key, list, flags);
+ return;
+ }
+ case QVariant::SizeF: {
+ QVariantList list;
+ const QSizeF rSizeF = value.toSizeF();
+ list.insert(0, rSizeF.width());
+ list.insert(1, rSizeF.height());
+
+ writeEntry(key, list, flags);
+ return;
+ }
+ case QVariant::Date: {
+ QVariantList list;
+ const QDate date = value.toDate();
- list.insert( 0, date.year() );
- list.insert( 1, date.month() );
- list.insert( 2, date.day() );
+ list.insert(0, date.year());
+ list.insert(1, date.month());
+ list.insert(2, date.day());
- writeEntry( key, list, flags );
- return;
- }
- case QVariant::DateTime: {
- QVariantList list;
- const QDateTime rDateTime = value.toDateTime();
+ writeEntry(key, list, flags);
+ return;
+ }
+ case QVariant::DateTime: {
+ QVariantList list;
+ const QDateTime rDateTime = value.toDateTime();
- const QTime time = rDateTime.time();
- const QDate date = rDateTime.date();
+ const QTime time = rDateTime.time();
+ const QDate date = rDateTime.date();
- list.insert( 0, date.year() );
- list.insert( 1, date.month() );
- list.insert( 2, date.day() );
+ list.insert(0, date.year());
+ list.insert(1, date.month());
+ list.insert(2, date.day());
- list.insert( 3, time.hour() );
- list.insert( 4, time.minute() );
- list.insert( 5, time.second() );
+ list.insert(3, time.hour());
+ list.insert(4, time.minute());
+ list.insert(5, time.second());
- writeEntry( key, list, flags );
- return;
- }
+ writeEntry(key, list, flags);
+ return;
+ }
- case QVariant::Color:
- case QVariant::Font:
- qWarning() << "KConfigGroup::writeEntry was passed GUI type '"
- << value.typeName()
- << "' but kdeui isn't linked! If it is linked to your program, this is a platform bug. "
- "Please inform the KDE developers";
- break;
- case QVariant::Url:
- data = QUrl(value.toUrl()).toString().toUtf8();
- break;
- default:
- qWarning() << "KConfigGroup::writeEntry - unhandled type" << value.typeName() << "in group" << name();
- }
+ case QVariant::Color:
+ case QVariant::Font:
+ qWarning() << "KConfigGroup::writeEntry was passed GUI type '"
+ << value.typeName()
+ << "' but kdeui isn't linked! If it is linked to your program, this is a platform bug. "
+ "Please inform the KDE developers";
+ break;
+ case QVariant::Url:
+ data = QUrl(value.toUrl()).toString().toUtf8();
+ break;
+ default:
+ qWarning() << "KConfigGroup::writeEntry - unhandled type" << value.typeName() << "in group" << name();
+ }
writeEntry(key, data, flags);
}
-void KConfigGroup::writeEntry( const QString& key, const QVariant& value, WriteConfigFlags flags )
+void KConfigGroup::writeEntry(const QString &key, const QVariant &value, WriteConfigFlags flags)
{
writeEntry(key.toUtf8().constData(), value, flags);
}
-void KConfigGroup::writeEntry(const QString& key, const QVariantList &list, WriteConfigFlags flags)
+void KConfigGroup::writeEntry(const QString &key, const QVariantList &list, WriteConfigFlags flags)
{
writeEntry(key.toUtf8().constData(), list, flags);
}
-void KConfigGroup::writeXdgListEntry(const QString& key, const QStringList &value, WriteConfigFlags pFlags)
+void KConfigGroup::writeXdgListEntry(const QString &key, const QStringList &value, WriteConfigFlags pFlags)
{
writeXdgListEntry(key.toUtf8().constData(), value, pFlags);
}
@@ -1067,12 +1106,12 @@ void KConfigGroup::writeXdgListEntry(const char *key, const QStringList &list, W
writeEntry(key, value, flags);
}
-void KConfigGroup::writePathEntry(const QString& pKey, const QString & path, WriteConfigFlags pFlags)
+void KConfigGroup::writePathEntry(const QString &pKey, const QString &path, WriteConfigFlags pFlags)
{
writePathEntry(pKey.toUtf8().constData(), path, pFlags);
}
-void KConfigGroup::writePathEntry(const char *pKey, const QString & path, WriteConfigFlags pFlags)
+void KConfigGroup::writePathEntry(const char *pKey, const QString &path, WriteConfigFlags pFlags)
{
Q_ASSERT_X(isValid(), "KConfigGroup::writePathEntry", "accessing an invalid group");
Q_ASSERT_X(!d->bConst, "KConfigGroup::writePathEntry", "writing to a read-only group");
@@ -1080,7 +1119,7 @@ void KConfigGroup::writePathEntry(const char *pKey, const QString & path, WriteC
config()->d_func()->putData(d->fullName(), pKey, translatePath(path).toUtf8(), pFlags, true);
}
-void KConfigGroup::writePathEntry(const QString& pKey, const QStringList &value, WriteConfigFlags pFlags)
+void KConfigGroup::writePathEntry(const QString &pKey, const QStringList &value, WriteConfigFlags pFlags)
{
writePathEntry(pKey.toUtf8().constData(), value, pFlags);
}
@@ -1091,13 +1130,14 @@ void KConfigGroup::writePathEntry(const char *pKey, const QStringList &value, Wr
Q_ASSERT_X(!d->bConst, "KConfigGroup::writePathEntry", "writing to a read-only group");
QList<QByteArray> list;
- Q_FOREACH(const QString& path, value)
+ Q_FOREACH (const QString &path, value) {
list << translatePath(path).toUtf8();
+ }
config()->d_func()->putData(d->fullName(), pKey, KConfigGroupPrivate::serializeList(list), pFlags, true);
}
-void KConfigGroup::deleteEntry( const char *key, WriteConfigFlags flags)
+void KConfigGroup::deleteEntry(const char *key, WriteConfigFlags flags)
{
Q_ASSERT_X(isValid(), "KConfigGroup::deleteEntry", "accessing an invalid group");
Q_ASSERT_X(!d->bConst, "KConfigGroup::deleteEntry", "deleting from a read-only group");
@@ -1105,7 +1145,7 @@ void KConfigGroup::deleteEntry( const char *key, WriteConfigFlags flags)
config()->d_func()->putData(d->fullName(), key, QByteArray(), flags);
}
-void KConfigGroup::deleteEntry( const QString& key, WriteConfigFlags flags)
+void KConfigGroup::deleteEntry(const QString &key, WriteConfigFlags flags)
{
deleteEntry(key.toUtf8().constData(), flags);
}
@@ -1127,7 +1167,7 @@ bool KConfigGroup::hasDefault(const char *key) const
{
Q_ASSERT_X(isValid(), "KConfigGroup::hasDefault", "accessing an invalid group");
- KEntryMap::SearchFlags flags = KEntryMap::SearchDefaults|KEntryMap::SearchLocalized;
+ KEntryMap::SearchFlags flags = KEntryMap::SearchDefaults | KEntryMap::SearchLocalized;
return !config()->d_func()->lookupData(d->fullName(), key, flags).isNull();
}
@@ -1142,15 +1182,16 @@ bool KConfigGroup::hasKey(const char *key) const
Q_ASSERT_X(isValid(), "KConfigGroup::hasKey", "accessing an invalid group");
KEntryMap::SearchFlags flags = KEntryMap::SearchLocalized;
- if ( config()->readDefaults() )
+ if (config()->readDefaults()) {
flags |= KEntryMap::SearchDefaults;
+ }
return !config()->d_func()->lookupData(d->fullName(), key, flags).isNull();
}
bool KConfigGroup::hasKey(const QString &key) const
{
- return hasKey(key.toUtf8().constData());
+ return hasKey(key.toUtf8().constData());
}
bool KConfigGroup::isImmutable() const
@@ -1188,7 +1229,7 @@ KConfigGroup::AccessMode KConfigGroup::accessMode() const
return config()->accessMode();
}
-bool KConfigGroup::hasGroupImpl(const QByteArray & b) const
+bool KConfigGroup::hasGroupImpl(const QByteArray &b) const
{
Q_ASSERT_X(isValid(), "KConfigGroup::hasGroupImpl", "accessing an invalid group");
@@ -1198,29 +1239,30 @@ bool KConfigGroup::hasGroupImpl(const QByteArray & b) const
void KConfigGroup::deleteGroupImpl(const QByteArray &b, WriteConfigFlags flags)
{
Q_ASSERT_X(isValid(), "KConfigGroup::deleteGroupImpl", "accessing an invalid group");
- Q_ASSERT_X(!d->bConst,"KConfigGroup::deleteGroupImpl", "deleting from a read-only group");
+ Q_ASSERT_X(!d->bConst, "KConfigGroup::deleteGroupImpl", "deleting from a read-only group");
config()->deleteGroup(d->fullName(b), flags);
}
-bool KConfigGroup::isGroupImmutableImpl(const QByteArray& b) const
+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.
+ if (!hasGroupImpl(b)) { // group doesn't exist yet
+ return d->bImmutable; // child groups are immutable if the parent is immutable.
+ }
return config()->isGroupImmutable(d->fullName(b));
}
-void KConfigGroup::copyTo(KConfigBase* other, WriteConfigFlags pFlags) const
+void KConfigGroup::copyTo(KConfigBase *other, WriteConfigFlags pFlags) const
{
Q_ASSERT_X(isValid(), "KConfigGroup::copyTo", "accessing an invalid group");
Q_ASSERT(other != 0);
- if (KConfigGroup *otherGroup = dynamic_cast<KConfigGroup*>(other)) {
+ if (KConfigGroup *otherGroup = dynamic_cast<KConfigGroup *>(other)) {
config()->d_func()->copyGroup(d->fullName(), otherGroup->d->fullName(), otherGroup, pFlags);
- } else if (KConfig* otherConfig = dynamic_cast<KConfig*>(other)) {
+ } else if (KConfig *otherConfig = dynamic_cast<KConfig *>(other)) {
KConfigGroup newGroup = otherConfig->group(d->fullName());
otherConfig->d_func()->copyGroup(d->fullName(), d->fullName(), &newGroup, pFlags);
} else {
@@ -1228,7 +1270,7 @@ void KConfigGroup::copyTo(KConfigBase* other, WriteConfigFlags pFlags) const
}
}
-void KConfigGroup::reparent(KConfigBase* parent, WriteConfigFlags pFlags)
+void KConfigGroup::reparent(KConfigBase *parent, WriteConfigFlags pFlags)
{
Q_ASSERT_X(isValid(), "KConfigGroup::reparent", "accessing an invalid group");
Q_ASSERT_X(!d->bConst, "KConfigGroup::reparent", "reparenting a read-only group");
diff --git a/src/core/kconfiggroup.h b/src/core/kconfiggroup.h
index ce0330be..cc8a51b1 100644
--- a/src/core/kconfiggroup.h
+++ b/src/core/kconfiggroup.h
@@ -135,11 +135,11 @@ public:
/**
* Return the config object that this group belongs to
*/
- KConfig* config();
+ KConfig *config();
/**
* Return the config object that this group belongs to
*/
- const KConfig* config() const;
+ const KConfig *config() const;
/**
* Changes the group of the object
@@ -243,12 +243,16 @@ public:
* @see writeEntry(), deleteEntry(), hasKey()
*/
template <typename T>
- inline T readEntry(const QString &key, const T &aDefault) const
- { return readCheck(key.toUtf8().constData(), aDefault); }
+ inline T readEntry(const QString &key, const T &aDefault) const
+ {
+ return readCheck(key.toUtf8().constData(), aDefault);
+ }
/** Overload for readEntry(const QString&, const T&) const */
template <typename T>
- inline T readEntry(const char *key, const T &aDefault) const
- { return readCheck(key, aDefault); }
+ inline T readEntry(const char *key, const T &aDefault) const
+ {
+ return readCheck(key, aDefault);
+ }
/**
* Reads the value of an entry specified by @p key in the current group
@@ -318,12 +322,16 @@ public:
* @see readXdgListEntry(), writeEntry(), deleteEntry(), hasKey()
*/
template<typename T>
- inline QList<T> readEntry(const QString &key, const QList<T> &aDefault) const
- { return readListCheck(key.toUtf8().constData(), aDefault); }
+ inline QList<T> readEntry(const QString &key, const QList<T> &aDefault) const
+ {
+ return readListCheck(key.toUtf8().constData(), aDefault);
+ }
/** Overload for readEntry(const QString&, const QList<T>&) */
template<typename T>
- inline QList<T> readEntry(const char *key, const QList<T> &aDefault) const
- { return readListCheck(key, aDefault); }
+ inline QList<T> readEntry(const char *key, const QList<T> &aDefault) const
+ {
+ return readListCheck(key, aDefault);
+ }
/**
* Reads a list of strings from the config object, following XDG
@@ -420,12 +428,16 @@ public:
/** Overload for writeEntry(const QString&, const QVariant&, WriteConfigFlags) */
template <typename T>
- inline void writeEntry(const char *key, const T &value, WriteConfigFlags pFlags = Normal)
- { writeCheck( key, value, pFlags ); }
+ inline void writeEntry(const char *key, const T &value, WriteConfigFlags pFlags = Normal)
+ {
+ writeCheck(key, value, pFlags);
+ }
/** Overload for writeEntry(const QString&, const QVariant&, WriteConfigFlags) */
template <typename T>
- inline void writeEntry(const QString &key, const T &value, WriteConfigFlags pFlags = Normal)
- { writeCheck( key.toUtf8().constData(), value, pFlags ); }
+ inline void writeEntry(const QString &key, const T &value, WriteConfigFlags pFlags = Normal)
+ {
+ writeCheck(key.toUtf8().constData(), value, pFlags);
+ }
/** Overload for writeEntry(const QString&, const QVariant&, WriteConfigFlags) */
void writeEntry(const QString &key, const QStringList &value,
@@ -443,12 +455,16 @@ public:
/** Overload for writeEntry(const QString&, const QVariant&, WriteConfigFlags) */
template <typename T>
- inline void writeEntry(const QString &key, const QList<T> &value, WriteConfigFlags pFlags = Normal)
- { writeListCheck( key.toUtf8().constData(), value, pFlags ); }
+ inline void writeEntry(const QString &key, const QList<T> &value, WriteConfigFlags pFlags = Normal)
+ {
+ writeListCheck(key.toUtf8().constData(), value, pFlags);
+ }
/** Overload for writeEntry(const QString&, const QVariant&, WriteConfigFlags) */
template <typename T>
- inline void writeEntry(const char *key, const QList<T> &value, WriteConfigFlags pFlags = Normal)
- { writeListCheck( key, value, pFlags ); }
+ inline void writeEntry(const char *key, const QList<T> &value, WriteConfigFlags pFlags = Normal)
+ {
+ writeListCheck(key, value, pFlags);
+ }
/**
* Writes a list of strings to the config object, following XDG
@@ -576,7 +592,7 @@ public:
*/
void revertToDefault(const QString &key);
/** Overload for revertToDefault(const QString&) */
- void revertToDefault(const char* key);
+ void revertToDefault(const char *key);
/**
* Whether a default is specified for an entry in either the
@@ -657,8 +673,8 @@ private:
};
#define KCONFIGGROUP_ENUMERATOR_ERROR(ENUM) \
-"The Qt MetaObject system does not seem to know about \"" ENUM \
-"\" please use Q_ENUMS or Q_FLAGS to register it."
+ "The Qt MetaObject system does not seem to know about \"" ENUM \
+ "\" please use Q_ENUMS or Q_FLAGS to register it."
/**
* To add support for your own enums in KConfig, you can declare them with Q_ENUMS()
@@ -672,74 +688,75 @@ private:
*
*/
#define KCONFIGGROUP_DECLARE_ENUM_QOBJECT(Class, Enum) \
-inline Class::Enum readEntry(const KConfigGroup& group, const char* key, const Class::Enum& def) \
-{ \
-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 = group.readEntry(key, QByteArray(M_enum.valueToKey(def)));\
-return static_cast<Class::Enum>(M_enum.keyToValue(M_data.constData())); \
-} \
-inline void writeEntry(KConfigGroup& group, const char* key, const Class::Enum& value, KConfigBase::WriteConfigFlags flags = KConfigBase::Normal)\
-{ \
-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); \
-group.writeEntry(key, QByteArray(M_enum.valueToKey(value)), flags); \
-}
+ inline Class::Enum readEntry(const KConfigGroup& group, const char* key, const Class::Enum& def) \
+ { \
+ 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 = group.readEntry(key, QByteArray(M_enum.valueToKey(def)));\
+ return static_cast<Class::Enum>(M_enum.keyToValue(M_data.constData())); \
+ } \
+ inline void writeEntry(KConfigGroup& group, const char* key, const Class::Enum& value, KConfigBase::WriteConfigFlags flags = KConfigBase::Normal)\
+ { \
+ 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); \
+ group.writeEntry(key, QByteArray(M_enum.valueToKey(value)), flags); \
+ }
/**
* Similar to KCONFIGGROUP_DECLARE_ENUM_QOBJECT but for flags declared with Q_FLAGS()
* (where multiple values can be set at the same time)
*/
#define KCONFIGGROUP_DECLARE_FLAGS_QOBJECT(Class, Flags) \
-inline Class::Flags readEntry(const KConfigGroup& group, const char* key, const Class::Flags& def) \
-{ \
-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 = group.readEntry(key, QByteArray(M_enum.valueToKeys(def)));\
-return static_cast<Class::Flags>(M_enum.keysToValue(M_data.constData())); \
-} \
-inline void writeEntry(KConfigGroup& group, const char* key, const Class::Flags& value, KConfigBase::WriteConfigFlags flags = KConfigBase::Normal)\
-{ \
-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); \
-group.writeEntry(key, QByteArray(M_enum.valueToKeys(value)), flags); \
-}
+ inline Class::Flags readEntry(const KConfigGroup& group, const char* key, const Class::Flags& def) \
+ { \
+ 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 = group.readEntry(key, QByteArray(M_enum.valueToKeys(def)));\
+ return static_cast<Class::Flags>(M_enum.keysToValue(M_data.constData())); \
+ } \
+ inline void writeEntry(KConfigGroup& group, const char* key, const Class::Flags& value, KConfigBase::WriteConfigFlags flags = KConfigBase::Normal)\
+ { \
+ 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); \
+ group.writeEntry(key, QByteArray(M_enum.valueToKeys(value)), flags); \
+ }
#include "conversion_check.h"
template <typename T>
T KConfigGroup::readCheck(const char *key, const T &defaultValue) const
{
- ConversionCheck::to_QVariant<T>();
- return qvariant_cast<T>(readEntry(key, qVariantFromValue(defaultValue)));
+ ConversionCheck::to_QVariant<T>();
+ return qvariant_cast<T>(readEntry(key, qVariantFromValue(defaultValue)));
}
template <typename T>
QList<T> KConfigGroup::readListCheck(const char *key, const QList<T> &defaultValue) const
{
- ConversionCheck::to_QVariant<T>();
- ConversionCheck::to_QString<T>();
+ ConversionCheck::to_QVariant<T>();
+ ConversionCheck::to_QString<T>();
- QVariantList data;
+ QVariantList data;
- Q_FOREACH(const T& value, defaultValue)
- data.append(qVariantFromValue(value));
+ Q_FOREACH (const T &value, defaultValue) {
+ data.append(qVariantFromValue(value));
+ }
- QList<T> list;
- Q_FOREACH (const QVariant &value, readEntry<QVariantList>(key, data)) {
- Q_ASSERT(value.canConvert<T>());
- list.append(qvariant_cast<T>(value));
- }
+ QList<T> list;
+ Q_FOREACH (const QVariant &value, readEntry<QVariantList>(key, data)) {
+ Q_ASSERT(value.canConvert<T>());
+ list.append(qvariant_cast<T>(value));
+ }
- return list;
+ return list;
}
template <typename T>
@@ -754,14 +771,14 @@ template <typename T>
void KConfigGroup::writeListCheck(const char *key, const QList<T> &list,
WriteConfigFlags pFlags)
{
- ConversionCheck::to_QVariant<T>();
- ConversionCheck::to_QString<T>();
- QVariantList data;
- Q_FOREACH(const T &value, list) {
- data.append(qVariantFromValue(value));
- }
-
- writeEntry(key, data, pFlags);
+ ConversionCheck::to_QVariant<T>();
+ ConversionCheck::to_QString<T>();
+ QVariantList data;
+ Q_FOREACH (const T &value, list) {
+ data.append(qVariantFromValue(value));
+ }
+
+ writeEntry(key, data, pFlags);
}
#endif // KCONFIGGROUP_H
diff --git a/src/core/kconfiggroup_p.h b/src/core/kconfiggroup_p.h
index c5d4f150..edc59cc8 100644
--- a/src/core/kconfiggroup_p.h
+++ b/src/core/kconfiggroup_p.h
@@ -26,11 +26,10 @@
class KConfigGroup;
-struct KConfigGroupGui
-{
- typedef bool (*kReadEntryGui)(const QByteArray& data, const char* key, const QVariant &input,
+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,
+ typedef bool (*kWriteEntryGui)(KConfigGroup *, const char *key, const QVariant &input,
KConfigGroup::WriteConfigFlags flags);
kReadEntryGui readEntryGui;
diff --git a/src/core/kconfigini.cpp b/src/core/kconfigini.cpp
index f44b2c39..71a8a653 100644
--- a/src/core/kconfigini.cpp
+++ b/src/core/kconfigini.cpp
@@ -47,11 +47,11 @@ KCONFIGCORE_EXPORT bool kde_kiosk_exception = false; // flag to disable kiosk re
QString KConfigIniBackend::warningProlog(const QFile &file, int line)
{
return QString::fromLatin1("KConfigIni: In file %2, line %1: ")
- .arg(line).arg(file.fileName());
+ .arg(line).arg(file.fileName());
}
KConfigIniBackend::KConfigIniBackend()
- : KConfigBackend(), lockFile(NULL)
+ : KConfigBackend(), lockFile(NULL)
{
}
@@ -60,8 +60,8 @@ KConfigIniBackend::~KConfigIniBackend()
}
KConfigBackend::ParseInfo
- KConfigIniBackend::parseConfig(const QByteArray& currentLocale, KEntryMap& entryMap,
- ParseOptions options)
+KConfigIniBackend::parseConfig(const QByteArray &currentLocale, KEntryMap &entryMap,
+ ParseOptions options)
{
return parseConfig(currentLocale, entryMap, options, false);
}
@@ -69,20 +69,22 @@ KConfigBackend::ParseInfo
// 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& currentLocale, KEntryMap& entryMap,
+KConfigIniBackend::parseConfig(const QByteArray &currentLocale, KEntryMap &entryMap,
ParseOptions options, bool merging)
{
- if (filePath().isEmpty() || !QFile::exists(filePath()))
+ if (filePath().isEmpty() || !QFile::exists(filePath())) {
return ParseOk;
+ }
- bool bDefault = options&ParseDefaults;
- bool allowExecutableValues = options&ParseExpansions;
+ bool bDefault = options & ParseDefaults;
+ bool allowExecutableValues = options & ParseExpansions;
QByteArray currentGroup("<default>");
QFile file(filePath());
- if (!file.open(QIODevice::ReadOnly|QIODevice::Text))
+ if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
return ParseOpenError;
+ }
QList<QByteArray> immutableGroups;
@@ -104,8 +106,9 @@ KConfigIniBackend::parseConfig(const QByteArray& currentLocale, KEntryMap& entry
lineNo++;
// skip empty lines and lines beginning with '#'
- if (line.isEmpty() || line.at(0) == '#')
+ if (line.isEmpty() || line.at(0) == '#') {
continue;
+ }
if (line.at(0) == '[') { // found a group
groupOptionImmutable = fileOptionImmutable;
@@ -120,22 +123,23 @@ KConfigIniBackend::parseConfig(const QByteArray& currentLocale, KEntryMap& entry
// XXX maybe reset the current group here?
goto next_line;
}
- if (line.at(end) == ']')
+ if (line.at(end) == ']') {
break;
+ }
end++;
}
if (end + 1 == line.length() && start + 2 == end &&
- line.at(start) == '$' && line.at(start + 1) == 'i')
- {
- if (newGroup.isEmpty())
+ line.at(start) == '$' && line.at(start + 1) == 'i') {
+ if (newGroup.isEmpty()) {
fileOptionImmutable = !kde_kiosk_exception;
- else
+ } else {
groupOptionImmutable = !kde_kiosk_exception;
- }
- else {
- if (!newGroup.isEmpty())
+ }
+ } else {
+ if (!newGroup.isEmpty()) {
newGroup += '\x1d';
- BufferFragment namePart=line.mid(start, end - start);
+ }
+ BufferFragment namePart = line.mid(start, end - start);
printableToString(&namePart, file, lineNo);
newGroup += namePart.toByteArray();
}
@@ -144,16 +148,20 @@ KConfigIniBackend::parseConfig(const QByteArray& currentLocale, KEntryMap& entry
groupSkip = entryMap.getEntryOption(currentGroup, 0, 0, KEntryMap::EntryImmutable);
- if (groupSkip && !bDefault)
+ if (groupSkip && !bDefault) {
continue;
+ }
if (groupOptionImmutable)
// 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
+ if (groupSkip && !bDefault) {
+ continue; // skip entry
+ }
BufferFragment aKey;
int eqpos = line.indexOf('=');
@@ -171,9 +179,10 @@ KConfigIniBackend::parseConfig(const QByteArray& currentLocale, KEntryMap& entry
continue;
}
- KEntryMap::EntryOptions entryOptions=0;
- if (groupOptionImmutable)
+ KEntryMap::EntryOptions entryOptions = 0;
+ if (groupOptionImmutable) {
entryOptions |= KEntryMap::EntryImmutable;
+ }
BufferFragment locale;
int start;
@@ -181,39 +190,41 @@ KConfigIniBackend::parseConfig(const QByteArray& currentLocale, KEntryMap& entry
int end = aKey.indexOf(']', start);
if (end < 0) {
qWarning() << warningProlog(file, lineNo)
- << "Invalid entry (missing ']')";
+ << "Invalid entry (missing ']')";
goto next_line;
} else if (end > start + 1 && aKey.at(start + 1) == '$') { // found option(s)
int i = start + 2;
while (i < end) {
switch (aKey.at(i)) {
- case 'i':
- if (!kde_kiosk_exception)
- entryOptions |= KEntryMap::EntryImmutable;
- break;
- case 'e':
- if (allowExecutableValues)
- entryOptions |= KEntryMap::EntryExpansion;
- break;
- case 'd':
- entryOptions |= KEntryMap::EntryDeleted;
- aKey = aKey.left(start);
- printableToString(&aKey, file, lineNo);
- entryMap.setEntry(currentGroup, aKey.toByteArray(), QByteArray(), entryOptions);
- goto next_line;
- default:
- break;
+ case 'i':
+ if (!kde_kiosk_exception) {
+ entryOptions |= KEntryMap::EntryImmutable;
+ }
+ break;
+ case 'e':
+ if (allowExecutableValues) {
+ entryOptions |= KEntryMap::EntryExpansion;
+ }
+ break;
+ case 'd':
+ entryOptions |= KEntryMap::EntryDeleted;
+ aKey = aKey.left(start);
+ printableToString(&aKey, file, lineNo);
+ entryMap.setEntry(currentGroup, aKey.toByteArray(), QByteArray(), entryOptions);
+ goto next_line;
+ default:
+ break;
}
i++;
}
} else { // found a locale
if (!locale.isNull()) {
qWarning() << warningProlog(file, lineNo)
- << "Invalid entry (second locale!?)";
+ << "Invalid entry (second locale!?)";
goto next_line;
}
- locale = aKey.mid(start + 1,end - start - 1);
+ locale = aKey.mid(start + 1, end - start - 1);
}
aKey.truncate(start);
}
@@ -226,23 +237,28 @@ KConfigIniBackend::parseConfig(const QByteArray& currentLocale, KEntryMap& entry
if (locale != currentLocale) {
// backward compatibility. C == en_US
if (locale.at(0) != 'C' || currentLocale != "en_US") {
- if (merging)
+ if (merging) {
entryOptions |= KEntryMap::EntryRawKey;
- else
- goto next_line; // skip this entry if we're not merging
+ } else {
+ goto next_line; // skip this entry if we're not merging
+ }
}
}
}
- if (!(entryOptions & KEntryMap::EntryRawKey))
+ if (!(entryOptions & KEntryMap::EntryRawKey)) {
printableToString(&aKey, file, lineNo);
+ }
- if (options&ParseGlobal)
+ if (options & ParseGlobal) {
entryOptions |= KEntryMap::EntryGlobal;
- if (bDefault)
+ }
+ if (bDefault) {
entryOptions |= KEntryMap::EntryDefault;
- if (!locale.isNull())
+ }
+ if (!locale.isNull()) {
entryOptions |= KEntryMap::EntryLocalized;
+ }
printableToString(&line, file, lineNo);
if (entryOptions & KEntryMap::EntryRawKey) {
QByteArray rawKey;
@@ -254,30 +270,31 @@ KConfigIniBackend::parseConfig(const QByteArray& currentLocale, KEntryMap& entry
entryMap.setEntry(currentGroup, aKey.toByteArray(), line.toByteArray(), entryOptions);
}
}
-next_line:
+ next_line:
continue;
}
// now make sure immutable groups are marked immutable
- Q_FOREACH(const QByteArray& group, immutableGroups) {
+ Q_FOREACH (const QByteArray &group, immutableGroups) {
entryMap.setEntry(group, QByteArray(), QByteArray(), KEntryMap::EntryImmutable);
}
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;
const KEntryMapConstIterator end = map.constEnd();
for (KEntryMapConstIterator it = map.constBegin(); it != end; ++it) {
- const KEntryKey& key = it.key();
+ const KEntryKey &key = it.key();
// Either process the default group or all others
- if ((key.mGroup != "<default>") == defaultGroup)
- continue; // skip
+ if ((key.mGroup != "<default>") == defaultGroup) {
+ continue; // skip
+ }
// the only thing we care about groups is, is it immutable?
if (key.mKey.isNull()) {
@@ -285,10 +302,11 @@ void KConfigIniBackend::writeEntries(const QByteArray& locale, QIODevice& file,
continue; // skip
}
- const KEntry& currentEntry = *it;
+ const KEntry &currentEntry = *it;
if (!defaultGroup && currentGroup != key.mGroup) {
- if (!firstEntry)
+ if (!firstEntry) {
file.putChar('\n');
+ }
currentGroup = key.mGroup;
for (int start = 0, end;; start = end + 1) {
file.putChar('[');
@@ -298,13 +316,14 @@ void KConfigIniBackend::writeEntries(const QByteArray& locale, QIODevice& file,
if (currentGroup.at(start) == '$' && cgl - start <= 10) {
for (int i = start + 1; i < cgl; i++) {
char c = currentGroup.at(i);
- if (c < 'a' || c > 'z')
+ if (c < 'a' || c > 'z') {
goto nope;
+ }
}
file.write("\\x24");
start++;
}
- nope:
+ nope:
file.write(stringToPrintable(currentGroup.mid(start), GroupString));
file.putChar(']');
if (groupIsImmutable) {
@@ -322,9 +341,9 @@ void KConfigIniBackend::writeEntries(const QByteArray& locale, QIODevice& file,
firstEntry = false;
// it is data for a group
- if (key.bRaw) // unprocessed key with attached locale from merge
+ if (key.bRaw) { // unprocessed key with attached locale from merge
file.write(key.mKey);
- else {
+ } else {
file.write(stringToPrintable(key.mKey, KeyString)); // Key
if (key.bLocal && locale != "C") { // 'C' locale == untranslated
file.putChar('[');
@@ -333,17 +352,20 @@ void KConfigIniBackend::writeEntries(const QByteArray& locale, QIODevice& file,
}
}
if (currentEntry.bDeleted) {
- if (currentEntry.bImmutable)
- file.write("[$di]", 5); // Deleted + immutable
- else
- file.write("[$d]", 4); // Deleted
+ if (currentEntry.bImmutable) {
+ file.write("[$di]", 5); // Deleted + immutable
+ } else {
+ file.write("[$d]", 4); // Deleted
+ }
} else {
if (currentEntry.bImmutable || currentEntry.bExpand) {
file.write("[$", 2);
- if (currentEntry.bImmutable)
+ if (currentEntry.bImmutable) {
file.putChar('i');
- if (currentEntry.bExpand)
+ }
+ if (currentEntry.bExpand) {
file.putChar('e');
+ }
file.putChar(']');
}
file.putChar('=');
@@ -353,7 +375,7 @@ void KConfigIniBackend::writeEntries(const QByteArray& locale, QIODevice& file,
}
}
-void KConfigIniBackend::writeEntries(const QByteArray& locale, QIODevice& file, const KEntryMap& map)
+void KConfigIniBackend::writeEntries(const QByteArray &locale, QIODevice &file, const KEntryMap &map)
{
bool firstEntry = true;
@@ -364,7 +386,7 @@ void KConfigIniBackend::writeEntries(const QByteArray& locale, QIODevice& file,
writeEntries(locale, file, map, false, firstEntry);
}
-bool KConfigIniBackend::writeConfig(const QByteArray& locale, KEntryMap& entryMap,
+bool KConfigIniBackend::writeConfig(const QByteArray &locale, KEntryMap &entryMap,
WriteOptions options)
{
Q_ASSERT(!filePath().isEmpty());
@@ -376,19 +398,22 @@ bool KConfigIniBackend::writeConfig(const QByteArray& locale, KEntryMap& entryMa
// Store the result into writeMap.
{
ParseOptions opts = ParseExpansions;
- if (bGlobal)
+ if (bGlobal) {
opts |= ParseGlobal;
+ }
ParseInfo info = parseConfig(locale, writeMap, opts, true);
- if (info != ParseOk) // either there was an error or the file became immutable
+ if (info != ParseOk) { // either there was an error or the file became immutable
return false;
+ }
}
const KEntryMapIterator end = entryMap.end();
- for (KEntryMapIterator it=entryMap.begin(); it != end; ++it) {
- if (!it.key().mKey.isEmpty() && !it->bDirty) // not dirty, doesn't overwrite entry in writeMap. skips default entries, too.
+ for (KEntryMapIterator it = entryMap.begin(); it != end; ++it) {
+ if (!it.key().mKey.isEmpty() && !it->bDirty) { // not dirty, doesn't overwrite entry in writeMap. skips default entries, too.
continue;
+ }
- const KEntryKey& key = it.key();
+ const KEntryKey &key = it.key();
// only write entries that have the same "globality" as the file
if (it->bGlobal == bGlobal) {
@@ -419,19 +444,15 @@ bool KConfigIniBackend::writeConfig(const QByteArray& locale, KEntryMap& entryMa
bool createNew = true;
QFileInfo fi(filePath());
- if (fi.exists())
- {
+ if (fi.exists()) {
#ifdef Q_OS_WIN
//TODO: getuid does not exist on windows, use GetSecurityInfo and GetTokenInformation instead
createNew = false;
#else
- if (fi.ownerId() == ::getuid())
- {
+ if (fi.ownerId() == ::getuid()) {
// Preserve file mode if file exists and is owned by user.
fileMode = fi.permissions();
- }
- else
- {
+ } else {
// File is not owned by user:
// Don't create new file but write to existing file instead.
createNew = false;
@@ -490,9 +511,9 @@ bool KConfigIniBackend::writeConfig(const QByteArray& locale, KEntryMap& entryMa
f.close();
fclose(fp);
#else
- QFile f( filePath() );
+ QFile f(filePath());
// XXX This is broken - it DOES create the file if it is suddenly gone.
- if (!f.open( QIODevice::WriteOnly | QIODevice::Truncate )) {
+ if (!f.open(QIODevice::WriteOnly | QIODevice::Truncate)) {
return false;
}
f.setTextModeEnabled(true);
@@ -502,7 +523,6 @@ bool KConfigIniBackend::writeConfig(const QByteArray& locale, KEntryMap& entryMa
return true;
}
-
bool KConfigIniBackend::isWritable() const
{
const QString filePath = this->filePath();
@@ -537,18 +557,20 @@ QString KConfigIniBackend::nonWritableErrorMessage() const
void KConfigIniBackend::createEnclosing()
{
const QString file = filePath();
- if (file.isEmpty())
- return; // nothing to do
+ if (file.isEmpty()) {
+ return; // nothing to do
+ }
// Create the containing dir, maybe it wasn't there
QDir dir;
dir.mkpath(QFileInfo(file).absolutePath());
}
-void KConfigIniBackend::setFilePath(const QString& file)
+void KConfigIniBackend::setFilePath(const QString &file)
{
- if (file.isEmpty())
+ if (file.isEmpty()) {
return;
+ }
Q_ASSERT(QDir::isAbsolutePath(file));
@@ -568,11 +590,13 @@ void KConfigIniBackend::setFilePath(const QString& file)
KConfigBase::AccessMode KConfigIniBackend::accessMode() const
{
- if (filePath().isEmpty())
+ if (filePath().isEmpty()) {
return KConfigBase::NoAccess;
+ }
- if (isWritable())
+ if (isWritable()) {
return KConfigBase::ReadWrite;
+ }
return KConfigBase::ReadOnly;
}
@@ -608,15 +632,16 @@ bool KConfigIniBackend::isLocked() const
return lockFile && lockFile->isLocked();
}
-QByteArray KConfigIniBackend::stringToPrintable(const QByteArray& aString, StringType type)
+QByteArray KConfigIniBackend::stringToPrintable(const QByteArray &aString, StringType type)
{
static const char nibbleLookup[] = {
'0', '1', '2', '3', '4', '5', '6', '7',
'8', '9', 'a', 'b', 'c', 'd', 'e', 'f'
};
- if (aString.isEmpty())
+ if (aString.isEmpty()) {
return aString;
+ }
const int l = aString.length();
QByteArray result; // Guesstimated that it's good to avoid data() initialization for a length of l*4
@@ -635,47 +660,48 @@ QByteArray KConfigIniBackend::stringToPrintable(const QByteArray& aString, Strin
for (; i < l; ++i/*, r++*/) {
switch (s[i]) {
- default:
+ default:
// The \n, \t, \r cases (all < 32) are handled below; we can ignore them here
- if (((unsigned char)s[i]) < 32)
- goto doEscape;
+ if (((unsigned char)s[i]) < 32) {
+ goto doEscape;
+ }
+ *data++ = s[i];
+ break;
+ case '\n':
+ *data++ = '\\';
+ *data++ = 'n';
+ break;
+ case '\t':
+ *data++ = '\\';
+ *data++ = 't';
+ break;
+ case '\r':
+ *data++ = '\\';
+ *data++ = 'r';
+ break;
+ case '\\':
+ *data++ = '\\';
+ *data++ = '\\';
+ break;
+ case '=':
+ if (type != KeyString) {
*data++ = s[i];
break;
- case '\n':
- *data++ = '\\';
- *data++ = 'n';
- break;
- case '\t':
- *data++ = '\\';
- *data++ = 't';
- break;
- case '\r':
- *data++ = '\\';
- *data++ = 'r';
- break;
- case '\\':
- *data++ = '\\';
- *data++ = '\\';
- break;
- case '=':
- if (type != KeyString) {
- *data++ = s[i];
- break;
- }
- goto doEscape;
- case '[':
- case ']':
+ }
+ goto doEscape;
+ case '[':
+ case ']':
// Above chars are OK to put in *value* strings as plaintext
- if (type == ValueString) {
- *data++ = s[i];
- break;
- }
- doEscape:
- *data++ = '\\';
- *data++ = 'x';
- *data++ = nibbleLookup[((unsigned char)s[i]) >> 4];
- *data++ = nibbleLookup[((unsigned char)s[i]) & 0x0f];
+ if (type == ValueString) {
+ *data++ = s[i];
break;
+ }
+ doEscape:
+ *data++ = '\\';
+ *data++ = 'x';
+ *data++ = nibbleLookup[((unsigned char)s[i]) >> 4];
+ *data++ = nibbleLookup[((unsigned char)s[i]) & 0x0f];
+ break;
}
}
*data = 0;
@@ -690,7 +716,7 @@ QByteArray KConfigIniBackend::stringToPrintable(const QByteArray& aString, Strin
return result;
}
-char KConfigIniBackend::charFromHex(const char *str, const QFile& file, int line)
+char KConfigIniBackend::charFromHex(const char *str, const QFile &file, int line)
{
unsigned char ret = 0;
for (int i = 0; i < 2; i++) {
@@ -707,25 +733,26 @@ char KConfigIniBackend::charFromHex(const char *str, const QFile& file, int line
QByteArray e(str, 2);
e.prepend("\\x");
qWarning() << warningProlog(file, line) << "Invalid hex character " << c
- << " in \\x<nn>-type escape sequence \"" << e.constData() << "\".";
+ << " in \\x<nn>-type escape sequence \"" << e.constData() << "\".";
return 'x';
}
}
return char(ret);
}
-void KConfigIniBackend::printableToString(BufferFragment* aString, const QFile& file, int line)
+void KConfigIniBackend::printableToString(BufferFragment *aString, const QFile &file, int line)
{
- if (aString->isEmpty() || aString->indexOf('\\')==-1)
+ if (aString->isEmpty() || aString->indexOf('\\') == -1) {
return;
+ }
aString->trim();
int l = aString->length();
char *r = aString->data();
- char *str=r;
+ char *str = r;
- for(int i = 0; i < l; i++, r++) {
- if (str[i]!= '\\') {
- *r=str[i];
+ for (int i = 0; i < l; i++, r++) {
+ if (str[i] != '\\') {
+ *r = str[i];
} else {
// Probable escape sequence
i++;
@@ -734,35 +761,35 @@ void KConfigIniBackend::printableToString(BufferFragment* aString, const QFile&
break;
}
- switch(str[i]) {
- case 's':
- *r = ' ';
- break;
- case 't':
- *r = '\t';
- break;
- case 'n':
- *r = '\n';
- break;
- case 'r':
- *r = '\r';
- break;
- case '\\':
- *r = '\\';
- break;
- case 'x':
- if (i + 2 < l) {
- *r = charFromHex(str + i + 1, file, line);
- i += 2;
- } else {
- *r = 'x';
- i = l - 1;
- }
- break;
- default:
- *r = '\\';
- qWarning() << warningProlog(file, line)
- << QString::fromLatin1("Invalid escape sequence \"\\%1\".").arg(str[i]);
+ switch (str[i]) {
+ case 's':
+ *r = ' ';
+ break;
+ case 't':
+ *r = '\t';
+ break;
+ case 'n':
+ *r = '\n';
+ break;
+ case 'r':
+ *r = '\r';
+ break;
+ case '\\':
+ *r = '\\';
+ break;
+ case 'x':
+ if (i + 2 < l) {
+ *r = charFromHex(str + i + 1, file, line);
+ i += 2;
+ } else {
+ *r = 'x';
+ i = l - 1;
+ }
+ break;
+ default:
+ *r = '\\';
+ qWarning() << warningProlog(file, line)
+ << QString::fromLatin1("Invalid escape sequence \"\\%1\".").arg(str[i]);
}
}
}
diff --git a/src/core/kconfigini_p.h b/src/core/kconfigini_p.h
index 368a78fb..fb1aca16 100644
--- a/src/core/kconfigini_p.h
+++ b/src/core/kconfigini_p.h
@@ -40,21 +40,21 @@ public:
KConfigIniBackend();
~KConfigIniBackend();
- ParseInfo parseConfig(const QByteArray& locale,
- KEntryMap& entryMap,
+ ParseInfo parseConfig(const QByteArray &locale,
+ KEntryMap &entryMap,
ParseOptions options);
- ParseInfo parseConfig(const QByteArray& locale,
- KEntryMap& entryMap,
+ ParseInfo parseConfig(const QByteArray &locale,
+ KEntryMap &entryMap,
ParseOptions options,
bool merging);
- bool writeConfig(const QByteArray& locale, KEntryMap& entryMap,
+ bool writeConfig(const QByteArray &locale, KEntryMap &entryMap,
WriteOptions options);
bool isWritable() const;
QString nonWritableErrorMessage() const;
KConfigBase::AccessMode accessMode() const;
void createEnclosing();
- void setFilePath(const QString& path);
+ void setFilePath(const QString &path);
bool lock();
void unlock();
bool isLocked() const;
@@ -68,13 +68,13 @@ protected:
};
// Warning: this modifies data in-place. Other BufferFragment objects referencing the same buffer
// fragment will get their data modified too.
- static void printableToString(BufferFragment* aString, const QFile& file, int line);
- static QByteArray stringToPrintable(const QByteArray& aString, StringType type);
- static char charFromHex(const char *str, const QFile& file, int line);
- static QString warningProlog(const QFile& file, int line);
+ static void printableToString(BufferFragment *aString, const QFile &file, int line);
+ static QByteArray stringToPrintable(const QByteArray &aString, StringType type);
+ static char charFromHex(const char *str, const QFile &file, int line);
+ 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,
+ void writeEntries(const QByteArray &locale, QIODevice &file, const KEntryMap &map);
+ void writeEntries(const QByteArray &locale, QIODevice &file, const KEntryMap &map,
bool defaultGroup, bool &firstEntry);
};
diff --git a/src/core/kcoreconfigskeleton.cpp b/src/core/kcoreconfigskeleton.cpp
index 691e0b54..d9b95b4b 100644
--- a/src/core/kcoreconfigskeleton.cpp
+++ b/src/core/kcoreconfigskeleton.cpp
@@ -24,25 +24,24 @@
#include <QUrl>
-
static QString obscuredString(const QString &str)
{
QString result;
const QChar *unicode = str.unicode();
- for ( int i = 0; i < str.length(); ++i )
+ 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;
+ return result;
}
-KConfigSkeletonItem::KConfigSkeletonItem(const QString & _group,
- const QString & _key)
+KConfigSkeletonItem::KConfigSkeletonItem(const QString &_group,
+ const QString &_key)
: mGroup(_group)
, mKey(_key)
- , d( new KConfigSkeletonItemPrivate )
+ , d(new KConfigSkeletonItemPrivate)
{
}
@@ -51,7 +50,7 @@ KConfigSkeletonItem::~KConfigSkeletonItem()
delete d;
}
-void KConfigSkeletonItem::setGroup( const QString &_group )
+void KConfigSkeletonItem::setGroup(const QString &_group)
{
mGroup = _group;
}
@@ -61,7 +60,7 @@ QString KConfigSkeletonItem::group() const
return mGroup;
}
-void KConfigSkeletonItem::setKey( const QString &_key )
+void KConfigSkeletonItem::setKey(const QString &_key)
{
mKey = _key;
}
@@ -81,7 +80,7 @@ QString KConfigSkeletonItem::name() const
return mName;
}
-void KConfigSkeletonItem::setLabel( const QString &l )
+void KConfigSkeletonItem::setLabel(const QString &l)
{
d->mLabel = l;
}
@@ -91,7 +90,7 @@ QString KConfigSkeletonItem::label() const
return d->mLabel;
}
-void KConfigSkeletonItem::setToolTip( const QString &t )
+void KConfigSkeletonItem::setToolTip(const QString &t)
{
d->mToolTip = t;
}
@@ -101,7 +100,7 @@ QString KConfigSkeletonItem::toolTip() const
return d->mToolTip;
}
-void KConfigSkeletonItem::setWhatsThis( const QString &w )
+void KConfigSkeletonItem::setWhatsThis(const QString &w)
{
d->mWhatsThis = w;
}
@@ -126,64 +125,57 @@ bool KConfigSkeletonItem::isImmutable() const
return d->mIsImmutable;
}
-void KConfigSkeletonItem::readImmutability( const KConfigGroup &group )
+void KConfigSkeletonItem::readImmutability(const KConfigGroup &group)
{
- d->mIsImmutable = group.isEntryImmutable( mKey );
+ d->mIsImmutable = group.isEntryImmutable(mKey);
}
-
-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)
{
}
-void KCoreConfigSkeleton::ItemString::writeConfig( KConfig *config )
+void KCoreConfigSkeleton::ItemString::writeConfig(KConfig *config)
{
- if ( mReference != mLoadedValue ) // WABA: Is this test needed?
- {
- KConfigGroup cg(config, mGroup );
- if ((mDefault == mReference) && !cg.hasDefault( mKey))
- cg.revertToDefault( mKey );
- else if ( mType == Path )
- cg.writePathEntry( mKey, mReference );
- else if ( mType == Password )
- cg.writeEntry( mKey, obscuredString( mReference ) );
- else
- cg.writeEntry( mKey, mReference );
- }
+ if (mReference != mLoadedValue) { // WABA: Is this test needed?
+ KConfigGroup cg(config, mGroup);
+ if ((mDefault == mReference) && !cg.hasDefault(mKey)) {
+ cg.revertToDefault(mKey);
+ } else if (mType == Path) {
+ cg.writePathEntry(mKey, mReference);
+ } else if (mType == Password) {
+ cg.writeEntry(mKey, obscuredString(mReference));
+ } else {
+ cg.writeEntry(mKey, mReference);
+ }
+ }
}
-
-void KCoreConfigSkeleton::ItemString::readConfig( KConfig *config )
+void KCoreConfigSkeleton::ItemString::readConfig(KConfig *config)
{
- KConfigGroup cg(config, mGroup );
+ KConfigGroup cg(config, mGroup);
- if ( mType == Path )
- {
- mReference = cg.readPathEntry( mKey, mDefault );
- }
- else if ( mType == Password )
- {
- QString val = cg.readEntry( mKey, obscuredString( mDefault ) );
- mReference = obscuredString( val );
- }
- else
- {
- mReference = cg.readEntry( mKey, mDefault );
- }
+ if (mType == Path) {
+ mReference = cg.readPathEntry(mKey, mDefault);
+ } else if (mType == Password) {
+ QString val = cg.readEntry(mKey, obscuredString(mDefault));
+ mReference = obscuredString(val);
+ } else {
+ mReference = cg.readEntry(mKey, mDefault);
+ }
- mLoadedValue = mReference;
+ mLoadedValue = mReference;
- readImmutability( cg );
+ readImmutability(cg);
}
-void KCoreConfigSkeleton::ItemString::setProperty(const QVariant & p)
+void KCoreConfigSkeleton::ItemString::setProperty(const QVariant &p)
{
- mReference = p.toString();
+ mReference = p.toString();
}
bool KCoreConfigSkeleton::ItemString::isEqual(const QVariant &v) const
@@ -193,53 +185,53 @@ bool KCoreConfigSkeleton::ItemString::isEqual(const QVariant &v) const
QVariant KCoreConfigSkeleton::ItemString::property() const
{
- return QVariant(mReference);
+ return QVariant(mReference);
}
-KCoreConfigSkeleton::ItemPassword::ItemPassword( const QString &_group, const QString &_key,
- QString &reference,
- const QString &defaultValue)
- : ItemString( _group, _key, reference, defaultValue, Password )
+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)
- : ItemString( _group, _key, reference, defaultValue, Path )
+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 )
- : KConfigSkeletonGenericItem<QUrl>( _group, _key, reference, defaultValue )
+KCoreConfigSkeleton::ItemUrl::ItemUrl(const QString &_group, const QString &_key,
+ QUrl &reference,
+ const QUrl &defaultValue)
+ : KConfigSkeletonGenericItem<QUrl>(_group, _key, reference, defaultValue)
{
}
-void KCoreConfigSkeleton::ItemUrl::writeConfig( KConfig *config )
+void KCoreConfigSkeleton::ItemUrl::writeConfig(KConfig *config)
{
- if ( mReference != mLoadedValue ) // WABA: Is this test needed?
- {
- KConfigGroup cg(config, mGroup );
- if ((mDefault == mReference) && !cg.hasDefault( mKey))
- cg.revertToDefault( mKey );
- else
- cg.writeEntry<QString>( mKey, mReference.toString() );
+ if (mReference != mLoadedValue) { // WABA: Is this test needed?
+ KConfigGroup cg(config, mGroup);
+ if ((mDefault == mReference) && !cg.hasDefault(mKey)) {
+ cg.revertToDefault(mKey);
+ } else {
+ cg.writeEntry<QString>(mKey, mReference.toString());
+ }
}
}
-void KCoreConfigSkeleton::ItemUrl::readConfig( KConfig *config )
+void KCoreConfigSkeleton::ItemUrl::readConfig(KConfig *config)
{
- KConfigGroup cg(config, mGroup );
+ KConfigGroup cg(config, mGroup);
- mReference = QUrl( cg.readEntry<QString>( mKey, mDefault.toString() ) );
+ mReference = QUrl(cg.readEntry<QString>(mKey, mDefault.toString()));
mLoadedValue = mReference;
- readImmutability( cg );
+ readImmutability(cg);
}
-void KCoreConfigSkeleton::ItemUrl::setProperty(const QVariant & p)
+void KCoreConfigSkeleton::ItemUrl::setProperty(const QVariant &p)
{
mReference = qvariant_cast<QUrl>(p);
}
@@ -254,26 +246,26 @@ QVariant KCoreConfigSkeleton::ItemUrl::property() const
return qVariantFromValue<QUrl>(mReference);
}
-KCoreConfigSkeleton::ItemProperty::ItemProperty( const QString &_group,
- const QString &_key,
- QVariant &reference,
- const QVariant &defaultValue )
- : KConfigSkeletonGenericItem<QVariant>( _group, _key, reference, defaultValue )
+KCoreConfigSkeleton::ItemProperty::ItemProperty(const QString &_group,
+ const QString &_key,
+ QVariant &reference,
+ const QVariant &defaultValue)
+ : KConfigSkeletonGenericItem<QVariant>(_group, _key, reference, defaultValue)
{
}
-void KCoreConfigSkeleton::ItemProperty::readConfig( KConfig *config )
+void KCoreConfigSkeleton::ItemProperty::readConfig(KConfig *config)
{
- KConfigGroup cg(config, mGroup );
- mReference = cg.readEntry( mKey, mDefault );
- mLoadedValue = mReference;
+ KConfigGroup cg(config, mGroup);
+ mReference = cg.readEntry(mKey, mDefault);
+ mLoadedValue = mReference;
- readImmutability( cg );
+ readImmutability(cg);
}
-void KCoreConfigSkeleton::ItemProperty::setProperty(const QVariant & p)
+void KCoreConfigSkeleton::ItemProperty::setProperty(const QVariant &p)
{
- mReference = p;
+ mReference = p;
}
bool KCoreConfigSkeleton::ItemProperty::isEqual(const QVariant &v) const
@@ -284,27 +276,27 @@ bool KCoreConfigSkeleton::ItemProperty::isEqual(const QVariant &v) const
QVariant KCoreConfigSkeleton::ItemProperty::property() const
{
- return mReference;
+ return mReference;
}
-KCoreConfigSkeleton::ItemBool::ItemBool( const QString &_group, const QString &_key,
- bool &reference, bool defaultValue )
- : KConfigSkeletonGenericItem<bool>( _group, _key, reference, defaultValue )
+KCoreConfigSkeleton::ItemBool::ItemBool(const QString &_group, const QString &_key,
+ bool &reference, bool defaultValue)
+ : KConfigSkeletonGenericItem<bool>(_group, _key, reference, defaultValue)
{
}
-void KCoreConfigSkeleton::ItemBool::readConfig( KConfig *config )
+void KCoreConfigSkeleton::ItemBool::readConfig(KConfig *config)
{
- KConfigGroup cg(config, mGroup );
- mReference = cg.readEntry( mKey, mDefault );
- mLoadedValue = mReference;
+ KConfigGroup cg(config, mGroup);
+ mReference = cg.readEntry(mKey, mDefault);
+ mLoadedValue = mReference;
- readImmutability( cg );
+ readImmutability(cg);
}
-void KCoreConfigSkeleton::ItemBool::setProperty(const QVariant & p)
+void KCoreConfigSkeleton::ItemBool::setProperty(const QVariant &p)
{
- mReference = p.toBool();
+ mReference = p.toBool();
}
bool KCoreConfigSkeleton::ItemBool::isEqual(const QVariant &v) const
@@ -314,33 +306,34 @@ bool KCoreConfigSkeleton::ItemBool::isEqual(const QVariant &v) const
QVariant KCoreConfigSkeleton::ItemBool::property() const
{
- return QVariant( mReference );
+ return QVariant(mReference);
}
-
-KCoreConfigSkeleton::ItemInt::ItemInt( const QString &_group, const QString &_key,
- qint32 &reference, qint32 defaultValue )
- : KConfigSkeletonGenericItem<qint32>( _group, _key, reference, defaultValue )
- ,mHasMin(false), mHasMax(false)
+KCoreConfigSkeleton::ItemInt::ItemInt(const QString &_group, const QString &_key,
+ qint32 &reference, qint32 defaultValue)
+ : KConfigSkeletonGenericItem<qint32>(_group, _key, reference, defaultValue)
+ , mHasMin(false), mHasMax(false)
{
}
-void KCoreConfigSkeleton::ItemInt::readConfig( KConfig *config )
+void KCoreConfigSkeleton::ItemInt::readConfig(KConfig *config)
{
- KConfigGroup cg(config, mGroup );
- mReference = cg.readEntry( mKey, mDefault );
- if (mHasMin)
- mReference = qMax(mReference, mMin);
- if (mHasMax)
- mReference = qMin(mReference, mMax);
- mLoadedValue = mReference;
+ KConfigGroup cg(config, mGroup);
+ mReference = cg.readEntry(mKey, mDefault);
+ if (mHasMin) {
+ mReference = qMax(mReference, mMin);
+ }
+ if (mHasMax) {
+ mReference = qMin(mReference, mMax);
+ }
+ mLoadedValue = mReference;
- readImmutability( cg );
+ readImmutability(cg);
}
-void KCoreConfigSkeleton::ItemInt::setProperty(const QVariant & p)
+void KCoreConfigSkeleton::ItemInt::setProperty(const QVariant &p)
{
- mReference = p.toInt();
+ mReference = p.toInt();
}
bool KCoreConfigSkeleton::ItemInt::isEqual(const QVariant &v) const
@@ -350,59 +343,62 @@ bool KCoreConfigSkeleton::ItemInt::isEqual(const QVariant &v) const
QVariant KCoreConfigSkeleton::ItemInt::property() const
{
- return QVariant(mReference);
+ return QVariant(mReference);
}
QVariant KCoreConfigSkeleton::ItemInt::minValue() const
{
- if (mHasMin)
- return QVariant(mMin);
- return QVariant();
+ if (mHasMin) {
+ return QVariant(mMin);
+ }
+ return QVariant();
}
QVariant KCoreConfigSkeleton::ItemInt::maxValue() const
{
- if (mHasMax)
- return QVariant(mMax);
- return QVariant();
+ if (mHasMax) {
+ return QVariant(mMax);
+ }
+ return QVariant();
}
void KCoreConfigSkeleton::ItemInt::setMinValue(qint32 v)
{
- mHasMin = true;
- mMin = v;
+ mHasMin = true;
+ mMin = v;
}
void KCoreConfigSkeleton::ItemInt::setMaxValue(qint32 v)
{
- mHasMax = true;
- mMax = v;
+ mHasMax = true;
+ mMax = v;
}
-
-KCoreConfigSkeleton::ItemLongLong::ItemLongLong( const QString &_group, const QString &_key,
- qint64 &reference, qint64 defaultValue )
- : KConfigSkeletonGenericItem<qint64>( _group, _key, reference, defaultValue )
- ,mHasMin(false), mHasMax(false)
+KCoreConfigSkeleton::ItemLongLong::ItemLongLong(const QString &_group, const QString &_key,
+ qint64 &reference, qint64 defaultValue)
+ : KConfigSkeletonGenericItem<qint64>(_group, _key, reference, defaultValue)
+ , mHasMin(false), mHasMax(false)
{
}
-void KCoreConfigSkeleton::ItemLongLong::readConfig( KConfig *config )
+void KCoreConfigSkeleton::ItemLongLong::readConfig(KConfig *config)
{
- KConfigGroup cg(config, mGroup );
- mReference = cg.readEntry( mKey, mDefault );
- if (mHasMin)
- mReference = qMax(mReference, mMin);
- if (mHasMax)
- mReference = qMin(mReference, mMax);
- mLoadedValue = mReference;
+ KConfigGroup cg(config, mGroup);
+ mReference = cg.readEntry(mKey, mDefault);
+ if (mHasMin) {
+ mReference = qMax(mReference, mMin);
+ }
+ if (mHasMax) {
+ mReference = qMin(mReference, mMax);
+ }
+ mLoadedValue = mReference;
- readImmutability( cg );
+ readImmutability(cg);
}
-void KCoreConfigSkeleton::ItemLongLong::setProperty(const QVariant & p)
+void KCoreConfigSkeleton::ItemLongLong::setProperty(const QVariant &p)
{
- mReference = p.toLongLong();
+ mReference = p.toLongLong();
}
bool KCoreConfigSkeleton::ItemLongLong::isEqual(const QVariant &v) const
@@ -412,84 +408,82 @@ bool KCoreConfigSkeleton::ItemLongLong::isEqual(const QVariant &v) const
QVariant KCoreConfigSkeleton::ItemLongLong::property() const
{
- return QVariant(mReference);
+ return QVariant(mReference);
}
QVariant KCoreConfigSkeleton::ItemLongLong::minValue() const
{
- if (mHasMin)
- return QVariant(mMin);
- return QVariant();
+ if (mHasMin) {
+ return QVariant(mMin);
+ }
+ return QVariant();
}
QVariant KCoreConfigSkeleton::ItemLongLong::maxValue() const
{
- if (mHasMax)
- return QVariant(mMax);
- return QVariant();
+ if (mHasMax) {
+ return QVariant(mMax);
+ }
+ return QVariant();
}
void KCoreConfigSkeleton::ItemLongLong::setMinValue(qint64 v)
{
- mHasMin = true;
- mMin = v;
+ mHasMin = true;
+ mMin = v;
}
void KCoreConfigSkeleton::ItemLongLong::setMaxValue(qint64 v)
{
- mHasMax = true;
- mMax = v;
-}
-
-KCoreConfigSkeleton::ItemEnum::ItemEnum( const QString &_group, const QString &_key,
- qint32 &reference,
- const QList<Choice> &choices,
- qint32 defaultValue )
- : ItemInt( _group, _key, reference, defaultValue ), mChoices(choices)
-{
-}
-
-void KCoreConfigSkeleton::ItemEnum::readConfig( KConfig *config )
-{
- KConfigGroup cg(config, mGroup );
- if (!cg.hasKey(mKey))
- {
- mReference = mDefault;
- }
- else
- {
- int i = 0;
- mReference = -1;
- QString tmp = cg.readEntry( mKey, QString() ).toLower();
- for(QList<Choice>::ConstIterator it = mChoices.constBegin();
- it != mChoices.constEnd(); ++it, ++i)
- {
- if ((*it).name.toLower() == tmp)
- {
- mReference = i;
- break;
- }
+ mHasMax = true;
+ mMax = v;
+}
+
+KCoreConfigSkeleton::ItemEnum::ItemEnum(const QString &_group, const QString &_key,
+ qint32 &reference,
+ const QList<Choice> &choices,
+ qint32 defaultValue)
+ : ItemInt(_group, _key, reference, defaultValue), mChoices(choices)
+{
+}
+
+void KCoreConfigSkeleton::ItemEnum::readConfig(KConfig *config)
+{
+ KConfigGroup cg(config, mGroup);
+ if (!cg.hasKey(mKey)) {
+ mReference = mDefault;
+ } else {
+ int i = 0;
+ mReference = -1;
+ QString tmp = cg.readEntry(mKey, QString()).toLower();
+ for (QList<Choice>::ConstIterator it = mChoices.constBegin();
+ it != mChoices.constEnd(); ++it, ++i) {
+ if ((*it).name.toLower() == tmp) {
+ mReference = i;
+ break;
+ }
+ }
+ if (mReference == -1) {
+ mReference = cg.readEntry(mKey, mDefault);
+ }
}
- if (mReference == -1)
- mReference = cg.readEntry( mKey, mDefault );
- }
- mLoadedValue = mReference;
+ mLoadedValue = mReference;
- readImmutability( cg );
+ readImmutability(cg);
}
-void KCoreConfigSkeleton::ItemEnum::writeConfig( KConfig *config )
+void KCoreConfigSkeleton::ItemEnum::writeConfig(KConfig *config)
{
- if ( mReference != mLoadedValue ) // WABA: Is this test needed?
- {
- KConfigGroup cg(config, mGroup );
- if ((mDefault == mReference) && !cg.hasDefault( mKey))
- cg.revertToDefault( mKey );
- else if ((mReference >= 0) && (mReference < (int) mChoices.count()))
- cg.writeEntry( mKey, mChoices[mReference].name );
- else
- cg.writeEntry( mKey, mReference );
- }
+ if (mReference != mLoadedValue) { // WABA: Is this test needed?
+ KConfigGroup cg(config, mGroup);
+ if ((mDefault == mReference) && !cg.hasDefault(mKey)) {
+ cg.revertToDefault(mKey);
+ } else if ((mReference >= 0) && (mReference < (int) mChoices.count())) {
+ cg.writeEntry(mKey, mChoices[mReference].name);
+ } else {
+ cg.writeEntry(mKey, mReference);
+ }
+ }
}
QList<KCoreConfigSkeleton::ItemEnum::Choice> KCoreConfigSkeleton::ItemEnum::choices() const
@@ -502,30 +496,32 @@ QList<KCoreConfigSkeleton::ItemEnum::Choice> KCoreConfigSkeleton::ItemEnum::choi
return mChoices;
}
-KCoreConfigSkeleton::ItemUInt::ItemUInt( const QString &_group, const QString &_key,
- quint32 &reference,
- quint32 defaultValue )
- : KConfigSkeletonGenericItem<quint32>( _group, _key, reference, defaultValue )
- ,mHasMin(false), mHasMax(false)
+KCoreConfigSkeleton::ItemUInt::ItemUInt(const QString &_group, const QString &_key,
+ quint32 &reference,
+ quint32 defaultValue)
+ : KConfigSkeletonGenericItem<quint32>(_group, _key, reference, defaultValue)
+ , mHasMin(false), mHasMax(false)
{
}
-void KCoreConfigSkeleton::ItemUInt::readConfig( KConfig *config )
+void KCoreConfigSkeleton::ItemUInt::readConfig(KConfig *config)
{
- KConfigGroup cg(config, mGroup );
- mReference = cg.readEntry( mKey, mDefault );
- if (mHasMin)
- mReference = qMax(mReference, mMin);
- if (mHasMax)
- mReference = qMin(mReference, mMax);
- mLoadedValue = mReference;
+ KConfigGroup cg(config, mGroup);
+ mReference = cg.readEntry(mKey, mDefault);
+ if (mHasMin) {
+ mReference = qMax(mReference, mMin);
+ }
+ if (mHasMax) {
+ mReference = qMin(mReference, mMax);
+ }
+ mLoadedValue = mReference;
- readImmutability( cg );
+ readImmutability(cg);
}
-void KCoreConfigSkeleton::ItemUInt::setProperty(const QVariant & p)
+void KCoreConfigSkeleton::ItemUInt::setProperty(const QVariant &p)
{
- mReference = p.toUInt();
+ mReference = p.toUInt();
}
bool KCoreConfigSkeleton::ItemUInt::isEqual(const QVariant &v) const
@@ -535,59 +531,62 @@ bool KCoreConfigSkeleton::ItemUInt::isEqual(const QVariant &v) const
QVariant KCoreConfigSkeleton::ItemUInt::property() const
{
- return QVariant(mReference);
+ return QVariant(mReference);
}
QVariant KCoreConfigSkeleton::ItemUInt::minValue() const
{
- if (mHasMin)
- return QVariant(mMin);
- return QVariant();
+ if (mHasMin) {
+ return QVariant(mMin);
+ }
+ return QVariant();
}
QVariant KCoreConfigSkeleton::ItemUInt::maxValue() const
{
- if (mHasMax)
- return QVariant(mMax);
- return QVariant();
+ if (mHasMax) {
+ return QVariant(mMax);
+ }
+ return QVariant();
}
void KCoreConfigSkeleton::ItemUInt::setMinValue(quint32 v)
{
- mHasMin = true;
- mMin = v;
+ mHasMin = true;
+ mMin = v;
}
void KCoreConfigSkeleton::ItemUInt::setMaxValue(quint32 v)
{
- mHasMax = true;
- mMax = v;
+ mHasMax = true;
+ mMax = v;
}
-
-KCoreConfigSkeleton::ItemULongLong::ItemULongLong( const QString &_group, const QString &_key,
- quint64 &reference, quint64 defaultValue )
- : KConfigSkeletonGenericItem<quint64>( _group, _key, reference, defaultValue )
- ,mHasMin(false), mHasMax(false)
+KCoreConfigSkeleton::ItemULongLong::ItemULongLong(const QString &_group, const QString &_key,
+ quint64 &reference, quint64 defaultValue)
+ : KConfigSkeletonGenericItem<quint64>(_group, _key, reference, defaultValue)
+ , mHasMin(false), mHasMax(false)
{
}
-void KCoreConfigSkeleton::ItemULongLong::readConfig( KConfig *config )
+void KCoreConfigSkeleton::ItemULongLong::readConfig(KConfig *config)
{
- KConfigGroup cg(config, mGroup );
- mReference = cg.readEntry( mKey, mDefault );
- if (mHasMin)
- mReference = qMax(mReference, mMin);
- if (mHasMax)
- mReference = qMin(mReference, mMax);
- mLoadedValue = mReference;
+ KConfigGroup cg(config, mGroup);
+ mReference = cg.readEntry(mKey, mDefault);
+ if (mHasMin) {
+ mReference = qMax(mReference, mMin);
+ }
+ if (mHasMax) {
+ mReference = qMin(mReference, mMax);
+ }
+ mLoadedValue = mReference;
- readImmutability( cg );
+ readImmutability(cg);
}
-void KCoreConfigSkeleton::ItemULongLong::setProperty(const QVariant & p)
+void KCoreConfigSkeleton::ItemULongLong::setProperty(const QVariant &p)
{
- mReference = p.toULongLong();
+ mReference = p.toULongLong();
}
bool KCoreConfigSkeleton::ItemULongLong::isEqual(const QVariant &v) const
@@ -597,58 +596,62 @@ bool KCoreConfigSkeleton::ItemULongLong::isEqual(const QVariant &v) const
QVariant KCoreConfigSkeleton::ItemULongLong::property() const
{
- return QVariant(mReference);
+ return QVariant(mReference);
}
QVariant KCoreConfigSkeleton::ItemULongLong::minValue() const
{
- if (mHasMin)
- return QVariant(mMin);
- return QVariant();
+ if (mHasMin) {
+ return QVariant(mMin);
+ }
+ return QVariant();
}
QVariant KCoreConfigSkeleton::ItemULongLong::maxValue() const
{
- if (mHasMax)
- return QVariant(mMax);
- return QVariant();
+ if (mHasMax) {
+ return QVariant(mMax);
+ }
+ return QVariant();
}
void KCoreConfigSkeleton::ItemULongLong::setMinValue(quint64 v)
{
- mHasMin = true;
- mMin = v;
+ mHasMin = true;
+ mMin = v;
}
void KCoreConfigSkeleton::ItemULongLong::setMaxValue(quint64 v)
{
- mHasMax = true;
- mMax = v;
+ mHasMax = true;
+ mMax = v;
}
-KCoreConfigSkeleton::ItemDouble::ItemDouble( const QString &_group, const QString &_key,
- double &reference, double defaultValue )
- : KConfigSkeletonGenericItem<double>( _group, _key, reference, defaultValue )
- ,mHasMin(false), mHasMax(false)
+KCoreConfigSkeleton::ItemDouble::ItemDouble(const QString &_group, const QString &_key,
+ double &reference, double defaultValue)
+ : KConfigSkeletonGenericItem<double>(_group, _key, reference, defaultValue)
+ , mHasMin(false), mHasMax(false)
{
}
-void KCoreConfigSkeleton::ItemDouble::readConfig( KConfig *config )
+void KCoreConfigSkeleton::ItemDouble::readConfig(KConfig *config)
{
- KConfigGroup cg(config, mGroup );
- mReference = cg.readEntry( mKey, mDefault );
- if (mHasMin)
- mReference = qMax(mReference, mMin);
- if (mHasMax)
- mReference = qMin(mReference, mMax);
- mLoadedValue = mReference;
+ KConfigGroup cg(config, mGroup);
+ mReference = cg.readEntry(mKey, mDefault);
+ if (mHasMin) {
+ mReference = qMax(mReference, mMin);
+ }
+ if (mHasMax) {
+ mReference = qMin(mReference, mMax);
+ }
+ mLoadedValue = mReference;
- readImmutability( cg );
+ readImmutability(cg);
}
-void KCoreConfigSkeleton::ItemDouble::setProperty(const QVariant & p)
+void KCoreConfigSkeleton::ItemDouble::setProperty(const QVariant &p)
{
- mReference = p.toDouble();
+ mReference = p.toDouble();
}
bool KCoreConfigSkeleton::ItemDouble::isEqual(const QVariant &v) const
@@ -658,55 +661,56 @@ bool KCoreConfigSkeleton::ItemDouble::isEqual(const QVariant &v) const
QVariant KCoreConfigSkeleton::ItemDouble::property() const
{
- return QVariant(mReference);
+ return QVariant(mReference);
}
QVariant KCoreConfigSkeleton::ItemDouble::minValue() const
{
- if (mHasMin)
- return QVariant(mMin);
- return QVariant();
+ if (mHasMin) {
+ return QVariant(mMin);
+ }
+ return QVariant();
}
QVariant KCoreConfigSkeleton::ItemDouble::maxValue() const
{
- if (mHasMax)
- return QVariant(mMax);
- return QVariant();
+ if (mHasMax) {
+ return QVariant(mMax);
+ }
+ return QVariant();
}
void KCoreConfigSkeleton::ItemDouble::setMinValue(double v)
{
- mHasMin = true;
- mMin = v;
+ mHasMin = true;
+ mMin = v;
}
void KCoreConfigSkeleton::ItemDouble::setMaxValue(double v)
{
- mHasMax = true;
- mMax = v;
+ mHasMax = true;
+ mMax = v;
}
-
-KCoreConfigSkeleton::ItemRect::ItemRect( const QString &_group, const QString &_key,
- QRect &reference,
- const QRect &defaultValue )
- : KConfigSkeletonGenericItem<QRect>( _group, _key, reference, defaultValue )
+KCoreConfigSkeleton::ItemRect::ItemRect(const QString &_group, const QString &_key,
+ QRect &reference,
+ const QRect &defaultValue)
+ : KConfigSkeletonGenericItem<QRect>(_group, _key, reference, defaultValue)
{
}
-void KCoreConfigSkeleton::ItemRect::readConfig( KConfig *config )
+void KCoreConfigSkeleton::ItemRect::readConfig(KConfig *config)
{
- KConfigGroup cg(config, mGroup );
- mReference = cg.readEntry( mKey, mDefault );
- mLoadedValue = mReference;
+ KConfigGroup cg(config, mGroup);
+ mReference = cg.readEntry(mKey, mDefault);
+ mLoadedValue = mReference;
- readImmutability( cg );
+ readImmutability(cg);
}
-void KCoreConfigSkeleton::ItemRect::setProperty(const QVariant & p)
+void KCoreConfigSkeleton::ItemRect::setProperty(const QVariant &p)
{
- mReference = p.toRect();
+ mReference = p.toRect();
}
bool KCoreConfigSkeleton::ItemRect::isEqual(const QVariant &v) const
@@ -716,29 +720,28 @@ bool KCoreConfigSkeleton::ItemRect::isEqual(const QVariant &v) const
QVariant KCoreConfigSkeleton::ItemRect::property() const
{
- return QVariant(mReference);
+ return QVariant(mReference);
}
-
-KCoreConfigSkeleton::ItemPoint::ItemPoint( const QString &_group, const QString &_key,
- QPoint &reference,
- const QPoint &defaultValue )
- : KConfigSkeletonGenericItem<QPoint>( _group, _key, reference, defaultValue )
+KCoreConfigSkeleton::ItemPoint::ItemPoint(const QString &_group, const QString &_key,
+ QPoint &reference,
+ const QPoint &defaultValue)
+ : KConfigSkeletonGenericItem<QPoint>(_group, _key, reference, defaultValue)
{
}
-void KCoreConfigSkeleton::ItemPoint::readConfig( KConfig *config )
+void KCoreConfigSkeleton::ItemPoint::readConfig(KConfig *config)
{
- KConfigGroup cg(config, mGroup );
- mReference = cg.readEntry( mKey, mDefault );
- mLoadedValue = mReference;
+ KConfigGroup cg(config, mGroup);
+ mReference = cg.readEntry(mKey, mDefault);
+ mLoadedValue = mReference;
- readImmutability( cg );
+ readImmutability(cg);
}
-void KCoreConfigSkeleton::ItemPoint::setProperty(const QVariant & p)
+void KCoreConfigSkeleton::ItemPoint::setProperty(const QVariant &p)
{
- mReference = p.toPoint();
+ mReference = p.toPoint();
}
bool KCoreConfigSkeleton::ItemPoint::isEqual(const QVariant &v) const
@@ -748,29 +751,28 @@ bool KCoreConfigSkeleton::ItemPoint::isEqual(const QVariant &v) const
QVariant KCoreConfigSkeleton::ItemPoint::property() const
{
- return QVariant(mReference);
+ return QVariant(mReference);
}
-
-KCoreConfigSkeleton::ItemSize::ItemSize( const QString &_group, const QString &_key,
- QSize &reference,
- const QSize &defaultValue )
- : KConfigSkeletonGenericItem<QSize>( _group, _key, reference, defaultValue )
+KCoreConfigSkeleton::ItemSize::ItemSize(const QString &_group, const QString &_key,
+ QSize &reference,
+ const QSize &defaultValue)
+ : KConfigSkeletonGenericItem<QSize>(_group, _key, reference, defaultValue)
{
}
-void KCoreConfigSkeleton::ItemSize::readConfig( KConfig *config )
+void KCoreConfigSkeleton::ItemSize::readConfig(KConfig *config)
{
- KConfigGroup cg(config, mGroup );
- mReference = cg.readEntry( mKey, mDefault );
- mLoadedValue = mReference;
+ KConfigGroup cg(config, mGroup);
+ mReference = cg.readEntry(mKey, mDefault);
+ mLoadedValue = mReference;
- readImmutability( cg );
+ readImmutability(cg);
}
-void KCoreConfigSkeleton::ItemSize::setProperty(const QVariant & p)
+void KCoreConfigSkeleton::ItemSize::setProperty(const QVariant &p)
{
- mReference = p.toSize();
+ mReference = p.toSize();
}
bool KCoreConfigSkeleton::ItemSize::isEqual(const QVariant &v) const
@@ -780,29 +782,28 @@ bool KCoreConfigSkeleton::ItemSize::isEqual(const QVariant &v) const
QVariant KCoreConfigSkeleton::ItemSize::property() const
{
- return QVariant(mReference);
+ return QVariant(mReference);
}
-
-KCoreConfigSkeleton::ItemDateTime::ItemDateTime( const QString &_group, const QString &_key,
- QDateTime &reference,
- const QDateTime &defaultValue )
- : KConfigSkeletonGenericItem<QDateTime>( _group, _key, reference, defaultValue )
+KCoreConfigSkeleton::ItemDateTime::ItemDateTime(const QString &_group, const QString &_key,
+ QDateTime &reference,
+ const QDateTime &defaultValue)
+ : KConfigSkeletonGenericItem<QDateTime>(_group, _key, reference, defaultValue)
{
}
-void KCoreConfigSkeleton::ItemDateTime::readConfig( KConfig *config )
+void KCoreConfigSkeleton::ItemDateTime::readConfig(KConfig *config)
{
- KConfigGroup cg(config, mGroup );
- mReference = cg.readEntry( mKey, mDefault );
- mLoadedValue = mReference;
+ KConfigGroup cg(config, mGroup);
+ mReference = cg.readEntry(mKey, mDefault);
+ mLoadedValue = mReference;
- readImmutability( cg );
+ readImmutability(cg);
}
-void KCoreConfigSkeleton::ItemDateTime::setProperty(const QVariant & p)
+void KCoreConfigSkeleton::ItemDateTime::setProperty(const QVariant &p)
{
- mReference = p.toDateTime();
+ mReference = p.toDateTime();
}
bool KCoreConfigSkeleton::ItemDateTime::isEqual(const QVariant &v) const
@@ -812,32 +813,32 @@ bool KCoreConfigSkeleton::ItemDateTime::isEqual(const QVariant &v) const
QVariant KCoreConfigSkeleton::ItemDateTime::property() const
{
- return QVariant(mReference);
+ return QVariant(mReference);
}
-
-KCoreConfigSkeleton::ItemStringList::ItemStringList( const QString &_group, const QString &_key,
- QStringList &reference,
- const QStringList &defaultValue )
- : KConfigSkeletonGenericItem<QStringList>( _group, _key, reference, defaultValue )
+KCoreConfigSkeleton::ItemStringList::ItemStringList(const QString &_group, const QString &_key,
+ QStringList &reference,
+ const QStringList &defaultValue)
+ : KConfigSkeletonGenericItem<QStringList>(_group, _key, reference, defaultValue)
{
}
-void KCoreConfigSkeleton::ItemStringList::readConfig( KConfig *config )
+void KCoreConfigSkeleton::ItemStringList::readConfig(KConfig *config)
{
- KConfigGroup cg(config, mGroup );
- if ( !cg.hasKey( mKey ) )
- mReference = mDefault;
- else
- mReference = cg.readEntry( mKey, mDefault );
- mLoadedValue = mReference;
+ KConfigGroup cg(config, mGroup);
+ if (!cg.hasKey(mKey)) {
+ mReference = mDefault;
+ } else {
+ mReference = cg.readEntry(mKey, mDefault);
+ }
+ mLoadedValue = mReference;
- readImmutability( cg );
+ readImmutability(cg);
}
-void KCoreConfigSkeleton::ItemStringList::setProperty(const QVariant & p)
+void KCoreConfigSkeleton::ItemStringList::setProperty(const QVariant &p)
{
- mReference = p.toStringList();
+ mReference = p.toStringList();
}
bool KCoreConfigSkeleton::ItemStringList::isEqual(const QVariant &v) const
@@ -847,81 +848,79 @@ bool KCoreConfigSkeleton::ItemStringList::isEqual(const QVariant &v) const
QVariant KCoreConfigSkeleton::ItemStringList::property() const
{
- return QVariant(mReference);
+ return QVariant(mReference);
}
-
-KCoreConfigSkeleton::ItemPathList::ItemPathList( const QString &_group, const QString &_key,
- QStringList &reference,
- const QStringList &defaultValue )
- : ItemStringList( _group, _key, reference, defaultValue )
+KCoreConfigSkeleton::ItemPathList::ItemPathList(const QString &_group, const QString &_key,
+ QStringList &reference,
+ const QStringList &defaultValue)
+ : ItemStringList(_group, _key, reference, defaultValue)
{
}
-void KCoreConfigSkeleton::ItemPathList::readConfig( KConfig *config )
+void KCoreConfigSkeleton::ItemPathList::readConfig(KConfig *config)
{
- KConfigGroup cg(config, mGroup );
- if ( !cg.hasKey( mKey ) )
- mReference = mDefault;
- else
- mReference = cg.readPathEntry( mKey, QStringList() );
- mLoadedValue = mReference;
+ KConfigGroup cg(config, mGroup);
+ if (!cg.hasKey(mKey)) {
+ mReference = mDefault;
+ } else {
+ mReference = cg.readPathEntry(mKey, QStringList());
+ }
+ mLoadedValue = mReference;
- readImmutability( cg );
+ readImmutability(cg);
}
-void KCoreConfigSkeleton::ItemPathList::writeConfig( KConfig *config )
+void KCoreConfigSkeleton::ItemPathList::writeConfig(KConfig *config)
{
- if ( mReference != mLoadedValue ) // WABA: Is this test needed?
- {
- KConfigGroup cg(config, mGroup );
- if ((mDefault == mReference) && !cg.hasDefault( mKey))
- cg.revertToDefault( mKey );
- else {
- QStringList sl = mReference;
- cg.writePathEntry( mKey, sl );
+ if (mReference != mLoadedValue) { // WABA: Is this test needed?
+ KConfigGroup cg(config, mGroup);
+ if ((mDefault == mReference) && !cg.hasDefault(mKey)) {
+ cg.revertToDefault(mKey);
+ } else {
+ QStringList sl = mReference;
+ cg.writePathEntry(mKey, sl);
+ }
}
- }
}
-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)
{
}
-void KCoreConfigSkeleton::ItemUrlList::readConfig( KConfig *config )
+void KCoreConfigSkeleton::ItemUrlList::readConfig(KConfig *config)
{
- KConfigGroup cg(config, mGroup );
- if ( !cg.hasKey( mKey ) )
+ KConfigGroup cg(config, mGroup);
+ if (!cg.hasKey(mKey)) {
mReference = mDefault;
- else {
+ } else {
QStringList strList;
- Q_FOREACH (const QUrl& url, mDefault) {
+ Q_FOREACH (const QUrl &url, mDefault) {
strList.append(url.toString());
}
mReference.clear();
const QStringList readList = cg.readEntry<QStringList>(mKey, strList);
- Q_FOREACH (const QString& str, readList) {
+ Q_FOREACH (const QString &str, readList) {
mReference.append(QUrl(str));
}
}
mLoadedValue = mReference;
- readImmutability( cg );
+ readImmutability(cg);
}
-void KCoreConfigSkeleton::ItemUrlList::writeConfig( KConfig *config )
+void KCoreConfigSkeleton::ItemUrlList::writeConfig(KConfig *config)
{
- if ( mReference != mLoadedValue ) // WABA: Is this test needed?
- {
- KConfigGroup cg(config, mGroup );
- if ((mDefault == mReference) && !cg.hasDefault( mKey))
- cg.revertToDefault( mKey );
- else {
+ if (mReference != mLoadedValue) { // WABA: Is this test needed?
+ KConfigGroup cg(config, mGroup);
+ if ((mDefault == mReference) && !cg.hasDefault(mKey)) {
+ cg.revertToDefault(mKey);
+ } else {
QStringList strList;
- Q_FOREACH (const QUrl& url, mReference) {
+ Q_FOREACH (const QUrl &url, mReference) {
strList.append(url.toString());
}
cg.writeEntry<QStringList>(mKey, strList);
@@ -929,7 +928,7 @@ void KCoreConfigSkeleton::ItemUrlList::writeConfig( KConfig *config )
}
}
-void KCoreConfigSkeleton::ItemUrlList::setProperty(const QVariant & p)
+void KCoreConfigSkeleton::ItemUrlList::setProperty(const QVariant &p)
{
mReference = qvariant_cast<QList<QUrl> >(p);
}
@@ -944,24 +943,24 @@ QVariant KCoreConfigSkeleton::ItemUrlList::property() const
return qVariantFromValue<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)
{
}
-void KCoreConfigSkeleton::ItemIntList::readConfig( KConfig *config )
+void KCoreConfigSkeleton::ItemIntList::readConfig(KConfig *config)
{
- KConfigGroup cg(config, mGroup );
- if ( !cg.hasKey( mKey ) )
- mReference = mDefault;
- else
- mReference = cg.readEntry( mKey , mDefault );
- mLoadedValue = mReference;
+ KConfigGroup cg(config, mGroup);
+ if (!cg.hasKey(mKey)) {
+ mReference = mDefault;
+ } else {
+ mReference = cg.readEntry(mKey, mDefault);
+ }
+ mLoadedValue = mReference;
- readImmutability( cg );
+ readImmutability(cg);
}
void KCoreConfigSkeleton::ItemIntList::setProperty(const QVariant &p)
@@ -981,32 +980,31 @@ QVariant KCoreConfigSkeleton::ItemIntList::property() const
//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 Private )
+KCoreConfigSkeleton::KCoreConfigSkeleton(const QString &configname, QObject *parent)
+ : QObject(parent),
+ d(new Private)
{
//qDebug() << "Creating KCoreConfigSkeleton (" << (void *)this << ")";
- d->mConfig = KSharedConfig::openConfig( configname );
+ d->mConfig = KSharedConfig::openConfig(configname);
}
-KCoreConfigSkeleton::KCoreConfigSkeleton(KSharedConfig::Ptr pConfig, QObject* parent)
- : QObject(parent),
- d( new Private )
+KCoreConfigSkeleton::KCoreConfigSkeleton(KSharedConfig::Ptr pConfig, QObject *parent)
+ : QObject(parent),
+ d(new Private)
{
//qDebug() << "Creating KCoreConfigSkeleton (" << (void *)this << ")";
d->mConfig = pConfig;
}
-
KCoreConfigSkeleton::~KCoreConfigSkeleton()
{
- delete d;
+ delete d;
}
-void KCoreConfigSkeleton::setCurrentGroup( const QString &group )
+void KCoreConfigSkeleton::setCurrentGroup(const QString &group)
{
- d->mCurrentGroup = group;
+ d->mCurrentGroup = group;
}
QString KCoreConfigSkeleton::currentGroup() const
@@ -1016,12 +1014,12 @@ QString KCoreConfigSkeleton::currentGroup() const
KConfig *KCoreConfigSkeleton::config()
{
- return d->mConfig.data();
+ return d->mConfig.data();
}
const KConfig *KCoreConfigSkeleton::config() const
{
- return d->mConfig.data();
+ return d->mConfig.data();
}
void KCoreConfigSkeleton::setSharedConfig(KSharedConfig::Ptr pConfig)
@@ -1036,63 +1034,63 @@ KConfigSkeletonItem::List KCoreConfigSkeleton::items() const
bool KCoreConfigSkeleton::useDefaults(bool b)
{
- if (b == d->mUseDefaults)
- return d->mUseDefaults;
+ if (b == d->mUseDefaults) {
+ return d->mUseDefaults;
+ }
- d->mUseDefaults = b;
- KConfigSkeletonItem::List::ConstIterator it;
- for( it = d->mItems.constBegin(); it != d->mItems.constEnd(); ++it )
- {
- (*it)->swapDefault();
- }
- usrUseDefaults(b);
- return !d->mUseDefaults;
+ d->mUseDefaults = b;
+ KConfigSkeletonItem::List::ConstIterator it;
+ for (it = d->mItems.constBegin(); it != d->mItems.constEnd(); ++it) {
+ (*it)->swapDefault();
+ }
+ usrUseDefaults(b);
+ return !d->mUseDefaults;
}
void KCoreConfigSkeleton::setDefaults()
{
- KConfigSkeletonItem::List::ConstIterator it;
- for( it = d->mItems.constBegin(); it != d->mItems.constEnd(); ++it ) {
- (*it)->setDefault();
- }
- usrSetDefaults();
+ KConfigSkeletonItem::List::ConstIterator it;
+ for (it = d->mItems.constBegin(); it != d->mItems.constEnd(); ++it) {
+ (*it)->setDefault();
+ }
+ usrSetDefaults();
}
void KCoreConfigSkeleton::readConfig()
{
// qDebug();
- d->mConfig->reparseConfiguration();
- KConfigSkeletonItem::List::ConstIterator it;
- for( it = d->mItems.constBegin(); it != d->mItems.constEnd(); ++it )
- {
- (*it)->readConfig( d->mConfig.data() );
- }
- usrReadConfig();
+ d->mConfig->reparseConfiguration();
+ KConfigSkeletonItem::List::ConstIterator it;
+ for (it = d->mItems.constBegin(); it != d->mItems.constEnd(); ++it) {
+ (*it)->readConfig(d->mConfig.data());
+ }
+ usrReadConfig();
}
bool KCoreConfigSkeleton::writeConfig()
{
//qDebug();
- KConfigSkeletonItem::List::ConstIterator it;
- for( it = d->mItems.constBegin(); it != d->mItems.constEnd(); ++it )
- {
- (*it)->writeConfig( d->mConfig.data() );
- }
- if (!usrWriteConfig())
- return false;
+ KConfigSkeletonItem::List::ConstIterator it;
+ for (it = d->mItems.constBegin(); it != d->mItems.constEnd(); ++it) {
+ (*it)->writeConfig(d->mConfig.data());
+ }
+ if (!usrWriteConfig()) {
+ return false;
+ }
- if (d->mConfig->isDirty()) {
- if (!d->mConfig->sync())
- return false;
- readConfig();
- emit configChanged();
- }
- return true;
+ if (d->mConfig->isDirty()) {
+ if (!d->mConfig->sync()) {
+ return false;
+ }
+ readConfig();
+ emit configChanged();
+ }
+ return true;
}
bool KCoreConfigSkeleton::usrUseDefaults(bool)
{
- return false;
+ return false;
}
void KCoreConfigSkeleton::usrSetDefaults()
@@ -1105,14 +1103,14 @@ void KCoreConfigSkeleton::usrReadConfig()
bool KCoreConfigSkeleton::usrWriteConfig()
{
- return true;
+ return true;
}
-void KCoreConfigSkeleton::addItem( KConfigSkeletonItem *item, const QString &name )
+void KCoreConfigSkeleton::addItem(KConfigSkeletonItem *item, const QString &name)
{
if (d->mItems.contains(item)) {
if (item->name() == name ||
- (name.isEmpty() && item->name() == item->key())) {
+ (name.isEmpty() && item->name() == item->key())) {
// nothing to do -> it is already in our collection
// and the name isn't changing
return;
@@ -1120,7 +1118,7 @@ void KCoreConfigSkeleton::addItem( KConfigSkeletonItem *item, const QString &nam
d->mItemDict.remove(item->name());
} else {
- d->mItems.append( item );
+ d->mItems.append(item);
}
item->setName(name.isEmpty() ? item->key() : name);
@@ -1147,197 +1145,197 @@ 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 );
- addItem( item, name );
- return item;
+ KCoreConfigSkeleton::ItemString *item;
+ 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 );
- addItem( item, name );
- return item;
+ KCoreConfigSkeleton::ItemPassword *item;
+ 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 );
- addItem( item, name );
- return item;
+ KCoreConfigSkeleton::ItemPath *item;
+ 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 );
- addItem( item, name );
- return item;
+ KCoreConfigSkeleton::ItemProperty *item;
+ 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 );
- addItem( item, name );
- return item;
+ KCoreConfigSkeleton::ItemBool *item;
+ 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 );
- addItem( item, name );
- return item;
+ KCoreConfigSkeleton::ItemInt *item;
+ 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 );
- addItem( item, name );
- return item;
+ KCoreConfigSkeleton::ItemUInt *item;
+ 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 );
- addItem( item, name );
- return item;
+ KCoreConfigSkeleton::ItemLongLong *item;
+ item = new KCoreConfigSkeleton::ItemLongLong(d->mCurrentGroup, key.isNull() ? name : key,
+ reference, defaultValue);
+ addItem(item, name);
+ return item;
}
#ifndef KDE_NO_DEPRECATED
KCoreConfigSkeleton::ItemLongLong *KCoreConfigSkeleton::addItemInt64(
- const QString& name,
- qint64 &reference,
- qint64 defaultValue,
- const QString & key)
+ 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 );
- addItem( item, name );
- return item;
+ KCoreConfigSkeleton::ItemULongLong *item;
+ item = new KCoreConfigSkeleton::ItemULongLong(d->mCurrentGroup, key.isNull() ? name : key,
+ reference, defaultValue);
+ addItem(item, name);
+ return item;
}
#ifndef KDE_NO_DEPRECATED
KCoreConfigSkeleton::ItemULongLong *KCoreConfigSkeleton::addItemUInt64(
- const QString & name,
- quint64 &reference,
- quint64 defaultValue,
- const QString & key)
+ 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 );
- addItem( item, name );
- return item;
+ KCoreConfigSkeleton::ItemDouble *item;
+ 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 );
- addItem( item, name );
- return item;
+ KCoreConfigSkeleton::ItemRect *item;
+ 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 );
- addItem( item, name );
- return item;
+ KCoreConfigSkeleton::ItemPoint *item;
+ 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 );
- addItem( item, name );
- return item;
+ KCoreConfigSkeleton::ItemSize *item;
+ 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 );
- addItem( item, name );
- return item;
+ KCoreConfigSkeleton::ItemDateTime *item;
+ 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 );
- addItem( item, name );
- return item;
+ KCoreConfigSkeleton::ItemStringList *item;
+ 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 );
- addItem( item, name );
- return item;
+ KCoreConfigSkeleton::ItemIntList *item;
+ item = new KCoreConfigSkeleton::ItemIntList(d->mCurrentGroup, key.isNull() ? name : key,
+ reference, defaultValue);
+ addItem(item, name);
+ return item;
}
bool KCoreConfigSkeleton::isImmutable(const QString &name) const
{
- KConfigSkeletonItem *item = findItem(name);
- return !item || item->isImmutable();
+ KConfigSkeletonItem *item = findItem(name);
+ return !item || item->isImmutable();
}
KConfigSkeletonItem *KCoreConfigSkeleton::findItem(const QString &name) const
{
- return d->mItemDict.value(name);
+ return d->mItemDict.value(name);
}
diff --git a/src/core/kcoreconfigskeleton.h b/src/core/kcoreconfigskeleton.h
index 75f6fa28..c1a15877 100644
--- a/src/core/kcoreconfigskeleton.h
+++ b/src/core/kcoreconfigskeleton.h
@@ -35,26 +35,26 @@
#include <QtCore/QVariant>
#include <QtCore/QUrl>
- class KConfigSkeletonItemPrivate;
- /**
- * \class KConfigSkeletonItem kcoreconfigskeleton.h <KConfigSkeletonItem>
- *
- * @short Class for storing a preferences setting
- * @author Cornelius Schumacher
- * @see KCoreConfigSkeleton
- *
- * This class represents one preferences setting as used by @ref KCoreConfigSkeleton.
- * Subclasses of KConfigSkeletonItem implement storage functions for a certain type of
- * setting. Normally you don't have to use this class directly. Use the special
- * addItem() functions of KCoreConfigSkeleton instead. If you subclass this class you will
- * have to register instances with the function KCoreConfigSkeleton::addItem().
- */
- class KCONFIGCORE_EXPORT KConfigSkeletonItem
- {
- public:
+class KConfigSkeletonItemPrivate;
+/**
+ * \class KConfigSkeletonItem kcoreconfigskeleton.h <KConfigSkeletonItem>
+ *
+ * @short Class for storing a preferences setting
+ * @author Cornelius Schumacher
+ * @see KCoreConfigSkeleton
+ *
+ * This class represents one preferences setting as used by @ref KCoreConfigSkeleton.
+ * Subclasses of KConfigSkeletonItem implement storage functions for a certain type of
+ * setting. Normally you don't have to use this class directly. Use the special
+ * addItem() functions of KCoreConfigSkeleton instead. If you subclass this class you will
+ * have to register instances with the function KCoreConfigSkeleton::addItem().
+ */
+class KCONFIGCORE_EXPORT KConfigSkeletonItem
+{
+public:
typedef QList < KConfigSkeletonItem * >List;
- typedef QHash < QString, KConfigSkeletonItem* > Dict;
- typedef QHash < QString, KConfigSkeletonItem* >::Iterator DictIterator;
+ typedef QHash < QString, KConfigSkeletonItem * > Dict;
+ typedef QHash < QString, KConfigSkeletonItem * >::Iterator DictIterator;
/**
* Constructor.
@@ -62,7 +62,7 @@
* @param _group Config file group.
* @param _key Config file key.
*/
- KConfigSkeletonItem(const QString & _group, const QString & _key);
+ KConfigSkeletonItem(const QString &_group, const QString &_key);
/**
* Destructor.
@@ -72,7 +72,7 @@
/**
* Set config file group.
*/
- void setGroup( const QString &_group );
+ void setGroup(const QString &_group);
/**
* Return config file group.
@@ -82,7 +82,7 @@
/**
* Set config file key.
*/
- void setKey( const QString &_key );
+ void setKey(const QString &_key);
/**
* Return config file key.
@@ -102,7 +102,7 @@
/**
Set label providing a translated one-line description of the item.
*/
- void setLabel( const QString &l );
+ void setLabel(const QString &l);
/**
Return label of item. See setLabel().
@@ -113,7 +113,7 @@
Set ToolTip description of item.
@since 4.2
*/
- void setToolTip( const QString &t );
+ void setToolTip(const QString &t);
/**
Return ToolTip description of item. See setToolTip().
@@ -124,7 +124,7 @@
/**
Set WhatsThis description of item.
*/
- void setWhatsThis( const QString &w );
+ void setWhatsThis(const QString &w);
/**
Return WhatsThis description of item. See setWhatsThis().
@@ -195,7 +195,7 @@
*/
bool isImmutable() const;
- protected:
+protected:
/**
* sets mIsImmutable to true if mKey in config is immutable
* @param group KConfigGroup to check if mKey is immutable in
@@ -206,58 +206,57 @@
QString mKey; ///< The config key for this item
QString mName; ///< The name of this item
- private:
- KConfigSkeletonItemPrivate * const d;
- };
-
+private:
+ KConfigSkeletonItemPrivate *const d;
+};
/**
* \class KConfigSkeletonGenericItem kcoreconfigskeleton.h <KConfigSkeletonGenericItem>
*/
-template < typename T > class KConfigSkeletonGenericItem:public KConfigSkeletonItem
- {
- public:
+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)
{
}
/**
* Set value of this KConfigSkeletonItem.
*/
- void setValue(const T & v)
+ void setValue(const T &v)
{
- mReference = v;
+ mReference = v;
}
/**
* Return value of this KConfigSkeletonItem.
*/
- T & value()
+ T &value()
{
- return mReference;
+ return mReference;
}
/**
* Return const value of this KConfigSkeletonItem.
*/
- const T & value() const
+ const T &value() const
{
- return mReference;
+ return mReference;
}
/**
Set default value for this item.
*/
- virtual void setDefaultValue( const T &v )
+ virtual void setDefaultValue(const T &v)
{
- mDefault = v;
+ mDefault = v;
}
/**
@@ -265,1142 +264,1130 @@ template < typename T > class KConfigSkeletonGenericItem:public KConfigSkeletonI
*/
virtual void setDefault()
{
- mReference = mDefault;
+ mReference = mDefault;
}
/** @copydoc KConfigSkeletonItem::writeConfig(KConfig *) */
- virtual void writeConfig(KConfig * config)
+ virtual void writeConfig(KConfig *config)
{
- if ( mReference != mLoadedValue ) // Is this needed?
- {
- KConfigGroup cg(config, mGroup);
- if ((mDefault == mReference) && !cg.hasDefault( mKey))
- cg.revertToDefault( mKey );
- else
- cg.writeEntry(mKey, mReference);
- }
+ if (mReference != mLoadedValue) { // Is this needed?
+ KConfigGroup cg(config, mGroup);
+ if ((mDefault == mReference) && !cg.hasDefault(mKey)) {
+ cg.revertToDefault(mKey);
+ } else {
+ cg.writeEntry(mKey, mReference);
+ }
+ }
}
/** @copydoc KConfigSkeletonItem::readDefault(KConfig*) */
- void readDefault(KConfig * config)
+ void readDefault(KConfig *config)
{
- config->setReadDefaults(true);
- readConfig(config);
- config->setReadDefaults(false);
- mDefault = mReference;
+ config->setReadDefaults(true);
+ readConfig(config);
+ config->setReadDefaults(false);
+ mDefault = mReference;
}
/** @copydoc KConfigSkeletonItem::swapDefault() */
void swapDefault()
{
- T tmp = mReference;
- mReference = mDefault;
- mDefault = tmp;
+ T tmp = mReference;
+ mReference = mDefault;
+ mDefault = tmp;
}
- protected:
- T & mReference; ///< Stores the value for this item
+protected:
+ T &mReference; ///< Stores the value for this item
T mDefault; ///< The default value for this item
T mLoadedValue;
- };
-
- /**
- * \class KCoreConfigSkeleton kcoreconfigskeleton.h <KCoreConfigSkeleton>
- *
- * @short Class for handling preferences settings for an application.
- * @author Cornelius Schumacher
- * @see KConfigSkeletonItem
- *
- * This class provides an interface to preferences settings. Preferences items
- * can be registered by the addItem() function corresponding to the data type of
- * the setting. KCoreConfigSkeleton then handles reading and writing of config files and
- * setting of default values.
- *
- * Normally you will subclass KCoreConfigSkeleton, add data members for the preferences
- * settings and register the members in the constructor of the subclass.
- *
- * Example:
- * \code
- * class MyPrefs : public KCoreConfigSkeleton
- * {
- * public:
- * MyPrefs()
- * {
- * setCurrentGroup("MyGroup");
- * addItemBool("MySetting1", mMyBool, false);
- * addItemPoint("MySetting2", mMyPoint, QPoint(100, 200));
- *
- * setCurrentGroup("MyOtherGroup");
- * addItemDouble("MySetting3", mMyDouble, 3.14);
- * }
- *
- * bool mMyBool;
- * QPoint mMyPoint;
- * double mMyDouble;
- * }
- * \endcode
- *
- * It might be convenient in many cases to make this subclass of KCoreConfigSkeleton a
- * singleton for global access from all over the application without passing
- * references to the KCoreConfigSkeleton object around.
- *
- * You can write the data to the configuration file by calling @ref writeConfig()
- * and read the data from the configuration file by calling @ref readConfig().
- * If you want to watch for config changes, use @ref configChanged() signal.
- *
- * If you have items, which are not covered by the existing addItem() functions
- * you can add customized code for reading, writing and default setting by
- * implementing the functions @ref usrUseDefaults(), @ref usrReadConfig() and
- * @ref usrWriteConfig().
- *
- * Internally preferences settings are stored in instances of subclasses of
- * @ref KConfigSkeletonItem. You can also add KConfigSkeletonItem subclasses
- * for your own types and call the generic @ref addItem() to register them.
- *
- * In many cases you don't have to write the specific KCoreConfigSkeleton
- * subclasses yourself, but you can use \ref kconfig_compiler to automatically
- * generate the C++ code from an XML description of the configuration options.
- *
- * Use KConfigSkeleton if you need GUI types as well.
- */
+};
+
+/**
+ * \class KCoreConfigSkeleton kcoreconfigskeleton.h <KCoreConfigSkeleton>
+ *
+ * @short Class for handling preferences settings for an application.
+ * @author Cornelius Schumacher
+ * @see KConfigSkeletonItem
+ *
+ * This class provides an interface to preferences settings. Preferences items
+ * can be registered by the addItem() function corresponding to the data type of
+ * the setting. KCoreConfigSkeleton then handles reading and writing of config files and
+ * setting of default values.
+ *
+ * Normally you will subclass KCoreConfigSkeleton, add data members for the preferences
+ * settings and register the members in the constructor of the subclass.
+ *
+ * Example:
+ * \code
+ * class MyPrefs : public KCoreConfigSkeleton
+ * {
+ * public:
+ * MyPrefs()
+ * {
+ * setCurrentGroup("MyGroup");
+ * addItemBool("MySetting1", mMyBool, false);
+ * addItemPoint("MySetting2", mMyPoint, QPoint(100, 200));
+ *
+ * setCurrentGroup("MyOtherGroup");
+ * addItemDouble("MySetting3", mMyDouble, 3.14);
+ * }
+ *
+ * bool mMyBool;
+ * QPoint mMyPoint;
+ * double mMyDouble;
+ * }
+ * \endcode
+ *
+ * It might be convenient in many cases to make this subclass of KCoreConfigSkeleton a
+ * singleton for global access from all over the application without passing
+ * references to the KCoreConfigSkeleton object around.
+ *
+ * You can write the data to the configuration file by calling @ref writeConfig()
+ * and read the data from the configuration file by calling @ref readConfig().
+ * If you want to watch for config changes, use @ref configChanged() signal.
+ *
+ * If you have items, which are not covered by the existing addItem() functions
+ * you can add customized code for reading, writing and default setting by
+ * implementing the functions @ref usrUseDefaults(), @ref usrReadConfig() and
+ * @ref usrWriteConfig().
+ *
+ * Internally preferences settings are stored in instances of subclasses of
+ * @ref KConfigSkeletonItem. You can also add KConfigSkeletonItem subclasses
+ * for your own types and call the generic @ref addItem() to register them.
+ *
+ * In many cases you don't have to write the specific KCoreConfigSkeleton
+ * subclasses yourself, but you can use \ref kconfig_compiler to automatically
+ * generate the C++ code from an XML description of the configuration options.
+ *
+ * Use KConfigSkeleton if you need GUI types as well.
+ */
class KCONFIGCORE_EXPORT KCoreConfigSkeleton : public QObject
{
- Q_OBJECT
+ Q_OBJECT
public:
- /**
- * Class for handling a string preferences item.
- */
- class KCONFIGCORE_EXPORT ItemString:public KConfigSkeletonGenericItem < QString >
- {
- public:
- enum Type { Normal, Password, Path };
-
- /** @enum Type
- The type of string that is held in this item
+ /**
+ * Class for handling a string preferences item.
+ */
+ class KCONFIGCORE_EXPORT ItemString: public KConfigSkeletonGenericItem < QString >
+ {
+ public:
+ enum Type { Normal, Password, Path };
- @var ItemString::Type ItemString::Normal
- A normal string
+ /** @enum Type
+ The type of string that is held in this item
- @var ItemString::Type ItemString::Password
- A password string
+ @var ItemString::Type ItemString::Normal
+ A normal string
- @var ItemString::Type ItemString::Path
- A path to a file or directory
- */
+ @var ItemString::Type ItemString::Password
+ A password string
+ @var ItemString::Type ItemString::Path
+ A path to a file or directory
+ */
- /** @copydoc KConfigSkeletonGenericItem::KConfigSkeletonGenericItem
- @param type The type of string held by the item
- */
- ItemString(const QString & _group, const QString & _key,
- QString & reference,
- const QString & defaultValue = QLatin1String(""), // NOT QString() !!
- Type type = Normal);
+ /** @copydoc KConfigSkeletonGenericItem::KConfigSkeletonGenericItem
+ @param type The type of string held by the item
+ */
+ ItemString(const QString &_group, const QString &_key,
+ QString &reference,
+ const QString &defaultValue = QLatin1String(""), // NOT QString() !!
+ Type type = Normal);
- /** @copydoc KConfigSkeletonItem::writeConfig(KConfig*) */
- void writeConfig(KConfig * config);
+ /** @copydoc KConfigSkeletonItem::writeConfig(KConfig*) */
+ void writeConfig(KConfig *config);
- /** @copydoc KConfigSkeletonItem::readConfig(KConfig*) */
- void readConfig(KConfig * config);
+ /** @copydoc KConfigSkeletonItem::readConfig(KConfig*) */
+ void readConfig(KConfig *config);
- /** @copydoc KConfigSkeletonItem::setProperty(const QVariant&) */
- void setProperty(const QVariant & p);
+ /** @copydoc KConfigSkeletonItem::setProperty(const QVariant&) */
+ void setProperty(const QVariant &p);
- /** @copydoc KConfigSkeletonItem::isEqual(const QVariant &) const */
- bool isEqual(const QVariant &p) const;
+ /** @copydoc KConfigSkeletonItem::isEqual(const QVariant &) const */
+ bool isEqual(const QVariant &p) const;
- /** @copydoc KConfigSkeletonItem::property() const */
- QVariant property() const;
+ /** @copydoc KConfigSkeletonItem::property() const */
+ QVariant property() const;
- private:
- Type mType;
- };
+ private:
+ Type mType;
+ };
- /**
- * Class for handling a password preferences item.
- */
- 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() !!
- };
+ /**
+ * Class for handling a password preferences item.
+ */
+ 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() !!
+ };
- /**
- * Class for handling a path preferences item.
- */
- class KCONFIGCORE_EXPORT ItemPath:public ItemString
- {
- public:
- /** @copydoc KConfigSkeletonGenericItem::KConfigSkeletonGenericItem */
- ItemPath(const QString & _group, const QString & _key,
- QString & reference,
- const QString & defaultValue = QString());
- };
+ /**
+ * Class for handling a path preferences item.
+ */
+ class KCONFIGCORE_EXPORT ItemPath: public ItemString
+ {
+ public:
+ /** @copydoc KConfigSkeletonGenericItem::KConfigSkeletonGenericItem */
+ 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);
+ void writeConfig(KConfig *config);
/** @copydoc KConfigSkeletonItem::readConfig(KConfig*) */
- void readConfig(KConfig * config);
+ void readConfig(KConfig *config);
/** @copydoc KConfigSkeletonItem::setProperty(const QVariant&) */
- void setProperty(const QVariant & p);
+ void setProperty(const QVariant &p);
/** @copydoc KConfigSkeletonItem::isEqual(const QVariant &) const */
- bool isEqual(const QVariant &p) const;
+ bool isEqual(const QVariant &p) const;
/** @copydoc KConfigSkeletonItem::property() const */
QVariant property() const;
};
- /**
- * Class for handling a QVariant preferences item.
- */
- class KCONFIGCORE_EXPORT ItemProperty:public KConfigSkeletonGenericItem < QVariant >
- {
- public:
- /** @copydoc KConfigSkeletonGenericItem::KConfigSkeletonGenericItem */
- ItemProperty(const QString & _group, const QString & _key,
- QVariant & reference, const QVariant & defaultValue = 0);
+ /**
+ * Class for handling a QVariant preferences item.
+ */
+ class KCONFIGCORE_EXPORT ItemProperty: public KConfigSkeletonGenericItem < QVariant >
+ {
+ public:
+ /** @copydoc KConfigSkeletonGenericItem::KConfigSkeletonGenericItem */
+ ItemProperty(const QString &_group, const QString &_key,
+ QVariant &reference, const QVariant &defaultValue = 0);
- void readConfig(KConfig * config);
- void setProperty(const QVariant & p);
+ void readConfig(KConfig *config);
+ void setProperty(const QVariant &p);
- /** @copydoc KConfigSkeletonItem::isEqual(const QVariant &) const */
- bool isEqual(const QVariant &p) const;
+ /** @copydoc KConfigSkeletonItem::isEqual(const QVariant &) const */
+ bool isEqual(const QVariant &p) const;
- /** @copydoc KConfigSkeletonItem::property() const */
- QVariant property() const;
- };
+ /** @copydoc KConfigSkeletonItem::property() const */
+ QVariant property() const;
+ };
+ /**
+ * Class for handling a bool preferences item.
+ */
+ class KCONFIGCORE_EXPORT ItemBool: public KConfigSkeletonGenericItem < bool >
+ {
+ public:
+ /** @copydoc KConfigSkeletonGenericItem::KConfigSkeletonGenericItem */
+ ItemBool(const QString &_group, const QString &_key, bool &reference,
+ bool defaultValue = true);
- /**
- * Class for handling a bool preferences item.
- */
- class KCONFIGCORE_EXPORT ItemBool:public KConfigSkeletonGenericItem < bool >
- {
- public:
- /** @copydoc KConfigSkeletonGenericItem::KConfigSkeletonGenericItem */
- ItemBool(const QString & _group, const QString & _key, bool & reference,
- bool defaultValue = true);
+ /** @copydoc KConfigSkeletonItem::readConfig(KConfig*) */
+ void readConfig(KConfig *config);
- /** @copydoc KConfigSkeletonItem::readConfig(KConfig*) */
- void readConfig(KConfig * config);
+ /** @copydoc KConfigSkeletonItem::setProperty(const QVariant&) */
+ void setProperty(const QVariant &p);
- /** @copydoc KConfigSkeletonItem::setProperty(const QVariant&) */
- void setProperty(const QVariant & p);
+ /** @copydoc KConfigSkeletonItem::isEqual(const QVariant &) const */
+ bool isEqual(const QVariant &p) const;
- /** @copydoc KConfigSkeletonItem::isEqual(const QVariant &) const */
- bool isEqual(const QVariant &p) const;
+ /** @copydoc KConfigSkeletonItem::property() const */
+ QVariant property() const;
+ };
- /** @copydoc KConfigSkeletonItem::property() const */
- QVariant property() const;
- };
+ /**
+ * Class for handling a 32-bit integer preferences item.
+ */
+ class KCONFIGCORE_EXPORT ItemInt: public KConfigSkeletonGenericItem < qint32 >
+ {
+ public:
+ /** @copydoc KConfigSkeletonGenericItem::KConfigSkeletonGenericItem */
+ ItemInt(const QString &_group, const QString &_key, qint32 &reference,
+ qint32 defaultValue = 0);
+ /** @copydoc KConfigSkeletonItem::readConfig(KConfig*) */
+ void readConfig(KConfig *config);
- /**
- * Class for handling a 32-bit integer preferences item.
- */
- class KCONFIGCORE_EXPORT ItemInt:public KConfigSkeletonGenericItem < qint32 >
- {
- public:
- /** @copydoc KConfigSkeletonGenericItem::KConfigSkeletonGenericItem */
- ItemInt(const QString & _group, const QString & _key, qint32 &reference,
- qint32 defaultValue = 0);
+ /** @copydoc KConfigSkeletonItem::setProperty(const QVariant&) */
+ void setProperty(const QVariant &p);
- /** @copydoc KConfigSkeletonItem::readConfig(KConfig*) */
- void readConfig(KConfig * config);
+ /** @copydoc KConfigSkeletonItem::isEqual(const QVariant &) const */
+ bool isEqual(const QVariant &p) const;
- /** @copydoc KConfigSkeletonItem::setProperty(const QVariant&) */
- void setProperty(const QVariant & p);
+ /** @copydoc KConfigSkeletonItem::property() */
+ QVariant property() const;
- /** @copydoc KConfigSkeletonItem::isEqual(const QVariant &) const */
- bool isEqual(const QVariant &p) const;
+ /** Get the minimum value that is allowed to be stored in this item */
+ QVariant minValue() const;
- /** @copydoc KConfigSkeletonItem::property() */
- QVariant property() const;
+ /** Get the maximum value this is allowed to be stored in this item */
+ QVariant maxValue() const;
- /** Get the minimum value that is allowed to be stored in this item */
- QVariant minValue() const;
+ /** Set the minimum value for the item
+ @sa minValue()
+ */
+ void setMinValue(qint32);
- /** Get the maximum value this is allowed to be stored in this item */
- QVariant maxValue() const;
+ /** Set the maximum value for the item
+ @sa maxValue
+ */
+ void setMaxValue(qint32);
- /** Set the minimum value for the item
- @sa minValue()
- */
- void setMinValue(qint32);
+ private:
+ bool mHasMin : 1;
+ bool mHasMax : 1;
+ qint32 mMin;
+ qint32 mMax;
+ };
- /** Set the maximum value for the item
- @sa maxValue
+ /**
+ * Class for handling a 64-bit integer preferences item.
*/
- void setMaxValue(qint32);
-
- private:
- bool mHasMin : 1;
- bool mHasMax : 1;
- qint32 mMin;
- qint32 mMax;
- };
-
- /**
- * Class for handling a 64-bit integer preferences item.
- */
- class KCONFIGCORE_EXPORT ItemLongLong:public KConfigSkeletonGenericItem < qint64 >
- {
- public:
- /** @copydoc KConfigSkeletonGenericItem::KConfigSkeletonGenericItem */
- ItemLongLong(const QString & _group, const QString & _key, qint64 &reference,
- qint64 defaultValue = 0);
+ class KCONFIGCORE_EXPORT ItemLongLong: public KConfigSkeletonGenericItem < qint64 >
+ {
+ public:
+ /** @copydoc KConfigSkeletonGenericItem::KConfigSkeletonGenericItem */
+ ItemLongLong(const QString &_group, const QString &_key, qint64 &reference,
+ qint64 defaultValue = 0);
- /** @copydoc KConfigSkeletonItem::readConfig(KConfig*) */
- void readConfig(KConfig * config);
+ /** @copydoc KConfigSkeletonItem::readConfig(KConfig*) */
+ void readConfig(KConfig *config);
- /** @copydoc KConfigSkeletonItem::setProperty(const QVariant&) */
- void setProperty(const QVariant & p);
+ /** @copydoc KConfigSkeletonItem::setProperty(const QVariant&) */
+ void setProperty(const QVariant &p);
- /** @copydoc KConfigSkeletonItem::isEqual(const QVariant &) const */
- bool isEqual(const QVariant &p) const;
+ /** @copydoc KConfigSkeletonItem::isEqual(const QVariant &) const */
+ bool isEqual(const QVariant &p) const;
- /** @copydoc KConfigSkeletonItem::property() */
- QVariant property() const;
+ /** @copydoc KConfigSkeletonItem::property() */
+ QVariant property() const;
- /** @copydoc ItemInt::minValue() */
- QVariant minValue() const;
+ /** @copydoc ItemInt::minValue() */
+ QVariant minValue() const;
- /** @copydoc ItemInt::maxValue() */
- QVariant maxValue() const;
+ /** @copydoc ItemInt::maxValue() */
+ QVariant maxValue() const;
- /** @copydoc ItemInt::setMinValue(qint32) */
- void setMinValue(qint64);
+ /** @copydoc ItemInt::setMinValue(qint32) */
+ void setMinValue(qint64);
- /** @copydoc ItemInt::setMaxValue(qint32) */
- void setMaxValue(qint64);
+ /** @copydoc ItemInt::setMaxValue(qint32) */
+ void setMaxValue(qint64);
- private:
- bool mHasMin : 1;
- bool mHasMax : 1;
- qint64 mMin;
- qint64 mMax;
- };
+ private:
+ bool mHasMin : 1;
+ bool mHasMax : 1;
+ qint64 mMin;
+ qint64 mMax;
+ };
#ifndef KDE_NO_DEPRECATED
- typedef KCONFIGCORE_DEPRECATED ItemLongLong ItemInt64;
+ typedef KCONFIGCORE_DEPRECATED ItemLongLong ItemInt64;
#endif
- /**
- * Class for handling enums.
- */
- class KCONFIGCORE_EXPORT ItemEnum:public ItemInt
- {
- public:
- struct Choice
+ /**
+ * Class for handling enums.
+ */
+ class KCONFIGCORE_EXPORT ItemEnum: public ItemInt
{
- QString name;
- QString label;
- QString toolTip;
- QString whatsThis;
- };
-
- /** @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);
+ public:
+ struct Choice {
+ QString name;
+ QString label;
+ QString toolTip;
+ QString whatsThis;
+ };
- QList<Choice> choices() const;
+ /** @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);
- /** @copydoc KConfigSkeletonItem::readConfig(KConfig*) */
- void readConfig(KConfig * config);
+ QList<Choice> choices() const;
- /** @copydoc KConfigSkeletonItem::writeConfig(KConfig*) */
- void writeConfig(KConfig * config);
+ /** @copydoc KConfigSkeletonItem::readConfig(KConfig*) */
+ void readConfig(KConfig *config);
- // Source compatibility with 4.x
- typedef Choice Choice2;
- QList<Choice> choices2() const;
+ /** @copydoc KConfigSkeletonItem::writeConfig(KConfig*) */
+ void writeConfig(KConfig *config);
- private:
- QList<Choice> mChoices;
- };
+ // Source compatibility with 4.x
+ typedef Choice Choice2;
+ QList<Choice> choices2() const;
+ private:
+ QList<Choice> mChoices;
+ };
- /**
- * Class for handling an unsigned 32-bit integer preferences item.
- */
- class KCONFIGCORE_EXPORT ItemUInt:public KConfigSkeletonGenericItem < quint32 >
- {
- public:
- /** @copydoc KConfigSkeletonGenericItem::KConfigSkeletonGenericItem */
- ItemUInt(const QString & _group, const QString & _key,
- quint32 &reference, quint32 defaultValue = 0);
+ /**
+ * Class for handling an unsigned 32-bit integer preferences item.
+ */
+ class KCONFIGCORE_EXPORT ItemUInt: public KConfigSkeletonGenericItem < quint32 >
+ {
+ public:
+ /** @copydoc KConfigSkeletonGenericItem::KConfigSkeletonGenericItem */
+ ItemUInt(const QString &_group, const QString &_key,
+ quint32 &reference, quint32 defaultValue = 0);
- /** @copydoc KConfigSkeletonItem::readConfig(KConfig*) */
- void readConfig(KConfig * config);
+ /** @copydoc KConfigSkeletonItem::readConfig(KConfig*) */
+ void readConfig(KConfig *config);
- /** @copydoc KConfigSkeletonItem::setProperty(const QVariant&) */
- void setProperty(const QVariant & p);
+ /** @copydoc KConfigSkeletonItem::setProperty(const QVariant&) */
+ void setProperty(const QVariant &p);
- /** @copydoc KConfigSkeletonItem::isEqual(const QVariant &) const */
- bool isEqual(const QVariant &p) const;
+ /** @copydoc KConfigSkeletonItem::isEqual(const QVariant &) const */
+ bool isEqual(const QVariant &p) const;
- /** @copydoc KConfigSkeletonItem::property() */
- QVariant property() const;
+ /** @copydoc KConfigSkeletonItem::property() */
+ QVariant property() const;
- /** @copydoc ItemInt::minValue() */
- QVariant minValue() const;
+ /** @copydoc ItemInt::minValue() */
+ QVariant minValue() const;
- /** @copydoc ItemInt::maxValue() */
- QVariant maxValue() const;
+ /** @copydoc ItemInt::maxValue() */
+ QVariant maxValue() const;
- /** @copydoc ItemInt::setMinValue(qint32) */
- void setMinValue(quint32);
+ /** @copydoc ItemInt::setMinValue(qint32) */
+ void setMinValue(quint32);
- /** @copydoc ItemInt::setMaxValue(qint32) */
- void setMaxValue(quint32);
+ /** @copydoc ItemInt::setMaxValue(qint32) */
+ void setMaxValue(quint32);
- private:
- bool mHasMin : 1;
- bool mHasMax : 1;
- quint32 mMin;
- quint32 mMax;
- };
+ private:
+ bool mHasMin : 1;
+ bool mHasMax : 1;
+ quint32 mMin;
+ quint32 mMax;
+ };
- /**
- * Class for handling unsigned 64-bit integer preferences item.
- */
- class KCONFIGCORE_EXPORT ItemULongLong:public KConfigSkeletonGenericItem < quint64 >
- {
- public:
- /** @copydoc KConfigSkeletonGenericItem::KConfigSkeletonGenericItem */
- ItemULongLong(const QString & _group, const QString & _key, quint64 &reference,
- quint64 defaultValue = 0);
+ /**
+ * Class for handling unsigned 64-bit integer preferences item.
+ */
+ class KCONFIGCORE_EXPORT ItemULongLong: public KConfigSkeletonGenericItem < quint64 >
+ {
+ public:
+ /** @copydoc KConfigSkeletonGenericItem::KConfigSkeletonGenericItem */
+ ItemULongLong(const QString &_group, const QString &_key, quint64 &reference,
+ quint64 defaultValue = 0);
- /** @copydoc KConfigSkeletonItem::readConfig(KConfig*) */
- void readConfig(KConfig * config);
+ /** @copydoc KConfigSkeletonItem::readConfig(KConfig*) */
+ void readConfig(KConfig *config);
- /** @copydoc KConfigSkeletonItem::setProperty(const QVariant&) */
- void setProperty(const QVariant & p);
+ /** @copydoc KConfigSkeletonItem::setProperty(const QVariant&) */
+ void setProperty(const QVariant &p);
- /** @copydoc KConfigSkeletonItem::isEqual(const QVariant &) const */
- bool isEqual(const QVariant &p) const;
+ /** @copydoc KConfigSkeletonItem::isEqual(const QVariant &) const */
+ bool isEqual(const QVariant &p) const;
- /** @copydoc KConfigSkeletonItem::property() */
- QVariant property() const;
+ /** @copydoc KConfigSkeletonItem::property() */
+ QVariant property() const;
- /** @copydoc ItemInt::minValue() */
- QVariant minValue() const;
+ /** @copydoc ItemInt::minValue() */
+ QVariant minValue() const;
- /** @copydoc ItemInt::maxValue() */
- QVariant maxValue() const;
+ /** @copydoc ItemInt::maxValue() */
+ QVariant maxValue() const;
- /** @copydoc ItemInt::setMinValue(qint32) */
- void setMinValue(quint64);
+ /** @copydoc ItemInt::setMinValue(qint32) */
+ void setMinValue(quint64);
- /** @copydoc ItemInt::setMaxValue(qint32) */
- void setMaxValue(quint64);
+ /** @copydoc ItemInt::setMaxValue(qint32) */
+ void setMaxValue(quint64);
- private:
- bool mHasMin : 1;
- bool mHasMax : 1;
- quint64 mMin;
- quint64 mMax;
- };
+ private:
+ bool mHasMin : 1;
+ bool mHasMax : 1;
+ quint64 mMin;
+ quint64 mMax;
+ };
#ifndef KDE_NO_DEPRECATED
- typedef KCONFIGCORE_DEPRECATED ItemULongLong ItemUInt64;
+ typedef KCONFIGCORE_DEPRECATED ItemULongLong ItemUInt64;
#endif
- /**
- * Class for handling a floating point preference item.
- */
- class KCONFIGCORE_EXPORT ItemDouble:public KConfigSkeletonGenericItem < double >
- {
- public:
- /** @copydoc KConfigSkeletonGenericItem::KConfigSkeletonGenericItem */
- ItemDouble(const QString & _group, const QString & _key,
- double &reference, double defaultValue = 0);
+ /**
+ * Class for handling a floating point preference item.
+ */
+ class KCONFIGCORE_EXPORT ItemDouble: public KConfigSkeletonGenericItem < double >
+ {
+ public:
+ /** @copydoc KConfigSkeletonGenericItem::KConfigSkeletonGenericItem */
+ ItemDouble(const QString &_group, const QString &_key,
+ double &reference, double defaultValue = 0);
- /** @copydoc KConfigSkeletonItem::readConfig(KConfig*) */
- void readConfig(KConfig * config);
+ /** @copydoc KConfigSkeletonItem::readConfig(KConfig*) */
+ void readConfig(KConfig *config);
- /** @copydoc KConfigSkeletonItem::setProperty(const QVariant&) */
- void setProperty(const QVariant & p);
+ /** @copydoc KConfigSkeletonItem::setProperty(const QVariant&) */
+ void setProperty(const QVariant &p);
- /** @copydoc KConfigSkeletonItem::isEqual(const QVariant &) const */
- bool isEqual(const QVariant &p) const;
+ /** @copydoc KConfigSkeletonItem::isEqual(const QVariant &) const */
+ bool isEqual(const QVariant &p) const;
- /** @copydoc KConfigSkeletonItem::property() */
- QVariant property() const;
+ /** @copydoc KConfigSkeletonItem::property() */
+ QVariant property() const;
- /** @copydoc ItemInt::minValue() */
- QVariant minValue() const;
+ /** @copydoc ItemInt::minValue() */
+ QVariant minValue() const;
- /** @copydoc ItemInt::maxValue() */
- QVariant maxValue() const;
+ /** @copydoc ItemInt::maxValue() */
+ QVariant maxValue() const;
- /** @copydoc ItemInt::setMinValue() */
- void setMinValue(double);
+ /** @copydoc ItemInt::setMinValue() */
+ void setMinValue(double);
- /** @copydoc ItemInt::setMaxValue() */
- void setMaxValue(double);
+ /** @copydoc ItemInt::setMaxValue() */
+ void setMaxValue(double);
- private:
- bool mHasMin : 1;
- bool mHasMax : 1;
- double mMin;
- double mMax;
- };
+ private:
+ bool mHasMin : 1;
+ bool mHasMax : 1;
+ double mMin;
+ double mMax;
+ };
+ /**
+ * Class for handling a QRect preferences item.
+ */
+ class KCONFIGCORE_EXPORT ItemRect: public KConfigSkeletonGenericItem < QRect >
+ {
+ public:
+ /** @copydoc KConfigSkeletonGenericItem::KConfigSkeletonGenericItem */
+ ItemRect(const QString &_group, const QString &_key, QRect &reference,
+ const QRect &defaultValue = QRect());
- /**
- * Class for handling a QRect preferences item.
- */
- class KCONFIGCORE_EXPORT ItemRect:public KConfigSkeletonGenericItem < QRect >
- {
- public:
- /** @copydoc KConfigSkeletonGenericItem::KConfigSkeletonGenericItem */
- ItemRect(const QString & _group, const QString & _key, QRect & reference,
- const QRect & defaultValue = QRect());
-
- /** @copydoc KConfigSkeletonItem::readConfig(KConfig*) */
- void readConfig(KConfig * config);
-
- /** @copydoc KConfigSkeletonItem::setProperty(const QVariant&) */
- void setProperty(const QVariant & p);
+ /** @copydoc KConfigSkeletonItem::readConfig(KConfig*) */
+ void readConfig(KConfig *config);
- /** @copydoc KConfigSkeletonItem::isEqual(const QVariant &) const */
- bool isEqual(const QVariant &p) const;
+ /** @copydoc KConfigSkeletonItem::setProperty(const QVariant&) */
+ void setProperty(const QVariant &p);
- /** @copydoc KConfigSkeletonItem::property() */
- QVariant property() const;
- };
+ /** @copydoc KConfigSkeletonItem::isEqual(const QVariant &) const */
+ bool isEqual(const QVariant &p) const;
+ /** @copydoc KConfigSkeletonItem::property() */
+ QVariant property() const;
+ };
- /**
- * Class for handling a QPoint preferences item.
- */
- class KCONFIGCORE_EXPORT ItemPoint:public KConfigSkeletonGenericItem < QPoint >
- {
- public:
- /** @copydoc KConfigSkeletonGenericItem::KConfigSkeletonGenericItem */
- ItemPoint(const QString & _group, const QString & _key, QPoint & reference,
- const QPoint & defaultValue = QPoint());
-
- /** @copydoc KConfigSkeletonItem::readConfig(KConfig*) */
- void readConfig(KConfig * config);
-
- /** @copydoc KConfigSkeletonItem::setProperty(const QVariant&) */
- void setProperty(const QVariant & p);
+ /**
+ * Class for handling a QPoint preferences item.
+ */
+ class KCONFIGCORE_EXPORT ItemPoint: public KConfigSkeletonGenericItem < QPoint >
+ {
+ public:
+ /** @copydoc KConfigSkeletonGenericItem::KConfigSkeletonGenericItem */
+ ItemPoint(const QString &_group, const QString &_key, QPoint &reference,
+ const QPoint &defaultValue = QPoint());
- /** @copydoc KConfigSkeletonItem::isEqual(const QVariant &) const */
- bool isEqual(const QVariant &p) const;
+ /** @copydoc KConfigSkeletonItem::readConfig(KConfig*) */
+ void readConfig(KConfig *config);
- /** @copydoc KConfigSkeletonItem::property() */
- QVariant property() const;
- };
+ /** @copydoc KConfigSkeletonItem::setProperty(const QVariant&) */
+ void setProperty(const QVariant &p);
+ /** @copydoc KConfigSkeletonItem::isEqual(const QVariant &) const */
+ bool isEqual(const QVariant &p) const;
- /**
- * Class for handling a QSize preferences item.
- */
- class KCONFIGCORE_EXPORT ItemSize:public KConfigSkeletonGenericItem < QSize >
- {
- public:
- /** @copydoc KConfigSkeletonGenericItem::KConfigSkeletonGenericItem */
- ItemSize(const QString & _group, const QString & _key, QSize & reference,
- const QSize & defaultValue = QSize());
+ /** @copydoc KConfigSkeletonItem::property() */
+ QVariant property() const;
+ };
- /** @copydoc KConfigSkeletonItem::readConfig(KConfig*) */
- void readConfig(KConfig * config);
-
- /** @copydoc KConfigSkeletonItem::setProperty(const QVariant&) */
- void setProperty(const QVariant & p);
+ /**
+ * Class for handling a QSize preferences item.
+ */
+ class KCONFIGCORE_EXPORT ItemSize: public KConfigSkeletonGenericItem < QSize >
+ {
+ public:
+ /** @copydoc KConfigSkeletonGenericItem::KConfigSkeletonGenericItem */
+ ItemSize(const QString &_group, const QString &_key, QSize &reference,
+ const QSize &defaultValue = QSize());
- /** @copydoc KConfigSkeletonItem::isEqual(const QVariant &) const */
- bool isEqual(const QVariant &p) const;
+ /** @copydoc KConfigSkeletonItem::readConfig(KConfig*) */
+ void readConfig(KConfig *config);
- /** @copydoc KConfigSkeletonItem::property() */
- QVariant property() const;
- };
+ /** @copydoc KConfigSkeletonItem::setProperty(const QVariant&) */
+ void setProperty(const QVariant &p);
+ /** @copydoc KConfigSkeletonItem::isEqual(const QVariant &) const */
+ bool isEqual(const QVariant &p) const;
- /**
- * Class for handling a QDateTime preferences item.
- */
- class KCONFIGCORE_EXPORT ItemDateTime:public KConfigSkeletonGenericItem < QDateTime >
- {
- public:
- /** @copydoc KConfigSkeletonGenericItem::KConfigSkeletonGenericItem */
- ItemDateTime(const QString & _group, const QString & _key,
- QDateTime & reference,
- const QDateTime & defaultValue = QDateTime());
+ /** @copydoc KConfigSkeletonItem::property() */
+ QVariant property() const;
+ };
- /** @copydoc KConfigSkeletonItem::readConfig(KConfig*) */
- void readConfig(KConfig * config);
+ /**
+ * Class for handling a QDateTime preferences item.
+ */
+ class KCONFIGCORE_EXPORT ItemDateTime: public KConfigSkeletonGenericItem < QDateTime >
+ {
+ public:
+ /** @copydoc KConfigSkeletonGenericItem::KConfigSkeletonGenericItem */
+ ItemDateTime(const QString &_group, const QString &_key,
+ QDateTime &reference,
+ const QDateTime &defaultValue = QDateTime());
- /** @copydoc KConfigSkeletonItem::setProperty(const QVariant&) */
- void setProperty(const QVariant & p);
-
- /** @copydoc KConfigSkeletonItem::isEqual(const QVariant &) const */
- bool isEqual(const QVariant &p) const;
-
- /** @copydoc KConfigSkeletonItem::property() */
- QVariant property() const;
- };
-
-
- /**
- * Class for handling a string list preferences item.
- */
- class KCONFIGCORE_EXPORT ItemStringList:public KConfigSkeletonGenericItem < QStringList >
- {
- public:
- /** @copydoc KConfigSkeletonGenericItem::KConfigSkeletonGenericItem */
- ItemStringList(const QString & _group, const QString & _key,
- QStringList & reference,
- const QStringList & defaultValue = QStringList());
+ /** @copydoc KConfigSkeletonItem::readConfig(KConfig*) */
+ void readConfig(KConfig *config);
- /** @copydoc KConfigSkeletonItem::readConfig(KConfig*) */
- void readConfig(KConfig * config);
+ /** @copydoc KConfigSkeletonItem::setProperty(const QVariant&) */
+ void setProperty(const QVariant &p);
- /** @copydoc KConfigSkeletonItem::setProperty(const QVariant&) */
- void setProperty(const QVariant & p);
-
- /** @copydoc KConfigSkeletonItem::isEqual(const QVariant &) const */
- bool isEqual(const QVariant &p) const;
-
- /** @copydoc KConfigSkeletonItem::property() */
- QVariant property() const;
- };
+ /** @copydoc KConfigSkeletonItem::isEqual(const QVariant &) const */
+ bool isEqual(const QVariant &p) const;
+ /** @copydoc KConfigSkeletonItem::property() */
+ QVariant property() const;
+ };
- /**
- * Class for handling a path list preferences item.
- */
- class KCONFIGCORE_EXPORT ItemPathList:public ItemStringList
- {
- public:
- /** @copydoc KConfigSkeletonGenericItem::KConfigSkeletonGenericItem */
- ItemPathList(const QString & _group, const QString & _key,
- QStringList & reference,
- const QStringList & defaultValue = QStringList());
+ /**
+ * Class for handling a string list preferences item.
+ */
+ class KCONFIGCORE_EXPORT ItemStringList: public KConfigSkeletonGenericItem < QStringList >
+ {
+ public:
+ /** @copydoc KConfigSkeletonGenericItem::KConfigSkeletonGenericItem */
+ ItemStringList(const QString &_group, const QString &_key,
+ QStringList &reference,
+ const QStringList &defaultValue = QStringList());
+
+ /** @copydoc KConfigSkeletonItem::readConfig(KConfig*) */
+ void readConfig(KConfig *config);
+
+ /** @copydoc KConfigSkeletonItem::setProperty(const QVariant&) */
+ void setProperty(const QVariant &p);
- /** @copydoc KConfigSkeletonItem::readConfig */
- void readConfig(KConfig * config);
- /** @copydoc KConfigSkeletonItem::writeConfig */
- void writeConfig(KConfig * config);
- };
+ /** @copydoc KConfigSkeletonItem::isEqual(const QVariant &) const */
+ bool isEqual(const QVariant &p) const;
+
+ /** @copydoc KConfigSkeletonItem::property() */
+ QVariant property() const;
+ };
+
+ /**
+ * Class for handling a path list preferences item.
+ */
+ class KCONFIGCORE_EXPORT ItemPathList: public ItemStringList
+ {
+ public:
+ /** @copydoc KConfigSkeletonGenericItem::KConfigSkeletonGenericItem */
+ ItemPathList(const QString &_group, const QString &_key,
+ QStringList &reference,
+ const QStringList &defaultValue = QStringList());
+
+ /** @copydoc KConfigSkeletonItem::readConfig */
+ void readConfig(KConfig *config);
+ /** @copydoc KConfigSkeletonItem::writeConfig */
+ void writeConfig(KConfig *config);
+ };
/**
* 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);
+ void readConfig(KConfig *config);
/** @copydoc KConfigSkeletonItem::writeConfig(KConfig*) */
- void writeConfig(KConfig * config);
+ void writeConfig(KConfig *config);
/** @copydoc KConfigSkeletonItem::setProperty(const QVariant&) */
- void setProperty(const QVariant & p);
+ void setProperty(const QVariant &p);
/** @copydoc KConfigSkeletonItem::isEqual(const QVariant &) const */
- bool isEqual(const QVariant &p) const;
+ bool isEqual(const QVariant &p) const;
/** @copydoc KConfigSkeletonItem::property() */
QVariant property() const;
};
- /**
- * Class for handling an integer list preferences item.
- */
- 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 >());
-
- /** @copydoc KConfigSkeletonItem::readConfig(KConfig*) */
- void readConfig(KConfig * config);
+ /**
+ * Class for handling an integer list preferences item.
+ */
+ 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 >());
- /** @copydoc KConfigSkeletonItem::setProperty(const QVariant&) */
- void setProperty(const QVariant & p);
+ /** @copydoc KConfigSkeletonItem::readConfig(KConfig*) */
+ void readConfig(KConfig *config);
- /** @copydoc KConfigSkeletonItem::isEqual(const QVariant &) const */
- bool isEqual(const QVariant &p) const;
+ /** @copydoc KConfigSkeletonItem::setProperty(const QVariant&) */
+ void setProperty(const QVariant &p);
- /** @copydoc KConfigSkeletonItem::property() */
- QVariant property() const;
- };
+ /** @copydoc KConfigSkeletonItem::isEqual(const QVariant &) const */
+ bool isEqual(const QVariant &p) const;
+ /** @copydoc KConfigSkeletonItem::property() */
+ QVariant property() const;
+ };
public:
- /**
- * Constructor.
- *
- * @param configname name of config file. If no name is given, the default
- * config file as returned by KSharedConfig::openConfig() is used
- * @param parent the parent object (see QObject documentation)
- */
- explicit KCoreConfigSkeleton(const QString & configname = QString(), QObject* parent = 0);
-
- /**
- * Constructor.
- *
- * @param config configuration object to use
- * @param parent the parent object (see QObject documentation)
- */
- explicit KCoreConfigSkeleton(KSharedConfig::Ptr config, QObject* parent = 0);
-
- /**
- * Destructor
- */
- virtual ~KCoreConfigSkeleton();
-
- /**
- * Set all registered items to their default values.
- * This method calls usrSetDefaults() after setting the defaults for the
- * registered items. You can overridde usrSetDefaults() in derived classes
- * if you have special requirements.
- * If you need more fine-grained control of setting the default values of
- * the registered items you can override setDefaults() in a derived class.
- */
- virtual void setDefaults();
-
- /**
- * Read preferences from config file. All registered items are set to the
- * values read from disk.
- * This method calls usrReadConfig() after reading the settings of the
- * registered items from the KConfig. You can overridde usrReadConfig()
- * in derived classes if you have special requirements.
- * If you need more fine-grained control of storing the settings from
- * the registered items you can override readConfig() in a derived class.
- */
- virtual void readConfig();
-
- /**
- * Set the config file group for subsequent addItem() calls. It is valid
- * until setCurrentGroup() is called with a new argument. Call this before
- * you add any items. The default value is "No Group".
- */
- void setCurrentGroup(const QString & group);
-
- /**
- * Returns the current group used for addItem() calls.
- */
- QString currentGroup() const;
-
- /**
- * Register a custom @ref KConfigSkeletonItem with a given name.
- *
- * If the name parameter is null, take the name from KConfigSkeletonItem::key().
- * Note that all names must be unique but that multiple entries can have
- * the same key if they reside in different groups.
- *
- * KCoreConfigSkeleton takes ownership of the KConfigSkeletonItem.
- */
- void addItem(KConfigSkeletonItem *, const QString & name = QString() );
-
- /**
- * Register an item of type QString.
- *
- * @param name Name used to identify this setting. Names must be unique.
- * @param reference Pointer to the variable, which is set by readConfig()
- * calls and read by writeConfig() calls.
- * @param defaultValue Default value, which is used when the config file
- * does not yet contain the key of this item.
- * @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() !!
- const QString & key = QString());
-
- /**
- * Register a password item of type QString. The string value is written
- * encrypted to the config file. Note that the current encryption scheme
- * is very weak.
- *
- * @param name Name used to identify this setting. Names must be unique.
- * @param reference Pointer to the variable, which is set by readConfig()
- * calls and read by writeConfig() calls.
- * @param defaultValue Default value, which is used when the config file
- * does not yet contain the key of this item.
- * @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());
-
- /**
- * Register a path item of type QString. The string value is interpreted
- * as a path. This means, dollar expension is activated for this value, so
- * that e.g. $HOME gets expanded.
- *
- * @param name Name used to identify this setting. Names must be unique.
- * @param reference Pointer to the variable, which is set by readConfig()
- * calls and read by writeConfig() calls.
- * @param defaultValue Default value, which is used when the config file
- * does not yet contain the key of this item.
- * @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());
-
- /**
- * Register a property item of type QVariant. Note that only the following
- * QVariant types are allowed: String, StringList, Font, Point, Rect, Size,
- * Color, Int, UInt, Bool, Double, DateTime and Date.
- *
- * @param name Name used to identify this setting. Names must be unique.
- * @param reference Pointer to the variable, which is set by readConfig()
- * calls and read by writeConfig() calls.
- * @param defaultValue Default value, which is used when the config file
- * does not yet contain the key of this item.
- * @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());
- /**
- * Register an item of type bool.
- *
- * @param name Name used to identify this setting. Names must be unique.
- * @param reference Pointer to the variable, which is set by readConfig()
- * calls and read by writeConfig() calls.
- * @param defaultValue Default value, which is used when the config file
- * does not yet contain the key of this item.
- * @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());
-
- /**
- * Register an item of type qint32.
- *
- * @param name Name used to identify this setting. Names must be unique.
- * @param reference Pointer to the variable, which is set by readConfig()
- * calls and read by writeConfig() calls.
- * @param defaultValue Default value, which is used when the config file
- * does not yet contain the key of this item.
- * @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());
-
- /**
- * Register an item of type quint32.
- *
- * @param name Name used to identify this setting. Names must be unique.
- * @param reference Pointer to the variable, which is set by readConfig()
- * calls and read by writeConfig() calls.
- * @param defaultValue Default value, which is used when the config file
- * does not yet contain the key of this item.
- * @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());
-
- /**
- * Register an item of type qint64.
- *
- * @param name Name used to identify this setting. Names must be unique.
- * @param reference Pointer to the variable, which is set by readConfig()
- * calls and read by writeConfig() calls.
- * @param defaultValue Default value, which is used when the config file
- * does not yet contain the key of this item.
- * @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());
-
- /**
- * @deprecated
- * Use addItemLongLong().
- */
+ /**
+ * Constructor.
+ *
+ * @param configname name of config file. If no name is given, the default
+ * config file as returned by KSharedConfig::openConfig() is used
+ * @param parent the parent object (see QObject documentation)
+ */
+ explicit KCoreConfigSkeleton(const QString &configname = QString(), QObject *parent = 0);
+
+ /**
+ * Constructor.
+ *
+ * @param config configuration object to use
+ * @param parent the parent object (see QObject documentation)
+ */
+ explicit KCoreConfigSkeleton(KSharedConfig::Ptr config, QObject *parent = 0);
+
+ /**
+ * Destructor
+ */
+ virtual ~KCoreConfigSkeleton();
+
+ /**
+ * Set all registered items to their default values.
+ * This method calls usrSetDefaults() after setting the defaults for the
+ * registered items. You can overridde usrSetDefaults() in derived classes
+ * if you have special requirements.
+ * If you need more fine-grained control of setting the default values of
+ * the registered items you can override setDefaults() in a derived class.
+ */
+ virtual void setDefaults();
+
+ /**
+ * Read preferences from config file. All registered items are set to the
+ * values read from disk.
+ * This method calls usrReadConfig() after reading the settings of the
+ * registered items from the KConfig. You can overridde usrReadConfig()
+ * in derived classes if you have special requirements.
+ * If you need more fine-grained control of storing the settings from
+ * the registered items you can override readConfig() in a derived class.
+ */
+ virtual void readConfig();
+
+ /**
+ * Set the config file group for subsequent addItem() calls. It is valid
+ * until setCurrentGroup() is called with a new argument. Call this before
+ * you add any items. The default value is "No Group".
+ */
+ void setCurrentGroup(const QString &group);
+
+ /**
+ * Returns the current group used for addItem() calls.
+ */
+ QString currentGroup() const;
+
+ /**
+ * Register a custom @ref KConfigSkeletonItem with a given name.
+ *
+ * If the name parameter is null, take the name from KConfigSkeletonItem::key().
+ * Note that all names must be unique but that multiple entries can have
+ * the same key if they reside in different groups.
+ *
+ * KCoreConfigSkeleton takes ownership of the KConfigSkeletonItem.
+ */
+ void addItem(KConfigSkeletonItem *, const QString &name = QString());
+
+ /**
+ * Register an item of type QString.
+ *
+ * @param name Name used to identify this setting. Names must be unique.
+ * @param reference Pointer to the variable, which is set by readConfig()
+ * calls and read by writeConfig() calls.
+ * @param defaultValue Default value, which is used when the config file
+ * does not yet contain the key of this item.
+ * @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() !!
+ const QString &key = QString());
+
+ /**
+ * Register a password item of type QString. The string value is written
+ * encrypted to the config file. Note that the current encryption scheme
+ * is very weak.
+ *
+ * @param name Name used to identify this setting. Names must be unique.
+ * @param reference Pointer to the variable, which is set by readConfig()
+ * calls and read by writeConfig() calls.
+ * @param defaultValue Default value, which is used when the config file
+ * does not yet contain the key of this item.
+ * @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());
+
+ /**
+ * Register a path item of type QString. The string value is interpreted
+ * as a path. This means, dollar expension is activated for this value, so
+ * that e.g. $HOME gets expanded.
+ *
+ * @param name Name used to identify this setting. Names must be unique.
+ * @param reference Pointer to the variable, which is set by readConfig()
+ * calls and read by writeConfig() calls.
+ * @param defaultValue Default value, which is used when the config file
+ * does not yet contain the key of this item.
+ * @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());
+
+ /**
+ * Register a property item of type QVariant. Note that only the following
+ * QVariant types are allowed: String, StringList, Font, Point, Rect, Size,
+ * Color, Int, UInt, Bool, Double, DateTime and Date.
+ *
+ * @param name Name used to identify this setting. Names must be unique.
+ * @param reference Pointer to the variable, which is set by readConfig()
+ * calls and read by writeConfig() calls.
+ * @param defaultValue Default value, which is used when the config file
+ * does not yet contain the key of this item.
+ * @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());
+ /**
+ * Register an item of type bool.
+ *
+ * @param name Name used to identify this setting. Names must be unique.
+ * @param reference Pointer to the variable, which is set by readConfig()
+ * calls and read by writeConfig() calls.
+ * @param defaultValue Default value, which is used when the config file
+ * does not yet contain the key of this item.
+ * @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());
+
+ /**
+ * Register an item of type qint32.
+ *
+ * @param name Name used to identify this setting. Names must be unique.
+ * @param reference Pointer to the variable, which is set by readConfig()
+ * calls and read by writeConfig() calls.
+ * @param defaultValue Default value, which is used when the config file
+ * does not yet contain the key of this item.
+ * @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());
+
+ /**
+ * Register an item of type quint32.
+ *
+ * @param name Name used to identify this setting. Names must be unique.
+ * @param reference Pointer to the variable, which is set by readConfig()
+ * calls and read by writeConfig() calls.
+ * @param defaultValue Default value, which is used when the config file
+ * does not yet contain the key of this item.
+ * @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());
+
+ /**
+ * Register an item of type qint64.
+ *
+ * @param name Name used to identify this setting. Names must be unique.
+ * @param reference Pointer to the variable, which is set by readConfig()
+ * calls and read by writeConfig() calls.
+ * @param defaultValue Default value, which is used when the config file
+ * does not yet contain the key of this item.
+ * @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());
+
+ /**
+ * @deprecated
+ * Use addItemLongLong().
+ */
#ifndef KDE_NO_DEPRECATED
- KCONFIGCORE_DEPRECATED ItemLongLong *addItemInt64( const QString& name, qint64 &reference,
- qint64 defaultValue = 0,
- const QString & key = QString());
+ KCONFIGCORE_DEPRECATED ItemLongLong *addItemInt64(const QString &name, qint64 &reference,
+ qint64 defaultValue = 0,
+ const QString &key = QString());
#endif
- /**
- * Register an item of type quint64
- *
- * @param name Name used to identify this setting. Names must be unique.
- * @param reference Pointer to the variable, which is set by readConfig()
- * calls and read by writeConfig() calls.
- * @param defaultValue Default value, which is used when the config file
- * does not yet contain the key of this item.
- * @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());
-
- /**
- * @deprecated
- * Use addItemULongLong().
- */
+ /**
+ * Register an item of type quint64
+ *
+ * @param name Name used to identify this setting. Names must be unique.
+ * @param reference Pointer to the variable, which is set by readConfig()
+ * calls and read by writeConfig() calls.
+ * @param defaultValue Default value, which is used when the config file
+ * does not yet contain the key of this item.
+ * @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());
+
+ /**
+ * @deprecated
+ * Use addItemULongLong().
+ */
#ifndef KDE_NO_DEPRECATED
- KCONFIGCORE_DEPRECATED ItemULongLong *addItemUInt64(const QString & name, quint64 &reference,
- quint64 defaultValue = 0,
- const QString & key = QString());
+ KCONFIGCORE_DEPRECATED ItemULongLong *addItemUInt64(const QString &name, quint64 &reference,
+ quint64 defaultValue = 0,
+ const QString &key = QString());
#endif
- /**
- * Register an item of type double.
- *
- * @param name Name used to identify this setting. Names must be unique.
- * @param reference Pointer to the variable, which is set by readConfig()
- * calls and read by writeConfig() calls.
- * @param defaultValue Default value, which is used when the config file
- * does not yet contain the key of this item.
- * @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());
-
- /**
- * Register an item of type QRect.
- *
- * @param name Name used to identify this setting. Names must be unique.
- * @param reference Pointer to the variable, which is set by readConfig()
- * calls and read by writeConfig() calls.
- * @param defaultValue Default value, which is used when the config file
- * does not yet contain the key of this item.
- * @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());
-
- /**
- * Register an item of type QPoint.
- *
- * @param name Name used to identify this setting. Names must be unique.
- * @param reference Pointer to the variable, which is set by readConfig()
- * calls and read by writeConfig() calls.
- * @param defaultValue Default value, which is used when the config file
- * does not yet contain the key of this item.
- * @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());
-
- /**
- * Register an item of type QSize.
- *
- * @param name Name used to identify this setting. Names must be unique.
- * @param reference Pointer to the variable, which is set by readConfig()
- * calls and read by writeConfig() calls.
- * @param defaultValue Default value, which is used when the config file
- * does not yet contain the key of this item.
- * @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());
-
- /**
- * Register an item of type QDateTime.
- *
- * @param name Name used to identify this setting. Names must be unique.
- * @param reference Pointer to the variable, which is set by readConfig()
- * calls and read by writeConfig() calls.
- * @param defaultValue Default value, which is used when the config file
- * does not yet contain the key of this item.
- * @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());
-
- /**
- * Register an item of type QStringList.
- *
- * @param name Name used to identify this setting. Names must be unique.
- * @param reference Pointer to the variable, which is set by readConfig()
- * calls and read by writeConfig() calls.
- * @param defaultValue Default value, which is used when the config file
- * does not yet contain the key of this item.
- * @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());
-
- /**
- * Register an item of type QList<int>.
- *
- * @param name Name used to identify this setting. Names must be unique.
- * @param reference Pointer to the variable, which is set by readConfig()
- * calls and read by writeConfig() calls.
- * @param defaultValue Default value, which is used when the config file
- * does not yet contain the key of this item.
- * @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());
-
- /**
- * Return the @ref KConfig object used for reading and writing the settings.
- */
- KConfig *config();
-
- /**
- * Return the @ref KConfig object used for reading and writing the settings.
- */
- const KConfig *config() const;
-
- /**
- * Set the @ref KSharedConfig object used for reading and writing the settings.
- */
- void setSharedConfig(KSharedConfig::Ptr pConfig);
-
- /**
- * Return list of items managed by this KCoreConfigSkeleton object.
- */
- KConfigSkeletonItem::List items() const;
-
- /**
- * Removes and deletes an item by name
- * @arg name the name of the item to remove
- */
- void removeItem(const QString &name);
-
- /**
- * Removes and deletes all items
- */
- void clearItems();
-
- /**
- * Return whether a certain item is immutable
- * @since 4.4
- */
- bool isImmutable(const QString & name) const;
-
- /**
- * Lookup item by name
- * @since 4.4
- */
- KConfigSkeletonItem * findItem(const QString & name) const;
-
- /**
- * Specify whether this object should reflect the actual values or the
- * default values.
- * This method is implemented by usrUseDefaults(), which can be overridden
- * in derived classes if you have special requirements and can call
- * usrUseDefaults() directly.
- * If you don't have control whether useDefaults() or usrUseDefaults() is
- * called override useDefaults() directly.
- * @param b true to make this object reflect the default values,
- * false to make it reflect the actual values.
- * @return The state prior to this call
- */
- virtual bool useDefaults(bool b);
+ /**
+ * Register an item of type double.
+ *
+ * @param name Name used to identify this setting. Names must be unique.
+ * @param reference Pointer to the variable, which is set by readConfig()
+ * calls and read by writeConfig() calls.
+ * @param defaultValue Default value, which is used when the config file
+ * does not yet contain the key of this item.
+ * @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());
+
+ /**
+ * Register an item of type QRect.
+ *
+ * @param name Name used to identify this setting. Names must be unique.
+ * @param reference Pointer to the variable, which is set by readConfig()
+ * calls and read by writeConfig() calls.
+ * @param defaultValue Default value, which is used when the config file
+ * does not yet contain the key of this item.
+ * @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());
+
+ /**
+ * Register an item of type QPoint.
+ *
+ * @param name Name used to identify this setting. Names must be unique.
+ * @param reference Pointer to the variable, which is set by readConfig()
+ * calls and read by writeConfig() calls.
+ * @param defaultValue Default value, which is used when the config file
+ * does not yet contain the key of this item.
+ * @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());
+
+ /**
+ * Register an item of type QSize.
+ *
+ * @param name Name used to identify this setting. Names must be unique.
+ * @param reference Pointer to the variable, which is set by readConfig()
+ * calls and read by writeConfig() calls.
+ * @param defaultValue Default value, which is used when the config file
+ * does not yet contain the key of this item.
+ * @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());
+
+ /**
+ * Register an item of type QDateTime.
+ *
+ * @param name Name used to identify this setting. Names must be unique.
+ * @param reference Pointer to the variable, which is set by readConfig()
+ * calls and read by writeConfig() calls.
+ * @param defaultValue Default value, which is used when the config file
+ * does not yet contain the key of this item.
+ * @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());
+
+ /**
+ * Register an item of type QStringList.
+ *
+ * @param name Name used to identify this setting. Names must be unique.
+ * @param reference Pointer to the variable, which is set by readConfig()
+ * calls and read by writeConfig() calls.
+ * @param defaultValue Default value, which is used when the config file
+ * does not yet contain the key of this item.
+ * @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());
+
+ /**
+ * Register an item of type QList<int>.
+ *
+ * @param name Name used to identify this setting. Names must be unique.
+ * @param reference Pointer to the variable, which is set by readConfig()
+ * calls and read by writeConfig() calls.
+ * @param defaultValue Default value, which is used when the config file
+ * does not yet contain the key of this item.
+ * @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());
+
+ /**
+ * Return the @ref KConfig object used for reading and writing the settings.
+ */
+ KConfig *config();
+
+ /**
+ * Return the @ref KConfig object used for reading and writing the settings.
+ */
+ const KConfig *config() const;
+
+ /**
+ * Set the @ref KSharedConfig object used for reading and writing the settings.
+ */
+ void setSharedConfig(KSharedConfig::Ptr pConfig);
+
+ /**
+ * Return list of items managed by this KCoreConfigSkeleton object.
+ */
+ KConfigSkeletonItem::List items() const;
+
+ /**
+ * Removes and deletes an item by name
+ * @arg name the name of the item to remove
+ */
+ void removeItem(const QString &name);
+
+ /**
+ * Removes and deletes all items
+ */
+ void clearItems();
+
+ /**
+ * Return whether a certain item is immutable
+ * @since 4.4
+ */
+ bool isImmutable(const QString &name) const;
+
+ /**
+ * Lookup item by name
+ * @since 4.4
+ */
+ KConfigSkeletonItem *findItem(const QString &name) const;
+
+ /**
+ * Specify whether this object should reflect the actual values or the
+ * default values.
+ * This method is implemented by usrUseDefaults(), which can be overridden
+ * in derived classes if you have special requirements and can call
+ * usrUseDefaults() directly.
+ * If you don't have control whether useDefaults() or usrUseDefaults() is
+ * called override useDefaults() directly.
+ * @param b true to make this object reflect the default values,
+ * false to make it reflect the actual values.
+ * @return The state prior to this call
+ */
+ virtual bool useDefaults(bool b);
public Q_SLOTS:
- /**
- * Write preferences to config file. The values of all registered items are
- * written to disk.
- * This method calls usrWriteConfig() after writing the settings from the
- * registered items to the KConfig. You can overridde usrWriteConfig()
- * in derived classes if you have special requirements.
- * If you need more fine-grained control of storing the settings from
- * the registered items you can override writeConfig() in a derived class.
- */
- virtual bool writeConfig();
+ /**
+ * Write preferences to config file. The values of all registered items are
+ * written to disk.
+ * This method calls usrWriteConfig() after writing the settings from the
+ * registered items to the KConfig. You can overridde usrWriteConfig()
+ * in derived classes if you have special requirements.
+ * If you need more fine-grained control of storing the settings from
+ * the registered items you can override writeConfig() in a derived class.
+ */
+ virtual bool writeConfig();
Q_SIGNALS:
- /**
- * This signal is emitted when the configuration change.
- */
- void configChanged();
+ /**
+ * This signal is emitted when the configuration change.
+ */
+ void configChanged();
protected:
- /**
- * Implemented by subclasses that use special defaults.
- * It replaces the default values with the actual values and
- * vice versa. Called from @ref useDefaults()
- * @param b true to make this object reflect the default values,
- * false to make it reflect the actual values.
- * @return The state prior to this call
- */
- virtual bool usrUseDefaults(bool b);
-
- /**
- * Perform the actual setting of default values.
- * Override in derived classes to set special default values.
- * Called from @ref setDefaults()
- */
- virtual void usrSetDefaults();
-
- /**
- * Perform the actual reading of the configuration file.
- * Override in derived classes to read special config values.
- * Called from @ref readConfig()
- */
- virtual void usrReadConfig();
-
- /**
- * Perform the actual writing of the configuration file.
- * Override in derived classes to write special config values.
- * Called from @ref writeConfig()
- */
- virtual bool usrWriteConfig();
+ /**
+ * Implemented by subclasses that use special defaults.
+ * It replaces the default values with the actual values and
+ * vice versa. Called from @ref useDefaults()
+ * @param b true to make this object reflect the default values,
+ * false to make it reflect the actual values.
+ * @return The state prior to this call
+ */
+ virtual bool usrUseDefaults(bool b);
+
+ /**
+ * Perform the actual setting of default values.
+ * Override in derived classes to set special default values.
+ * Called from @ref setDefaults()
+ */
+ virtual void usrSetDefaults();
+
+ /**
+ * Perform the actual reading of the configuration file.
+ * Override in derived classes to read special config values.
+ * Called from @ref readConfig()
+ */
+ virtual void usrReadConfig();
+
+ /**
+ * Perform the actual writing of the configuration file.
+ * Override in derived classes to write special config values.
+ * Called from @ref writeConfig()
+ */
+ virtual bool usrWriteConfig();
private:
- class Private;
- Private * const d;
- friend class KConfigSkeleton;
+ class Private;
+ Private *const d;
+ friend class KConfigSkeleton;
};
diff --git a/src/core/kcoreconfigskeleton_p.h b/src/core/kcoreconfigskeleton_p.h
index 0912019c..0b020ed3 100644
--- a/src/core/kcoreconfigskeleton_p.h
+++ b/src/core/kcoreconfigskeleton_p.h
@@ -27,25 +27,24 @@
class KCoreConfigSkeleton::Private
{
public:
- Private()
- : mCurrentGroup( QLatin1String("No Group") ), mUseDefaults( false )
- {}
- ~Private()
- {
- KConfigSkeletonItem::List::ConstIterator it;
- for( it = mItems.constBegin(); it != mItems.constEnd(); ++it )
+ Private()
+ : mCurrentGroup(QLatin1String("No Group")), mUseDefaults(false)
+ {}
+ ~Private()
{
- delete *it;
+ KConfigSkeletonItem::List::ConstIterator it;
+ for (it = mItems.constBegin(); it != mItems.constEnd(); ++it) {
+ delete *it;
+ }
}
- }
- QString mCurrentGroup;
+ QString mCurrentGroup;
- KSharedConfig::Ptr mConfig; // pointer to KConfig object
+ KSharedConfig::Ptr mConfig; // pointer to KConfig object
- KConfigSkeletonItem::List mItems;
- KConfigSkeletonItem::Dict mItemDict;
+ KConfigSkeletonItem::List mItems;
+ KConfigSkeletonItem::Dict mItemDict;
- bool mUseDefaults;
+ bool mUseDefaults;
};
class KConfigSkeletonItemPrivate
diff --git a/src/core/kdesktopfile.cpp b/src/core/kdesktopfile.cpp
index 0ebbb4b0..9fa3654d 100644
--- a/src/core/kdesktopfile.cpp
+++ b/src/core/kdesktopfile.cpp
@@ -40,7 +40,7 @@
class KDesktopFilePrivate : public KConfigPrivate
{
- public:
+public:
KDesktopFilePrivate(QStandardPaths::StandardLocation resourceType, const QString &fileName);
KConfigGroup desktopGroup;
};
@@ -83,129 +83,137 @@ QString KDesktopFile::locateLocal(const QString &path)
{
QString relativePath;
// Relative to config? (e.g. for autostart)
- Q_FOREACH(const QString& dir, QStandardPaths::standardLocations(QStandardPaths::GenericConfigLocation)) {
+ Q_FOREACH (const QString &dir, QStandardPaths::standardLocations(QStandardPaths::GenericConfigLocation)) {
if (path.startsWith(dir) + '/') {
relativePath = dir.mid(path.length() + 1);
return QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation) + QLatin1Char('/') + relativePath;
}
}
// Relative to xdg data dir? (much more common)
- Q_FOREACH(const QString& dir, QStandardPaths::standardLocations(QStandardPaths::GenericDataLocation)) {
- if (path.startsWith(dir) + '/')
+ Q_FOREACH (const QString &dir, QStandardPaths::standardLocations(QStandardPaths::GenericDataLocation)) {
+ if (path.startsWith(dir) + '/') {
relativePath = dir.mid(path.length() + 1);
+ }
}
if (relativePath.isEmpty()) {
// What now? The desktop file doesn't come from XDG_DATA_DIRS. Use filename only and hope for the best.
- relativePath = path.mid(path.lastIndexOf(QLatin1Char('/'))+1);
+ relativePath = path.mid(path.lastIndexOf(QLatin1Char('/')) + 1);
}
return QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + QLatin1Char('/') + relativePath;
}
-bool KDesktopFile::isDesktopFile(const QString& path)
+bool KDesktopFile::isDesktopFile(const QString &path)
{
- return (path.length() > 8
- && path.endsWith(QLatin1String(".desktop")));
+ return (path.length() > 8
+ && path.endsWith(QLatin1String(".desktop")));
}
-bool KDesktopFile::isAuthorizedDesktopFile(const QString& path)
+bool KDesktopFile::isAuthorizedDesktopFile(const QString &path)
{
- if (path.isEmpty())
- return false; // Empty paths are not ok.
+ if (path.isEmpty()) {
+ return false; // Empty paths are not ok.
+ }
- if (QDir::isRelativePath(path))
- return true; // Relative paths are ok.
+ if (QDir::isRelativePath(path)) {
+ return true; // Relative paths are ok.
+ }
- const QString realPath = QFileInfo(path).canonicalFilePath();
- if (realPath.isEmpty())
- return false; // File doesn't exist.
+ const QString realPath = QFileInfo(path).canonicalFilePath();
+ if (realPath.isEmpty()) {
+ return false; // File doesn't exist.
+ }
#ifndef Q_OS_WIN
- const Qt::CaseSensitivity sensitivity = Qt::CaseSensitive;
+ const Qt::CaseSensitivity sensitivity = Qt::CaseSensitive;
#else
- const Qt::CaseSensitivity sensitivity = Qt::CaseInsensitive;
+ const Qt::CaseSensitivity sensitivity = Qt::CaseInsensitive;
#endif
- // Check if the .desktop file is installed as part of KDE or XDG.
- const QStringList appsDirs = QStandardPaths::standardLocations(QStandardPaths::ApplicationsLocation);
- Q_FOREACH (const QString &prefix, appsDirs) {
- if (QDir(prefix).exists() && realPath.startsWith(QFileInfo(prefix).canonicalFilePath(), sensitivity))
- return true;
- }
- const QString servicesDir = QLatin1String("kde5/services/"); // KGlobal::dirs()->xdgDataRelativePath("services")
- Q_FOREACH (const QString &xdgDataPrefix, QStandardPaths::standardLocations(QStandardPaths::GenericDataLocation)) {
- if (QDir(xdgDataPrefix).exists()) {
- const QString prefix = QFileInfo(xdgDataPrefix).canonicalFilePath();
- if (realPath.startsWith(prefix + QLatin1Char('/') + servicesDir, sensitivity))
- return true;
- }
- }
- const QString autostartDir = QLatin1String("autostart/");
- Q_FOREACH (const QString &xdgDataPrefix, QStandardPaths::standardLocations(QStandardPaths::GenericConfigLocation)) {
- if (QDir(xdgDataPrefix).exists()) {
- const QString prefix = QFileInfo(xdgDataPrefix).canonicalFilePath();
- if (realPath.startsWith(prefix + QLatin1Char('/') + autostartDir, sensitivity))
- return true;
- }
- }
-
- // Forbid desktop files outside of standard locations if kiosk is set so
- if (!KAuthorized::authorize(QLatin1String("run_desktop_files"))) {
- qWarning() << "Access to '" << path << "' denied because of 'run_desktop_files' restriction." << endl;
- return false;
- }
-
- // Not otherwise permitted, so only allow if the file is executable, or if
- // owned by root (uid == 0)
- QFileInfo entryInfo( path );
- if (entryInfo.isExecutable() || entryInfo.ownerId() == 0)
- return true;
-
- qWarning() << "Access to '" << path << "' denied, not owned by root, executable flag not set." << endl;
- return false;
+ // Check if the .desktop file is installed as part of KDE or XDG.
+ const QStringList appsDirs = QStandardPaths::standardLocations(QStandardPaths::ApplicationsLocation);
+ Q_FOREACH (const QString &prefix, appsDirs) {
+ if (QDir(prefix).exists() && realPath.startsWith(QFileInfo(prefix).canonicalFilePath(), sensitivity)) {
+ return true;
+ }
+ }
+ const QString servicesDir = QLatin1String("kde5/services/"); // KGlobal::dirs()->xdgDataRelativePath("services")
+ Q_FOREACH (const QString &xdgDataPrefix, QStandardPaths::standardLocations(QStandardPaths::GenericDataLocation)) {
+ if (QDir(xdgDataPrefix).exists()) {
+ const QString prefix = QFileInfo(xdgDataPrefix).canonicalFilePath();
+ if (realPath.startsWith(prefix + QLatin1Char('/') + servicesDir, sensitivity)) {
+ return true;
+ }
+ }
+ }
+ const QString autostartDir = QLatin1String("autostart/");
+ Q_FOREACH (const QString &xdgDataPrefix, QStandardPaths::standardLocations(QStandardPaths::GenericConfigLocation)) {
+ if (QDir(xdgDataPrefix).exists()) {
+ const QString prefix = QFileInfo(xdgDataPrefix).canonicalFilePath();
+ if (realPath.startsWith(prefix + QLatin1Char('/') + autostartDir, sensitivity)) {
+ return true;
+ }
+ }
+ }
+
+ // Forbid desktop files outside of standard locations if kiosk is set so
+ if (!KAuthorized::authorize(QLatin1String("run_desktop_files"))) {
+ qWarning() << "Access to '" << path << "' denied because of 'run_desktop_files' restriction." << endl;
+ return false;
+ }
+
+ // Not otherwise permitted, so only allow if the file is executable, or if
+ // owned by root (uid == 0)
+ QFileInfo entryInfo(path);
+ if (entryInfo.isExecutable() || entryInfo.ownerId() == 0) {
+ return true;
+ }
+
+ qWarning() << "Access to '" << path << "' denied, not owned by root, executable flag not set." << endl;
+ return false;
}
QString KDesktopFile::readType() const
{
- Q_D(const KDesktopFile);
- return d->desktopGroup.readEntry("Type", QString());
+ Q_D(const KDesktopFile);
+ return d->desktopGroup.readEntry("Type", QString());
}
QString KDesktopFile::readIcon() const
{
- Q_D(const KDesktopFile);
- return d->desktopGroup.readEntry("Icon", QString());
+ Q_D(const KDesktopFile);
+ return d->desktopGroup.readEntry("Icon", QString());
}
QString KDesktopFile::readName() const
{
- Q_D(const KDesktopFile);
- return d->desktopGroup.readEntry("Name", QString());
+ Q_D(const KDesktopFile);
+ return d->desktopGroup.readEntry("Name", QString());
}
QString KDesktopFile::readComment() const
{
- Q_D(const KDesktopFile);
- return d->desktopGroup.readEntry("Comment", QString());
+ Q_D(const KDesktopFile);
+ return d->desktopGroup.readEntry("Comment", QString());
}
QString KDesktopFile::readGenericName() const
{
- Q_D(const KDesktopFile);
- return d->desktopGroup.readEntry("GenericName", QString());
+ Q_D(const KDesktopFile);
+ return d->desktopGroup.readEntry("GenericName", QString());
}
QString KDesktopFile::readPath() const
{
- Q_D(const KDesktopFile);
- // NOT readPathEntry, it is not XDG-compliant. Path entries written by
- // KDE4 will be still treated as such, though.
- return d->desktopGroup.readEntry("Path", QString());
+ Q_D(const KDesktopFile);
+ // NOT readPathEntry, it is not XDG-compliant. Path entries written by
+ // KDE4 will be still treated as such, though.
+ return d->desktopGroup.readEntry("Path", QString());
}
QString KDesktopFile::readDevice() const
{
- Q_D(const KDesktopFile);
- return d->desktopGroup.readEntry("Dev", QString());
+ Q_D(const KDesktopFile);
+ return d->desktopGroup.readEntry("Dev", QString());
}
QString KDesktopFile::readUrl() const
@@ -216,8 +224,7 @@ QString KDesktopFile::readUrl() const
} else {
// NOT readPathEntry (see readPath())
QString url = d->desktopGroup.readEntry("URL", QString());
- if ( !url.isEmpty() && !QDir::isRelativePath(url) )
- {
+ if (!url.isEmpty() && !QDir::isRelativePath(url)) {
// Handle absolute paths as such (i.e. we need to escape them)
return QUrl::fromLocalFile(url).toString();
}
@@ -236,67 +243,68 @@ KConfigGroup KDesktopFile::actionGroup(const QString &group)
return KConfigGroup(this, QLatin1String("Desktop Action ") + group);
}
-const KConfigGroup KDesktopFile::actionGroup(const QString& group) const
+const KConfigGroup KDesktopFile::actionGroup(const QString &group) const
{
- return const_cast<KDesktopFile*>(this)->actionGroup(group);
+ return const_cast<KDesktopFile *>(this)->actionGroup(group);
}
bool KDesktopFile::hasActionGroup(const QString &group) const
{
- return hasGroup(QString(QLatin1String("Desktop Action ") + group).toUtf8().constData());
+ return hasGroup(QString(QLatin1String("Desktop Action ") + group).toUtf8().constData());
}
bool KDesktopFile::hasLinkType() const
{
- return readType() == QLatin1String("Link");
+ return readType() == QLatin1String("Link");
}
bool KDesktopFile::hasApplicationType() const
{
- return readType() == QLatin1String("Application");
+ return readType() == QLatin1String("Application");
}
bool KDesktopFile::hasDeviceType() const
{
- return readType() == QLatin1String("FSDevice");
+ return readType() == QLatin1String("FSDevice");
}
bool KDesktopFile::tryExec() const
{
- Q_D(const KDesktopFile);
- // Test for TryExec and "X-KDE-AuthorizeAction"
- // NOT readPathEntry (see readPath())
- QString te = d->desktopGroup.readEntry("TryExec", QString());
-
- if (!te.isEmpty()) {
- return !QStandardPaths::findExecutable(te).isEmpty();
- }
- const QStringList list = d->desktopGroup.readEntry("X-KDE-AuthorizeAction", QStringList());
- if (!list.isEmpty())
- {
- for(QStringList::ConstIterator it = list.begin();
- it != list.end();
- ++it)
- {
- if (!KAuthorized::authorize((*it).trimmed()))
- return false;
- }
- }
-
- // See also KService::username()
- bool su = d->desktopGroup.readEntry("X-KDE-SubstituteUID", false);
- if (su)
- {
- QString user = d->desktopGroup.readEntry("X-KDE-Username", QString());
- if (user.isEmpty())
- user = QString::fromLocal8Bit(qgetenv("ADMIN_ACCOUNT"));
- if (user.isEmpty())
- user = QString::fromLatin1("root");
- if (!KAuthorized::authorize(QString::fromLatin1("user/")+user))
- return false;
- }
+ Q_D(const KDesktopFile);
+ // Test for TryExec and "X-KDE-AuthorizeAction"
+ // NOT readPathEntry (see readPath())
+ QString te = d->desktopGroup.readEntry("TryExec", QString());
+
+ if (!te.isEmpty()) {
+ return !QStandardPaths::findExecutable(te).isEmpty();
+ }
+ const QStringList list = d->desktopGroup.readEntry("X-KDE-AuthorizeAction", QStringList());
+ if (!list.isEmpty()) {
+ for (QStringList::ConstIterator it = list.begin();
+ it != list.end();
+ ++it) {
+ if (!KAuthorized::authorize((*it).trimmed())) {
+ return false;
+ }
+ }
+ }
- return true;
+ // See also KService::username()
+ bool su = d->desktopGroup.readEntry("X-KDE-SubstituteUID", false);
+ if (su) {
+ QString user = d->desktopGroup.readEntry("X-KDE-Username", QString());
+ if (user.isEmpty()) {
+ user = QString::fromLocal8Bit(qgetenv("ADMIN_ACCOUNT"));
+ }
+ if (user.isEmpty()) {
+ user = QString::fromLatin1("root");
+ }
+ if (!KAuthorized::authorize(QString::fromLatin1("user/") + user)) {
+ return false;
+ }
+ }
+
+ return true;
}
/**
@@ -313,8 +321,8 @@ bool KDesktopFile::tryExec() const
QStringList
KDesktopFile::sortOrder() const
{
- Q_D(const KDesktopFile);
- return d->desktopGroup.readEntry("SortOrder", QStringList());
+ Q_D(const KDesktopFile);
+ return d->desktopGroup.readEntry("SortOrder", QStringList());
}
//void KDesktopFile::virtual_hook( int id, void* data )
@@ -322,19 +330,20 @@ KDesktopFile::sortOrder() const
QString KDesktopFile::readDocPath() const
{
- Q_D(const KDesktopFile);
- //legacy entry in kde3 apps
- if(d->desktopGroup.hasKey( "DocPath" ))
- return d->desktopGroup.readPathEntry( "DocPath", QString() );
- return d->desktopGroup.readPathEntry( "X-DocPath", QString() );
+ Q_D(const KDesktopFile);
+ //legacy entry in kde3 apps
+ if (d->desktopGroup.hasKey("DocPath")) {
+ return d->desktopGroup.readPathEntry("DocPath", QString());
+ }
+ return d->desktopGroup.readPathEntry("X-DocPath", QString());
}
-KDesktopFile* KDesktopFile::copyTo(const QString &file) const
+KDesktopFile *KDesktopFile::copyTo(const QString &file) const
{
- KDesktopFile *config = new KDesktopFile(QString());
- this->KConfig::copyTo(file, config);
+ KDesktopFile *config = new KDesktopFile(QString());
+ this->KConfig::copyTo(file, config);
// config->setDesktopGroup();
- return config;
+ return config;
}
QStandardPaths::StandardLocation KDesktopFile::resource() const
@@ -355,12 +364,14 @@ bool KDesktopFile::noDisplay() const
return true;
}
if (d->desktopGroup.hasKey("OnlyShowIn")) {
- if (!d->desktopGroup.readXdgListEntry("OnlyShowIn").contains(QLatin1String("KDE")))
+ if (!d->desktopGroup.readXdgListEntry("OnlyShowIn").contains(QLatin1String("KDE"))) {
return true;
+ }
}
if (d->desktopGroup.hasKey("NotShowIn")) {
- if (d->desktopGroup.readXdgListEntry("NotShowIn").contains(QLatin1String("KDE")))
+ if (d->desktopGroup.readXdgListEntry("NotShowIn").contains(QLatin1String("KDE"))) {
return true;
+ }
}
return false;
}
diff --git a/src/core/kdesktopfile.h b/src/core/kdesktopfile.h
index f3c5fe8f..df8eff1a 100644
--- a/src/core/kdesktopfile.h
+++ b/src/core/kdesktopfile.h
@@ -38,215 +38,215 @@ class KDesktopFilePrivate;
class KCONFIGCORE_EXPORT KDesktopFile : public KConfig
{
public:
- /**
- * Constructs a KDesktopFile object.
- *
- * See QStandardPaths for more information on resources.
- *
- * @param resourceType Allows you to change what sort of resource
- * to search for if @p fileName is not absolute.
- * For instance, you might want to specify GenericConfigLocation.
- * @param fileName The name or path of the desktop file. If it
- * is not absolute, it will be located
- * using the resource type @p resType.
- */
- explicit KDesktopFile(QStandardPaths::StandardLocation resourceType, const QString &fileName);
-
- /**
- * Constructs a KDesktopFile object.
- *
- * See QStandardPaths for more information on resources.
- *
- * @param fileName The name or path of the desktop file. If it
- * is not absolute, it will be located
- * using the resource type ApplicationsLocation
- */
- explicit KDesktopFile(const QString &fileName);
-
- /**
- * Destructs the KDesktopFile object.
- *
- * Writes back any dirty configuration entries.
- */
- virtual ~KDesktopFile();
-
- /**
- * Checks whether this is really a desktop file.
- *
- * The check is performed looking at the file extension (the file is not
- * opened).
- * Currently, the only valid extension is ".desktop".
- * @param path the path of the file to check
- * @return true if the file appears to be a desktop file.
- */
- static bool isDesktopFile(const QString& path);
-
- /**
- * Checks whether the user is authorized to run this desktop file.
- * By default users are authorized to run all desktop files but
- * the KIOSK framework can be used to activate certain restrictions.
- * See README.kiosk for more information.
- *
- * Note: Since KDE 4.3, there are more restrictions on authorized
- * desktop files to prevent users from inadvertently running trojan
- * desktop files. Your application launchers should have the executable
- * bit set to prevent issues. To see if a restriction is due to
- * KIOSK, see KAuthorized.
- *
- * @param path the file to check
- * @return true if the user is authorized to run the file
- */
- static bool isAuthorizedDesktopFile(const QString& path);
-
- /**
- * Returns the location where changes for the .desktop file @p path
- * should be written to.
- */
- static QString locateLocal(const QString &path);
-
- KConfigGroup desktopGroup() const;
-
- /**
- * Returns the value of the "Type=" entry.
- * @return the type or QString() if not specified
- */
- QString readType() const;
-
- /**
- * Returns the value of the "Icon=" entry.
- * @return the icon or QString() if not specified
- */
- QString readIcon() const;
-
- /**
- * Returns the value of the "Name=" entry.
- * @return the name or QString() if not specified
- */
- QString readName() const;
-
- /**
- * Returns the value of the "Comment=" entry.
- * @return the comment or QString() if not specified
- */
- QString readComment() const;
-
- /**
- * Returns the value of the "GenericName=" entry.
- * @return the generic name or QString() if not specified
- */
- QString readGenericName() const;
-
- /**
- * Returns the value of the "Path=" entry.
- * @return the path or QString() if not specified
- */
- QString readPath() const;
-
- /**
- * Returns the value of the "Dev=" entry.
- * @return the device or QString() if not specified
- */
- QString readDevice() const;
-
- /**
- * Returns the value of the "URL=" entry.
- * @return the URL or QString() if not specified
- */
- QString readUrl() const;
-
- /**
- * Returns a list of the "Actions=" entries.
- * @return the list of actions
- */
- QStringList readActions() const;
-
- /**
- * Sets the desktop action group.
- * @param group the new action group
- */
- KConfigGroup actionGroup(const QString &group);
-
- const KConfigGroup actionGroup(const QString &group) const;
-
- /**
- * Returns true if the action group exists, false otherwise
- * @param group the action group to test
- * @return true if the action group exists
- */
- bool hasActionGroup(const QString &group) const;
-
- /**
- * Checks whether there is a "Type=Link" entry.
- *
- * The link points to the "URL=" entry.
- * @return true if there is a "Type=Link" entry
- */
- bool hasLinkType() const;
-
- /**
- * Checks whether there is an entry "Type=Application".
- * @return true if there is a "Type=Application" entry
- */
- bool hasApplicationType() const;
-
- /**
- * Checks whether there is an entry "Type=FSDevice".
- * @return true if there is a "Type=FSDevice" entry
- */
- bool hasDeviceType() const;
-
- /**
- * Checks whether the TryExec field contains a binary
- * which is found on the local system.
- * @return true if TryExec contains an existing binary
- */
- bool tryExec() const;
-
- /**
- * Returns the value of the "X-DocPath=" Or "DocPath=" entry.
- * @return The value of the "X-DocPath=" Or "DocPath=" entry.
- */
- QString readDocPath() const;
-
- /**
- * Returns the entry of the "SortOrder=" entry.
- * @return the value of the "SortOrder=" entry.
- */
- QStringList sortOrder() const;
-
- /**
- * Whether the entry should be suppressed in menus.
- * This handles the NoDisplay key, but also OnlyShowIn / NotShowIn.
- * @return true to suppress this service
- * @since 4.1
- */
- bool noDisplay() const;
-
- /**
- * Copies all entries from this config object to a new
- * KDesktopFile object that will save itself to @p file.
- *
- * Actual saving to @p file happens when the returned object is
- * destructed or when sync() is called upon it.
- *
- * @param file the new KDesktopFile object it will save itself to.
- */
- KDesktopFile* copyTo(const QString &file) const;
-
- QString fileName() const;
-
- QStandardPaths::StandardLocation resource() const;
+ /**
+ * Constructs a KDesktopFile object.
+ *
+ * See QStandardPaths for more information on resources.
+ *
+ * @param resourceType Allows you to change what sort of resource
+ * to search for if @p fileName is not absolute.
+ * For instance, you might want to specify GenericConfigLocation.
+ * @param fileName The name or path of the desktop file. If it
+ * is not absolute, it will be located
+ * using the resource type @p resType.
+ */
+ explicit KDesktopFile(QStandardPaths::StandardLocation resourceType, const QString &fileName);
+
+ /**
+ * Constructs a KDesktopFile object.
+ *
+ * See QStandardPaths for more information on resources.
+ *
+ * @param fileName The name or path of the desktop file. If it
+ * is not absolute, it will be located
+ * using the resource type ApplicationsLocation
+ */
+ explicit KDesktopFile(const QString &fileName);
+
+ /**
+ * Destructs the KDesktopFile object.
+ *
+ * Writes back any dirty configuration entries.
+ */
+ virtual ~KDesktopFile();
+
+ /**
+ * Checks whether this is really a desktop file.
+ *
+ * The check is performed looking at the file extension (the file is not
+ * opened).
+ * Currently, the only valid extension is ".desktop".
+ * @param path the path of the file to check
+ * @return true if the file appears to be a desktop file.
+ */
+ static bool isDesktopFile(const QString &path);
+
+ /**
+ * Checks whether the user is authorized to run this desktop file.
+ * By default users are authorized to run all desktop files but
+ * the KIOSK framework can be used to activate certain restrictions.
+ * See README.kiosk for more information.
+ *
+ * Note: Since KDE 4.3, there are more restrictions on authorized
+ * desktop files to prevent users from inadvertently running trojan
+ * desktop files. Your application launchers should have the executable
+ * bit set to prevent issues. To see if a restriction is due to
+ * KIOSK, see KAuthorized.
+ *
+ * @param path the file to check
+ * @return true if the user is authorized to run the file
+ */
+ static bool isAuthorizedDesktopFile(const QString &path);
+
+ /**
+ * Returns the location where changes for the .desktop file @p path
+ * should be written to.
+ */
+ static QString locateLocal(const QString &path);
+
+ KConfigGroup desktopGroup() const;
+
+ /**
+ * Returns the value of the "Type=" entry.
+ * @return the type or QString() if not specified
+ */
+ QString readType() const;
+
+ /**
+ * Returns the value of the "Icon=" entry.
+ * @return the icon or QString() if not specified
+ */
+ QString readIcon() const;
+
+ /**
+ * Returns the value of the "Name=" entry.
+ * @return the name or QString() if not specified
+ */
+ QString readName() const;
+
+ /**
+ * Returns the value of the "Comment=" entry.
+ * @return the comment or QString() if not specified
+ */
+ QString readComment() const;
+
+ /**
+ * Returns the value of the "GenericName=" entry.
+ * @return the generic name or QString() if not specified
+ */
+ QString readGenericName() const;
+
+ /**
+ * Returns the value of the "Path=" entry.
+ * @return the path or QString() if not specified
+ */
+ QString readPath() const;
+
+ /**
+ * Returns the value of the "Dev=" entry.
+ * @return the device or QString() if not specified
+ */
+ QString readDevice() const;
+
+ /**
+ * Returns the value of the "URL=" entry.
+ * @return the URL or QString() if not specified
+ */
+ QString readUrl() const;
+
+ /**
+ * Returns a list of the "Actions=" entries.
+ * @return the list of actions
+ */
+ QStringList readActions() const;
+
+ /**
+ * Sets the desktop action group.
+ * @param group the new action group
+ */
+ KConfigGroup actionGroup(const QString &group);
+
+ const KConfigGroup actionGroup(const QString &group) const;
+
+ /**
+ * Returns true if the action group exists, false otherwise
+ * @param group the action group to test
+ * @return true if the action group exists
+ */
+ bool hasActionGroup(const QString &group) const;
+
+ /**
+ * Checks whether there is a "Type=Link" entry.
+ *
+ * The link points to the "URL=" entry.
+ * @return true if there is a "Type=Link" entry
+ */
+ bool hasLinkType() const;
+
+ /**
+ * Checks whether there is an entry "Type=Application".
+ * @return true if there is a "Type=Application" entry
+ */
+ bool hasApplicationType() const;
+
+ /**
+ * Checks whether there is an entry "Type=FSDevice".
+ * @return true if there is a "Type=FSDevice" entry
+ */
+ bool hasDeviceType() const;
+
+ /**
+ * Checks whether the TryExec field contains a binary
+ * which is found on the local system.
+ * @return true if TryExec contains an existing binary
+ */
+ bool tryExec() const;
+
+ /**
+ * Returns the value of the "X-DocPath=" Or "DocPath=" entry.
+ * @return The value of the "X-DocPath=" Or "DocPath=" entry.
+ */
+ QString readDocPath() const;
+
+ /**
+ * Returns the entry of the "SortOrder=" entry.
+ * @return the value of the "SortOrder=" entry.
+ */
+ QStringList sortOrder() const;
+
+ /**
+ * Whether the entry should be suppressed in menus.
+ * This handles the NoDisplay key, but also OnlyShowIn / NotShowIn.
+ * @return true to suppress this service
+ * @since 4.1
+ */
+ bool noDisplay() const;
+
+ /**
+ * Copies all entries from this config object to a new
+ * KDesktopFile object that will save itself to @p file.
+ *
+ * Actual saving to @p file happens when the returned object is
+ * destructed or when sync() is called upon it.
+ *
+ * @param file the new KDesktopFile object it will save itself to.
+ */
+ KDesktopFile *copyTo(const QString &file) const;
+
+ QString fileName() const;
+
+ QStandardPaths::StandardLocation resource() const;
protected:
- /** Virtual hook, used to add new "virtual" functions while maintaining
- binary compatibility. Unused in this class.
- */
+ /** Virtual hook, used to add new "virtual" functions while maintaining
+ binary compatibility. Unused in this class.
+ */
// virtual void virtual_hook( int id, void* data );
private:
- Q_DISABLE_COPY(KDesktopFile)
+ Q_DISABLE_COPY(KDesktopFile)
- Q_DECLARE_PRIVATE(KDesktopFile)
+ Q_DECLARE_PRIVATE(KDesktopFile)
};
#endif
diff --git a/src/core/kemailsettings.cpp b/src/core/kemailsettings.cpp
index 6a1f9448..230c2aa4 100644
--- a/src/core/kemailsettings.cpp
+++ b/src/core/kemailsettings.cpp
@@ -29,238 +29,245 @@
#include <kconfig.h>
#include <kconfiggroup.h>
-class KEMailSettingsPrivate {
+class KEMailSettingsPrivate
+{
public:
- KEMailSettingsPrivate() : m_pConfig( 0 ) {}
- ~KEMailSettingsPrivate() { delete m_pConfig; }
- KConfig *m_pConfig;
- QStringList profiles;
- QString m_sDefaultProfile, m_sCurrentProfile;
+ KEMailSettingsPrivate() : m_pConfig(0) {}
+ ~KEMailSettingsPrivate()
+ {
+ delete m_pConfig;
+ }
+ KConfig *m_pConfig;
+ QStringList profiles;
+ QString m_sDefaultProfile, m_sCurrentProfile;
};
QString KEMailSettings::defaultProfileName() const
{
- return p->m_sDefaultProfile;
+ return p->m_sDefaultProfile;
}
QString KEMailSettings::getSetting(KEMailSettings::Setting s) const
{
- KConfigGroup cg(p->m_pConfig, QStringLiteral("PROFILE_") + p->m_sCurrentProfile);
- switch (s) {
- case ClientProgram: {
- return cg.readEntry("EmailClient");
- break;
- }
- case ClientTerminal: {
- return cg.readEntry("TerminalClient", QVariant(false)).toString();
- break;
- }
- case RealName: {
- return cg.readEntry("FullName");
- break;
- }
- case EmailAddress: {
- return cg.readEntry("EmailAddress");
- break;
- }
- case ReplyToAddress: {
- return cg.readEntry("ReplyAddr");
- break;
- }
- case Organization: {
- return cg.readEntry("Organization");
- break;
- }
- case OutServer: {
- return cg.readEntry("OutgoingServer");
- break;
- }
- case OutServerLogin: {
- return cg.readEntry("OutgoingUserName");
- break;
- }
- case OutServerPass: {
- return cg.readEntry("OutgoingPassword");
- break;
- }
- case OutServerType: {
- return cg.readEntry("OutgoingServerType");
- break;
- }
- case OutServerCommand: {
- return cg.readEntry("OutgoingCommand");
- break;
- }
- case OutServerTLS: {
- return cg.readEntry("OutgoingServerTLS", QVariant(false)).toString();
- break;
- }
- case InServer: {
- return cg.readEntry("IncomingServer");
- break;
- }
- case InServerLogin: {
- return cg.readEntry("IncomingUserName");
- break;
- }
- case InServerPass: {
- return cg.readEntry("IncomingPassword");
- break;
- }
- case InServerType: {
- return cg.readEntry("IncomingServerType");
- break;
- }
- case InServerMBXType: {
- return cg.readEntry("IncomingServerMBXType");
- break;
- }
- case InServerTLS: {
- return cg.readEntry("IncomingServerTLS", QVariant(false)).toString();
- break;
- }
- };
- return QString();
+ KConfigGroup cg(p->m_pConfig, QStringLiteral("PROFILE_") + p->m_sCurrentProfile);
+ switch (s) {
+ case ClientProgram: {
+ return cg.readEntry("EmailClient");
+ break;
+ }
+ case ClientTerminal: {
+ return cg.readEntry("TerminalClient", QVariant(false)).toString();
+ break;
+ }
+ case RealName: {
+ return cg.readEntry("FullName");
+ break;
+ }
+ case EmailAddress: {
+ return cg.readEntry("EmailAddress");
+ break;
+ }
+ case ReplyToAddress: {
+ return cg.readEntry("ReplyAddr");
+ break;
+ }
+ case Organization: {
+ return cg.readEntry("Organization");
+ break;
+ }
+ case OutServer: {
+ return cg.readEntry("OutgoingServer");
+ break;
+ }
+ case OutServerLogin: {
+ return cg.readEntry("OutgoingUserName");
+ break;
+ }
+ case OutServerPass: {
+ return cg.readEntry("OutgoingPassword");
+ break;
+ }
+ case OutServerType: {
+ return cg.readEntry("OutgoingServerType");
+ break;
+ }
+ case OutServerCommand: {
+ return cg.readEntry("OutgoingCommand");
+ break;
+ }
+ case OutServerTLS: {
+ return cg.readEntry("OutgoingServerTLS", QVariant(false)).toString();
+ break;
+ }
+ case InServer: {
+ return cg.readEntry("IncomingServer");
+ break;
+ }
+ case InServerLogin: {
+ return cg.readEntry("IncomingUserName");
+ break;
+ }
+ case InServerPass: {
+ return cg.readEntry("IncomingPassword");
+ break;
+ }
+ case InServerType: {
+ return cg.readEntry("IncomingServerType");
+ break;
+ }
+ case InServerMBXType: {
+ return cg.readEntry("IncomingServerMBXType");
+ break;
+ }
+ case InServerTLS: {
+ return cg.readEntry("IncomingServerTLS", QVariant(false)).toString();
+ break;
+ }
+ };
+ return QString();
}
void KEMailSettings::setSetting(KEMailSettings::Setting s, const QString &v)
{
- KConfigGroup cg(p->m_pConfig, QStringLiteral("PROFILE_") + p->m_sCurrentProfile);
- switch (s) {
- case ClientProgram: {
- cg.writePathEntry("EmailClient", v);
- break;
- }
- case ClientTerminal: {
- cg.writeEntry("TerminalClient", (v == QLatin1String("true")));
- break;
- }
- case RealName: {
- cg.writeEntry("FullName", v);
- break;
- }
- case EmailAddress: {
- cg.writeEntry("EmailAddress", v);
- break;
- }
- case ReplyToAddress: {
- cg.writeEntry("ReplyAddr", v);
- break;
- }
- case Organization: {
- cg.writeEntry("Organization", v);
- break;
- }
- case OutServer: {
- cg.writeEntry("OutgoingServer", v);
- break;
- }
- case OutServerLogin: {
- cg.writeEntry("OutgoingUserName", v);
- break;
- }
- case OutServerPass: {
- cg.writeEntry("OutgoingPassword", v);
- break;
- }
- case OutServerType: {
- cg.writeEntry("OutgoingServerType", v);
- break;
- }
- case OutServerCommand: {
- cg.writeEntry("OutgoingCommand", v);
- break;
- }
- case OutServerTLS: {
- cg.writeEntry("OutgoingServerTLS", (v == QLatin1String("true")));
- break;
- }
- case InServer: {
- cg.writeEntry("IncomingServer", v);
- break;
- }
- case InServerLogin: {
- cg.writeEntry("IncomingUserName", v);
- break;
- }
- case InServerPass: {
- cg.writeEntry("IncomingPassword", v);
- break;
- }
- case InServerType: {
- cg.writeEntry("IncomingServerType", v);
- break;
- }
- case InServerMBXType: {
- cg.writeEntry("IncomingServerMBXType", v);
- break;
- }
- case InServerTLS: {
- cg.writeEntry("IncomingServerTLS", (v == QLatin1String("true")));
- break;
- }
- };
- cg.sync();
+ KConfigGroup cg(p->m_pConfig, QStringLiteral("PROFILE_") + p->m_sCurrentProfile);
+ switch (s) {
+ case ClientProgram: {
+ cg.writePathEntry("EmailClient", v);
+ break;
+ }
+ case ClientTerminal: {
+ cg.writeEntry("TerminalClient", (v == QLatin1String("true")));
+ break;
+ }
+ case RealName: {
+ cg.writeEntry("FullName", v);
+ break;
+ }
+ case EmailAddress: {
+ cg.writeEntry("EmailAddress", v);
+ break;
+ }
+ case ReplyToAddress: {
+ cg.writeEntry("ReplyAddr", v);
+ break;
+ }
+ case Organization: {
+ cg.writeEntry("Organization", v);
+ break;
+ }
+ case OutServer: {
+ cg.writeEntry("OutgoingServer", v);
+ break;
+ }
+ case OutServerLogin: {
+ cg.writeEntry("OutgoingUserName", v);
+ break;
+ }
+ case OutServerPass: {
+ cg.writeEntry("OutgoingPassword", v);
+ break;
+ }
+ case OutServerType: {
+ cg.writeEntry("OutgoingServerType", v);
+ break;
+ }
+ case OutServerCommand: {
+ cg.writeEntry("OutgoingCommand", v);
+ break;
+ }
+ case OutServerTLS: {
+ cg.writeEntry("OutgoingServerTLS", (v == QLatin1String("true")));
+ break;
+ }
+ case InServer: {
+ cg.writeEntry("IncomingServer", v);
+ break;
+ }
+ case InServerLogin: {
+ cg.writeEntry("IncomingUserName", v);
+ break;
+ }
+ case InServerPass: {
+ cg.writeEntry("IncomingPassword", v);
+ break;
+ }
+ case InServerType: {
+ cg.writeEntry("IncomingServerType", v);
+ break;
+ }
+ case InServerMBXType: {
+ cg.writeEntry("IncomingServerMBXType", v);
+ break;
+ }
+ case InServerTLS: {
+ cg.writeEntry("IncomingServerTLS", (v == QLatin1String("true")));
+ break;
+ }
+ };
+ cg.sync();
}
void KEMailSettings::setDefault(const QString &s)
{
- p->m_pConfig->group("Defaults").writeEntry("Profile", s);
- p->m_pConfig->sync();
- p->m_sDefaultProfile=s;
+ p->m_pConfig->group("Defaults").writeEntry("Profile", s);
+ p->m_pConfig->sync();
+ p->m_sDefaultProfile = s;
}
-void KEMailSettings::setProfile (const QString &s)
+void KEMailSettings::setProfile(const QString &s)
{
- QString groupname = QStringLiteral("PROFILE_");
- groupname.append(s);
- p->m_sCurrentProfile=s;
- if (!p->m_pConfig->hasGroup(groupname)) { // Create a group if it doesn't exist
- KConfigGroup cg(p->m_pConfig, groupname);
- cg.writeEntry("ServerType", QString());
- p->profiles+=s;
- }
+ QString groupname = QStringLiteral("PROFILE_");
+ groupname.append(s);
+ p->m_sCurrentProfile = s;
+ if (!p->m_pConfig->hasGroup(groupname)) { // Create a group if it doesn't exist
+ KConfigGroup cg(p->m_pConfig, groupname);
+ cg.writeEntry("ServerType", QString());
+ p->profiles += s;
+ }
}
#ifndef KDE_NO_DEPRECATED
QString KEMailSettings::currentProfileName() const
{
- return p->m_sCurrentProfile;
+ return p->m_sCurrentProfile;
}
#endif
QStringList KEMailSettings::profiles() const
{
- return p->profiles;
+ return p->profiles;
}
KEMailSettings::KEMailSettings()
- :p(new KEMailSettingsPrivate())
+ : p(new KEMailSettingsPrivate())
{
- p->m_sCurrentProfile.clear();
+ p->m_sCurrentProfile.clear();
- p->m_pConfig = new KConfig(QStringLiteral("emaildefaults"));
+ p->m_pConfig = new KConfig(QStringLiteral("emaildefaults"));
- const QStringList groups = p->m_pConfig->groupList();
- for (QStringList::ConstIterator it = groups.begin(); it != groups.end(); ++it) {
- if ( (*it).startsWith( QLatin1String( "PROFILE_" ) ) )
- p->profiles+= (*it).mid(8, (*it).length());
- }
+ const QStringList groups = p->m_pConfig->groupList();
+ for (QStringList::ConstIterator it = groups.begin(); it != groups.end(); ++it) {
+ if ((*it).startsWith(QLatin1String("PROFILE_"))) {
+ p->profiles += (*it).mid(8, (*it).length());
+ }
+ }
- KConfigGroup cg( p->m_pConfig, "Defaults");
- p->m_sDefaultProfile = cg.readEntry("Profile", tr("Default"));
- if (!p->m_sDefaultProfile.isNull()) {
- if (!p->m_pConfig->hasGroup(QStringLiteral("PROFILE_") + p->m_sDefaultProfile))
- setDefault(tr("Default"));
- else
- setDefault(p->m_sDefaultProfile);
- } else {
- if (p->profiles.count()) {
- setDefault(p->profiles[0]);
- } else
- setDefault(tr("Default"));
- }
- setProfile(defaultProfileName());
+ KConfigGroup cg(p->m_pConfig, "Defaults");
+ p->m_sDefaultProfile = cg.readEntry("Profile", tr("Default"));
+ if (!p->m_sDefaultProfile.isNull()) {
+ if (!p->m_pConfig->hasGroup(QStringLiteral("PROFILE_") + p->m_sDefaultProfile)) {
+ setDefault(tr("Default"));
+ } else {
+ setDefault(p->m_sDefaultProfile);
+ }
+ } else {
+ if (p->profiles.count()) {
+ setDefault(p->profiles[0]);
+ } else {
+ setDefault(tr("Default"));
+ }
+ }
+ setProfile(defaultProfileName());
}
KEMailSettings::~KEMailSettings()
diff --git a/src/core/kemailsettings.h b/src/core/kemailsettings.h
index 32610d61..03249e50 100644
--- a/src/core/kemailsettings.h
+++ b/src/core/kemailsettings.h
@@ -35,142 +35,142 @@
class KEMailSettingsPrivate;
-
/**
- * 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
+ * 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 {
+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()
- **/
- enum Setting {
- ClientProgram,
- ClientTerminal,
- RealName,
- EmailAddress,
- ReplyToAddress,
- Organization,
- OutServer,
- OutServerLogin,
- OutServerPass,
+ /**
+ * 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,
+ RealName,
+ EmailAddress,
+ ReplyToAddress,
+ Organization,
+ OutServer,
+ OutServerLogin,
+ OutServerPass,
#ifndef KDE_NO_DEPRECATED
- /**
- * @deprecated since Frameworks 5.0
- */
- OutServerType,
- /**
- * @deprecated since Frameworks 5.0
- */
- OutServerCommand,
- /**
- * @deprecated since Frameworks 5.0
- */
- OutServerTLS,
+ /**
+ * @deprecated since Frameworks 5.0
+ */
+ OutServerType,
+ /**
+ * @deprecated since Frameworks 5.0
+ */
+ OutServerCommand,
+ /**
+ * @deprecated since Frameworks 5.0
+ */
+ OutServerTLS,
#endif
- InServer,
- InServerLogin,
- InServerPass,
+ InServer,
+ InServerLogin,
+ InServerPass,
#ifndef KDE_NO_DEPRECATED
- /**
- * @deprecated since Frameworks 5.0
- */
- InServerType,
- /**
- * @deprecated since Frameworks 5.0
- */
- InServerMBXType,
- /**
- * @deprecated since Frameworks 5.0
- */
- InServerTLS
+ /**
+ * @deprecated since Frameworks 5.0
+ */
+ InServerType,
+ /**
+ * @deprecated since Frameworks 5.0
+ */
+ InServerMBXType,
+ /**
+ * @deprecated since Frameworks 5.0
+ */
+ InServerTLS
#endif
- };
-
- /**
- * The various extensions allowed.
- **/
- enum Extension {
- POP3,
- SMTP,
- OTHER
- };
-
- /**
- * Default constructor, just sets things up and sets the default profile
- * as the current profile
- **/
- KEMailSettings();
-
- /**
- * Default destructor, nothing to see here.
- **/
- ~KEMailSettings();
-
- /**
- * List of profiles available.
- * @return the list of profiles
- **/
- QStringList profiles() const;
+ };
+
+ /**
+ * The various extensions allowed.
+ **/
+ enum Extension {
+ POP3,
+ SMTP,
+ OTHER
+ };
+
+ /**
+ * Default constructor, just sets things up and sets the default profile
+ * as the current profile
+ **/
+ KEMailSettings();
+
+ /**
+ * Default destructor, nothing to see here.
+ **/
+ ~KEMailSettings();
+
+ /**
+ * List of profiles available.
+ * @return the list of profiles
+ **/
+ QStringList profiles() const;
#ifndef KDE_NO_DEPRECATED
- /**
- * @deprecated since Frameworks 5.0
- * Returns the name of the current profile.
- * @returns what profile we're currently using
- **/
- KCONFIGCORE_DEPRECATED QString currentProfileName() const;
+ /**
+ * @deprecated since Frameworks 5.0
+ * Returns the name of the current profile.
+ * @returns what profile we're currently using
+ **/
+ KCONFIGCORE_DEPRECATED QString currentProfileName() const;
#endif
- /**
- * Change the current profile.
- * @param s the name of the new profile
- **/
- void setProfile (const QString &s);
-
- /**
- * Returns the name of the default profile.
- * @returns the name of the one that's currently default QString() if none
- **/
- QString defaultProfileName() const;
-
- /**
- * 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
- **/
- 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
- **/
- void setSetting(KEMailSettings::Setting s, const QString &v);
+ /**
+ * Change the current profile.
+ * @param s the name of the new profile
+ **/
+ void setProfile(const QString &s);
+
+ /**
+ * Returns the name of the default profile.
+ * @returns the name of the one that's currently default QString() if none
+ **/
+ QString defaultProfileName() const;
+
+ /**
+ * 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
+ **/
+ 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
+ **/
+ void setSetting(KEMailSettings::Setting s, const QString &v);
private:
- KEMailSettingsPrivate* const p;
+ KEMailSettingsPrivate *const p;
};
#endif
diff --git a/src/core/ksharedconfig.cpp b/src/core/ksharedconfig.cpp
index 0e5d1959..4f0e8d69 100644
--- a/src/core/ksharedconfig.cpp
+++ b/src/core/ksharedconfig.cpp
@@ -27,7 +27,7 @@
void _k_globalMainConfigSync();
-class GlobalSharedConfigList : public QList<KSharedConfig*>
+class GlobalSharedConfigList : public QList<KSharedConfig *>
{
public:
GlobalSharedConfigList()
@@ -44,19 +44,18 @@ public:
KSharedConfigPtr mainConfig;
};
-
Q_GLOBAL_STATIC(GlobalSharedConfigList, globalSharedConfigList)
void _k_globalMainConfigSync()
{
- if (globalSharedConfigList->mainConfig)
+ if (globalSharedConfigList->mainConfig) {
globalSharedConfigList->mainConfig->sync();
+ }
}
-
-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();
@@ -66,10 +65,10 @@ KSharedConfigPtr KSharedConfig::openConfig(const QString& _fileName,
}
if (list) {
- for(QList<KSharedConfig*>::ConstIterator it = list->constBegin(); it != list->constEnd(); ++it) {
- if ( (*it)->name() == fileName &&
- (*it)->d_ptr->openFlags == flags &&
- (*it)->locationType() == resType
+ for (QList<KSharedConfig *>::ConstIterator it = list->constBegin(); it != list->constEnd(); ++it) {
+ if ((*it)->name() == fileName &&
+ (*it)->d_ptr->openFlags == flags &&
+ (*it)->locationType() == resType
// (*it)->backEnd()->type() == backEnd
) {
return KSharedConfigPtr(*it);
@@ -85,8 +84,9 @@ KSharedConfigPtr KSharedConfig::openConfig(const QString& _fileName,
userWarned = true;
QByteArray readOnly = qgetenv("KDE_HOME_READONLY");
if (readOnly.isEmpty() && QCoreApplication::applicationName() != QLatin1String("kdialog")) {
- if (ptr->group("General").readEntry(QLatin1String("warn_unwritable_config"), true))
+ if (ptr->group("General").readEntry(QLatin1String("warn_unwritable_config"), true)) {
ptr->isConfigWritable(true);
+ }
}
}
}
@@ -94,7 +94,6 @@ KSharedConfigPtr KSharedConfig::openConfig(const QString& _fileName,
return ptr;
}
-
KSharedConfig::KSharedConfig(const QString &fileName,
OpenFlags flags,
QStandardPaths::StandardLocation resType)
@@ -105,18 +104,19 @@ KSharedConfig::KSharedConfig(const QString &fileName,
KSharedConfig::~KSharedConfig()
{
- if (!globalSharedConfigList.isDestroyed())
+ if (!globalSharedConfigList.isDestroyed()) {
globalSharedConfigList()->removeAll(this);
+ }
}
KConfigGroup KSharedConfig::groupImpl(const QByteArray &groupName)
{
KSharedConfigPtr ptr(this);
- return KConfigGroup( ptr, groupName.constData());
+ return KConfigGroup(ptr, groupName.constData());
}
const KConfigGroup KSharedConfig::groupImpl(const QByteArray &groupName) const
{
- const KSharedConfigPtr ptr(const_cast<KSharedConfig*>(this));
- return KConfigGroup( ptr, groupName.constData());
+ const KSharedConfigPtr ptr(const_cast<KSharedConfig *>(this));
+ return KConfigGroup(ptr, groupName.constData());
}
diff --git a/src/core/ksharedconfig.h b/src/core/ksharedconfig.h
index 42f7440e..bb5e8665 100644
--- a/src/core/ksharedconfig.h
+++ b/src/core/ksharedconfig.h
@@ -40,7 +40,7 @@
class KCONFIGCORE_EXPORT KSharedConfig : public KConfig, public QSharedData //krazy:exclude=dpointer (only for refcounting)
{
public:
- typedef QExplicitlySharedDataPointer<KSharedConfig> Ptr;
+ typedef QExplicitlySharedDataPointer<KSharedConfig> Ptr;
public:
/**
@@ -67,7 +67,7 @@ public:
*
* @sa KConfig
*/
- static KSharedConfig::Ptr openConfig(const QString& fileName = QString(),
+ static KSharedConfig::Ptr openConfig(const QString &fileName = QString(),
OpenFlags mode = FullConfig,
QStandardPaths::StandardLocation type = QStandardPaths::GenericConfigLocation);
@@ -75,10 +75,10 @@ public:
private:
Q_DISABLE_COPY(KSharedConfig)
- virtual KConfigGroup groupImpl(const QByteArray& aGroup);
- virtual const KConfigGroup groupImpl(const QByteArray& aGroup) const;
+ virtual KConfigGroup groupImpl(const QByteArray &aGroup);
+ virtual const KConfigGroup groupImpl(const QByteArray &aGroup) const;
- KSharedConfig(const QString& file, OpenFlags mode,
+ KSharedConfig(const QString &file, OpenFlags mode,
QStandardPaths::StandardLocation resourceType);
};