aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-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
-rw-r--r--src/gui/kconfiggroupgui.cpp33
-rw-r--r--src/gui/kconfiggui.cpp9
-rw-r--r--src/gui/kconfiggui.h46
-rw-r--r--src/gui/kconfigloader.cpp34
-rw-r--r--src/gui/kconfigloader.h2
-rw-r--r--src/gui/kconfigloader_p.h385
-rw-r--r--src/gui/kconfigskeleton.cpp88
-rw-r--r--src/gui/kconfigskeleton.h183
-rw-r--r--src/gui/kstandardshortcut.cpp485
-rw-r--r--src/gui/kstandardshortcut.h765
-rw-r--r--src/gui/kwindowconfig.cpp29
-rw-r--r--src/gui/kwindowconfig.h48
-rw-r--r--src/kconf_update/kconf_update.cpp76
-rw-r--r--src/kconfig_compiler/kconfig_compiler.cpp3885
41 files changed, 7108 insertions, 6586 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);
};
diff --git a/src/gui/kconfiggroupgui.cpp b/src/gui/kconfiggroupgui.cpp
index 22706e77..fc0a55b1 100644
--- a/src/gui/kconfiggroupgui.cpp
+++ b/src/gui/kconfiggroupgui.cpp
@@ -35,7 +35,7 @@
* @returns true if something was handled (even if output was set to clear or default)
* or false if nothing was handled (e.g., Core type)
*/
-static bool readEntryGui(const QByteArray& data, const char* key, const QVariant &input,
+static bool readEntryGui(const QByteArray &data, const char *key, const QVariant &input,
QVariant &output)
{
const QString errString = QString::fromLatin1("\"%1\" - conversion from \"%3\" to %2 failed")
@@ -60,8 +60,9 @@ static bool readEntryGui(const QByteArray& data, const char* key, const QVariant
} else if (!data.contains(',')) {
QColor col;
col.setNamedColor(QString::fromUtf8(data.constData(), data.length()));
- if (!col.isValid())
+ if (!col.isValid()) {
qCritical() << qPrintable(errString);
+ }
output = col;
return true;
} else {
@@ -75,7 +76,7 @@ static bool readEntryGui(const QByteArray& data, const char* key, const QVariant
int temp[4];
// bounds check components
- for(int i = 0; i < count; i++) {
+ for (int i = 0; i < count; i++) {
bool ok;
const int j = temp[i] = list.at(i).toInt(&ok);
if (!ok) { // failed to convert to int
@@ -88,28 +89,31 @@ static bool readEntryGui(const QByteArray& data, const char* key, const QVariant
};
const QString boundsError = QLatin1String(" (bounds error: %1 component %2)");
qCritical() << qPrintable(errString)
- << qPrintable(boundsError.arg(QLatin1String(components[i])).arg(j < 0? QLatin1String("< 0"): QLatin1String("> 255")));
+ << qPrintable(boundsError.arg(QLatin1String(components[i])).arg(j < 0 ? QLatin1String("< 0") : QLatin1String("> 255")));
return true; // return default
}
}
QColor aColor(temp[0], temp[1], temp[2]);
- if (count == 4)
+ if (count == 4) {
aColor.setAlpha(temp[3]);
+ }
- if (aColor.isValid())
+ if (aColor.isValid()) {
output = aColor;
- else
+ } else {
qCritical() << qPrintable(errString);
+ }
return true;
}
}
case QVariant::Font: {
QVariant tmp = QString::fromUtf8(data.constData(), data.length());
- if (tmp.convert(QVariant::Font))
+ if (tmp.convert(QVariant::Font)) {
output = tmp;
- else
+ } else {
qCritical() << qPrintable(errString);
+ }
return true;
}
case QVariant::Pixmap:
@@ -122,7 +126,7 @@ static bool readEntryGui(const QByteArray& data, const char* key, const QVariant
case QVariant::Cursor:
case QVariant::SizePolicy:
case QVariant::Pen:
- // we may want to handle these in the future
+ // we may want to handle these in the future
default:
break;
@@ -137,7 +141,7 @@ static bool readEntryGui(const QByteArray& data, const char* key, const QVariant
* @returns true if something was handled (even if an empty value was written)
* or false if nothing was handled (e.g., Core type)
*/
-static bool writeEntryGui(KConfigGroup *cg, const char* key, const QVariant &prop,
+static bool writeEntryGui(KConfigGroup *cg, const char *key, const QVariant &prop,
KConfigGroup::WriteConfigFlags pFlags)
{
switch (prop.type()) {
@@ -153,14 +157,15 @@ static bool writeEntryGui(KConfigGroup *cg, const char* key, const QVariant &pro
list.insert(0, rColor.red());
list.insert(1, rColor.green());
list.insert(2, rColor.blue());
- if (rColor.alpha() != 255)
+ if (rColor.alpha() != 255) {
list.insert(3, rColor.alpha());
+ }
- cg->writeEntry( key, list, pFlags );
+ cg->writeEntry(key, list, pFlags);
return true;
}
case QVariant::Font:
- cg->writeEntry( key, prop.toString().toUtf8(), pFlags );
+ cg->writeEntry(key, prop.toString().toUtf8(), pFlags);
return true;
case QVariant::Pixmap:
diff --git a/src/gui/kconfiggui.cpp b/src/gui/kconfiggui.cpp
index 88da6b56..1eee8ce5 100644
--- a/src/gui/kconfiggui.cpp
+++ b/src/gui/kconfiggui.cpp
@@ -25,12 +25,13 @@
#include <kconfig.h>
-static KConfig* s_sessionConfig = 0;
+static KConfig *s_sessionConfig = 0;
-KConfig* KConfigGui::sessionConfig()
+KConfig *KConfigGui::sessionConfig()
{
- if (!s_sessionConfig) // create an instance specific config object
- s_sessionConfig = new KConfig( sessionConfigName(), KConfig::SimpleConfig );
+ if (!s_sessionConfig) { // create an instance specific config object
+ s_sessionConfig = new KConfig(sessionConfigName(), KConfig::SimpleConfig);
+ }
return s_sessionConfig;
}
diff --git a/src/gui/kconfiggui.h b/src/gui/kconfiggui.h
index 4e2313f3..173400fd 100644
--- a/src/gui/kconfiggui.h
+++ b/src/gui/kconfiggui.h
@@ -30,29 +30,29 @@ class KConfig;
namespace KConfigGui
{
- /**
- * Returns the application session config object.
- *
- * @return A pointer to the application's instance specific
- * KConfig object.
- * @see KConfig
- */
- KCONFIGGUI_EXPORT KConfig* sessionConfig();
-
- /**
- * Indicates if a session config has been created for that application
- * (ie. if sessionConfig() got called at least once)
- *
- * @return true if a sessionConfig object was created, false otherwise
- */
- KCONFIGGUI_EXPORT bool hasSessionConfig();
-
- /**
- * Returns the name of the application session
- *
- * @return the application session name
- */
- KCONFIGGUI_EXPORT QString sessionConfigName();
+/**
+ * Returns the application session config object.
+ *
+ * @return A pointer to the application's instance specific
+ * KConfig object.
+ * @see KConfig
+ */
+KCONFIGGUI_EXPORT KConfig *sessionConfig();
+
+/**
+ * Indicates if a session config has been created for that application
+ * (ie. if sessionConfig() got called at least once)
+ *
+ * @return true if a sessionConfig object was created, false otherwise
+ */
+KCONFIGGUI_EXPORT bool hasSessionConfig();
+
+/**
+ * Returns the name of the application session
+ *
+ * @return the application session name
+ */
+KCONFIGGUI_EXPORT QString sessionConfigName();
}
#endif // KCONFIGGUI_H
diff --git a/src/gui/kconfigloader.cpp b/src/gui/kconfigloader.cpp
index 150c6b69..4713e324 100644
--- a/src/gui/kconfigloader.cpp
+++ b/src/gui/kconfigloader.cpp
@@ -152,7 +152,7 @@ QString ConfigLoaderHandler::defaultValue() const
}
bool ConfigLoaderHandler::endElement(const QString &namespaceURI,
- const QString &localName, const QString &qName)
+ const QString &localName, const QString &qName)
{
Q_UNUSED(namespaceURI)
Q_UNUSED(qName)
@@ -224,7 +224,7 @@ void ConfigLoaderHandler::addItem()
item = m_config->addItemFont(m_name, *d->newFont(), QFont(m_default), m_key);
} else if (m_type == QStringLiteral("int")) {
KConfigSkeleton::ItemInt *intItem = m_config->addItemInt(m_name, *d->newInt(),
- m_default.toInt(), m_key);
+ m_default.toInt(), m_key);
if (m_haveMin) {
intItem->setMinValue(m_min);
@@ -290,11 +290,11 @@ void ConfigLoaderHandler::addItem()
longlongItem->setMaxValue(m_max);
}
item = longlongItem;
- /* No addItemPathList in KConfigSkeleton ?
- } else if (m_type == "PathList") {
- //FIXME: the split() is naive and will break on lists with ,'s in them
- item = m_config->addItemPathList(m_name, *d->newStringList(), m_default.split(","), m_key);
- */
+ /* No addItemPathList in KConfigSkeleton ?
+ } else if (m_type == "PathList") {
+ //FIXME: the split() is naive and will break on lists with ,'s in them
+ item = m_config->addItemPathList(m_name, *d->newStringList(), m_default.split(","), m_key);
+ */
} else if (m_type == QStringLiteral("point")) {
QPoint defaultPoint;
QStringList tmpList = m_default.split(QStringLiteral(","));
@@ -329,15 +329,15 @@ void ConfigLoaderHandler::addItem()
ulonglongItem->setMaxValue(m_max);
}
item = ulonglongItem;
- /* No addItemUrlList in KConfigSkeleton ?
- } else if (m_type == "urllist") {
- //FIXME: the split() is naive and will break on lists with ,'s in them
- QStringList tmpList = m_default.split(",");
- QList<QUrl> defaultList;
- foreach (const QString& tmp, tmpList) {
- defaultList.append(QUrl(tmp));
- }
- item = m_config->addItemUrlList(m_name, *d->newUrlList(), defaultList, m_key);*/
+ /* No addItemUrlList in KConfigSkeleton ?
+ } else if (m_type == "urllist") {
+ //FIXME: the split() is naive and will break on lists with ,'s in them
+ QStringList tmpList = m_default.split(",");
+ QList<QUrl> defaultList;
+ foreach (const QString& tmp, tmpList) {
+ defaultList.append(QUrl(tmp));
+ }
+ item = m_config->addItemUrlList(m_name, *d->newUrlList(), defaultList, m_key);*/
}
if (item) {
@@ -433,7 +433,7 @@ bool KConfigLoader::usrWriteConfig()
{
if (d->saveDefaults) {
KConfigSkeletonItem::List itemList = items();
- for(int i = 0; i < itemList.size(); i++) {
+ for (int i = 0; i < itemList.size(); i++) {
KConfigGroup cg(config(), itemList.at(i)->group());
cg.writeEntry(itemList.at(i)->key(), "");
}
diff --git a/src/gui/kconfigloader.h b/src/gui/kconfigloader.h
index df38ce79..36eb182f 100644
--- a/src/gui/kconfigloader.h
+++ b/src/gui/kconfigloader.h
@@ -170,7 +170,7 @@ protected:
bool usrWriteConfig();
private:
- ConfigLoaderPrivate * const d;
+ ConfigLoaderPrivate *const d;
};
#endif //multiple inclusion guard
diff --git a/src/gui/kconfigloader_p.h b/src/gui/kconfigloader_p.h
index f9aa9191..b030fc30 100644
--- a/src/gui/kconfigloader_p.h
+++ b/src/gui/kconfigloader_p.h
@@ -24,199 +24,198 @@
class ConfigLoaderPrivate
{
- public:
- ConfigLoaderPrivate()
- : saveDefaults(false)
- {
- }
-
- ~ConfigLoaderPrivate()
- {
- clearData();
- }
-
- void clearData()
- {
- qDeleteAll(bools);
- qDeleteAll(strings);
- qDeleteAll(stringlists);
- qDeleteAll(colors);
- qDeleteAll(fonts);
- qDeleteAll(ints);
- qDeleteAll(uints);
- qDeleteAll(urls);
- qDeleteAll(dateTimes);
- qDeleteAll(doubles);
- qDeleteAll(intlists);
- qDeleteAll(longlongs);
- qDeleteAll(points);
- qDeleteAll(rects);
- qDeleteAll(sizes);
- qDeleteAll(ulonglongs);
- qDeleteAll(urllists);
- }
-
- bool *newBool()
- {
- bool *v = new bool;
- bools.append(v);
- return v;
- }
-
- QString *newString()
- {
- QString *v = new QString;
- strings.append(v);
- return v;
- }
-
- QStringList *newStringList()
- {
- QStringList *v = new QStringList;
- stringlists.append(v);
- return v;
- }
-
- QColor *newColor()
- {
- QColor *v = new QColor;
- colors.append(v);
- return v;
- }
-
- QFont *newFont()
- {
- QFont *v = new QFont;
- fonts.append(v);
- return v;
- }
-
- qint32 *newInt()
- {
- qint32 *v = new qint32;
- ints.append(v);
- return v;
- }
-
- quint32 *newUint()
- {
- quint32 *v = new quint32;
- uints.append(v);
- return v;
- }
-
- QUrl *newUrl()
- {
- QUrl *v = new QUrl;
- urls.append(v);
- return v;
- }
-
- QDateTime *newDateTime()
- {
- QDateTime *v = new QDateTime;
- dateTimes.append(v);
- return v;
- }
-
- double *newDouble()
- {
- double *v = new double;
- doubles.append(v);
- return v;
- }
-
- QList<qint32>* newIntList()
- {
- QList<qint32> *v = new QList<qint32>;
- intlists.append(v);
- return v;
- }
-
- qint64 *newLongLong()
- {
- qint64 *v = new qint64;
- longlongs.append(v);
- return v;
- }
-
- QPoint *newPoint()
- {
- QPoint *v = new QPoint;
- points.append(v);
- return v;
- }
-
- QRect *newRect()
- {
- QRect *v = new QRect;
- rects.append(v);
- return v;
- }
-
- QSize *newSize()
- {
- QSize *v = new QSize;
- sizes.append(v);
- return v;
- }
-
- quint64 *newULongLong()
- {
- quint64 *v = new quint64;
- ulonglongs.append(v);
- return v;
- }
-
- QList<QUrl> *newUrlList()
- {
- QList<QUrl> *v = new QList<QUrl>();
- urllists.append(v);
- return v;
- }
-
- void parse(KConfigLoader *loader, QIODevice *xml);
-
- /**
- * Whether or not to write out default values.
- *
- * @param writeDefaults true if defaults should be written out
- */
- void setWriteDefaults(bool writeDefaults)
- {
- saveDefaults = writeDefaults;
- }
-
- /**
- * @return true if default values will also be written out
- */
- bool writeDefaults() const
- {
- return saveDefaults;
- }
-
-
- QList<bool *> bools;
- QList<QString *> strings;
- QList<QStringList *> stringlists;
- QList<QColor *> colors;
- QList<QFont *> fonts;
- QList<qint32 *> ints;
- QList<quint32 *> uints;
- QList<QUrl *> urls;
- QList<QDateTime *> dateTimes;
- QList<double *> doubles;
- QList<QList<qint32> *> intlists;
- QList<qint64 *> longlongs;
- QList<QPoint *> points;
- QList<QRect *> rects;
- QList<QSize *> sizes;
- QList<quint64 *> ulonglongs;
- QList<QList<QUrl> *> urllists;
- QString baseGroup;
- QStringList groups;
- QHash<QString, QString> keysToNames;
- bool saveDefaults;
+public:
+ ConfigLoaderPrivate()
+ : saveDefaults(false)
+ {
+ }
+
+ ~ConfigLoaderPrivate()
+ {
+ clearData();
+ }
+
+ void clearData()
+ {
+ qDeleteAll(bools);
+ qDeleteAll(strings);
+ qDeleteAll(stringlists);
+ qDeleteAll(colors);
+ qDeleteAll(fonts);
+ qDeleteAll(ints);
+ qDeleteAll(uints);
+ qDeleteAll(urls);
+ qDeleteAll(dateTimes);
+ qDeleteAll(doubles);
+ qDeleteAll(intlists);
+ qDeleteAll(longlongs);
+ qDeleteAll(points);
+ qDeleteAll(rects);
+ qDeleteAll(sizes);
+ qDeleteAll(ulonglongs);
+ qDeleteAll(urllists);
+ }
+
+ bool *newBool()
+ {
+ bool *v = new bool;
+ bools.append(v);
+ return v;
+ }
+
+ QString *newString()
+ {
+ QString *v = new QString;
+ strings.append(v);
+ return v;
+ }
+
+ QStringList *newStringList()
+ {
+ QStringList *v = new QStringList;
+ stringlists.append(v);
+ return v;
+ }
+
+ QColor *newColor()
+ {
+ QColor *v = new QColor;
+ colors.append(v);
+ return v;
+ }
+
+ QFont *newFont()
+ {
+ QFont *v = new QFont;
+ fonts.append(v);
+ return v;
+ }
+
+ qint32 *newInt()
+ {
+ qint32 *v = new qint32;
+ ints.append(v);
+ return v;
+ }
+
+ quint32 *newUint()
+ {
+ quint32 *v = new quint32;
+ uints.append(v);
+ return v;
+ }
+
+ QUrl *newUrl()
+ {
+ QUrl *v = new QUrl;
+ urls.append(v);
+ return v;
+ }
+
+ QDateTime *newDateTime()
+ {
+ QDateTime *v = new QDateTime;
+ dateTimes.append(v);
+ return v;
+ }
+
+ double *newDouble()
+ {
+ double *v = new double;
+ doubles.append(v);
+ return v;
+ }
+
+ QList<qint32> *newIntList()
+ {
+ QList<qint32> *v = new QList<qint32>;
+ intlists.append(v);
+ return v;
+ }
+
+ qint64 *newLongLong()
+ {
+ qint64 *v = new qint64;
+ longlongs.append(v);
+ return v;
+ }
+
+ QPoint *newPoint()
+ {
+ QPoint *v = new QPoint;
+ points.append(v);
+ return v;
+ }
+
+ QRect *newRect()
+ {
+ QRect *v = new QRect;
+ rects.append(v);
+ return v;
+ }
+
+ QSize *newSize()
+ {
+ QSize *v = new QSize;
+ sizes.append(v);
+ return v;
+ }
+
+ quint64 *newULongLong()
+ {
+ quint64 *v = new quint64;
+ ulonglongs.append(v);
+ return v;
+ }
+
+ QList<QUrl> *newUrlList()
+ {
+ QList<QUrl> *v = new QList<QUrl>();
+ urllists.append(v);
+ return v;
+ }
+
+ void parse(KConfigLoader *loader, QIODevice *xml);
+
+ /**
+ * Whether or not to write out default values.
+ *
+ * @param writeDefaults true if defaults should be written out
+ */
+ void setWriteDefaults(bool writeDefaults)
+ {
+ saveDefaults = writeDefaults;
+ }
+
+ /**
+ * @return true if default values will also be written out
+ */
+ bool writeDefaults() const
+ {
+ return saveDefaults;
+ }
+
+ QList<bool *> bools;
+ QList<QString *> strings;
+ QList<QStringList *> stringlists;
+ QList<QColor *> colors;
+ QList<QFont *> fonts;
+ QList<qint32 *> ints;
+ QList<quint32 *> uints;
+ QList<QUrl *> urls;
+ QList<QDateTime *> dateTimes;
+ QList<double *> doubles;
+ QList<QList<qint32> *> intlists;
+ QList<qint64 *> longlongs;
+ QList<QPoint *> points;
+ QList<QRect *> rects;
+ QList<QSize *> sizes;
+ QList<quint64 *> ulonglongs;
+ QList<QList<QUrl> *> urllists;
+ QString baseGroup;
+ QStringList groups;
+ QHash<QString, QString> keysToNames;
+ bool saveDefaults;
};
#endif
diff --git a/src/gui/kconfigskeleton.cpp b/src/gui/kconfigskeleton.cpp
index 7704d36e..22f3c25c 100644
--- a/src/gui/kconfigskeleton.cpp
+++ b/src/gui/kconfigskeleton.cpp
@@ -23,36 +23,35 @@
#include <kcoreconfigskeleton_p.h>
-KConfigSkeleton::KConfigSkeleton(const QString &configname, QObject* parent)
- : KCoreConfigSkeleton(configname, parent)
+KConfigSkeleton::KConfigSkeleton(const QString &configname, QObject *parent)
+ : KCoreConfigSkeleton(configname, parent)
{
}
-KConfigSkeleton::KConfigSkeleton(KSharedConfig::Ptr pConfig, QObject* parent)
- : KCoreConfigSkeleton(pConfig, parent)
+KConfigSkeleton::KConfigSkeleton(KSharedConfig::Ptr pConfig, QObject *parent)
+ : KCoreConfigSkeleton(pConfig, parent)
{
}
-
-KConfigSkeleton::ItemColor::ItemColor( const QString &_group, const QString &_key,
- QColor &reference,
- const QColor &defaultValue )
- : KConfigSkeletonGenericItem<QColor>( _group, _key, reference, defaultValue )
+KConfigSkeleton::ItemColor::ItemColor(const QString &_group, const QString &_key,
+ QColor &reference,
+ const QColor &defaultValue)
+ : KConfigSkeletonGenericItem<QColor>(_group, _key, reference, defaultValue)
{
}
-void KConfigSkeleton::ItemColor::readConfig( KConfig *config )
+void KConfigSkeleton::ItemColor::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 KConfigSkeleton::ItemColor::setProperty(const QVariant & p)
+void KConfigSkeleton::ItemColor::setProperty(const QVariant &p)
{
- mReference = qvariant_cast<QColor>(p);
+ mReference = qvariant_cast<QColor>(p);
}
bool KConfigSkeleton::ItemColor::isEqual(const QVariant &v) const
@@ -62,29 +61,28 @@ bool KConfigSkeleton::ItemColor::isEqual(const QVariant &v) const
QVariant KConfigSkeleton::ItemColor::property() const
{
- return QVariant(mReference);
+ return QVariant(mReference);
}
-
-KConfigSkeleton::ItemFont::ItemFont( const QString &_group, const QString &_key,
- QFont &reference,
- const QFont &defaultValue )
- : KConfigSkeletonGenericItem<QFont>( _group, _key, reference, defaultValue )
+KConfigSkeleton::ItemFont::ItemFont(const QString &_group, const QString &_key,
+ QFont &reference,
+ const QFont &defaultValue)
+ : KConfigSkeletonGenericItem<QFont>(_group, _key, reference, defaultValue)
{
}
-void KConfigSkeleton::ItemFont::readConfig( KConfig *config )
+void KConfigSkeleton::ItemFont::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 KConfigSkeleton::ItemFont::setProperty(const QVariant & p)
+void KConfigSkeleton::ItemFont::setProperty(const QVariant &p)
{
- mReference = qvariant_cast<QFont>(p);
+ mReference = qvariant_cast<QFont>(p);
}
bool KConfigSkeleton::ItemFont::isEqual(const QVariant &v) const
@@ -94,28 +92,26 @@ bool KConfigSkeleton::ItemFont::isEqual(const QVariant &v) const
QVariant KConfigSkeleton::ItemFont::property() const
{
- return QVariant(mReference);
+ return QVariant(mReference);
}
-
-KConfigSkeleton::ItemColor *KConfigSkeleton::addItemColor( const QString &name, QColor &reference,
- const QColor &defaultValue, const QString &key )
+KConfigSkeleton::ItemColor *KConfigSkeleton::addItemColor(const QString &name, QColor &reference,
+ const QColor &defaultValue, const QString &key)
{
- KConfigSkeleton::ItemColor *item;
- item = new KConfigSkeleton::ItemColor( d->mCurrentGroup, key.isNull() ? name : key,
- reference, defaultValue );
- addItem( item, name );
- return item;
+ KConfigSkeleton::ItemColor *item;
+ item = new KConfigSkeleton::ItemColor(d->mCurrentGroup, key.isNull() ? name : key,
+ reference, defaultValue);
+ addItem(item, name);
+ return item;
}
-KConfigSkeleton::ItemFont *KConfigSkeleton::addItemFont( const QString &name, QFont &reference,
- const QFont &defaultValue, const QString &key )
+KConfigSkeleton::ItemFont *KConfigSkeleton::addItemFont(const QString &name, QFont &reference,
+ const QFont &defaultValue, const QString &key)
{
- KConfigSkeleton::ItemFont *item;
- item = new KConfigSkeleton::ItemFont( d->mCurrentGroup, key.isNull() ? name : key,
- reference, defaultValue );
- addItem( item, name );
- return item;
+ KConfigSkeleton::ItemFont *item;
+ item = new KConfigSkeleton::ItemFont(d->mCurrentGroup, key.isNull() ? name : key,
+ reference, defaultValue);
+ addItem(item, name);
+ return item;
}
-
diff --git a/src/gui/kconfigskeleton.h b/src/gui/kconfigskeleton.h
index e62e60b4..8262f5ce 100644
--- a/src/gui/kconfigskeleton.h
+++ b/src/gui/kconfigskeleton.h
@@ -39,101 +39,100 @@
*/
class KCONFIGGUI_EXPORT KConfigSkeleton : public KCoreConfigSkeleton
{
- Q_OBJECT
+ Q_OBJECT
public:
- /**
- * Class for handling a color preferences item.
- */
- class KCONFIGGUI_EXPORT ItemColor:public KConfigSkeletonGenericItem < QColor >
- {
- public:
- /** @copydoc KConfigSkeletonGenericItem::KConfigSkeletonGenericItem */
- ItemColor(const QString & _group, const QString & _key,
- QColor & reference,
- const QColor & defaultValue = QColor(128, 128, 128));
-
- /** @copydoc KConfigSkeletonItem::readConfig(KConfig*) */
- void readConfig(KConfig * config);
-
- /** @copydoc KConfigSkeletonItem::setProperty(const QVariant&) */
- void setProperty(const QVariant & p);
-
- /** @copydoc KConfigSkeletonItem::isEqual(const QVariant &) */
- bool isEqual(const QVariant &p) const;
-
- /** @copydoc KConfigSkeletonItem::property() */
- QVariant property() const;
- };
-
-
- /**
- * Class for handling a font preferences item.
- */
- class KCONFIGGUI_EXPORT ItemFont:public KConfigSkeletonGenericItem < QFont >
- {
- public:
- /** @copydoc KConfigSkeletonGenericItem::KConfigSkeletonGenericItem */
- ItemFont(const QString & _group, const QString & _key, QFont & reference,
- const QFont & defaultValue = QFont());
-
- /** @copydoc KConfigSkeletonItem::readConfig(KConfig*) */
- void readConfig(KConfig * config);
-
- /** @copydoc KConfigSkeletonItem::setProperty(const QVariant&) */
- void setProperty(const QVariant & p);
-
- /** @copydoc KConfigSkeletonItem::isEqual(const QVariant &) */
- bool isEqual(const QVariant &p) const;
-
- /** @copydoc KConfigSkeletonItem::property() */
- QVariant property() const;
- };
+ /**
+ * Class for handling a color preferences item.
+ */
+ class KCONFIGGUI_EXPORT ItemColor: public KConfigSkeletonGenericItem < QColor >
+ {
+ public:
+ /** @copydoc KConfigSkeletonGenericItem::KConfigSkeletonGenericItem */
+ ItemColor(const QString &_group, const QString &_key,
+ QColor &reference,
+ const QColor &defaultValue = QColor(128, 128, 128));
+
+ /** @copydoc KConfigSkeletonItem::readConfig(KConfig*) */
+ void readConfig(KConfig *config);
+
+ /** @copydoc KConfigSkeletonItem::setProperty(const QVariant&) */
+ void setProperty(const QVariant &p);
+
+ /** @copydoc KConfigSkeletonItem::isEqual(const QVariant &) */
+ bool isEqual(const QVariant &p) const;
+
+ /** @copydoc KConfigSkeletonItem::property() */
+ QVariant property() const;
+ };
+
+ /**
+ * Class for handling a font preferences item.
+ */
+ class KCONFIGGUI_EXPORT ItemFont: public KConfigSkeletonGenericItem < QFont >
+ {
+ public:
+ /** @copydoc KConfigSkeletonGenericItem::KConfigSkeletonGenericItem */
+ ItemFont(const QString &_group, const QString &_key, QFont &reference,
+ const QFont &defaultValue = QFont());
+
+ /** @copydoc KConfigSkeletonItem::readConfig(KConfig*) */
+ void readConfig(KConfig *config);
+
+ /** @copydoc KConfigSkeletonItem::setProperty(const QVariant&) */
+ void setProperty(const QVariant &p);
+
+ /** @copydoc KConfigSkeletonItem::isEqual(const QVariant &) */
+ 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.
- */
- explicit KConfigSkeleton(const QString & configname = QString(), QObject* parent = 0);
-
- /**
- * Constructor.
- *
- * @param config configuration object to use.
- */
- explicit KConfigSkeleton(KSharedConfig::Ptr config, QObject* parent = 0);
-
- /**
- * Register an item of type QColor.
- *
- * @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
- */
- ItemColor *addItemColor(const QString & name, QColor & reference,
- const QColor & defaultValue = QColor(128, 128, 128),
- const QString & key = QString());
-
- /**
- * Register an item of type QFont.
- *
- * @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
- */
- ItemFont *addItemFont(const QString & name, QFont & reference,
- const QFont & defaultValue = QFont(),
- const QString & key = QString());
+ /**
+ * Constructor.
+ *
+ * @param configname name of config file. If no name is given, the default
+ * config file as returned by KSharedConfig::openConfig() is used.
+ */
+ explicit KConfigSkeleton(const QString &configname = QString(), QObject *parent = 0);
+
+ /**
+ * Constructor.
+ *
+ * @param config configuration object to use.
+ */
+ explicit KConfigSkeleton(KSharedConfig::Ptr config, QObject *parent = 0);
+
+ /**
+ * Register an item of type QColor.
+ *
+ * @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
+ */
+ ItemColor *addItemColor(const QString &name, QColor &reference,
+ const QColor &defaultValue = QColor(128, 128, 128),
+ const QString &key = QString());
+
+ /**
+ * Register an item of type QFont.
+ *
+ * @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
+ */
+ ItemFont *addItemFont(const QString &name, QFont &reference,
+ const QFont &defaultValue = QFont(),
+ const QString &key = QString());
};
diff --git a/src/gui/kstandardshortcut.cpp b/src/gui/kstandardshortcut.cpp
index a377ff0f..83d91360 100644
--- a/src/gui/kstandardshortcut.cpp
+++ b/src/gui/kstandardshortcut.cpp
@@ -31,23 +31,22 @@
namespace KStandardShortcut
{
-struct KStandardShortcutInfo
-{
+struct KStandardShortcutInfo {
//! The standard shortcut id. @see StandardShortcut
StandardShortcut id;
- /**
+ /**
* Unique name for the given accel. The name is used to save the user
* settings. It's not representable. Use description for that.
* @warning NEVER EVER CHANGE IT OR TRANSLATE IT!
*/
- const char* name;
+ const char *name;
//! Context for the translation
- const char* translation_context;
+ const char *translation_context;
//! Localized label for user-visible display
- const char* description;
+ const char *description;
//! The keys for this shortcut
int cutDefault, cutDefault2;
@@ -75,121 +74,120 @@ struct KStandardShortcutInfo
*/
// STUFF WILL BREAK IF YOU DON'T READ THIS!!!
// Read the comments of the big enum in kstandardshortcut.h before you change anything!
-static KStandardShortcutInfo g_infoStandardShortcut[] =
-{
+static KStandardShortcutInfo g_infoStandardShortcut[] = {
//Group File,
- {AccelNone, 0 , 0 , 0 , 0 , 0 , QList<QKeySequence>(), false },
- { Open , "Open" , I18N_NOOP2("@action", "Open") , CTRL(O), 0 , QList<QKeySequence>(), false } ,
- { New , "New" , I18N_NOOP2("@action", "New") , CTRL(N), 0 , QList<QKeySequence>(), false } ,
- { Close , "Close", I18N_NOOP2("@action", "Close"), CTRL(W), CTRL(Escape), QList<QKeySequence>(), false } ,
- { Save , "Save" , I18N_NOOP2("@action", "Save") , CTRL(S), 0 , QList<QKeySequence>(), false } ,
- { Print , "Print", I18N_NOOP2("@action", "Print"), CTRL(P), 0 , QList<QKeySequence>(), false } ,
- { Quit , "Quit" , I18N_NOOP2("@action", "Quit") , CTRL(Q), 0 , QList<QKeySequence>(), false } ,
+ {AccelNone, 0, 0, 0, 0, 0, QList<QKeySequence>(), false },
+ { Open, "Open", I18N_NOOP2("@action", "Open"), CTRL(O), 0, QList<QKeySequence>(), false },
+ { New, "New", I18N_NOOP2("@action", "New"), CTRL(N), 0, QList<QKeySequence>(), false },
+ { Close, "Close", I18N_NOOP2("@action", "Close"), CTRL(W), CTRL(Escape), QList<QKeySequence>(), false },
+ { Save, "Save", I18N_NOOP2("@action", "Save"), CTRL(S), 0, QList<QKeySequence>(), false },
+ { Print, "Print", I18N_NOOP2("@action", "Print"), CTRL(P), 0, QList<QKeySequence>(), false },
+ { Quit, "Quit", I18N_NOOP2("@action", "Quit"), CTRL(Q), 0, QList<QKeySequence>(), false },
//Group Edit
- { Undo , "Undo" , I18N_NOOP2("@action", "Undo") , CTRL(Z) , 0 , QList<QKeySequence>(), false },
- { Redo , "Redo" , I18N_NOOP2("@action", "Redo") , CTRLSHIFT(Z) , 0 , QList<QKeySequence>(), false },
- { Cut , "Cut" , I18N_NOOP2("@action", "Cut") , CTRL(X) , SHIFT(Delete), QList<QKeySequence>(), false },
- { Copy , "Copy" , I18N_NOOP2("@action", "Copy") , CTRL(C) , CTRL(Insert) , QList<QKeySequence>(), false },
- { Paste , "Paste" , I18N_NOOP2("@action", "Paste") , CTRL(V) , SHIFT(Insert), QList<QKeySequence>(), false },
- { PasteSelection , "Paste Selection" , I18N_NOOP2("@action", "Paste Selection") , CTRLSHIFT(Insert), 0 , QList<QKeySequence>(), false },
-
- { SelectAll , "SelectAll" , I18N_NOOP2("@action", "Select All") , CTRL(A) , 0 , QList<QKeySequence>(), false },
- { Deselect , "Deselect" , I18N_NOOP2("@action", "Deselect") , CTRLSHIFT(A) , 0 , QList<QKeySequence>(), false },
- { DeleteWordBack , "DeleteWordBack" , I18N_NOOP2("@action", "Delete Word Backwards"), CTRL(Backspace) , 0 , QList<QKeySequence>(), false },
- { DeleteWordForward, "DeleteWordForward", I18N_NOOP2("@action", "Delete Word Forward") , CTRL(Delete) , 0 , QList<QKeySequence>(), false },
-
- { Find , "Find" , I18N_NOOP2("@action", "Find") , CTRL(F) , 0 , QList<QKeySequence>(), false },
- { FindNext , "FindNext" , I18N_NOOP2("@action", "Find Next") , Qt::Key_F3 , 0 , QList<QKeySequence>(), false },
- { FindPrev , "FindPrev" , I18N_NOOP2("@action", "Find Prev") , SHIFT(F3) , 0 , QList<QKeySequence>(), false },
- { Replace , "Replace" , I18N_NOOP2("@action", "Replace") , CTRL(R) , 0 , QList<QKeySequence>(), false },
+ { Undo, "Undo", I18N_NOOP2("@action", "Undo"), CTRL(Z), 0, QList<QKeySequence>(), false },
+ { Redo, "Redo", I18N_NOOP2("@action", "Redo"), CTRLSHIFT(Z), 0, QList<QKeySequence>(), false },
+ { Cut, "Cut", I18N_NOOP2("@action", "Cut"), CTRL(X), SHIFT(Delete), QList<QKeySequence>(), false },
+ { Copy, "Copy", I18N_NOOP2("@action", "Copy"), CTRL(C), CTRL(Insert), QList<QKeySequence>(), false },
+ { Paste, "Paste", I18N_NOOP2("@action", "Paste"), CTRL(V), SHIFT(Insert), QList<QKeySequence>(), false },
+ { PasteSelection, "Paste Selection", I18N_NOOP2("@action", "Paste Selection"), CTRLSHIFT(Insert), 0, QList<QKeySequence>(), false },
+
+ { SelectAll, "SelectAll", I18N_NOOP2("@action", "Select All"), CTRL(A), 0, QList<QKeySequence>(), false },
+ { Deselect, "Deselect", I18N_NOOP2("@action", "Deselect"), CTRLSHIFT(A), 0, QList<QKeySequence>(), false },
+ { DeleteWordBack, "DeleteWordBack", I18N_NOOP2("@action", "Delete Word Backwards"), CTRL(Backspace), 0, QList<QKeySequence>(), false },
+ { DeleteWordForward, "DeleteWordForward", I18N_NOOP2("@action", "Delete Word Forward"), CTRL(Delete), 0, QList<QKeySequence>(), false },
+
+ { Find, "Find", I18N_NOOP2("@action", "Find"), CTRL(F), 0, QList<QKeySequence>(), false },
+ { FindNext, "FindNext", I18N_NOOP2("@action", "Find Next"), Qt::Key_F3, 0, QList<QKeySequence>(), false },
+ { FindPrev, "FindPrev", I18N_NOOP2("@action", "Find Prev"), SHIFT(F3), 0, QList<QKeySequence>(), false },
+ { Replace, "Replace", I18N_NOOP2("@action", "Replace"), CTRL(R), 0, QList<QKeySequence>(), false },
//Group Navigation
- { Home , "Home" , I18N_NOOP2("@action Go to main page" , "Home") , ALT(Home) , Qt::Key_HomePage , QList<QKeySequence>(), false },
- { Begin , "Begin" , I18N_NOOP2("@action Beginning of document", "Begin") , CTRL(Home) , 0 , QList<QKeySequence>(), false },
- { End , "End" , I18N_NOOP2("@action End of document" , "End") , CTRL(End) , 0 , QList<QKeySequence>(), false },
- { Prior , "Prior" , I18N_NOOP2("@action" , "Prior") , Qt::Key_PageUp , 0 , QList<QKeySequence>(), false },
- { Next , "Next" , I18N_NOOP2("@action Opposite to Prior" , "Next") , Qt::Key_PageDown, 0 , QList<QKeySequence>(), false },
-
- { Up , "Up" , I18N_NOOP2("@action" , "Up") , ALT(Up) , 0 , QList<QKeySequence>(), false },
- { Back , "Back" , I18N_NOOP2("@action" , "Back") , ALT(Left) , Qt::Key_Back , QList<QKeySequence>(), false },
- { Forward , "Forward" , I18N_NOOP2("@action" , "Forward") , ALT(Right) , Qt::Key_Forward , QList<QKeySequence>(), false },
- { Reload , "Reload" , I18N_NOOP2("@action" , "Reload") , Qt::Key_F5 , Qt::Key_Refresh , QList<QKeySequence>(), false },
-
- { BeginningOfLine, "BeginningOfLine" , I18N_NOOP2("@action" , "Beginning of Line") , Qt::Key_Home , 0 , QList<QKeySequence>(), false },
- { EndOfLine , "EndOfLine" , I18N_NOOP2("@action" , "End of Line") , Qt::Key_End , 0 , QList<QKeySequence>(), false },
- { GotoLine , "GotoLine" , I18N_NOOP2("@action" , "Go to Line") , CTRL(G) , 0 , QList<QKeySequence>(), false },
- { BackwardWord , "BackwardWord" , I18N_NOOP2("@action" , "Backward Word") , CTRL(Left) , 0 , QList<QKeySequence>(), false },
- { ForwardWord , "ForwardWord" , I18N_NOOP2("@action" , "Forward Word") , CTRL(Right) , 0 , QList<QKeySequence>(), false },
-
- { AddBookmark , "AddBookmark" , I18N_NOOP2("@action" , "Add Bookmark") , CTRL(B) , 0 , QList<QKeySequence>(), false },
- { ZoomIn , "ZoomIn" , I18N_NOOP2("@action" , "Zoom In") , CTRL(Plus) , CTRL(Equal) , QList<QKeySequence>(), false },
- { ZoomOut , "ZoomOut" , I18N_NOOP2("@action" , "Zoom Out") , CTRL(Minus) , 0 , QList<QKeySequence>(), false },
- { FullScreen , "FullScreen" , I18N_NOOP2("@action" , "Full Screen Mode") , CTRLSHIFT(F) , 0 , QList<QKeySequence>(), false },
-
- { ShowMenubar , "ShowMenubar" , I18N_NOOP2("@action" , "Show Menu Bar") , CTRL(M) , 0 , QList<QKeySequence>(), false },
- { TabNext , "Activate Next Tab" , I18N_NOOP2("@action" , "Activate Next Tab") , CTRL(Period) , CTRL(BracketRight), QList<QKeySequence>(), false },
- { TabPrev , "Activate Previous Tab", I18N_NOOP2("@action" , "Activate Previous Tab"), CTRL(Comma) , CTRL(BracketLeft) , QList<QKeySequence>(), false },
+ { Home, "Home", I18N_NOOP2("@action Go to main page", "Home"), ALT(Home), Qt::Key_HomePage, QList<QKeySequence>(), false },
+ { Begin, "Begin", I18N_NOOP2("@action Beginning of document", "Begin"), CTRL(Home), 0, QList<QKeySequence>(), false },
+ { End, "End", I18N_NOOP2("@action End of document", "End"), CTRL(End), 0, QList<QKeySequence>(), false },
+ { Prior, "Prior", I18N_NOOP2("@action", "Prior"), Qt::Key_PageUp, 0, QList<QKeySequence>(), false },
+ { Next, "Next", I18N_NOOP2("@action Opposite to Prior", "Next"), Qt::Key_PageDown, 0, QList<QKeySequence>(), false },
+
+ { Up, "Up", I18N_NOOP2("@action", "Up"), ALT(Up), 0, QList<QKeySequence>(), false },
+ { Back, "Back", I18N_NOOP2("@action", "Back"), ALT(Left), Qt::Key_Back, QList<QKeySequence>(), false },
+ { Forward, "Forward", I18N_NOOP2("@action", "Forward"), ALT(Right), Qt::Key_Forward, QList<QKeySequence>(), false },
+ { Reload, "Reload", I18N_NOOP2("@action", "Reload"), Qt::Key_F5, Qt::Key_Refresh, QList<QKeySequence>(), false },
+
+ { BeginningOfLine, "BeginningOfLine", I18N_NOOP2("@action", "Beginning of Line"), Qt::Key_Home, 0, QList<QKeySequence>(), false },
+ { EndOfLine, "EndOfLine", I18N_NOOP2("@action", "End of Line"), Qt::Key_End, 0, QList<QKeySequence>(), false },
+ { GotoLine, "GotoLine", I18N_NOOP2("@action", "Go to Line"), CTRL(G), 0, QList<QKeySequence>(), false },
+ { BackwardWord, "BackwardWord", I18N_NOOP2("@action", "Backward Word"), CTRL(Left), 0, QList<QKeySequence>(), false },
+ { ForwardWord, "ForwardWord", I18N_NOOP2("@action", "Forward Word"), CTRL(Right), 0, QList<QKeySequence>(), false },
+
+ { AddBookmark, "AddBookmark", I18N_NOOP2("@action", "Add Bookmark"), CTRL(B), 0, QList<QKeySequence>(), false },
+ { ZoomIn, "ZoomIn", I18N_NOOP2("@action", "Zoom In"), CTRL(Plus), CTRL(Equal), QList<QKeySequence>(), false },
+ { ZoomOut, "ZoomOut", I18N_NOOP2("@action", "Zoom Out"), CTRL(Minus), 0, QList<QKeySequence>(), false },
+ { FullScreen, "FullScreen", I18N_NOOP2("@action", "Full Screen Mode"), CTRLSHIFT(F), 0, QList<QKeySequence>(), false },
+
+ { ShowMenubar, "ShowMenubar", I18N_NOOP2("@action", "Show Menu Bar"), CTRL(M), 0, QList<QKeySequence>(), false },
+ { TabNext, "Activate Next Tab", I18N_NOOP2("@action", "Activate Next Tab"), CTRL(Period), CTRL(BracketRight), QList<QKeySequence>(), false },
+ { TabPrev, "Activate Previous Tab", I18N_NOOP2("@action", "Activate Previous Tab"), CTRL(Comma), CTRL(BracketLeft), QList<QKeySequence>(), false },
//Group Help
- { Help , "Help" , I18N_NOOP2("@action" , "Help") , Qt::Key_F1 , 0 , QList<QKeySequence>(), false },
- { WhatsThis , "WhatsThis" , I18N_NOOP2("@action" , "What's This") , SHIFT(F1) , 0 , QList<QKeySequence>(), false },
+ { Help, "Help", I18N_NOOP2("@action", "Help"), Qt::Key_F1, 0, QList<QKeySequence>(), false },
+ { WhatsThis, "WhatsThis", I18N_NOOP2("@action", "What's This"), SHIFT(F1), 0, QList<QKeySequence>(), false },
//Group TextCompletion
- { TextCompletion , "TextCompletion" , I18N_NOOP2("@action", "Text Completion") , CTRL(E) , 0, QList<QKeySequence>(), false },
- { PrevCompletion , "PrevCompletion" , I18N_NOOP2("@action", "Previous Completion Match"), CTRL(Up) , 0, QList<QKeySequence>(), false },
- { NextCompletion , "NextCompletion" , I18N_NOOP2("@action", "Next Completion Match") , CTRL(Down) , 0, QList<QKeySequence>(), false },
- { SubstringCompletion , "SubstringCompletion" , I18N_NOOP2("@action", "Substring Completion") , CTRL(T) , 0, QList<QKeySequence>(), false },
-
- { RotateUp , "RotateUp" , I18N_NOOP2("@action", "Previous Item in List") , Qt::Key_Up , 0, QList<QKeySequence>(), false },
- { RotateDown , "RotateDown" , I18N_NOOP2("@action", "Next Item in List") , Qt::Key_Down, 0, QList<QKeySequence>(), false },
-
- { OpenRecent , "OpenRecent" , I18N_NOOP2("@action", "Open Recent") , 0 , 0, QList<QKeySequence>(), false },
- { SaveAs , "SaveAs" , I18N_NOOP2("@action", "Save As") , CTRLSHIFT(S), 0, QList<QKeySequence>(), false },
- { Revert , "Revert" , I18N_NOOP2("@action", "Revert") , 0 , 0, QList<QKeySequence>(), false },
- { PrintPreview , "PrintPreview" , I18N_NOOP2("@action", "Print Preview") , 0 , 0, QList<QKeySequence>(), false },
- { Mail , "Mail" , I18N_NOOP2("@action", "Mail") , 0 , 0, QList<QKeySequence>(), false },
- { Clear , "Clear" , I18N_NOOP2("@action", "Clear") , 0 , 0, QList<QKeySequence>(), false },
- { ActualSize , "ActualSize" , I18N_NOOP2("@action", "Actual Size") , 0 , 0, QList<QKeySequence>(), false },
- { FitToPage , "FitToPage" , I18N_NOOP2("@action", "Fit To Page") , 0 , 0, QList<QKeySequence>(), false },
- { FitToWidth , "FitToWidth" , I18N_NOOP2("@action", "Fit To Width") , 0 , 0, QList<QKeySequence>(), false },
- { FitToHeight , "FitToHeight" , I18N_NOOP2("@action", "Fit To Height") , 0 , 0, QList<QKeySequence>(), false },
- { Zoom , "Zoom" , I18N_NOOP2("@action", "Zoom") , 0 , 0, QList<QKeySequence>(), false },
- { Goto , "Goto" , I18N_NOOP2("@action", "Goto") , 0 , 0, QList<QKeySequence>(), false },
- { GotoPage , "GotoPage" , I18N_NOOP2("@action", "Goto Page") , 0 , 0, QList<QKeySequence>(), false },
- { DocumentBack , "DocumentBack" , I18N_NOOP2("@action", "Document Back") , ALTSHIFT(Left), 0, QList<QKeySequence>(), false },
- { DocumentForward , "DocumentForward" , I18N_NOOP2("@action", "Document Forward") , ALTSHIFT(Right), 0, QList<QKeySequence>(), false },
- { EditBookmarks , "EditBookmarks" , I18N_NOOP2("@action", "Edit Bookmarks") , 0 , 0, QList<QKeySequence>(), false },
- { Spelling , "Spelling" , I18N_NOOP2("@action", "Spelling") , 0 , 0, QList<QKeySequence>(), false },
- { ShowToolbar , "ShowToolbar" , I18N_NOOP2("@action", "Show Toolbar") , 0 , 0, QList<QKeySequence>(), false },
- { ShowStatusbar , "ShowStatusbar" , I18N_NOOP2("@action", "Show Statusbar") , 0 , 0, QList<QKeySequence>(), false },
- { SaveOptions , "SaveOptions" , I18N_NOOP2("@action", "Save Options") , 0 , 0, QList<QKeySequence>(), false },
- { KeyBindings , "KeyBindings" , I18N_NOOP2("@action", "Key Bindings") , 0 , 0, QList<QKeySequence>(), false },
- { Preferences , "Preferences" , I18N_NOOP2("@action", "Preferences") , 0 , 0, QList<QKeySequence>(), false },
- { ConfigureToolbars , "ConfigureToolbars" , I18N_NOOP2("@action", "Configure Toolbars") , 0 , 0, QList<QKeySequence>(), false },
- { ConfigureNotifications , "ConfigureNotifications" , I18N_NOOP2("@action", "Configure Notifications") , 0 , 0, QList<QKeySequence>(), false },
- { TipofDay , "TipofDay" , I18N_NOOP2("@action", "Tip Of Day") , 0 , 0, QList<QKeySequence>(), false },
- { ReportBug , "ReportBug" , I18N_NOOP2("@action", "Report Bug") , 0 , 0, QList<QKeySequence>(), false },
- { SwitchApplicationLanguage, "SwitchApplicationLanguage", I18N_NOOP2("@action", "Switch Application Language"), 0 , 0, QList<QKeySequence>(), false },
- { AboutApp , "AboutApp" , I18N_NOOP2("@action", "About Application") , 0 , 0, QList<QKeySequence>(), false },
- { AboutKDE , "AboutKDE" , I18N_NOOP2("@action", "About KDE") , 0 , 0, QList<QKeySequence>(), false },
+ { TextCompletion, "TextCompletion", I18N_NOOP2("@action", "Text Completion"), CTRL(E), 0, QList<QKeySequence>(), false },
+ { PrevCompletion, "PrevCompletion", I18N_NOOP2("@action", "Previous Completion Match"), CTRL(Up), 0, QList<QKeySequence>(), false },
+ { NextCompletion, "NextCompletion", I18N_NOOP2("@action", "Next Completion Match"), CTRL(Down), 0, QList<QKeySequence>(), false },
+ { SubstringCompletion, "SubstringCompletion", I18N_NOOP2("@action", "Substring Completion"), CTRL(T), 0, QList<QKeySequence>(), false },
+
+ { RotateUp, "RotateUp", I18N_NOOP2("@action", "Previous Item in List"), Qt::Key_Up, 0, QList<QKeySequence>(), false },
+ { RotateDown, "RotateDown", I18N_NOOP2("@action", "Next Item in List"), Qt::Key_Down, 0, QList<QKeySequence>(), false },
+
+ { OpenRecent, "OpenRecent", I18N_NOOP2("@action", "Open Recent"), 0, 0, QList<QKeySequence>(), false },
+ { SaveAs, "SaveAs", I18N_NOOP2("@action", "Save As"), CTRLSHIFT(S), 0, QList<QKeySequence>(), false },
+ { Revert, "Revert", I18N_NOOP2("@action", "Revert"), 0, 0, QList<QKeySequence>(), false },
+ { PrintPreview, "PrintPreview", I18N_NOOP2("@action", "Print Preview"), 0, 0, QList<QKeySequence>(), false },
+ { Mail, "Mail", I18N_NOOP2("@action", "Mail"), 0, 0, QList<QKeySequence>(), false },
+ { Clear, "Clear", I18N_NOOP2("@action", "Clear"), 0, 0, QList<QKeySequence>(), false },
+ { ActualSize, "ActualSize", I18N_NOOP2("@action", "Actual Size"), 0, 0, QList<QKeySequence>(), false },
+ { FitToPage, "FitToPage", I18N_NOOP2("@action", "Fit To Page"), 0, 0, QList<QKeySequence>(), false },
+ { FitToWidth, "FitToWidth", I18N_NOOP2("@action", "Fit To Width"), 0, 0, QList<QKeySequence>(), false },
+ { FitToHeight, "FitToHeight", I18N_NOOP2("@action", "Fit To Height"), 0, 0, QList<QKeySequence>(), false },
+ { Zoom, "Zoom", I18N_NOOP2("@action", "Zoom"), 0, 0, QList<QKeySequence>(), false },
+ { Goto, "Goto", I18N_NOOP2("@action", "Goto"), 0, 0, QList<QKeySequence>(), false },
+ { GotoPage, "GotoPage", I18N_NOOP2("@action", "Goto Page"), 0, 0, QList<QKeySequence>(), false },
+ { DocumentBack, "DocumentBack", I18N_NOOP2("@action", "Document Back"), ALTSHIFT(Left), 0, QList<QKeySequence>(), false },
+ { DocumentForward, "DocumentForward", I18N_NOOP2("@action", "Document Forward"), ALTSHIFT(Right), 0, QList<QKeySequence>(), false },
+ { EditBookmarks, "EditBookmarks", I18N_NOOP2("@action", "Edit Bookmarks"), 0, 0, QList<QKeySequence>(), false },
+ { Spelling, "Spelling", I18N_NOOP2("@action", "Spelling"), 0, 0, QList<QKeySequence>(), false },
+ { ShowToolbar, "ShowToolbar", I18N_NOOP2("@action", "Show Toolbar"), 0, 0, QList<QKeySequence>(), false },
+ { ShowStatusbar, "ShowStatusbar", I18N_NOOP2("@action", "Show Statusbar"), 0, 0, QList<QKeySequence>(), false },
+ { SaveOptions, "SaveOptions", I18N_NOOP2("@action", "Save Options"), 0, 0, QList<QKeySequence>(), false },
+ { KeyBindings, "KeyBindings", I18N_NOOP2("@action", "Key Bindings"), 0, 0, QList<QKeySequence>(), false },
+ { Preferences, "Preferences", I18N_NOOP2("@action", "Preferences"), 0, 0, QList<QKeySequence>(), false },
+ { ConfigureToolbars, "ConfigureToolbars", I18N_NOOP2("@action", "Configure Toolbars"), 0, 0, QList<QKeySequence>(), false },
+ { ConfigureNotifications, "ConfigureNotifications", I18N_NOOP2("@action", "Configure Notifications"), 0, 0, QList<QKeySequence>(), false },
+ { TipofDay, "TipofDay", I18N_NOOP2("@action", "Tip Of Day"), 0, 0, QList<QKeySequence>(), false },
+ { ReportBug, "ReportBug", I18N_NOOP2("@action", "Report Bug"), 0, 0, QList<QKeySequence>(), false },
+ { SwitchApplicationLanguage, "SwitchApplicationLanguage", I18N_NOOP2("@action", "Switch Application Language"), 0, 0, QList<QKeySequence>(), false },
+ { AboutApp, "AboutApp", I18N_NOOP2("@action", "About Application"), 0, 0, QList<QKeySequence>(), false },
+ { AboutKDE, "AboutKDE", I18N_NOOP2("@action", "About KDE"), 0, 0, QList<QKeySequence>(), false },
//dummy entry to catch simple off-by-one errors. Insert new entries before this line.
- { AccelNone , 0 , 0 , 0 , 0, 0, QList<QKeySequence>(), false }
+ { AccelNone, 0, 0, 0, 0, 0, QList<QKeySequence>(), false }
};
-
/** Search for the KStandardShortcutInfo object associated with the given @p id.
Return a dummy entry with no name and an empty shortcut if @p id is invalid.
*/
static KStandardShortcutInfo *guardedStandardShortcutInfo(StandardShortcut id)
{
if (id >= static_cast<int>(sizeof(g_infoStandardShortcut) / sizeof(KStandardShortcutInfo)) ||
- id < 0) {
+ id < 0) {
qWarning() << "KStandardShortcut: id not found!";
return &g_infoStandardShortcut[AccelNone];
- } else
+ } else {
return &g_infoStandardShortcut[id];
+ }
}
/** Initialize the accelerator @p id by checking if it is overridden
@@ -202,7 +200,7 @@ static void initialize(StandardShortcut id)
KStandardShortcutInfo *info = guardedStandardShortcutInfo(id);
// All three are needed.
- if (info->id!=AccelNone) {
+ if (info->id != AccelNone) {
Q_ASSERT(info->description);
Q_ASSERT(info->translation_context);
Q_ASSERT(info->name);
@@ -212,10 +210,11 @@ static void initialize(StandardShortcut id)
if (cg.hasKey(info->name)) {
QString s = cg.readEntry(info->name);
- if (s != QLatin1String("none"))
+ if (s != QLatin1String("none")) {
info->cut = QKeySequence::listFromString(s);
- else
+ } else {
info->cut = QList<QKeySequence>();
+ }
} else {
info->cut = hardcodedDefaultShortcut(id);
}
@@ -228,8 +227,9 @@ void saveShortcut(StandardShortcut id, const QList<QKeySequence> &newShortcut)
KStandardShortcutInfo *info = guardedStandardShortcutInfo(id);
// If the action has no standard shortcut associated there is nothing to
// save
- if(info->id == AccelNone)
+ if (info->id == AccelNone) {
return;
+ }
KConfigGroup cg(KSharedConfig::openConfig(), "Shortcuts");
@@ -239,14 +239,15 @@ void saveShortcut(StandardShortcut id, const QList<QKeySequence> &newShortcut)
if (sameAsDefault) {
// If the shortcut is the equal to the hardcoded one we remove it from
// kdeglobal if necessary and return.
- if(cg.hasKey(info->name))
- cg.deleteEntry(info->name, KConfig::Global|KConfig::Persistent);
+ if (cg.hasKey(info->name)) {
+ cg.deleteEntry(info->name, KConfig::Global | KConfig::Persistent);
+ }
return;
}
// Write the changed shortcut to kdeglobals
- cg.writeEntry(info->name, QKeySequence::listToString(info->cut), KConfig::Global|KConfig::Persistent);
+ cg.writeEntry(info->name, QKeySequence::listToString(info->cut), KConfig::Global | KConfig::Persistent);
}
QString name(StandardShortcut id)
@@ -256,42 +257,45 @@ QString name(StandardShortcut id)
QString label(StandardShortcut id)
{
- KStandardShortcutInfo *info = guardedStandardShortcutInfo( id );
+ KStandardShortcutInfo *info = guardedStandardShortcutInfo(id);
return QCoreApplication::translate("KStandardShortcut",
info->description,
info->translation_context);
}
// TODO: Add psWhatsThis entry to KStandardShortcutInfo
-QString whatsThis( StandardShortcut /*id*/ )
+QString whatsThis(StandardShortcut /*id*/)
{
// KStandardShortcutInfo* info = guardedStandardShortcutInfo( id );
// if( info && info->whatsThis )
// return i18n(info->whatsThis);
// else
- return QString();
+ return QString();
}
const QList<QKeySequence> &shortcut(StandardShortcut id)
{
KStandardShortcutInfo *info = guardedStandardShortcutInfo(id);
- if(!info->isInitialized)
+ if (!info->isInitialized) {
initialize(id);
+ }
return info->cut;
}
StandardShortcut find(const QKeySequence &seq)
{
- if( !seq.isEmpty() ) {
- for(uint i = 0; i < sizeof(g_infoStandardShortcut) / sizeof(KStandardShortcutInfo); i++) {
+ if (!seq.isEmpty()) {
+ for (uint i = 0; i < sizeof(g_infoStandardShortcut) / sizeof(KStandardShortcutInfo); i++) {
StandardShortcut id = g_infoStandardShortcut[i].id;
- if( id != AccelNone ) {
- if(!g_infoStandardShortcut[i].isInitialized)
+ if (id != AccelNone) {
+ if (!g_infoStandardShortcut[i].isInitialized) {
initialize(id);
- if(g_infoStandardShortcut[i].cut.contains(seq))
+ }
+ if (g_infoStandardShortcut[i].cut.contains(seq)) {
return id;
+ }
}
}
}
@@ -300,9 +304,10 @@ StandardShortcut find(const QKeySequence &seq)
StandardShortcut find(const char *keyName)
{
- for(uint i = 0; i < sizeof(g_infoStandardShortcut) / sizeof(KStandardShortcutInfo); i++)
- if (qstrcmp(g_infoStandardShortcut[i].name, keyName))
+ for (uint i = 0; i < sizeof(g_infoStandardShortcut) / sizeof(KStandardShortcutInfo); i++)
+ if (qstrcmp(g_infoStandardShortcut[i].name, keyName)) {
return g_infoStandardShortcut[i].id;
+ }
return AccelNone;
}
@@ -312,12 +317,14 @@ QList<QKeySequence> hardcodedDefaultShortcut(StandardShortcut id)
QList<QKeySequence> cut;
KStandardShortcutInfo *info = guardedStandardShortcutInfo(id);
- if (info->cutDefault != 0)
+ if (info->cutDefault != 0) {
cut << info->cutDefault;
+ }
if (info->cutDefault2 != 0) {
- if (cut.isEmpty())
+ if (cut.isEmpty()) {
cut << QKeySequence();
+ }
cut << info->cutDefault2;
}
@@ -325,53 +332,197 @@ QList<QKeySequence> hardcodedDefaultShortcut(StandardShortcut id)
return cut;
}
-const QList<QKeySequence> &open() { return shortcut( Open ); }
-const QList<QKeySequence> &openNew() { return shortcut( New ); }
-const QList<QKeySequence> &close() { return shortcut( Close ); }
-const QList<QKeySequence> &save() { return shortcut( Save ); }
-const QList<QKeySequence> &print() { return shortcut( Print ); }
-const QList<QKeySequence> &quit() { return shortcut( Quit ); }
-const QList<QKeySequence> &cut() { return shortcut( Cut ); }
-const QList<QKeySequence> &copy() { return shortcut( Copy ); }
-const QList<QKeySequence> &paste() { return shortcut( Paste ); }
-const QList<QKeySequence> &pasteSelection() { return shortcut( PasteSelection ); }
-const QList<QKeySequence> &deleteWordBack() { return shortcut( DeleteWordBack ); }
-const QList<QKeySequence> &deleteWordForward() { return shortcut( DeleteWordForward ); }
-const QList<QKeySequence> &undo() { return shortcut( Undo ); }
-const QList<QKeySequence> &redo() { return shortcut( Redo ); }
-const QList<QKeySequence> &find() { return shortcut( Find ); }
-const QList<QKeySequence> &findNext() { return shortcut( FindNext ); }
-const QList<QKeySequence> &findPrev() { return shortcut( FindPrev ); }
-const QList<QKeySequence> &replace() { return shortcut( Replace ); }
-const QList<QKeySequence> &home() { return shortcut( Home ); }
-const QList<QKeySequence> &begin() { return shortcut( Begin ); }
-const QList<QKeySequence> &end() { return shortcut( End ); }
-const QList<QKeySequence> &beginningOfLine() { return shortcut( BeginningOfLine ); }
-const QList<QKeySequence> &endOfLine() { return shortcut( EndOfLine ); }
-const QList<QKeySequence> &prior() { return shortcut( Prior ); }
-const QList<QKeySequence> &next() { return shortcut( Next ); }
-const QList<QKeySequence> &backwardWord() { return shortcut( BackwardWord ); }
-const QList<QKeySequence> &forwardWord() { return shortcut( ForwardWord ); }
-const QList<QKeySequence> &gotoLine() { return shortcut( GotoLine ); }
-const QList<QKeySequence> &addBookmark() { return shortcut( AddBookmark ); }
-const QList<QKeySequence> &tabNext() { return shortcut( TabNext ); }
-const QList<QKeySequence> &tabPrev() { return shortcut( TabPrev ); }
-const QList<QKeySequence> &fullScreen() { return shortcut( FullScreen ); }
-const QList<QKeySequence> &zoomIn() { return shortcut( ZoomIn ); }
-const QList<QKeySequence> &zoomOut() { return shortcut( ZoomOut ); }
-const QList<QKeySequence> &help() { return shortcut( Help ); }
-const QList<QKeySequence> &completion() { return shortcut( TextCompletion ); }
-const QList<QKeySequence> &prevCompletion() { return shortcut( PrevCompletion ); }
-const QList<QKeySequence> &nextCompletion() { return shortcut( NextCompletion ); }
-const QList<QKeySequence> &rotateUp() { return shortcut( RotateUp ); }
-const QList<QKeySequence> &rotateDown() { return shortcut( RotateDown ); }
-const QList<QKeySequence> &substringCompletion() { return shortcut( SubstringCompletion ); }
-const QList<QKeySequence> &whatsThis() { return shortcut( WhatsThis ); }
-const QList<QKeySequence> &reload() { return shortcut( Reload ); }
-const QList<QKeySequence> &selectAll() { return shortcut( SelectAll ); }
-const QList<QKeySequence> &up() { return shortcut( Up ); }
-const QList<QKeySequence> &back() { return shortcut( Back ); }
-const QList<QKeySequence> &forward() { return shortcut( Forward ); }
-const QList<QKeySequence> &showMenubar() { return shortcut( ShowMenubar ); }
+const QList<QKeySequence> &open()
+{
+ return shortcut(Open);
+}
+const QList<QKeySequence> &openNew()
+{
+ return shortcut(New);
+}
+const QList<QKeySequence> &close()
+{
+ return shortcut(Close);
+}
+const QList<QKeySequence> &save()
+{
+ return shortcut(Save);
+}
+const QList<QKeySequence> &print()
+{
+ return shortcut(Print);
+}
+const QList<QKeySequence> &quit()
+{
+ return shortcut(Quit);
+}
+const QList<QKeySequence> &cut()
+{
+ return shortcut(Cut);
+}
+const QList<QKeySequence> &copy()
+{
+ return shortcut(Copy);
+}
+const QList<QKeySequence> &paste()
+{
+ return shortcut(Paste);
+}
+const QList<QKeySequence> &pasteSelection()
+{
+ return shortcut(PasteSelection);
+}
+const QList<QKeySequence> &deleteWordBack()
+{
+ return shortcut(DeleteWordBack);
+}
+const QList<QKeySequence> &deleteWordForward()
+{
+ return shortcut(DeleteWordForward);
+}
+const QList<QKeySequence> &undo()
+{
+ return shortcut(Undo);
+}
+const QList<QKeySequence> &redo()
+{
+ return shortcut(Redo);
+}
+const QList<QKeySequence> &find()
+{
+ return shortcut(Find);
+}
+const QList<QKeySequence> &findNext()
+{
+ return shortcut(FindNext);
+}
+const QList<QKeySequence> &findPrev()
+{
+ return shortcut(FindPrev);
+}
+const QList<QKeySequence> &replace()
+{
+ return shortcut(Replace);
+}
+const QList<QKeySequence> &home()
+{
+ return shortcut(Home);
+}
+const QList<QKeySequence> &begin()
+{
+ return shortcut(Begin);
+}
+const QList<QKeySequence> &end()
+{
+ return shortcut(End);
+}
+const QList<QKeySequence> &beginningOfLine()
+{
+ return shortcut(BeginningOfLine);
+}
+const QList<QKeySequence> &endOfLine()
+{
+ return shortcut(EndOfLine);
+}
+const QList<QKeySequence> &prior()
+{
+ return shortcut(Prior);
+}
+const QList<QKeySequence> &next()
+{
+ return shortcut(Next);
+}
+const QList<QKeySequence> &backwardWord()
+{
+ return shortcut(BackwardWord);
+}
+const QList<QKeySequence> &forwardWord()
+{
+ return shortcut(ForwardWord);
+}
+const QList<QKeySequence> &gotoLine()
+{
+ return shortcut(GotoLine);
+}
+const QList<QKeySequence> &addBookmark()
+{
+ return shortcut(AddBookmark);
+}
+const QList<QKeySequence> &tabNext()
+{
+ return shortcut(TabNext);
+}
+const QList<QKeySequence> &tabPrev()
+{
+ return shortcut(TabPrev);
+}
+const QList<QKeySequence> &fullScreen()
+{
+ return shortcut(FullScreen);
+}
+const QList<QKeySequence> &zoomIn()
+{
+ return shortcut(ZoomIn);
+}
+const QList<QKeySequence> &zoomOut()
+{
+ return shortcut(ZoomOut);
+}
+const QList<QKeySequence> &help()
+{
+ return shortcut(Help);
+}
+const QList<QKeySequence> &completion()
+{
+ return shortcut(TextCompletion);
+}
+const QList<QKeySequence> &prevCompletion()
+{
+ return shortcut(PrevCompletion);
+}
+const QList<QKeySequence> &nextCompletion()
+{
+ return shortcut(NextCompletion);
+}
+const QList<QKeySequence> &rotateUp()
+{
+ return shortcut(RotateUp);
+}
+const QList<QKeySequence> &rotateDown()
+{
+ return shortcut(RotateDown);
+}
+const QList<QKeySequence> &substringCompletion()
+{
+ return shortcut(SubstringCompletion);
+}
+const QList<QKeySequence> &whatsThis()
+{
+ return shortcut(WhatsThis);
+}
+const QList<QKeySequence> &reload()
+{
+ return shortcut(Reload);
+}
+const QList<QKeySequence> &selectAll()
+{
+ return shortcut(SelectAll);
+}
+const QList<QKeySequence> &up()
+{
+ return shortcut(Up);
+}
+const QList<QKeySequence> &back()
+{
+ return shortcut(Back);
+}
+const QList<QKeySequence> &forward()
+{
+ return shortcut(Forward);
+}
+const QList<QKeySequence> &showMenubar()
+{
+ return shortcut(ShowMenubar);
+}
}
diff --git a/src/gui/kstandardshortcut.h b/src/gui/kstandardshortcut.h
index b02a6ebf..5bb07fb9 100644
--- a/src/gui/kstandardshortcut.h
+++ b/src/gui/kstandardshortcut.h
@@ -33,29 +33,30 @@
* so do not hardcode the default behavior.
*/
namespace KStandardShortcut
-{ // STUFF WILL BREAK IF YOU DON'T READ THIS!!!
- /*
- *Always add new std-accels to the end of this enum, never in the middle!
- *Don't forget to add the corresponding entries in g_infoStandardShortcut[] in kstandardshortcut.cpp, too.
- *Values of elements here and positions of the corresponding entries in
- *the big array g_infoStandardShortcut[] ABSOLUTELY MUST BE THE SAME.
- * !!! !!!! !!!!! !!!!
- * !!!! !!! !!!! !!!!
- * Remember to also update kdoctools/genshortcutents.cpp.
- *
- * Other Rules:
- *
- * - Never change the name of an existing shortcut
- * - Never translate the name of a shortcut
- */
-
- /**
- * Defines the identifier of all standard accelerators.
- */
- enum StandardShortcut {
+{
+// STUFF WILL BREAK IF YOU DON'T READ THIS!!!
+/*
+ *Always add new std-accels to the end of this enum, never in the middle!
+ *Don't forget to add the corresponding entries in g_infoStandardShortcut[] in kstandardshortcut.cpp, too.
+ *Values of elements here and positions of the corresponding entries in
+ *the big array g_infoStandardShortcut[] ABSOLUTELY MUST BE THE SAME.
+ * !!! !!!! !!!!! !!!!
+ * !!!! !!! !!!! !!!!
+ * Remember to also update kdoctools/genshortcutents.cpp.
+ *
+ * Other Rules:
+ *
+ * - Never change the name of an existing shortcut
+ * - Never translate the name of a shortcut
+ */
+
+/**
+ * Defines the identifier of all standard accelerators.
+ */
+enum StandardShortcut {
//C++ requires that the value of an enum symbol be one more than the previous one.
- //This means that everything will be well-ordered from here on.
- AccelNone=0,
+ //This means that everything will be well-ordered from here on.
+ AccelNone = 0,
// File menu
Open, New, Close, Save,
// The Print item
@@ -116,366 +117,366 @@ namespace KStandardShortcut
// Insert new items here!
StandardShortcutCount // number of standard shortcuts
- };
-
- /**
- * Returns the keybinding for @p accel.
- * On X11, if QApplication was initialized with GUI disabled, the
- * default keybinding will always be returned.
- * @param id the id of the accelerator
- */
- KCONFIGGUI_EXPORT const QList<QKeySequence> &shortcut(StandardShortcut id);
-
- /**
- * Returns a unique name for the given accel.
- * @param id the id of the accelerator
- * @return the unique name of the accelerator
- */
- KCONFIGGUI_EXPORT QString name(StandardShortcut id);
-
- /**
- * Returns a localized label for user-visible display.
- * @param id the id of the accelerator
- * @return a localized label for the accelerator
- */
- KCONFIGGUI_EXPORT QString label(StandardShortcut id);
-
- /**
- * Returns an extended WhatsThis description for the given accelerator.
- * @param id the id of the accelerator
- * @return a localized description of the accelerator
- */
- KCONFIGGUI_EXPORT QString whatsThis(StandardShortcut id);
-
- /**
- * Return the StandardShortcut id of the standard accel action which
- * uses this key sequence, or AccelNone if none of them do.
- * This is used by class KKeyChooser.
- * @param keySeq the key sequence to search
- * @return the id of the standard accelerator, or AccelNone if there
- * is none
- */
- KCONFIGGUI_EXPORT StandardShortcut find(const QKeySequence &keySeq);
-
- /**
- * Return the StandardShortcut id of the standard accel action which
- * has \a keyName as its name, or AccelNone if none of them do.
- * This is used by class KKeyChooser.
- * @param keyName the key sequence to search
- * @return the id of the standard accelerator, or AccelNone if there
- * is none
- */
- KCONFIGGUI_EXPORT StandardShortcut find(const char *keyName);
-
- /**
- * Returns the hardcoded default shortcut for @p id.
- * This does not take into account the user's configuration.
- * @param id the id of the accelerator
- * @return the default shortcut of the accelerator
- */
- KCONFIGGUI_EXPORT QList<QKeySequence> hardcodedDefaultShortcut(StandardShortcut id);
-
- /**
- * Saves the new shortcut \a cut for standard accel \a id.
- */
- KCONFIGGUI_EXPORT void saveShortcut(StandardShortcut id, const QList<QKeySequence> &newShortcut);
-
- /**
- * Open file. Default: Ctrl-o
- * @return the shortcut of the standard accelerator
- */
- KCONFIGGUI_EXPORT const QList<QKeySequence> &open();
-
- /**
- * Create a new document (or whatever). Default: Ctrl-n
- * @return the shortcut of the standard accelerator
- */
- KCONFIGGUI_EXPORT const QList<QKeySequence> &openNew();
-
- /**
- * Close current document. Default: Ctrl-w
- * @return the shortcut of the standard accelerator
- */
- KCONFIGGUI_EXPORT const QList<QKeySequence> &close();
-
- /**
- * Save current document. Default: Ctrl-s
- * @return the shortcut of the standard accelerator
- */
- KCONFIGGUI_EXPORT const QList<QKeySequence> &save();
-
- /**
- * Print current document. Default: Ctrl-p
- * @return the shortcut of the standard accelerator
- */
- KCONFIGGUI_EXPORT const QList<QKeySequence> &print();
-
- /**
- * Quit the program. Default: Ctrl-q
- * @return the shortcut of the standard accelerator
- */
- KCONFIGGUI_EXPORT const QList<QKeySequence> &quit();
-
- /**
- * Undo last operation. Default: Ctrl-z
- * @return the shortcut of the standard accelerator
- */
- KCONFIGGUI_EXPORT const QList<QKeySequence> &undo();
-
- /**
- * Redo. Default: Shift-Ctrl-z
- * @return the shortcut of the standard accelerator
- */
- KCONFIGGUI_EXPORT const QList<QKeySequence> &redo();
-
- /**
- * Cut selected area and store it in the clipboard. Default: Ctrl-x
- * @return the shortcut of the standard accelerator
- */
- KCONFIGGUI_EXPORT const QList<QKeySequence> &cut();
-
- /**
- * Copy selected area into the clipboard. Default: Ctrl-c
- * @return the shortcut of the standard accelerator
- */
- KCONFIGGUI_EXPORT const QList<QKeySequence> &copy();
-
- /**
- * Paste contents of clipboard at mouse/cursor position. Default: Ctrl-v
- * @return the shortcut of the standard accelerator
- */
- KCONFIGGUI_EXPORT const QList<QKeySequence> &paste();
-
- /**
- * Paste the selection at mouse/cursor position. Default: Ctrl-Shift-Insert
- * @return the shortcut of the standard accelerator
- */
- KCONFIGGUI_EXPORT const QList<QKeySequence> &pasteSelection();
-
- /**
- * Select all. Default: Ctrl-A
- * @return the shortcut of the standard accelerator
- **/
- KCONFIGGUI_EXPORT const QList<QKeySequence> &selectAll();
-
- /**
- * Delete a word back from mouse/cursor position. Default: Ctrl-Backspace
- * @return the shortcut of the standard accelerator
- */
- KCONFIGGUI_EXPORT const QList<QKeySequence> &deleteWordBack();
-
- /**
- * Delete a word forward from mouse/cursor position. Default: Ctrl-Delete
- * @return the shortcut of the standard accelerator
- */
- KCONFIGGUI_EXPORT const QList<QKeySequence> &deleteWordForward();
-
- /**
- * Find, search. Default: Ctrl-f
- * @return the shortcut of the standard accelerator
- */
- KCONFIGGUI_EXPORT const QList<QKeySequence> &find();
-
- /**
- * Find/search next. Default: F3
- * @return the shortcut of the standard accelerator
- */
- KCONFIGGUI_EXPORT const QList<QKeySequence> &findNext();
-
- /**
- * Find/search previous. Default: Shift-F3
- * @return the shortcut of the standard accelerator
- */
- KCONFIGGUI_EXPORT const QList<QKeySequence> &findPrev();
-
- /**
- * Find and replace matches. Default: Ctrl-r
- * @return the shortcut of the standard accelerator
- */
- KCONFIGGUI_EXPORT const QList<QKeySequence> &replace();
-
- /**
- * Zoom in. Default: Ctrl-Plus
- * @return the shortcut of the standard accelerator
- */
- KCONFIGGUI_EXPORT const QList<QKeySequence> &zoomIn();
-
- /**
- * Zoom out. Default: Ctrl-Minus
- * @return the shortcut of the standard accelerator
- */
- KCONFIGGUI_EXPORT const QList<QKeySequence> &zoomOut();
-
- /**
- * Toggle insert/overwrite (with visual feedback, e.g. in the statusbar). Default: Insert
- * @return the shortcut of the standard accelerator
- */
- KCONFIGGUI_EXPORT const QList<QKeySequence> &insert();
-
- /**
- * Goto home page. Default: Alt-Home
- * @return the shortcut of the standard accelerator
- */
- KCONFIGGUI_EXPORT const QList<QKeySequence> &home();
-
- /**
- * Goto beginning of the document. Default: Ctrl-Home
- * @return the shortcut of the standard accelerator
- */
- KCONFIGGUI_EXPORT const QList<QKeySequence> &begin();
-
- /**
- * Goto end of the document. Default: Ctrl-End
- * @return the shortcut of the standard accelerator
- */
- KCONFIGGUI_EXPORT const QList<QKeySequence> &end();
-
- /**
- * Goto beginning of current line. Default: Home
- * @return the shortcut of the standard accelerator
- */
- KCONFIGGUI_EXPORT const QList<QKeySequence> &beginningOfLine();
-
- /**
- * Goto end of current line. Default: End
- * @return the shortcut of the standard accelerator
- */
- KCONFIGGUI_EXPORT const QList<QKeySequence> &endOfLine();
-
- /**
- * Scroll up one page. Default: Prior
- * @return the shortcut of the standard accelerator
- */
- KCONFIGGUI_EXPORT const QList<QKeySequence> &prior();
-
- /**
- * Scroll down one page. Default: Next
- * @return the shortcut of the standard accelerator
- */
- KCONFIGGUI_EXPORT const QList<QKeySequence> &next();
-
- /**
- * Go to line. Default: Ctrl+G
- * @return the shortcut of the standard accelerator
- */
- KCONFIGGUI_EXPORT const QList<QKeySequence> &gotoLine();
-
- /**
- * Add current page to bookmarks. Default: Ctrl+B
- * @return the shortcut of the standard accelerator
- */
- KCONFIGGUI_EXPORT const QList<QKeySequence> &addBookmark();
-
- /**
- * Next Tab. Default: Ctrl-<
- * @return the shortcut of the standard accelerator
- */
- KCONFIGGUI_EXPORT const QList<QKeySequence> &tabNext();
-
- /**
- * Previous Tab. Default: Ctrl->
- * @return the shortcut of the standard accelerator
- */
- KCONFIGGUI_EXPORT const QList<QKeySequence> &tabPrev();
-
- /**
- * Full Screen Mode. Default: Ctrl+Shift+F
- * @return the shortcut of the standard accelerator
- */
- KCONFIGGUI_EXPORT const QList<QKeySequence> &fullScreen();
-
- /**
- * Help the user in the current situation. Default: F1
- * @return the shortcut of the standard accelerator
- */
- KCONFIGGUI_EXPORT const QList<QKeySequence> &help();
-
- /**
- * Complete text in input widgets. Default Ctrl+E
- * @return the shortcut of the standard accelerator
- **/
- KCONFIGGUI_EXPORT const QList<QKeySequence> &completion();
-
- /**
- * Iterate through a list when completion returns
- * multiple items. Default: Ctrl+Up
- * @return the shortcut of the standard accelerator
- */
- KCONFIGGUI_EXPORT const QList<QKeySequence> &prevCompletion();
-
- /**
- * Iterate through a list when completion returns
- * multiple items. Default: Ctrl+Down
- * @return the shortcut of the standard accelerator
- */
- KCONFIGGUI_EXPORT const QList<QKeySequence> &nextCompletion();
-
- /**
- * Find a string within another string or list of strings.
- * Default: Ctrl-T
- * @return the shortcut of the standard accelerator
- */
- KCONFIGGUI_EXPORT const QList<QKeySequence> &substringCompletion();
-
- /**
- * Help users iterate through a list of entries. Default: Up
- * @return the shortcut of the standard accelerator
- */
- KCONFIGGUI_EXPORT const QList<QKeySequence> &rotateUp();
-
- /**
- * Help users iterate through a list of entries. Default: Down
- * @return the shortcut of the standard accelerator
- */
- KCONFIGGUI_EXPORT const QList<QKeySequence> &rotateDown();
-
- /**
- * What's This button. Default: Shift+F1
- * @return the shortcut of the standard accelerator
- */
- KCONFIGGUI_EXPORT const QList<QKeySequence> &whatsThis();
-
- /**
- * Reload. Default: F5
- * @return the shortcut of the standard accelerator
- */
- KCONFIGGUI_EXPORT const QList<QKeySequence> &reload();
-
- /**
- * Up. Default: Alt+Up
- * @return the shortcut of the standard accelerator
- */
- KCONFIGGUI_EXPORT const QList<QKeySequence> &up();
-
- /**
- * Back. Default: Alt+Left
- * @return the shortcut of the standard accelerator
- */
- KCONFIGGUI_EXPORT const QList<QKeySequence> &back();
-
- /**
- * Forward. Default: ALT+Right
- * @return the shortcut of the standard accelerator
- */
- KCONFIGGUI_EXPORT const QList<QKeySequence> &forward();
-
- /**
- * BackwardWord. Default: Ctrl+Left
- * @return the shortcut of the standard accelerator
- */
- KCONFIGGUI_EXPORT const QList<QKeySequence> &backwardWord();
-
- /**
- * ForwardWord. Default: Ctrl+Right
- * @return the shortcut of the standard accelerator
- */
- KCONFIGGUI_EXPORT const QList<QKeySequence> &forwardWord();
-
- /**
- * Show Menu Bar. Default: Ctrl-M
- * @return the shortcut of the standard accelerator
- */
- KCONFIGGUI_EXPORT const QList<QKeySequence> &showMenubar();
+};
+
+/**
+ * Returns the keybinding for @p accel.
+ * On X11, if QApplication was initialized with GUI disabled, the
+ * default keybinding will always be returned.
+ * @param id the id of the accelerator
+ */
+KCONFIGGUI_EXPORT const QList<QKeySequence> &shortcut(StandardShortcut id);
+
+/**
+ * Returns a unique name for the given accel.
+ * @param id the id of the accelerator
+ * @return the unique name of the accelerator
+ */
+KCONFIGGUI_EXPORT QString name(StandardShortcut id);
+
+/**
+ * Returns a localized label for user-visible display.
+ * @param id the id of the accelerator
+ * @return a localized label for the accelerator
+ */
+KCONFIGGUI_EXPORT QString label(StandardShortcut id);
+
+/**
+ * Returns an extended WhatsThis description for the given accelerator.
+ * @param id the id of the accelerator
+ * @return a localized description of the accelerator
+ */
+KCONFIGGUI_EXPORT QString whatsThis(StandardShortcut id);
+
+/**
+ * Return the StandardShortcut id of the standard accel action which
+ * uses this key sequence, or AccelNone if none of them do.
+ * This is used by class KKeyChooser.
+ * @param keySeq the key sequence to search
+ * @return the id of the standard accelerator, or AccelNone if there
+ * is none
+ */
+KCONFIGGUI_EXPORT StandardShortcut find(const QKeySequence &keySeq);
+
+/**
+ * Return the StandardShortcut id of the standard accel action which
+ * has \a keyName as its name, or AccelNone if none of them do.
+ * This is used by class KKeyChooser.
+ * @param keyName the key sequence to search
+ * @return the id of the standard accelerator, or AccelNone if there
+ * is none
+ */
+KCONFIGGUI_EXPORT StandardShortcut find(const char *keyName);
+
+/**
+ * Returns the hardcoded default shortcut for @p id.
+ * This does not take into account the user's configuration.
+ * @param id the id of the accelerator
+ * @return the default shortcut of the accelerator
+ */
+KCONFIGGUI_EXPORT QList<QKeySequence> hardcodedDefaultShortcut(StandardShortcut id);
+
+/**
+ * Saves the new shortcut \a cut for standard accel \a id.
+ */
+KCONFIGGUI_EXPORT void saveShortcut(StandardShortcut id, const QList<QKeySequence> &newShortcut);
+
+/**
+ * Open file. Default: Ctrl-o
+ * @return the shortcut of the standard accelerator
+ */
+KCONFIGGUI_EXPORT const QList<QKeySequence> &open();
+
+/**
+ * Create a new document (or whatever). Default: Ctrl-n
+ * @return the shortcut of the standard accelerator
+ */
+KCONFIGGUI_EXPORT const QList<QKeySequence> &openNew();
+
+/**
+ * Close current document. Default: Ctrl-w
+ * @return the shortcut of the standard accelerator
+ */
+KCONFIGGUI_EXPORT const QList<QKeySequence> &close();
+
+/**
+ * Save current document. Default: Ctrl-s
+ * @return the shortcut of the standard accelerator
+ */
+KCONFIGGUI_EXPORT const QList<QKeySequence> &save();
+
+/**
+ * Print current document. Default: Ctrl-p
+ * @return the shortcut of the standard accelerator
+ */
+KCONFIGGUI_EXPORT const QList<QKeySequence> &print();
+
+/**
+ * Quit the program. Default: Ctrl-q
+ * @return the shortcut of the standard accelerator
+ */
+KCONFIGGUI_EXPORT const QList<QKeySequence> &quit();
+
+/**
+ * Undo last operation. Default: Ctrl-z
+ * @return the shortcut of the standard accelerator
+ */
+KCONFIGGUI_EXPORT const QList<QKeySequence> &undo();
+
+/**
+ * Redo. Default: Shift-Ctrl-z
+ * @return the shortcut of the standard accelerator
+ */
+KCONFIGGUI_EXPORT const QList<QKeySequence> &redo();
+
+/**
+ * Cut selected area and store it in the clipboard. Default: Ctrl-x
+ * @return the shortcut of the standard accelerator
+ */
+KCONFIGGUI_EXPORT const QList<QKeySequence> &cut();
+
+/**
+ * Copy selected area into the clipboard. Default: Ctrl-c
+ * @return the shortcut of the standard accelerator
+ */
+KCONFIGGUI_EXPORT const QList<QKeySequence> &copy();
+
+/**
+ * Paste contents of clipboard at mouse/cursor position. Default: Ctrl-v
+ * @return the shortcut of the standard accelerator
+ */
+KCONFIGGUI_EXPORT const QList<QKeySequence> &paste();
+
+/**
+ * Paste the selection at mouse/cursor position. Default: Ctrl-Shift-Insert
+ * @return the shortcut of the standard accelerator
+ */
+KCONFIGGUI_EXPORT const QList<QKeySequence> &pasteSelection();
+
+/**
+ * Select all. Default: Ctrl-A
+ * @return the shortcut of the standard accelerator
+ **/
+KCONFIGGUI_EXPORT const QList<QKeySequence> &selectAll();
+
+/**
+ * Delete a word back from mouse/cursor position. Default: Ctrl-Backspace
+ * @return the shortcut of the standard accelerator
+ */
+KCONFIGGUI_EXPORT const QList<QKeySequence> &deleteWordBack();
+
+/**
+ * Delete a word forward from mouse/cursor position. Default: Ctrl-Delete
+ * @return the shortcut of the standard accelerator
+ */
+KCONFIGGUI_EXPORT const QList<QKeySequence> &deleteWordForward();
+
+/**
+ * Find, search. Default: Ctrl-f
+ * @return the shortcut of the standard accelerator
+ */
+KCONFIGGUI_EXPORT const QList<QKeySequence> &find();
+
+/**
+ * Find/search next. Default: F3
+ * @return the shortcut of the standard accelerator
+ */
+KCONFIGGUI_EXPORT const QList<QKeySequence> &findNext();
+
+/**
+ * Find/search previous. Default: Shift-F3
+ * @return the shortcut of the standard accelerator
+ */
+KCONFIGGUI_EXPORT const QList<QKeySequence> &findPrev();
+
+/**
+ * Find and replace matches. Default: Ctrl-r
+ * @return the shortcut of the standard accelerator
+ */
+KCONFIGGUI_EXPORT const QList<QKeySequence> &replace();
+
+/**
+ * Zoom in. Default: Ctrl-Plus
+ * @return the shortcut of the standard accelerator
+ */
+KCONFIGGUI_EXPORT const QList<QKeySequence> &zoomIn();
+
+/**
+ * Zoom out. Default: Ctrl-Minus
+ * @return the shortcut of the standard accelerator
+ */
+KCONFIGGUI_EXPORT const QList<QKeySequence> &zoomOut();
+
+/**
+ * Toggle insert/overwrite (with visual feedback, e.g. in the statusbar). Default: Insert
+ * @return the shortcut of the standard accelerator
+ */
+KCONFIGGUI_EXPORT const QList<QKeySequence> &insert();
+
+/**
+ * Goto home page. Default: Alt-Home
+ * @return the shortcut of the standard accelerator
+ */
+KCONFIGGUI_EXPORT const QList<QKeySequence> &home();
+
+/**
+ * Goto beginning of the document. Default: Ctrl-Home
+ * @return the shortcut of the standard accelerator
+ */
+KCONFIGGUI_EXPORT const QList<QKeySequence> &begin();
+
+/**
+ * Goto end of the document. Default: Ctrl-End
+ * @return the shortcut of the standard accelerator
+ */
+KCONFIGGUI_EXPORT const QList<QKeySequence> &end();
+
+/**
+ * Goto beginning of current line. Default: Home
+ * @return the shortcut of the standard accelerator
+ */
+KCONFIGGUI_EXPORT const QList<QKeySequence> &beginningOfLine();
+
+/**
+ * Goto end of current line. Default: End
+ * @return the shortcut of the standard accelerator
+ */
+KCONFIGGUI_EXPORT const QList<QKeySequence> &endOfLine();
+
+/**
+ * Scroll up one page. Default: Prior
+ * @return the shortcut of the standard accelerator
+ */
+KCONFIGGUI_EXPORT const QList<QKeySequence> &prior();
+
+/**
+ * Scroll down one page. Default: Next
+ * @return the shortcut of the standard accelerator
+ */
+KCONFIGGUI_EXPORT const QList<QKeySequence> &next();
+
+/**
+ * Go to line. Default: Ctrl+G
+ * @return the shortcut of the standard accelerator
+ */
+KCONFIGGUI_EXPORT const QList<QKeySequence> &gotoLine();
+
+/**
+ * Add current page to bookmarks. Default: Ctrl+B
+ * @return the shortcut of the standard accelerator
+ */
+KCONFIGGUI_EXPORT const QList<QKeySequence> &addBookmark();
+
+/**
+ * Next Tab. Default: Ctrl-<
+ * @return the shortcut of the standard accelerator
+ */
+KCONFIGGUI_EXPORT const QList<QKeySequence> &tabNext();
+
+/**
+ * Previous Tab. Default: Ctrl->
+ * @return the shortcut of the standard accelerator
+ */
+KCONFIGGUI_EXPORT const QList<QKeySequence> &tabPrev();
+
+/**
+ * Full Screen Mode. Default: Ctrl+Shift+F
+ * @return the shortcut of the standard accelerator
+ */
+KCONFIGGUI_EXPORT const QList<QKeySequence> &fullScreen();
+
+/**
+ * Help the user in the current situation. Default: F1
+ * @return the shortcut of the standard accelerator
+ */
+KCONFIGGUI_EXPORT const QList<QKeySequence> &help();
+
+/**
+ * Complete text in input widgets. Default Ctrl+E
+ * @return the shortcut of the standard accelerator
+ **/
+KCONFIGGUI_EXPORT const QList<QKeySequence> &completion();
+
+/**
+ * Iterate through a list when completion returns
+ * multiple items. Default: Ctrl+Up
+ * @return the shortcut of the standard accelerator
+ */
+KCONFIGGUI_EXPORT const QList<QKeySequence> &prevCompletion();
+
+/**
+ * Iterate through a list when completion returns
+ * multiple items. Default: Ctrl+Down
+ * @return the shortcut of the standard accelerator
+ */
+KCONFIGGUI_EXPORT const QList<QKeySequence> &nextCompletion();
+
+/**
+ * Find a string within another string or list of strings.
+ * Default: Ctrl-T
+ * @return the shortcut of the standard accelerator
+ */
+KCONFIGGUI_EXPORT const QList<QKeySequence> &substringCompletion();
+
+/**
+ * Help users iterate through a list of entries. Default: Up
+ * @return the shortcut of the standard accelerator
+ */
+KCONFIGGUI_EXPORT const QList<QKeySequence> &rotateUp();
+
+/**
+ * Help users iterate through a list of entries. Default: Down
+ * @return the shortcut of the standard accelerator
+ */
+KCONFIGGUI_EXPORT const QList<QKeySequence> &rotateDown();
+
+/**
+ * What's This button. Default: Shift+F1
+ * @return the shortcut of the standard accelerator
+ */
+KCONFIGGUI_EXPORT const QList<QKeySequence> &whatsThis();
+
+/**
+ * Reload. Default: F5
+ * @return the shortcut of the standard accelerator
+ */
+KCONFIGGUI_EXPORT const QList<QKeySequence> &reload();
+
+/**
+ * Up. Default: Alt+Up
+ * @return the shortcut of the standard accelerator
+ */
+KCONFIGGUI_EXPORT const QList<QKeySequence> &up();
+
+/**
+ * Back. Default: Alt+Left
+ * @return the shortcut of the standard accelerator
+ */
+KCONFIGGUI_EXPORT const QList<QKeySequence> &back();
+
+/**
+ * Forward. Default: ALT+Right
+ * @return the shortcut of the standard accelerator
+ */
+KCONFIGGUI_EXPORT const QList<QKeySequence> &forward();
+
+/**
+ * BackwardWord. Default: Ctrl+Left
+ * @return the shortcut of the standard accelerator
+ */
+KCONFIGGUI_EXPORT const QList<QKeySequence> &backwardWord();
+
+/**
+ * ForwardWord. Default: Ctrl+Right
+ * @return the shortcut of the standard accelerator
+ */
+KCONFIGGUI_EXPORT const QList<QKeySequence> &forwardWord();
+
+/**
+ * Show Menu Bar. Default: Ctrl-M
+ * @return the shortcut of the standard accelerator
+ */
+KCONFIGGUI_EXPORT const QList<QKeySequence> &showMenubar();
}
diff --git a/src/gui/kwindowconfig.cpp b/src/gui/kwindowconfig.cpp
index 6b7ae5f0..c3cefb74 100644
--- a/src/gui/kwindowconfig.cpp
+++ b/src/gui/kwindowconfig.cpp
@@ -24,13 +24,14 @@
#include <QScreen>
#include <QWindow>
-static const char* s_initialSizePropertyName = "_kconfig_initial_size";
-static const char* s_initialScreenSizePropertyName = "_kconfig_initial_screen_size";
+static const char *s_initialSizePropertyName = "_kconfig_initial_size";
+static const char *s_initialScreenSizePropertyName = "_kconfig_initial_screen_size";
void KWindowConfig::saveWindowSize(const QWindow *window, KConfigGroup &config, KConfigGroup::WriteConfigFlags options)
{
- if (!window)
+ if (!window) {
return;
+ }
const QRect desk = window->screen()->geometry();
const QSize sizeToSave = window->size();
@@ -41,25 +42,27 @@ void KWindowConfig::saveWindowSize(const QWindow *window, KConfigGroup &config,
if (!isMaximized) {
const QSize defaultSize(window->property(s_initialSizePropertyName).toSize());
const QSize defaultScreenSize(window->property(s_initialScreenSizePropertyName).toSize());
- const bool sizeValid = defaultSize.isValid() && defaultScreenSize.isValid();
- if (!sizeValid || (sizeValid && (defaultSize != sizeToSave || defaultScreenSize != desk.size()))) {
- const QString wString(QString::fromLatin1("Width %1").arg(desk.width()));
- const QString hString(QString::fromLatin1("Height %1").arg(desk.height()));
- config.writeEntry(wString, sizeToSave.width(), options);
- config.writeEntry(hString, sizeToSave.height(), options);
+ const bool sizeValid = defaultSize.isValid() && defaultScreenSize.isValid();
+ if (!sizeValid || (sizeValid && (defaultSize != sizeToSave || defaultScreenSize != desk.size()))) {
+ const QString wString(QString::fromLatin1("Width %1").arg(desk.width()));
+ const QString hString(QString::fromLatin1("Height %1").arg(desk.height()));
+ config.writeEntry(wString, sizeToSave.width(), options);
+ config.writeEntry(hString, sizeToSave.height(), options);
}
}
- if ( (isMaximized == false) && !config.hasDefault(screenMaximizedString) )
+ if ((isMaximized == false) && !config.hasDefault(screenMaximizedString)) {
config.revertToDefault(screenMaximizedString);
- else
+ } else {
config.writeEntry(screenMaximizedString, isMaximized, options);
+ }
}
-void KWindowConfig::restoreWindowSize(QWindow* window, const KConfigGroup& config)
+void KWindowConfig::restoreWindowSize(QWindow *window, const KConfigGroup &config)
{
- if (!window)
+ if (!window) {
return;
+ }
const QRect desk = window->screen()->geometry();
diff --git a/src/gui/kwindowconfig.h b/src/gui/kwindowconfig.h
index 2c70571d..e21d3d61 100644
--- a/src/gui/kwindowconfig.h
+++ b/src/gui/kwindowconfig.h
@@ -29,30 +29,30 @@ class QWindow;
namespace KWindowConfig
{
- /**
- * Saves the window's size dependent on the screen dimension either to the
- * global or application config file.
- *
- * @note the group must be set before calling
- *
- * @param window The window to save size.
- * @param config The config group to read from.
- * @param options passed to KConfigGroup::writeEntry()
- * @since 5.0
- */
- KCONFIGGUI_EXPORT void saveWindowSize( const QWindow* window, KConfigGroup& config, KConfigGroup::WriteConfigFlags options = KConfigGroup::Normal );
-
- /**
- * Restores the dialog's size from the configuration according to
- * the screen size.
- *
- * @note the group must be set before calling
- *
- * @param dialog The dialog to restore size.
- * @param config The config group to read from.
- * @since 5.0.
- */
- KCONFIGGUI_EXPORT void restoreWindowSize( QWindow* window, const KConfigGroup& config );
+/**
+ * Saves the window's size dependent on the screen dimension either to the
+ * global or application config file.
+ *
+ * @note the group must be set before calling
+ *
+ * @param window The window to save size.
+ * @param config The config group to read from.
+ * @param options passed to KConfigGroup::writeEntry()
+ * @since 5.0
+ */
+KCONFIGGUI_EXPORT void saveWindowSize(const QWindow *window, KConfigGroup &config, KConfigGroup::WriteConfigFlags options = KConfigGroup::Normal);
+
+/**
+ * Restores the dialog's size from the configuration according to
+ * the screen size.
+ *
+ * @note the group must be set before calling
+ *
+ * @param dialog The dialog to restore size.
+ * @param config The config group to read from.
+ * @since 5.0.
+ */
+KCONFIGGUI_EXPORT void restoreWindowSize(QWindow *window, const KConfigGroup &config);
}
#endif // KWINDOWCONFIG_H
diff --git a/src/kconf_update/kconf_update.cpp b/src/kconf_update/kconf_update.cpp
index 60a61db3..f8ba16d1 100644
--- a/src/kconf_update/kconf_update.cpp
+++ b/src/kconf_update/kconf_update.cpp
@@ -102,8 +102,8 @@ protected:
int m_lineCount;
};
-KonfUpdate::KonfUpdate(QCommandLineParser * parser)
- : m_textStream(0), m_file(0)
+KonfUpdate::KonfUpdate(QCommandLineParser *parser)
+ : m_textStream(0), m_file(0)
{
bool updateAll = false;
m_oldConfig1 = 0;
@@ -130,8 +130,9 @@ KonfUpdate::KonfUpdate(QCommandLineParser * parser)
} else if (parser->positionalArguments().count()) {
updateFiles += parser->positionalArguments();
} else {
- if (cg.readEntry("autoUpdateDisabled", false))
+ if (cg.readEntry("autoUpdateDisabled", false)) {
return;
+ }
updateFiles = findUpdateFiles(true);
updateAll = true;
}
@@ -162,7 +163,7 @@ KonfUpdate::~KonfUpdate()
delete m_textStream;
}
-QTextStream & operator<<(QTextStream & stream, const QStringList & lst)
+QTextStream &operator<<(QTextStream &stream, const QStringList &lst)
{
stream << lst.join(", ");
return stream;
@@ -200,9 +201,9 @@ QStringList KonfUpdate::findUpdateFiles(bool dirtyOnly)
QStringList result;
const QStringList dirs = QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, "kconf_update", QStandardPaths::LocateDirectory);
- Q_FOREACH(const QString& dir, dirs) {
+ Q_FOREACH (const QString &dir, dirs) {
const QStringList fileNames = QDir(dir).entryList(QStringList() << QStringLiteral("*.upd"));
- Q_FOREACH(const QString& fileName, fileNames) {
+ Q_FOREACH (const QString &fileName, fileNames) {
const QString file = dir + '/' + fileName;
QFileInfo info(file);
@@ -365,8 +366,6 @@ bool KonfUpdate::updateFile(const QString &filename)
return true;
}
-
-
void KonfUpdate::gotId(const QString &_id)
{
if (!m_id.isEmpty() && !m_skip) {
@@ -551,7 +550,6 @@ void KonfUpdate::gotRemoveGroup(const QString &_group)
log() << m_currentFilename << ": RemoveGroup removes group " << m_oldFile << ":" << m_oldGroup << endl;
}
-
void KonfUpdate::gotKey(const QString &_key)
{
QString oldKey, newKey;
@@ -584,8 +582,9 @@ void KonfUpdate::copyOrMoveKey(const QStringList &srcGroupPath, const QString &s
}
KConfigGroup srcCg = KConfigUtils::openGroup(m_oldConfig1, srcGroupPath);
- if (!srcCg.hasKey(srcKey))
+ if (!srcCg.hasKey(srcKey)) {
return;
+ }
QString value = srcCg.readEntry(srcKey, QString());
log() << m_currentFilename << ": Updating " << m_newFileName << ":" << dstCg.name() << ":" << dstKey << " to '" << value << "'" << endl;
dstCg.writeEntry(dstKey, value);
@@ -596,8 +595,8 @@ void KonfUpdate::copyOrMoveKey(const QStringList &srcGroupPath, const QString &s
// Delete old entry
if (m_oldConfig2 == m_newConfig
- && srcGroupPath == dstGroupPath
- && srcKey == dstKey) {
+ && srcGroupPath == dstGroupPath
+ && srcKey == dstKey) {
return; // Don't delete!
}
KConfigGroup srcCg2 = KConfigUtils::openGroup(m_oldConfig2, srcGroupPath);
@@ -610,12 +609,12 @@ void KonfUpdate::copyOrMoveGroup(const QStringList &srcGroupPath, const QStringL
KConfigGroup cg = KConfigUtils::openGroup(m_oldConfig1, srcGroupPath);
// Keys
- Q_FOREACH(const QString &key, cg.keyList()) {
+ Q_FOREACH (const QString &key, cg.keyList()) {
copyOrMoveKey(srcGroupPath, key, dstGroupPath, key);
}
// Subgroups
- Q_FOREACH(const QString &group, cg.groupList()) {
+ Q_FOREACH (const QString &group, cg.groupList()) {
QStringList groupPath = QStringList() << group;
copyOrMoveGroup(srcGroupPath + groupPath, dstGroupPath + groupPath);
}
@@ -711,7 +710,7 @@ void KonfUpdate::copyGroup(const KConfigGroup &cg1, KConfigGroup &cg2)
}
// Copy subgroups
- Q_FOREACH(const QString &group, cg1.groupList()) {
+ Q_FOREACH (const QString &group, cg1.groupList()) {
copyGroup(&cg1, group, &cg2, group);
}
}
@@ -732,23 +731,21 @@ void KonfUpdate::gotScript(const QString &_script)
interpreter = _script.mid(i + 1).trimmed();
}
-
if (script.isEmpty()) {
logFileError() << "Script fails to specify filename";
m_skip = true;
return;
}
-
-
QString path = QStandardPaths::locate(QStandardPaths::GenericDataLocation, "kconf_update/" + script);
if (path.isEmpty()) {
if (interpreter.isEmpty()) {
// KDE4: this was looking into locate("lib", "kconf_update_bin/"). But QStandardPaths doesn't know the lib dirs.
// Let's look in the install prefix and in PATH.
path = CMAKE_INSTALL_PREFIX "/" LIB_INSTALL_DIR "/kconf_update_bin/" + script;
- if (QFile::exists(path))
+ if (QFile::exists(path)) {
path = QStandardPaths::findExecutable(script);
+ }
}
if (path.isEmpty()) {
@@ -808,23 +805,20 @@ void KonfUpdate::gotScript(const QString &_script)
#ifndef _WIN32_WCE
result = system(QFile::encodeName(QString("%1 < %2 > %3 2> %4").arg(cmd, scriptIn.fileName(), scriptOut.fileName(), scriptErr.fileName())).constData());
#else
- QString path_ = QDir::convertSeparators ( QFileInfo ( cmd ).absoluteFilePath() );
- QString file_ = QFileInfo ( cmd ).fileName();
+ QString path_ = QDir::convertSeparators(QFileInfo(cmd).absoluteFilePath());
+ QString file_ = QFileInfo(cmd).fileName();
SHELLEXECUTEINFO execInfo;
- memset ( &execInfo,0,sizeof ( execInfo ) );
- execInfo.cbSize = sizeof ( execInfo );
+ memset(&execInfo, 0, sizeof(execInfo));
+ execInfo.cbSize = sizeof(execInfo);
execInfo.fMask = SEE_MASK_FLAG_NO_UI;
execInfo.lpVerb = L"open";
execInfo.lpFile = (LPCWSTR) path_.utf16();
execInfo.lpDirectory = (LPCWSTR) file_.utf16();
- execInfo.lpParameters = (LPCWSTR) QString(" < %1 > %2 2> %3").arg( scriptIn.fileName(), scriptOut.fileName(), scriptErr.fileName()).utf16();
- result = ShellExecuteEx ( &execInfo );
- if (result != 0)
- {
+ execInfo.lpParameters = (LPCWSTR) QString(" < %1 > %2 2> %3").arg(scriptIn.fileName(), scriptOut.fileName(), scriptErr.fileName()).utf16();
+ result = ShellExecuteEx(&execInfo);
+ if (result != 0) {
result = 0;
- }
- else
- {
+ } else {
result = -1;
}
#endif
@@ -833,23 +827,20 @@ void KonfUpdate::gotScript(const QString &_script)
#ifndef _WIN32_WCE
result = system(QFile::encodeName(QString("%1 2> %2").arg(cmd, scriptErr.fileName())).constData());
#else
- QString path_ = QDir::convertSeparators ( QFileInfo ( cmd ).absoluteFilePath() );
- QString file_ = QFileInfo ( cmd ).fileName();
+ QString path_ = QDir::convertSeparators(QFileInfo(cmd).absoluteFilePath());
+ QString file_ = QFileInfo(cmd).fileName();
SHELLEXECUTEINFO execInfo;
- memset ( &execInfo,0,sizeof ( execInfo ) );
- execInfo.cbSize = sizeof ( execInfo );
+ memset(&execInfo, 0, sizeof(execInfo));
+ execInfo.cbSize = sizeof(execInfo);
execInfo.fMask = SEE_MASK_FLAG_NO_UI;
execInfo.lpVerb = L"open";
execInfo.lpFile = (LPCWSTR) path_.utf16();
execInfo.lpDirectory = (LPCWSTR) file_.utf16();
- execInfo.lpParameters = (LPCWSTR) QString(" 2> %1").arg( scriptErr.fileName()).utf16();
- result = ShellExecuteEx ( &execInfo );
- if (result != 0)
- {
+ execInfo.lpParameters = (LPCWSTR) QString(" 2> %1").arg(scriptErr.fileName()).utf16();
+ result = ShellExecuteEx(&execInfo);
+ if (result != 0) {
result = 0;
- }
- else
- {
+ } else {
result = -1;
}
#endif
@@ -932,7 +923,7 @@ void KonfUpdate::gotScript(const QString &_script)
KConfigGroup dstCg = KConfigUtils::openGroup(m_newConfig, m_newGroup);
copyGroup(srcCg, dstCg);
}
- Q_FOREACH(const QString &group, scriptOutConfig.groupList()) {
+ Q_FOREACH (const QString &group, scriptOutConfig.groupList()) {
copyGroup(&scriptOutConfig, group, m_newConfig, group);
}
}
@@ -944,7 +935,6 @@ void KonfUpdate::resetOptions()
m_arguments.clear();
}
-
int main(int argc, char **argv)
{
QCoreApplication app(argc, argv);
diff --git a/src/kconfig_compiler/kconfig_compiler.cpp b/src/kconfig_compiler/kconfig_compiler.cpp
index ae192eec..bdbd03c3 100644
--- a/src/kconfig_compiler/kconfig_compiler.cpp
+++ b/src/kconfig_compiler/kconfig_compiler.cpp
@@ -1,4 +1,3 @@
-// -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
/*
This file is part of KDE.
@@ -42,8 +41,8 @@
namespace
{
- QTextStream cout(stdout);
- QTextStream cerr(stderr);
+QTextStream cout(stdout);
+QTextStream cerr(stderr);
}
static void parseArgs(const QStringList &args, QString &directory, QString &file1, QString &file2)
@@ -109,236 +108,379 @@ QString Const;
class CfgConfig
{
public:
- CfgConfig( const QString &codegenFilename )
- {
- // Configure the compiler with some settings
- QSettings codegenConfig(codegenFilename, QSettings::IniFormat);
-
- nameSpace = codegenConfig.value("NameSpace").toString();
- className = codegenConfig.value("ClassName").toString();
- if ( className.isEmpty() ) {
- cerr << "Class name missing" << endl;
- exit(1);
- }
- inherits = codegenConfig.value("Inherits").toString();
- if ( inherits.isEmpty() ) inherits = "KConfigSkeleton";
- visibility = codegenConfig.value("Visibility").toString();
- if ( !visibility.isEmpty() ) visibility += ' ';
- forceStringFilename = codegenConfig.value("ForceStringFilename", false).toBool();
- singleton = codegenConfig.value("Singleton", false).toBool();
- staticAccessors = singleton;
- customAddons = codegenConfig.value("CustomAdditions", false).toBool();
- memberVariables = codegenConfig.value("MemberVariables").toString();
- dpointer = (memberVariables == "dpointer");
- headerIncludes = codegenConfig.value("IncludeFiles", QStringList()).toStringList();
- sourceIncludes = codegenConfig.value("SourceIncludeFiles", QStringList()).toStringList();
- mutators = codegenConfig.value("Mutators", QStringList()).toStringList();
- allMutators = ((mutators.count() == 1) && (mutators.at(0).toLower() == "true"));
- itemAccessors = codegenConfig.value("ItemAccessors", false).toBool();
- setUserTexts = codegenConfig.value("SetUserTexts", false).toBool();
- defaultGetters = codegenConfig.value("DefaultValueGetters", QStringList()).toStringList();
- allDefaultGetters = (defaultGetters.count() == 1) && (defaultGetters.at(0).toLower() == "true");
- globalEnums = codegenConfig.value("GlobalEnums", false).toBool();
- useEnumTypes = codegenConfig.value("UseEnumTypes", false).toBool();
-
- const QString trString = codegenConfig.value("TranslationSystem").toString().toLower();
- if ( trString == "kde" ) {
- translationSystem = KdeTranslation;
- } else {
- if ( !trString.isEmpty() && trString != "qt" ) {
- cerr << "Unknown translation system, falling back to Qt tr()" << endl;
+ CfgConfig(const QString &codegenFilename)
+ {
+ // Configure the compiler with some settings
+ QSettings codegenConfig(codegenFilename, QSettings::IniFormat);
+
+ nameSpace = codegenConfig.value("NameSpace").toString();
+ className = codegenConfig.value("ClassName").toString();
+ if (className.isEmpty()) {
+ cerr << "Class name missing" << endl;
+ exit(1);
+ }
+ inherits = codegenConfig.value("Inherits").toString();
+ if (inherits.isEmpty()) {
+ inherits = "KConfigSkeleton";
+ }
+ visibility = codegenConfig.value("Visibility").toString();
+ if (!visibility.isEmpty()) {
+ visibility += ' ';
+ }
+ forceStringFilename = codegenConfig.value("ForceStringFilename", false).toBool();
+ singleton = codegenConfig.value("Singleton", false).toBool();
+ staticAccessors = singleton;
+ customAddons = codegenConfig.value("CustomAdditions", false).toBool();
+ memberVariables = codegenConfig.value("MemberVariables").toString();
+ dpointer = (memberVariables == "dpointer");
+ headerIncludes = codegenConfig.value("IncludeFiles", QStringList()).toStringList();
+ sourceIncludes = codegenConfig.value("SourceIncludeFiles", QStringList()).toStringList();
+ mutators = codegenConfig.value("Mutators", QStringList()).toStringList();
+ allMutators = ((mutators.count() == 1) && (mutators.at(0).toLower() == "true"));
+ itemAccessors = codegenConfig.value("ItemAccessors", false).toBool();
+ setUserTexts = codegenConfig.value("SetUserTexts", false).toBool();
+ defaultGetters = codegenConfig.value("DefaultValueGetters", QStringList()).toStringList();
+ allDefaultGetters = (defaultGetters.count() == 1) && (defaultGetters.at(0).toLower() == "true");
+ globalEnums = codegenConfig.value("GlobalEnums", false).toBool();
+ useEnumTypes = codegenConfig.value("UseEnumTypes", false).toBool();
+
+ const QString trString = codegenConfig.value("TranslationSystem").toString().toLower();
+ if (trString == "kde") {
+ translationSystem = KdeTranslation;
+ } else {
+ if (!trString.isEmpty() && trString != "qt") {
+ cerr << "Unknown translation system, falling back to Qt tr()" << endl;
+ }
+ translationSystem = QtTranslation;
}
- translationSystem = QtTranslation;
}
- }
public:
- enum TranslationSystem {
- QtTranslation,
- KdeTranslation
- };
-
- // These are read from the .kcfgc configuration file
- QString nameSpace; // The namespace for the class to be generated
- QString className; // The class name to be generated
- QString inherits; // The class the generated class inherits (if empty, from KConfigSkeleton)
- QString visibility;
- bool forceStringFilename;
- bool singleton; // The class will be a singleton
- bool staticAccessors; // provide or not static accessors
- bool customAddons;
- QString memberVariables;
- QStringList headerIncludes;
- QStringList sourceIncludes;
- QStringList mutators;
- QStringList defaultGetters;
- bool allMutators;
- bool setUserTexts;
- bool allDefaultGetters;
- bool dpointer;
- bool globalEnums;
- bool useEnumTypes;
- bool itemAccessors;
- TranslationSystem translationSystem;
-};
+ enum TranslationSystem {
+ QtTranslation,
+ KdeTranslation
+ };
+ // These are read from the .kcfgc configuration file
+ QString nameSpace; // The namespace for the class to be generated
+ QString className; // The class name to be generated
+ QString inherits; // The class the generated class inherits (if empty, from KConfigSkeleton)
+ QString visibility;
+ bool forceStringFilename;
+ bool singleton; // The class will be a singleton
+ bool staticAccessors; // provide or not static accessors
+ bool customAddons;
+ QString memberVariables;
+ QStringList headerIncludes;
+ QStringList sourceIncludes;
+ QStringList mutators;
+ QStringList defaultGetters;
+ bool allMutators;
+ bool setUserTexts;
+ bool allDefaultGetters;
+ bool dpointer;
+ bool globalEnums;
+ bool useEnumTypes;
+ bool itemAccessors;
+ TranslationSystem translationSystem;
+};
-struct SignalArguments
-{
- QString type;
- QString variableName;
+struct SignalArguments {
+ QString type;
+ QString variableName;
};
-class Signal {
+class Signal
+{
public:
- QString name;
- QString label;
- QList<SignalArguments> arguments;
+ QString name;
+ QString label;
+ QList<SignalArguments> arguments;
};
-
-
-
class CfgEntry
{
- public:
- struct Choice
- {
- QString name;
- QString context;
- QString label;
- QString toolTip;
- QString whatsThis;
+public:
+ struct Choice {
+ QString name;
+ QString context;
+ QString label;
+ QString toolTip;
+ QString whatsThis;
};
class Choices
{
- public:
+ public:
Choices() {}
- Choices( const QList<Choice> &d, const QString &n, const QString &p )
- : prefix(p), choices(d), mName(n)
+ Choices(const QList<Choice> &d, const QString &n, const QString &p)
+ : prefix(p), choices(d), mName(n)
{
- int i = n.indexOf(QLatin1String("::"));
- if (i >= 0)
- mExternalQual = n.left(i + 2);
+ int i = n.indexOf(QLatin1String("::"));
+ if (i >= 0) {
+ mExternalQual = n.left(i + 2);
+ }
}
QString prefix;
QList<Choice> choices;
- const QString& name() const { return mName; }
- const QString& externalQualifier() const { return mExternalQual; }
- bool external() const { return !mExternalQual.isEmpty(); }
- private:
+ const QString &name() const
+ {
+ return mName;
+ }
+ const QString &externalQualifier() const
+ {
+ return mExternalQual;
+ }
+ bool external() const
+ {
+ return !mExternalQual.isEmpty();
+ }
+ private:
QString mName;
QString mExternalQual;
};
- CfgEntry( const QString &group, const QString &type, const QString &key,
- const QString &name, const QString &labelContext, const QString &label,
- const QString &toolTipContext, const QString &toolTip, const QString &whatsThisContext, const QString &whatsThis, const QString &code,
- const QString &defaultValue, const Choices &choices, const QList<Signal> signalList,
- bool hidden )
- : mGroup( group ), mType( type ), mKey( key ), mName( name ),
- mLabelContext( labelContext ), mLabel( label ), mToolTipContext( toolTipContext ), mToolTip( toolTip ),
- mWhatsThisContext( whatsThisContext ), mWhatsThis( whatsThis ),
- mCode( code ), mDefaultValue( defaultValue ), mChoices( choices ),
- mSignalList(signalList), mHidden( hidden )
+ CfgEntry(const QString &group, const QString &type, const QString &key,
+ const QString &name, const QString &labelContext, const QString &label,
+ const QString &toolTipContext, const QString &toolTip, const QString &whatsThisContext, const QString &whatsThis, const QString &code,
+ const QString &defaultValue, const Choices &choices, const QList<Signal> signalList,
+ bool hidden)
+ : mGroup(group), mType(type), mKey(key), mName(name),
+ mLabelContext(labelContext), mLabel(label), mToolTipContext(toolTipContext), mToolTip(toolTip),
+ mWhatsThisContext(whatsThisContext), mWhatsThis(whatsThis),
+ mCode(code), mDefaultValue(defaultValue), mChoices(choices),
+ mSignalList(signalList), mHidden(hidden)
{
}
- void setGroup( const QString &group ) { mGroup = group; }
- QString group() const { return mGroup; }
+ void setGroup(const QString &group)
+ {
+ mGroup = group;
+ }
+ QString group() const
+ {
+ return mGroup;
+ }
- void setType( const QString &type ) { mType = type; }
- QString type() const { return mType; }
+ void setType(const QString &type)
+ {
+ mType = type;
+ }
+ QString type() const
+ {
+ return mType;
+ }
- void setKey( const QString &key ) { mKey = key; }
- QString key() const { return mKey; }
+ void setKey(const QString &key)
+ {
+ mKey = key;
+ }
+ QString key() const
+ {
+ return mKey;
+ }
- void setName( const QString &name ) { mName = name; }
- QString name() const { return mName; }
+ void setName(const QString &name)
+ {
+ mName = name;
+ }
+ QString name() const
+ {
+ return mName;
+ }
- void setLabelContext( const QString &labelContext ) { mLabelContext = labelContext; }
- QString labelContext() const { return mLabelContext; }
+ void setLabelContext(const QString &labelContext)
+ {
+ mLabelContext = labelContext;
+ }
+ QString labelContext() const
+ {
+ return mLabelContext;
+ }
- void setLabel( const QString &label ) { mLabel = label; }
- QString label() const { return mLabel; }
+ void setLabel(const QString &label)
+ {
+ mLabel = label;
+ }
+ QString label() const
+ {
+ return mLabel;
+ }
- void setToolTipContext( const QString &toolTipContext ) { mToolTipContext = toolTipContext; }
- QString toolTipContext() const { return mToolTipContext; }
+ void setToolTipContext(const QString &toolTipContext)
+ {
+ mToolTipContext = toolTipContext;
+ }
+ QString toolTipContext() const
+ {
+ return mToolTipContext;
+ }
- void setToolTip( const QString &toolTip ) { mToolTip = toolTip; }
- QString toolTip() const { return mToolTip; }
+ void setToolTip(const QString &toolTip)
+ {
+ mToolTip = toolTip;
+ }
+ QString toolTip() const
+ {
+ return mToolTip;
+ }
- void setWhatsThisContext( const QString &whatsThisContext ) { mWhatsThisContext = whatsThisContext; }
- QString whatsThisContext() const { return mWhatsThisContext; }
+ void setWhatsThisContext(const QString &whatsThisContext)
+ {
+ mWhatsThisContext = whatsThisContext;
+ }
+ QString whatsThisContext() const
+ {
+ return mWhatsThisContext;
+ }
- void setWhatsThis( const QString &whatsThis ) { mWhatsThis = whatsThis; }
- QString whatsThis() const { return mWhatsThis; }
+ void setWhatsThis(const QString &whatsThis)
+ {
+ mWhatsThis = whatsThis;
+ }
+ QString whatsThis() const
+ {
+ return mWhatsThis;
+ }
- void setDefaultValue( const QString &d ) { mDefaultValue = d; }
- QString defaultValue() const { return mDefaultValue; }
+ void setDefaultValue(const QString &d)
+ {
+ mDefaultValue = d;
+ }
+ QString defaultValue() const
+ {
+ return mDefaultValue;
+ }
- void setCode( const QString &d ) { mCode = d; }
- QString code() const { return mCode; }
+ void setCode(const QString &d)
+ {
+ mCode = d;
+ }
+ QString code() const
+ {
+ return mCode;
+ }
- void setMinValue( const QString &d ) { mMin = d; }
- QString minValue() const { return mMin; }
+ void setMinValue(const QString &d)
+ {
+ mMin = d;
+ }
+ QString minValue() const
+ {
+ return mMin;
+ }
- void setMaxValue( const QString &d ) { mMax = d; }
- QString maxValue() const { return mMax; }
+ void setMaxValue(const QString &d)
+ {
+ mMax = d;
+ }
+ QString maxValue() const
+ {
+ return mMax;
+ }
- void setParam( const QString &d ) { mParam = d; }
- QString param() const { return mParam; }
+ void setParam(const QString &d)
+ {
+ mParam = d;
+ }
+ QString param() const
+ {
+ return mParam;
+ }
- void setParamName( const QString &d ) { mParamName = d; }
- QString paramName() const { return mParamName; }
+ void setParamName(const QString &d)
+ {
+ mParamName = d;
+ }
+ QString paramName() const
+ {
+ return mParamName;
+ }
- void setParamType( const QString &d ) { mParamType = d; }
- QString paramType() const { return mParamType; }
+ void setParamType(const QString &d)
+ {
+ mParamType = d;
+ }
+ QString paramType() const
+ {
+ return mParamType;
+ }
- void setChoices( const QList<Choice> &d, const QString &n, const QString &p ) { mChoices = Choices( d, n, p ); }
- Choices choices() const { return mChoices; }
+ void setChoices(const QList<Choice> &d, const QString &n, const QString &p)
+ {
+ mChoices = Choices(d, n, p);
+ }
+ Choices choices() const
+ {
+ return mChoices;
+ }
- void setParamValues( const QStringList &d ) { mParamValues = d; }
- QStringList paramValues() const { return mParamValues; }
+ void setParamValues(const QStringList &d)
+ {
+ mParamValues = d;
+ }
+ QStringList paramValues() const
+ {
+ return mParamValues;
+ }
- void setParamDefaultValues( const QStringList &d ) { mParamDefaultValues = d; }
- QString paramDefaultValue(int i) const { return mParamDefaultValues[i]; }
+ void setParamDefaultValues(const QStringList &d)
+ {
+ mParamDefaultValues = d;
+ }
+ QString paramDefaultValue(int i) const
+ {
+ return mParamDefaultValues[i];
+ }
- void setParamMax( int d ) { mParamMax = d; }
- int paramMax() const { return mParamMax; }
+ void setParamMax(int d)
+ {
+ mParamMax = d;
+ }
+ int paramMax() const
+ {
+ return mParamMax;
+ }
- void setSignalList( const QList<Signal> &value ) { mSignalList = value; }
- QList<Signal> signalList() const { return mSignalList; }
+ void setSignalList(const QList<Signal> &value)
+ {
+ mSignalList = value;
+ }
+ QList<Signal> signalList() const
+ {
+ return mSignalList;
+ }
- bool hidden() const { return mHidden; }
+ bool hidden() const
+ {
+ return mHidden;
+ }
void dump() const
{
- cerr << "<entry>" << endl;
- cerr << " group: " << mGroup << endl;
- cerr << " type: " << mType << endl;
- cerr << " key: " << mKey << endl;
- cerr << " name: " << mName << endl;
- cerr << " label context: " << mLabelContext << endl;
- cerr << " label: " << mLabel << endl;
+ cerr << "<entry>" << endl;
+ cerr << " group: " << mGroup << endl;
+ cerr << " type: " << mType << endl;
+ cerr << " key: " << mKey << endl;
+ cerr << " name: " << mName << endl;
+ cerr << " label context: " << mLabelContext << endl;
+ cerr << " label: " << mLabel << endl;
// whatsthis
- cerr << " code: " << mCode << endl;
+ cerr << " code: " << mCode << endl;
// cerr << " values: " << mValues.join(":") << endl;
- if (!param().isEmpty())
- {
- cerr << " param name: "<< mParamName << endl;
- cerr << " param type: "<< mParamType << endl;
- cerr << " paramvalues: " << mParamValues.join(QChar::fromLatin1(':')) << endl;
- }
- cerr << " default: " << mDefaultValue << endl;
- cerr << " hidden: " << mHidden << endl;
- cerr << " min: " << mMin << endl;
- cerr << " max: " << mMax << endl;
- cerr << "</entry>" << endl;
+ if (!param().isEmpty()) {
+ cerr << " param name: " << mParamName << endl;
+ cerr << " param type: " << mParamType << endl;
+ cerr << " paramvalues: " << mParamValues.join(QChar::fromLatin1(':')) << endl;
+ }
+ cerr << " default: " << mDefaultValue << endl;
+ cerr << " hidden: " << mHidden << endl;
+ cerr << " min: " << mMin << endl;
+ cerr << " max: " << mMax << endl;
+ cerr << "</entry>" << endl;
}
- private:
+private:
QString mGroup;
QString mType;
QString mKey;
@@ -364,10 +506,11 @@ class CfgEntry
QString mMax;
};
-class Param {
+class Param
+{
public:
- QString name;
- QString type;
+ QString name;
+ QString type;
};
// returns the name of an member variable
@@ -375,558 +518,562 @@ public:
// like using d-> in case of dpointer
static QString varName(const QString &n, const CfgConfig &cfg)
{
- QString result;
- if ( !cfg.dpointer ) {
- result = QChar::fromLatin1('m') + n;
- result[1] = result[1].toUpper();
- }
- else {
- result = n;
- result[0] = result[0].toLower();
- }
- return result;
+ QString result;
+ if (!cfg.dpointer) {
+ result = QChar::fromLatin1('m') + n;
+ result[1] = result[1].toUpper();
+ } else {
+ result = n;
+ result[0] = result[0].toLower();
+ }
+ return result;
}
static QString varPath(const QString &n, const CfgConfig &cfg)
{
- QString result;
- if ( cfg.dpointer ) {
- result = "d->"+varName(n, cfg);
- }
- else {
- result = varName(n, cfg);
- }
- return result;
+ QString result;
+ if (cfg.dpointer) {
+ result = "d->" + varName(n, cfg);
+ } else {
+ result = varName(n, cfg);
+ }
+ return result;
}
static QString enumName(const QString &n)
{
- QString result = QString::fromLatin1("Enum") + n;
- result[4] = result[4].toUpper();
- return result;
+ QString result = QString::fromLatin1("Enum") + n;
+ result[4] = result[4].toUpper();
+ return result;
}
static QString enumName(const QString &n, const CfgEntry::Choices &c)
{
- QString result = c.name();
- if ( result.isEmpty() )
- {
- result = QString::fromLatin1("Enum") + n;
- result[4] = result[4].toUpper();
- }
- return result;
+ QString result = c.name();
+ if (result.isEmpty()) {
+ result = QString::fromLatin1("Enum") + n;
+ result[4] = result[4].toUpper();
+ }
+ return result;
}
static QString enumType(const CfgEntry *e, bool globalEnums)
{
- QString result = e->choices().name();
- if ( result.isEmpty() )
- {
- result = QString::fromLatin1("Enum") + e->name();
- if( !globalEnums )
- result += QString::fromLatin1("::type");
- result[4] = result[4].toUpper();
- }
- return result;
+ QString result = e->choices().name();
+ if (result.isEmpty()) {
+ result = QString::fromLatin1("Enum") + e->name();
+ if (!globalEnums) {
+ result += QString::fromLatin1("::type");
+ }
+ result[4] = result[4].toUpper();
+ }
+ return result;
}
static QString enumTypeQualifier(const QString &n, const CfgEntry::Choices &c)
{
- QString result = c.name();
- if ( result.isEmpty() )
- {
- result = QString::fromLatin1("Enum") + n + QString::fromLatin1("::");
- result[4] = result[4].toUpper();
- }
- else if ( c.external() )
- result = c.externalQualifier();
- else
- result.clear();
- return result;
+ QString result = c.name();
+ if (result.isEmpty()) {
+ result = QString::fromLatin1("Enum") + n + QString::fromLatin1("::");
+ result[4] = result[4].toUpper();
+ } else if (c.external()) {
+ result = c.externalQualifier();
+ } else {
+ result.clear();
+ }
+ return result;
}
static QString setFunction(const QString &n, const QString &className = QString())
{
- QString result = QString::fromLatin1("set") + n;
- result[3] = result[3].toUpper();
+ QString result = QString::fromLatin1("set") + n;
+ result[3] = result[3].toUpper();
- if ( !className.isEmpty() )
- result = className + QString::fromLatin1("::") + result;
- return result;
+ if (!className.isEmpty()) {
+ result = className + QString::fromLatin1("::") + result;
+ }
+ return result;
}
static QString getDefaultFunction(const QString &n, const QString &className = QString())
{
- QString result = QString::fromLatin1("default") + n + QString::fromLatin1("Value");
- result[7] = result[7].toUpper();
+ QString result = QString::fromLatin1("default") + n + QString::fromLatin1("Value");
+ result[7] = result[7].toUpper();
- if ( !className.isEmpty() )
- result = className + QString::fromLatin1("::") + result;
- return result;
+ if (!className.isEmpty()) {
+ result = className + QString::fromLatin1("::") + result;
+ }
+ return result;
}
static QString getFunction(const QString &n, const QString &className = QString())
{
- QString result = n;
- result[0] = result[0].toLower();
+ QString result = n;
+ result[0] = result[0].toLower();
- if ( !className.isEmpty() )
- result = className + QString::fromLatin1("::") + result;
- return result;
+ if (!className.isEmpty()) {
+ result = className + QString::fromLatin1("::") + result;
+ }
+ return result;
}
-
-static void addQuotes( QString &s )
+static void addQuotes(QString &s)
{
- if ( !s.startsWith( QLatin1Char('"') ) )
- s.prepend( QLatin1Char('"') );
- if ( !s.endsWith( QLatin1Char('"') ) )
- s.append( QLatin1Char('"') );
+ if (!s.startsWith(QLatin1Char('"'))) {
+ s.prepend(QLatin1Char('"'));
+ }
+ if (!s.endsWith(QLatin1Char('"'))) {
+ s.append(QLatin1Char('"'));
+ }
}
-static QString quoteString( const QString &s )
+static QString quoteString(const QString &s)
{
- QString r = s;
- r.replace( QLatin1Char('\\'), QLatin1String("\\\\") );
- r.replace( QLatin1Char('\"'), QLatin1String("\\\"") );
- r.remove( QLatin1Char('\r') );
- r.replace( QLatin1Char('\n'), QLatin1String("\\n\"\n\"") );
- return QLatin1Char('\"') + r + QLatin1Char('\"');
+ QString r = s;
+ r.replace(QLatin1Char('\\'), QLatin1String("\\\\"));
+ r.replace(QLatin1Char('\"'), QLatin1String("\\\""));
+ r.remove(QLatin1Char('\r'));
+ r.replace(QLatin1Char('\n'), QLatin1String("\\n\"\n\""));
+ return QLatin1Char('\"') + r + QLatin1Char('\"');
}
-static QString literalString( const QString &s )
+static QString literalString(const QString &s)
{
- bool isAscii = true;
- for(int i = s.length(); i--;)
- if (s[i].unicode() > 127) isAscii = false;
-
- if (isAscii)
- return QString::fromLatin1("QLatin1String( ") + quoteString(s) + QString::fromLatin1(" )");
- else
- return QString::fromLatin1("QString::fromUtf8( ") + quoteString(s) + QString::fromLatin1(" )");
+ bool isAscii = true;
+ for (int i = s.length(); i--;)
+ if (s[i].unicode() > 127) {
+ isAscii = false;
+ }
+
+ if (isAscii) {
+ return QString::fromLatin1("QLatin1String( ") + quoteString(s) + QString::fromLatin1(" )");
+ } else {
+ return QString::fromLatin1("QString::fromUtf8( ") + quoteString(s) + QString::fromLatin1(" )");
+ }
}
static QString dumpNode(const QDomNode &node)
{
- QString msg;
- QTextStream s(&msg, QIODevice::WriteOnly );
- node.save(s, 0);
-
- msg = msg.simplified();
- if (msg.length() > 40)
- return msg.left(37) + QString::fromLatin1("...");
- return msg;
+ QString msg;
+ QTextStream s(&msg, QIODevice::WriteOnly);
+ node.save(s, 0);
+
+ msg = msg.simplified();
+ if (msg.length() > 40) {
+ return msg.left(37) + QString::fromLatin1("...");
+ }
+ return msg;
}
-static QString filenameOnly(const QString& path)
+static QString filenameOnly(const QString &path)
{
- int i = path.lastIndexOf(QRegExp(QLatin1String("[/\\]")));
- if (i >= 0)
- return path.mid(i+1);
- return path;
+ int i = path.lastIndexOf(QRegExp(QLatin1String("[/\\]")));
+ if (i >= 0) {
+ return path.mid(i + 1);
+ }
+ return path;
}
static QString signalEnumName(const QString &signalName)
{
- QString result;
- result = QString::fromLatin1("signal") + signalName;
- result[6] = result[6].toUpper();
+ QString result;
+ result = QString::fromLatin1("signal") + signalName;
+ result[6] = result[6].toUpper();
- return result;
+ return result;
}
-static void preProcessDefault( QString &defaultValue, const QString &name,
- const QString &type,
- const CfgEntry::Choices &choices,
- QString &code, const CfgConfig &cfg )
+static void preProcessDefault(QString &defaultValue, const QString &name,
+ const QString &type,
+ const CfgEntry::Choices &choices,
+ QString &code, const CfgConfig &cfg)
{
- if ( type == QLatin1String("String") && !defaultValue.isEmpty() ) {
- defaultValue = literalString(defaultValue);
-
- } else if ( type == QLatin1String("Path") && !defaultValue.isEmpty() ) {
- defaultValue = literalString( defaultValue );
- } else if ( type == QLatin1String("Url") && !defaultValue.isEmpty() ) {
- // Use fromUserInput in order to support absolute paths and absolute urls, like KDE4's KUrl(QString) did.
- defaultValue = QString::fromLatin1("QUrl::fromUserInput( ") + literalString(defaultValue) + QLatin1Char(')');
- } else if ( ( type == QLatin1String("UrlList") || type == QLatin1String("StringList") || type == QLatin1String("PathList")) && !defaultValue.isEmpty() ) {
- QTextStream cpp( &code, QIODevice::WriteOnly | QIODevice::Append );
- if (!code.isEmpty())
- cpp << endl;
-
- if( type == "UrlList" ) {
- cpp << " QList<QUrl> default" << name << ";" << endl;
- } else {
- cpp << " QStringList default" << name << ";" << endl;
- }
- const QStringList defaults = defaultValue.split(QLatin1Char(','));
- QStringList::ConstIterator it;
- for( it = defaults.constBegin(); it != defaults.constEnd(); ++it ) {
- cpp << " default" << name << ".append( ";
- if( type == QLatin1String("UrlList") ) {
- cpp << "QUrl::fromUserInput(";
- }
- cpp << "QString::fromUtf8( \"" << *it << "\" ) ";
- if( type == QLatin1String("UrlList") ) {
- cpp << ") ";
- }
- cpp << ");" << endl;
- }
- defaultValue = QString::fromLatin1("default") + name;
-
- } else if ( type == QLatin1String("Color") && !defaultValue.isEmpty() ) {
- QRegExp colorRe(QLatin1String("\\d+,\\s*\\d+,\\s*\\d+(,\\s*\\d+)?"));
- if (colorRe.exactMatch(defaultValue))
- {
- defaultValue = QLatin1String("QColor( ") + defaultValue + QLatin1String(" )");
- }
- else
- {
- defaultValue = QLatin1String("QColor( \"") + defaultValue + QLatin1String("\" )");
- }
-
- } else if ( type == QLatin1String("Enum") ) {
- QList<CfgEntry::Choice>::ConstIterator it;
- for( it = choices.choices.constBegin(); it != choices.choices.constEnd(); ++it ) {
- if ( (*it).name == defaultValue ) {
- if ( cfg.globalEnums && choices.name().isEmpty() )
- defaultValue.prepend( choices.prefix );
- else
- defaultValue.prepend( enumTypeQualifier(name, choices) + choices.prefix );
- break;
- }
- }
-
- } else if ( type == QLatin1String("IntList") ) {
- QTextStream cpp( &code, QIODevice::WriteOnly | QIODevice::Append );
- if (!code.isEmpty())
- cpp << endl;
-
- cpp << " QList<int> default" << name << ";" << endl;
- if (!defaultValue.isEmpty())
- {
- const QStringList defaults = defaultValue.split( QLatin1Char(',') );
+ if (type == QLatin1String("String") && !defaultValue.isEmpty()) {
+ defaultValue = literalString(defaultValue);
+
+ } else if (type == QLatin1String("Path") && !defaultValue.isEmpty()) {
+ defaultValue = literalString(defaultValue);
+ } else if (type == QLatin1String("Url") && !defaultValue.isEmpty()) {
+ // Use fromUserInput in order to support absolute paths and absolute urls, like KDE4's KUrl(QString) did.
+ defaultValue = QString::fromLatin1("QUrl::fromUserInput( ") + literalString(defaultValue) + QLatin1Char(')');
+ } else if ((type == QLatin1String("UrlList") || type == QLatin1String("StringList") || type == QLatin1String("PathList")) && !defaultValue.isEmpty()) {
+ QTextStream cpp(&code, QIODevice::WriteOnly | QIODevice::Append);
+ if (!code.isEmpty()) {
+ cpp << endl;
+ }
+
+ if (type == "UrlList") {
+ cpp << " QList<QUrl> default" << name << ";" << endl;
+ } else {
+ cpp << " QStringList default" << name << ";" << endl;
+ }
+ const QStringList defaults = defaultValue.split(QLatin1Char(','));
QStringList::ConstIterator it;
- for( it = defaults.constBegin(); it != defaults.constEnd(); ++it ) {
- cpp << " default" << name << ".append( " << *it << " );"
- << endl;
+ for (it = defaults.constBegin(); it != defaults.constEnd(); ++it) {
+ cpp << " default" << name << ".append( ";
+ if (type == QLatin1String("UrlList")) {
+ cpp << "QUrl::fromUserInput(";
+ }
+ cpp << "QString::fromUtf8( \"" << *it << "\" ) ";
+ if (type == QLatin1String("UrlList")) {
+ cpp << ") ";
+ }
+ cpp << ");" << endl;
+ }
+ defaultValue = QString::fromLatin1("default") + name;
+
+ } else if (type == QLatin1String("Color") && !defaultValue.isEmpty()) {
+ QRegExp colorRe(QLatin1String("\\d+,\\s*\\d+,\\s*\\d+(,\\s*\\d+)?"));
+ if (colorRe.exactMatch(defaultValue)) {
+ defaultValue = QLatin1String("QColor( ") + defaultValue + QLatin1String(" )");
+ } else {
+ defaultValue = QLatin1String("QColor( \"") + defaultValue + QLatin1String("\" )");
+ }
+
+ } else if (type == QLatin1String("Enum")) {
+ QList<CfgEntry::Choice>::ConstIterator it;
+ for (it = choices.choices.constBegin(); it != choices.choices.constEnd(); ++it) {
+ if ((*it).name == defaultValue) {
+ if (cfg.globalEnums && choices.name().isEmpty()) {
+ defaultValue.prepend(choices.prefix);
+ } else {
+ defaultValue.prepend(enumTypeQualifier(name, choices) + choices.prefix);
+ }
+ break;
+ }
+ }
+
+ } else if (type == QLatin1String("IntList")) {
+ QTextStream cpp(&code, QIODevice::WriteOnly | QIODevice::Append);
+ if (!code.isEmpty()) {
+ cpp << endl;
+ }
+
+ cpp << " QList<int> default" << name << ";" << endl;
+ if (!defaultValue.isEmpty()) {
+ const QStringList defaults = defaultValue.split(QLatin1Char(','));
+ QStringList::ConstIterator it;
+ for (it = defaults.constBegin(); it != defaults.constEnd(); ++it) {
+ cpp << " default" << name << ".append( " << *it << " );"
+ << endl;
+ }
}
- }
- defaultValue = QString::fromLatin1("default") + name;
+ defaultValue = QString::fromLatin1("default") + name;
}
}
-
-CfgEntry *parseEntry( const QString &group, const QDomElement &element, const CfgConfig &cfg )
+CfgEntry *parseEntry(const QString &group, const QDomElement &element, const CfgConfig &cfg)
{
- bool defaultCode = false;
- QString type = element.attribute( "type" );
- QString name = element.attribute( "name" );
- QString key = element.attribute( "key" );
- QString hidden = element.attribute( "hidden" );
- QString labelContext;
- QString label;
- QString toolTipContext;
- QString toolTip;
- QString whatsThisContext;
- QString whatsThis;
- QString defaultValue;
- QString code;
- QString param;
- QString paramName;
- QString paramType;
- CfgEntry::Choices choices;
- QList<Signal> signalList;
- QStringList paramValues;
- QStringList paramDefaultValues;
- QString minValue;
- QString maxValue;
- int paramMax = 0;
-
- for ( QDomElement e = element.firstChildElement(); !e.isNull(); e = e.nextSiblingElement() ) {
- QString tag = e.tagName();
- if ( tag == "label" ) {
- label = e.text();
- labelContext = e.attribute( "context" );
- }
- else if ( tag == "tooltip" ) {
- toolTip = e.text();
- toolTipContext = e.attribute( "context" );
- }
- else if ( tag == "whatsthis" ) {
- whatsThis = e.text();
- whatsThisContext = e.attribute( "context" );
- }
- else if ( tag == "min" ) minValue = e.text();
- else if ( tag == "max" ) maxValue = e.text();
- else if ( tag == "code" ) code = e.text();
- else if ( tag == "parameter" )
- {
- param = e.attribute( "name" );
- paramType = e.attribute( "type" );
- if ( param.isEmpty() ) {
- cerr << "Parameter must have a name: " << dumpNode(e) << endl;
- return 0;
- }
- if ( paramType.isEmpty() ) {
- cerr << "Parameter must have a type: " << dumpNode(e) << endl;
- return 0;
- }
- if ((paramType == "Int") || (paramType == "UInt"))
- {
- bool ok;
- paramMax = e.attribute("max").toInt(&ok);
- if (!ok)
- {
- cerr << "Integer parameter must have a maximum (e.g. max=\"0\"): "
- << dumpNode(e) << endl;
- return 0;
- }
- }
- else if (paramType == "Enum")
- {
- for ( QDomElement e2 = e.firstChildElement(); !e2.isNull(); e2 = e2.nextSiblingElement() ) {
- if (e2.tagName() == "values")
- {
- for ( QDomElement e3 = e2.firstChildElement(); !e3.isNull(); e3 = e3.nextSiblingElement() ) {
- if (e3.tagName() == "value")
- {
- paramValues.append( e3.text() );
- }
- }
- break;
- }
- }
- if (paramValues.isEmpty())
- {
- cerr << "No values specified for parameter '" << param
- << "'." << endl;
- return 0;
- }
- paramMax = paramValues.count()-1;
- }
- else
- {
- cerr << "Parameter '" << param << "' has type " << paramType
- << " but must be of type int, uint or Enum." << endl;
- return 0;
- }
- }
- else if ( tag == "default" )
- {
- if (e.attribute("param").isEmpty())
- {
- defaultValue = e.text();
- if (e.attribute( "code" ) == "true")
- defaultCode = true;
- }
- }
- else if ( tag == "choices" ) {
- QString name = e.attribute( "name" );
- QString prefix = e.attribute( "prefix" );
- QList<CfgEntry::Choice> chlist;
- for( QDomElement e2 = e.firstChildElement(); !e2.isNull(); e2 = e2.nextSiblingElement() ) {
- if ( e2.tagName() == "choice" ) {
- CfgEntry::Choice choice;
- choice.name = e2.attribute( "name" );
- if ( choice.name.isEmpty() ) {
- cerr << "Tag <choice> requires attribute 'name'." << endl;
- }
- for( QDomElement e3 = e2.firstChildElement(); !e3.isNull(); e3 = e3.nextSiblingElement() ) {
- if ( e3.tagName() == "label" ) {
- choice.label = e3.text();
- choice.context = e3.attribute( "context" );
+ bool defaultCode = false;
+ QString type = element.attribute("type");
+ QString name = element.attribute("name");
+ QString key = element.attribute("key");
+ QString hidden = element.attribute("hidden");
+ QString labelContext;
+ QString label;
+ QString toolTipContext;
+ QString toolTip;
+ QString whatsThisContext;
+ QString whatsThis;
+ QString defaultValue;
+ QString code;
+ QString param;
+ QString paramName;
+ QString paramType;
+ CfgEntry::Choices choices;
+ QList<Signal> signalList;
+ QStringList paramValues;
+ QStringList paramDefaultValues;
+ QString minValue;
+ QString maxValue;
+ int paramMax = 0;
+
+ for (QDomElement e = element.firstChildElement(); !e.isNull(); e = e.nextSiblingElement()) {
+ QString tag = e.tagName();
+ if (tag == "label") {
+ label = e.text();
+ labelContext = e.attribute("context");
+ } else if (tag == "tooltip") {
+ toolTip = e.text();
+ toolTipContext = e.attribute("context");
+ } else if (tag == "whatsthis") {
+ whatsThis = e.text();
+ whatsThisContext = e.attribute("context");
+ } else if (tag == "min") {
+ minValue = e.text();
+ } else if (tag == "max") {
+ maxValue = e.text();
+ } else if (tag == "code") {
+ code = e.text();
+ } else if (tag == "parameter") {
+ param = e.attribute("name");
+ paramType = e.attribute("type");
+ if (param.isEmpty()) {
+ cerr << "Parameter must have a name: " << dumpNode(e) << endl;
+ return 0;
}
- if ( e3.tagName() == "tooltip" ) {
- choice.toolTip = e3.text();
- choice.context = e3.attribute( "context" );
+ if (paramType.isEmpty()) {
+ cerr << "Parameter must have a type: " << dumpNode(e) << endl;
+ return 0;
}
- if ( e3.tagName() == "whatsthis" ) {
- choice.whatsThis = e3.text();
- choice.context = e3.attribute( "context" );
+ if ((paramType == "Int") || (paramType == "UInt")) {
+ bool ok;
+ paramMax = e.attribute("max").toInt(&ok);
+ if (!ok) {
+ cerr << "Integer parameter must have a maximum (e.g. max=\"0\"): "
+ << dumpNode(e) << endl;
+ return 0;
+ }
+ } else if (paramType == "Enum") {
+ for (QDomElement e2 = e.firstChildElement(); !e2.isNull(); e2 = e2.nextSiblingElement()) {
+ if (e2.tagName() == "values") {
+ for (QDomElement e3 = e2.firstChildElement(); !e3.isNull(); e3 = e3.nextSiblingElement()) {
+ if (e3.tagName() == "value") {
+ paramValues.append(e3.text());
+ }
+ }
+ break;
+ }
+ }
+ if (paramValues.isEmpty()) {
+ cerr << "No values specified for parameter '" << param
+ << "'." << endl;
+ return 0;
+ }
+ paramMax = paramValues.count() - 1;
+ } else {
+ cerr << "Parameter '" << param << "' has type " << paramType
+ << " but must be of type int, uint or Enum." << endl;
+ return 0;
}
- }
- chlist.append( choice );
- }
- }
- choices = CfgEntry::Choices( chlist, name, prefix );
- }
- else if ( tag == "emit" ) {
- QDomNode signalNode;
- Signal signal;
- signal.name = e.attribute( "signal" );
- signalList.append( signal);
- }
- }
-
-
- bool nameIsEmpty = name.isEmpty();
- if ( nameIsEmpty && key.isEmpty() ) {
- cerr << "Entry must have a name or a key: " << dumpNode(element) << endl;
- return 0;
- }
-
- if ( key.isEmpty() ) {
- key = name;
- }
-
- if ( nameIsEmpty ) {
- name = key;
- name.remove( ' ' );
- } else if ( name.contains( ' ' ) ) {
- cout<<"Entry '"<<name<<"' contains spaces! <name> elements can not contain spaces!"<<endl;
- name.remove( ' ' );
- }
-
- if (name.contains("$("))
- {
- if (param.isEmpty())
- {
- cerr << "Name may not be parameterized: " << name << endl;
- return 0;
+ } else if (tag == "default") {
+ if (e.attribute("param").isEmpty()) {
+ defaultValue = e.text();
+ if (e.attribute("code") == "true") {
+ defaultCode = true;
+ }
+ }
+ } else if (tag == "choices") {
+ QString name = e.attribute("name");
+ QString prefix = e.attribute("prefix");
+ QList<CfgEntry::Choice> chlist;
+ for (QDomElement e2 = e.firstChildElement(); !e2.isNull(); e2 = e2.nextSiblingElement()) {
+ if (e2.tagName() == "choice") {
+ CfgEntry::Choice choice;
+ choice.name = e2.attribute("name");
+ if (choice.name.isEmpty()) {
+ cerr << "Tag <choice> requires attribute 'name'." << endl;
+ }
+ for (QDomElement e3 = e2.firstChildElement(); !e3.isNull(); e3 = e3.nextSiblingElement()) {
+ if (e3.tagName() == "label") {
+ choice.label = e3.text();
+ choice.context = e3.attribute("context");
+ }
+ if (e3.tagName() == "tooltip") {
+ choice.toolTip = e3.text();
+ choice.context = e3.attribute("context");
+ }
+ if (e3.tagName() == "whatsthis") {
+ choice.whatsThis = e3.text();
+ choice.context = e3.attribute("context");
+ }
+ }
+ chlist.append(choice);
+ }
+ }
+ choices = CfgEntry::Choices(chlist, name, prefix);
+ } else if (tag == "emit") {
+ QDomNode signalNode;
+ Signal signal;
+ signal.name = e.attribute("signal");
+ signalList.append(signal);
+ }
}
- }
- else
- {
- if (!param.isEmpty())
- {
- cerr << "Name must contain '$(" << param << ")': " << name << endl;
- return 0;
+
+ bool nameIsEmpty = name.isEmpty();
+ if (nameIsEmpty && key.isEmpty()) {
+ cerr << "Entry must have a name or a key: " << dumpNode(element) << endl;
+ return 0;
}
- }
- if ( label.isEmpty() ) {
- label = key;
- }
+ if (key.isEmpty()) {
+ key = name;
+ }
- if ( type.isEmpty() ) type = "String"; // XXX : implicit type might be bad
+ if (nameIsEmpty) {
+ name = key;
+ name.remove(' ');
+ } else if (name.contains(' ')) {
+ cout << "Entry '" << name << "' contains spaces! <name> elements can not contain spaces!" << endl;
+ name.remove(' ');
+ }
- if (!param.isEmpty())
- {
- // Adjust name
- paramName = name;
- name.remove("$("+param+')');
- // Lookup defaults for indexed entries
- for(int i = 0; i <= paramMax; i++)
- {
- paramDefaultValues.append(QString());
+ if (name.contains("$(")) {
+ if (param.isEmpty()) {
+ cerr << "Name may not be parameterized: " << name << endl;
+ return 0;
+ }
+ } else {
+ if (!param.isEmpty()) {
+ cerr << "Name must contain '$(" << param << ")': " << name << endl;
+ return 0;
+ }
}
- for ( QDomElement e = element.firstChildElement(); !e.isNull(); e = e.nextSiblingElement() ) {
- QString tag = e.tagName();
- if ( tag == "default" )
- {
- QString index = e.attribute("param");
- if (index.isEmpty())
- continue;
+ if (label.isEmpty()) {
+ label = key;
+ }
- bool ok;
- int i = index.toInt(&ok);
- if (!ok)
- {
- i = paramValues.indexOf(index);
- if (i == -1)
- {
- cerr << "Index '" << index << "' for default value is unknown." << endl;
- return 0;
- }
+ if (type.isEmpty()) {
+ type = "String"; // XXX : implicit type might be bad
+ }
+
+ if (!param.isEmpty()) {
+ // Adjust name
+ paramName = name;
+ name.remove("$(" + param + ')');
+ // Lookup defaults for indexed entries
+ for (int i = 0; i <= paramMax; i++) {
+ paramDefaultValues.append(QString());
}
- if ((i < 0) || (i > paramMax))
- {
- cerr << "Index '" << i << "' for default value is out of range [0, "<< paramMax<<"]." << endl;
- return 0;
- }
-
- QString tmpDefaultValue = e.text();
-
- if (e.attribute( "code" ) != "true")
- preProcessDefault(tmpDefaultValue, name, type, choices, code, cfg);
-
- paramDefaultValues[i] = tmpDefaultValue;
- }
- }
- }
-
- if (!validNameRegexp->exactMatch(name))
- {
- if (nameIsEmpty)
- cerr << "The key '" << key << "' can not be used as name for the entry because "
- "it is not a valid name. You need to specify a valid name for this entry." << endl;
- else
- cerr << "The name '" << name << "' is not a valid name for an entry." << endl;
- return 0;
- }
-
- if (allNames.contains(name))
- {
- if (nameIsEmpty)
- cerr << "The key '" << key << "' can not be used as name for the entry because "
- "it does not result in a unique name. You need to specify a unique name for this entry." << endl;
- else
- cerr << "The name '" << name << "' is not unique." << endl;
- return 0;
- }
- allNames.append(name);
-
- if (!defaultCode)
- {
- preProcessDefault(defaultValue, name, type, choices, code, cfg);
- }
-
- CfgEntry *result = new CfgEntry( group, type, key, name, labelContext, label, toolTipContext, toolTip, whatsThisContext, whatsThis,
- code, defaultValue, choices, signalList,
- hidden == "true" );
- if (!param.isEmpty())
- {
- result->setParam(param);
- result->setParamName(paramName);
- result->setParamType(paramType);
- result->setParamValues(paramValues);
- result->setParamDefaultValues(paramDefaultValues);
- result->setParamMax(paramMax);
- }
- result->setMinValue(minValue);
- result->setMaxValue(maxValue);
-
- return result;
+ for (QDomElement e = element.firstChildElement(); !e.isNull(); e = e.nextSiblingElement()) {
+ QString tag = e.tagName();
+ if (tag == "default") {
+ QString index = e.attribute("param");
+ if (index.isEmpty()) {
+ continue;
+ }
+
+ bool ok;
+ int i = index.toInt(&ok);
+ if (!ok) {
+ i = paramValues.indexOf(index);
+ if (i == -1) {
+ cerr << "Index '" << index << "' for default value is unknown." << endl;
+ return 0;
+ }
+ }
+
+ if ((i < 0) || (i > paramMax)) {
+ cerr << "Index '" << i << "' for default value is out of range [0, " << paramMax << "]." << endl;
+ return 0;
+ }
+
+ QString tmpDefaultValue = e.text();
+
+ if (e.attribute("code") != "true") {
+ preProcessDefault(tmpDefaultValue, name, type, choices, code, cfg);
+ }
+
+ paramDefaultValues[i] = tmpDefaultValue;
+ }
+ }
+ }
+
+ if (!validNameRegexp->exactMatch(name)) {
+ if (nameIsEmpty)
+ cerr << "The key '" << key << "' can not be used as name for the entry because "
+ "it is not a valid name. You need to specify a valid name for this entry." << endl;
+ else {
+ cerr << "The name '" << name << "' is not a valid name for an entry." << endl;
+ }
+ return 0;
+ }
+
+ if (allNames.contains(name)) {
+ if (nameIsEmpty)
+ cerr << "The key '" << key << "' can not be used as name for the entry because "
+ "it does not result in a unique name. You need to specify a unique name for this entry." << endl;
+ else {
+ cerr << "The name '" << name << "' is not unique." << endl;
+ }
+ return 0;
+ }
+ allNames.append(name);
+
+ if (!defaultCode) {
+ preProcessDefault(defaultValue, name, type, choices, code, cfg);
+ }
+
+ CfgEntry *result = new CfgEntry(group, type, key, name, labelContext, label, toolTipContext, toolTip, whatsThisContext, whatsThis,
+ code, defaultValue, choices, signalList,
+ hidden == "true");
+ if (!param.isEmpty()) {
+ result->setParam(param);
+ result->setParamName(paramName);
+ result->setParamType(paramType);
+ result->setParamValues(paramValues);
+ result->setParamDefaultValues(paramDefaultValues);
+ result->setParamMax(paramMax);
+ }
+ result->setMinValue(minValue);
+ result->setMaxValue(maxValue);
+
+ return result;
}
-static bool isUnsigned(const QString& type)
+static bool isUnsigned(const QString &type)
{
- if ( type == "UInt" ) return true;
- if ( type == "ULongLong" ) return true;
+ if (type == "UInt") {
+ return true;
+ }
+ if (type == "ULongLong") {
+ return true;
+ }
return false;
}
/**
Return parameter declaration for given type.
*/
-QString param( const QString &t )
+QString param(const QString &t)
{
const QString type = t.toLower();
- if ( type == "string" ) return "const QString &";
- else if ( type == "stringlist" ) return "const QStringList &";
- else if ( type == "font" ) return "const QFont &";
- else if ( type == "rect" ) return "const QRect &";
- else if ( type == "size" ) return "const QSize &";
- else if ( type == "color" ) return "const QColor &";
- else if ( type == "point" ) return "const QPoint &";
- else if ( type == "int" ) return "int";
- else if ( type == "uint" ) return "uint";
- else if ( type == "bool" ) return "bool";
- else if ( type == "double" ) return "double";
- else if ( type == "datetime" ) return "const QDateTime &";
- else if ( type == "longlong" ) return "qint64";
- else if ( type == "ulonglong" ) return "quint64";
- else if ( type == "intlist" ) return "const QList<int> &";
- else if ( type == "enum" ) return "int";
- else if ( type == "path" ) return "const QString &";
- else if ( type == "pathlist" ) return "const QStringList &";
- else if ( type == "password" ) return "const QString &";
- else if ( type == "url" ) return "const QUrl &";
- else if ( type == "urllist" ) return "const QList<QUrl> &";
- else {
- cerr <<"kconfig_compiler does not support type \""<< type <<"\""<<endl;
+ if (type == "string") {
+ return "const QString &";
+ } else if (type == "stringlist") {
+ return "const QStringList &";
+ } else if (type == "font") {
+ return "const QFont &";
+ } else if (type == "rect") {
+ return "const QRect &";
+ } else if (type == "size") {
+ return "const QSize &";
+ } else if (type == "color") {
+ return "const QColor &";
+ } else if (type == "point") {
+ return "const QPoint &";
+ } else if (type == "int") {
+ return "int";
+ } else if (type == "uint") {
+ return "uint";
+ } else if (type == "bool") {
+ return "bool";
+ } else if (type == "double") {
+ return "double";
+ } else if (type == "datetime") {
+ return "const QDateTime &";
+ } else if (type == "longlong") {
+ return "qint64";
+ } else if (type == "ulonglong") {
+ return "quint64";
+ } else if (type == "intlist") {
+ return "const QList<int> &";
+ } else if (type == "enum") {
+ return "int";
+ } else if (type == "path") {
+ return "const QString &";
+ } else if (type == "pathlist") {
+ return "const QStringList &";
+ } else if (type == "password") {
+ return "const QString &";
+ } else if (type == "url") {
+ return "const QUrl &";
+ } else if (type == "urllist") {
+ return "const QList<QUrl> &";
+ } else {
+ cerr << "kconfig_compiler does not support type \"" << type << "\"" << endl;
return "QString"; //For now, but an assert would be better
}
}
@@ -934,87 +1081,130 @@ QString param( const QString &t )
/**
Actual C++ storage type for given type.
*/
-QString cppType( const QString &t )
+QString cppType(const QString &t)
{
const QString type = t.toLower();
- if ( type == "string" ) return "QString";
- else if ( type == "stringlist" ) return "QStringList";
- else if ( type == "font" ) return "QFont";
- else if ( type == "rect" ) return "QRect";
- else if ( type == "size" ) return "QSize";
- else if ( type == "color" ) return "QColor";
- else if ( type == "point" ) return "QPoint";
- else if ( type == "int" ) return "int";
- else if ( type == "uint" ) return "uint";
- else if ( type == "bool" ) return "bool";
- else if ( type == "double" ) return "double";
- else if ( type == "datetime" ) return "QDateTime";
- else if ( type == "longlong" ) return "qint64";
- else if ( type == "ulonglong" ) return "quint64";
- else if ( type == "intlist" ) return "QList<int>";
- else if ( type == "enum" ) return "int";
- else if ( type == "path" ) return "QString";
- else if ( type == "pathlist" ) return "QStringList";
- else if ( type == "password" ) return "QString";
- else if ( type == "url" ) return "QUrl";
- else if ( type == "urllist" ) return "QList<QUrl>";
- else {
- cerr<<"kconfig_compiler does not support type \""<< type <<"\""<<endl;
+ if (type == "string") {
+ return "QString";
+ } else if (type == "stringlist") {
+ return "QStringList";
+ } else if (type == "font") {
+ return "QFont";
+ } else if (type == "rect") {
+ return "QRect";
+ } else if (type == "size") {
+ return "QSize";
+ } else if (type == "color") {
+ return "QColor";
+ } else if (type == "point") {
+ return "QPoint";
+ } else if (type == "int") {
+ return "int";
+ } else if (type == "uint") {
+ return "uint";
+ } else if (type == "bool") {
+ return "bool";
+ } else if (type == "double") {
+ return "double";
+ } else if (type == "datetime") {
+ return "QDateTime";
+ } else if (type == "longlong") {
+ return "qint64";
+ } else if (type == "ulonglong") {
+ return "quint64";
+ } else if (type == "intlist") {
+ return "QList<int>";
+ } else if (type == "enum") {
+ return "int";
+ } else if (type == "path") {
+ return "QString";
+ } else if (type == "pathlist") {
+ return "QStringList";
+ } else if (type == "password") {
+ return "QString";
+ } else if (type == "url") {
+ return "QUrl";
+ } else if (type == "urllist") {
+ return "QList<QUrl>";
+ } else {
+ cerr << "kconfig_compiler does not support type \"" << type << "\"" << endl;
return "QString"; //For now, but an assert would be better
}
}
-QString defaultValue( const QString &t )
+QString defaultValue(const QString &t)
{
const QString type = t.toLower();
- if ( type == "string" ) return "\"\""; // Use empty string, not null string!
- else if ( type == "stringlist" ) return "QStringList()";
- else if ( type == "font" ) return "QFont()";
- else if ( type == "rect" ) return "QRect()";
- else if ( type == "size" ) return "QSize()";
- else if ( type == "color" ) return "QColor(128, 128, 128)";
- else if ( type == "point" ) return "QPoint()";
- else if ( type == "int" ) return "0";
- else if ( type == "uint" ) return "0";
- else if ( type == "bool" ) return "false";
- else if ( type == "double" ) return "0.0";
- else if ( type == "datedime" ) return "QDateTime()";
- else if ( type == "longlong" ) return "0";
- else if ( type == "ulonglong" ) return "0";
- else if ( type == "intlist" ) return "QList<int>()";
- else if ( type == "enum" ) return "0";
- else if ( type == "path" ) return "\"\""; // Use empty string, not null string!
- else if ( type == "pathlist" ) return "QStringList()";
- else if ( type == "password" ) return "\"\""; // Use empty string, not null string!
- else if ( type == "url" ) return "QUrl()";
- else if ( type == "urllist" ) return "QList<QUrl>()";
- else {
- cerr<<"Error, kconfig_compiler does not support the \""<< type <<"\" type!"<<endl;
+ if (type == "string") {
+ return "\"\""; // Use empty string, not null string!
+ } else if (type == "stringlist") {
+ return "QStringList()";
+ } else if (type == "font") {
+ return "QFont()";
+ } else if (type == "rect") {
+ return "QRect()";
+ } else if (type == "size") {
+ return "QSize()";
+ } else if (type == "color") {
+ return "QColor(128, 128, 128)";
+ } else if (type == "point") {
+ return "QPoint()";
+ } else if (type == "int") {
+ return "0";
+ } else if (type == "uint") {
+ return "0";
+ } else if (type == "bool") {
+ return "false";
+ } else if (type == "double") {
+ return "0.0";
+ } else if (type == "datedime") {
+ return "QDateTime()";
+ } else if (type == "longlong") {
+ return "0";
+ } else if (type == "ulonglong") {
+ return "0";
+ } else if (type == "intlist") {
+ return "QList<int>()";
+ } else if (type == "enum") {
+ return "0";
+ } else if (type == "path") {
+ return "\"\""; // Use empty string, not null string!
+ } else if (type == "pathlist") {
+ return "QStringList()";
+ } else if (type == "password") {
+ return "\"\""; // Use empty string, not null string!
+ } else if (type == "url") {
+ return "QUrl()";
+ } else if (type == "urllist") {
+ return "QList<QUrl>()";
+ } else {
+ cerr << "Error, kconfig_compiler does not support the \"" << type << "\" type!" << endl;
return "QString"; //For now, but an assert would be better
}
}
-QString itemType( const QString &type )
+QString itemType(const QString &type)
{
- QString t;
+ QString t;
- t = type;
- t.replace( 0, 1, t.left( 1 ).toUpper() );
+ t = type;
+ t.replace(0, 1, t.left(1).toUpper());
- return t;
+ return t;
}
static QString itemDeclaration(const CfgEntry *e, const CfgConfig &cfg)
{
- if (cfg.itemAccessors)
- return QString();
-
- QString fCap = e->name();
- fCap[0] = fCap[0].toUpper();
- return " "+cfg.inherits+"::Item"+itemType( e->type() ) +
- " *item" + fCap +
- ( (!e->param().isEmpty())?(QString("[%1]").arg(e->paramMax()+1)) : QString()) +
- ";\n";
+ if (cfg.itemAccessors) {
+ return QString();
+ }
+
+ QString fCap = e->name();
+ fCap[0] = fCap[0].toUpper();
+ return " " + cfg.inherits + "::Item" + itemType(e->type()) +
+ " *item" + fCap +
+ ((!e->param().isEmpty()) ? (QString("[%1]").arg(e->paramMax() + 1)) : QString()) +
+ ";\n";
}
// returns the name of an item variable
@@ -1022,97 +1212,90 @@ static QString itemDeclaration(const CfgEntry *e, const CfgConfig &cfg)
// like using d-> in case of dpointer
static QString itemVar(const CfgEntry *e, const CfgConfig &cfg)
{
- QString result;
- if (cfg.itemAccessors)
- {
- if ( !cfg.dpointer )
- {
- result = 'm' + e->name() + "Item";
- result[1] = result[1].toUpper();
- }
- else
- {
- result = e->name() + "Item";
- result[0] = result[0].toLower();
+ QString result;
+ if (cfg.itemAccessors) {
+ if (!cfg.dpointer) {
+ result = 'm' + e->name() + "Item";
+ result[1] = result[1].toUpper();
+ } else {
+ result = e->name() + "Item";
+ result[0] = result[0].toLower();
+ }
+ } else {
+ result = "item" + e->name();
+ result[4] = result[4].toUpper();
}
- }
- else
- {
- result = "item" + e->name();
- result[4] = result[4].toUpper();
- }
- return result;
+ return result;
}
static QString itemPath(const CfgEntry *e, const CfgConfig &cfg)
{
- QString result;
- if ( cfg.dpointer ) {
- result = "d->"+itemVar(e, cfg);
- }
- else {
- result = itemVar(e, cfg);
- }
- return result;
+ QString result;
+ if (cfg.dpointer) {
+ result = "d->" + itemVar(e, cfg);
+ } else {
+ result = itemVar(e, cfg);
+ }
+ return result;
}
-QString newItem( const QString &type, const QString &name, const QString &key,
- const QString &defaultValue, const CfgConfig &cfg, const QString &param = QString())
+QString newItem(const QString &type, const QString &name, const QString &key,
+ const QString &defaultValue, const CfgConfig &cfg, const QString &param = QString())
{
- QString t = "new "+cfg.inherits+"::Item" + itemType( type ) +
- "( currentGroup(), " + key + ", " + varPath( name, cfg ) + param;
- if ( type == "Enum" ) t += ", values" + name;
- if ( !defaultValue.isEmpty() ) {
- t += ", ";
- if ( type == "String" ) t += defaultValue;
- else t+= defaultValue;
- }
- t += " );";
-
- return t;
+ QString t = "new " + cfg.inherits + "::Item" + itemType(type) +
+ "( currentGroup(), " + key + ", " + varPath(name, cfg) + param;
+ if (type == "Enum") {
+ t += ", values" + name;
+ }
+ if (!defaultValue.isEmpty()) {
+ t += ", ";
+ if (type == "String") {
+ t += defaultValue;
+ } else {
+ t += defaultValue;
+ }
+ }
+ t += " );";
+
+ return t;
}
QString paramString(const QString &s, const CfgEntry *e, int i)
{
- QString result = s;
- QString needle = "$("+e->param()+')';
- if (result.contains(needle))
- {
- QString tmp;
- if (e->paramType() == "Enum")
- {
- tmp = e->paramValues()[i];
- }
- else
- {
- tmp = QString::number(i);
- }
+ QString result = s;
+ QString needle = "$(" + e->param() + ')';
+ if (result.contains(needle)) {
+ QString tmp;
+ if (e->paramType() == "Enum") {
+ tmp = e->paramValues()[i];
+ } else {
+ tmp = QString::number(i);
+ }
- result.replace(needle, tmp);
- }
- return result;
+ result.replace(needle, tmp);
+ }
+ return result;
}
QString paramString(const QString &group, const QList<Param> &parameters)
{
- QString paramString = group;
- QString arguments;
- int i = 1;
- for (QList<Param>::ConstIterator it = parameters.constBegin();
- it != parameters.constEnd(); ++it)
- {
- if (paramString.contains("$("+(*it).name+')'))
- {
- QString tmp;
- tmp.sprintf("%%%d", i++);
- paramString.replace("$("+(*it).name+')', tmp);
- arguments += ".arg( mParam"+(*it).name+" )";
- }
- }
- if (arguments.isEmpty())
- return "QLatin1String( \""+group+"\" )";
-
- return "QString( QLatin1String( \""+paramString+"\" ) )"+arguments;
+ QString paramString = group;
+ QString arguments;
+ int i = 1;
+ for (QList<Param>::ConstIterator it = parameters.constBegin();
+ it != parameters.constEnd(); ++it) {
+ if (paramString.contains("$(" + (*it).name + ')')) {
+ QString tmp;
+ tmp.sprintf("%%%d", i++);
+ paramString.replace("$(" + (*it).name + ')', tmp);
+ arguments += ".arg( mParam" + (*it).name + " )";
+ }
+ }
+ if (arguments.isEmpty()) {
+ return "QLatin1String( \"" + group + "\" )";
+ }
+
+ return "QString( QLatin1String( \"" + paramString + "\" ) )" + arguments;
}
QString translatedString(const CfgConfig &cfg, const QString &string, const QString &context = QString(), const QString &param = QString(), const QString &paramValue = QString())
@@ -1122,62 +1305,64 @@ QString translatedString(const CfgConfig &cfg, const QString &string, const QStr
switch (cfg.translationSystem) {
case CfgConfig::QtTranslation:
if (!context.isEmpty()) {
- result+= "/*: " + context + " */ QCoreApplication::translate(\"";
+ result += "/*: " + context + " */ QCoreApplication::translate(\"";
} else {
- result+= "QCoreApplication::translate(\"";
+ result += "QCoreApplication::translate(\"";
}
- result+= cfg.className + "\", ";
+ result += cfg.className + "\", ";
break;
case CfgConfig::KdeTranslation:
if (!context.isEmpty()) {
- result+= "i18nc(" + quoteString(context) + ", ";
+ result += "i18nc(" + quoteString(context) + ", ";
} else {
- result+= "i18n(";
+ result += "i18n(";
}
break;
}
if (!param.isEmpty()) {
QString resolvedString = string;
- resolvedString.replace("$("+param+')', paramValue);
- result+= quoteString(resolvedString);
+ resolvedString.replace("$(" + param + ')', paramValue);
+ result += quoteString(resolvedString);
} else {
- result+= quoteString(string);
+ result += quoteString(string);
}
- result+= ')';
+ result += ')';
return result;
}
/* int i is the value of the parameter */
-QString userTextsFunctions( CfgEntry *e, const CfgConfig &cfg, QString itemVarStr=QString(), QString i=QString() )
+QString userTextsFunctions(CfgEntry *e, const CfgConfig &cfg, QString itemVarStr = QString(), QString i = QString())
{
- QString txt;
- if (itemVarStr.isNull()) itemVarStr=itemPath(e, cfg);
- if ( !e->label().isEmpty() ) {
- txt += " " + itemVarStr + "->setLabel( ";
- txt += translatedString(cfg, e->label(), e->labelContext(), e->param(), i);
- txt += " );\n";
- }
- if ( !e->toolTip().isEmpty() ) {
- txt += " " + itemVarStr + "->setToolTip( ";
- txt += translatedString(cfg, e->toolTip(), e->toolTipContext(), e->param(), i);
- txt += " );\n";
- }
- if ( !e->whatsThis().isEmpty() ) {
- txt += " " + itemVarStr + "->setWhatsThis( ";
- txt += translatedString(cfg, e->whatsThis(), e->whatsThisContext(), e->param(), i);
- txt += " );\n";
- }
- return txt;
+ QString txt;
+ if (itemVarStr.isNull()) {
+ itemVarStr = itemPath(e, cfg);
+ }
+ if (!e->label().isEmpty()) {
+ txt += " " + itemVarStr + "->setLabel( ";
+ txt += translatedString(cfg, e->label(), e->labelContext(), e->param(), i);
+ txt += " );\n";
+ }
+ if (!e->toolTip().isEmpty()) {
+ txt += " " + itemVarStr + "->setToolTip( ";
+ txt += translatedString(cfg, e->toolTip(), e->toolTipContext(), e->param(), i);
+ txt += " );\n";
+ }
+ if (!e->whatsThis().isEmpty()) {
+ txt += " " + itemVarStr + "->setWhatsThis( ";
+ txt += translatedString(cfg, e->whatsThis(), e->whatsThisContext(), e->param(), i);
+ txt += " );\n";
+ }
+ return txt;
}
// returns the member accesor implementation
// which should go in the h file if inline
// or the cpp file if not inline
-QString memberAccessorBody( CfgEntry *e, bool globalEnums, const CfgConfig &cfg )
+QString memberAccessorBody(CfgEntry *e, bool globalEnums, const CfgConfig &cfg)
{
QString result;
QTextStream out(&result, QIODevice::WriteOnly);
@@ -1186,13 +1371,16 @@ QString memberAccessorBody( CfgEntry *e, bool globalEnums, const CfgConfig &cfg
bool useEnumType = cfg.useEnumTypes && t == "Enum";
out << "return ";
- if (useEnumType)
- out << "static_cast<" << enumType(e, globalEnums) << ">(";
+ if (useEnumType) {
+ out << "static_cast<" << enumType(e, globalEnums) << ">(";
+ }
out << This << varPath(n, cfg);
- if (!e->param().isEmpty())
- out << "[i]";
- if (useEnumType)
- out << ")";
+ if (!e->param().isEmpty()) {
+ out << "[i]";
+ }
+ if (useEnumType) {
+ out << ")";
+ }
out << ";" << endl;
return result;
@@ -1201,113 +1389,110 @@ QString memberAccessorBody( CfgEntry *e, bool globalEnums, const CfgConfig &cfg
// returns the member mutator implementation
// which should go in the h file if inline
// or the cpp file if not inline
-QString memberMutatorBody( CfgEntry *e, const CfgConfig &cfg )
+QString memberMutatorBody(CfgEntry *e, const CfgConfig &cfg)
{
- QString result;
- QTextStream out(&result, QIODevice::WriteOnly);
- QString n = e->name();
- QString t = e->type();
-
- if (!e->minValue().isEmpty())
- {
- if (e->minValue() != "0" || !isUnsigned(t)) { // skip writing "if uint<0" (#187579)
- out << "if (v < " << e->minValue() << ")" << endl;
- out << "{" << endl;
- out << " qDebug() << \"" << setFunction(n);
- out << ": value \" << v << \" is less than the minimum value of ";
- out << e->minValue()<< "\";" << endl;
- out << " v = " << e->minValue() << ";" << endl;
- out << "}" << endl;
- }
- }
-
- if (!e->maxValue().isEmpty())
- {
- out << endl << "if (v > " << e->maxValue() << ")" << endl;
- out << "{" << endl;
- out << " qDebug() << \"" << setFunction(n);
- out << ": value \" << v << \" is greater than the maximum value of ";
- out << e->maxValue()<< "\";" << endl;
- out << " v = " << e->maxValue() << ";" << endl;
- out << "}" << endl << endl;
- }
-
- out << "if (!" << This << "isImmutable( QString::fromLatin1( \"";
- if (!e->param().isEmpty())
- {
- out << e->paramName().replace("$("+e->param()+")", "%1") << "\" ).arg( ";
- if ( e->paramType() == "Enum" ) {
- out << "QLatin1String( ";
-
- if (cfg.globalEnums)
- out << enumName(e->param()) << "ToString[i]";
- else
- out << enumName(e->param()) << "::enumToString[i]";
+ QString result;
+ QTextStream out(&result, QIODevice::WriteOnly);
+ QString n = e->name();
+ QString t = e->type();
+
+ if (!e->minValue().isEmpty()) {
+ if (e->minValue() != "0" || !isUnsigned(t)) { // skip writing "if uint<0" (#187579)
+ out << "if (v < " << e->minValue() << ")" << endl;
+ out << "{" << endl;
+ out << " qDebug() << \"" << setFunction(n);
+ out << ": value \" << v << \" is less than the minimum value of ";
+ out << e->minValue() << "\";" << endl;
+ out << " v = " << e->minValue() << ";" << endl;
+ out << "}" << endl;
+ }
+ }
+
+ if (!e->maxValue().isEmpty()) {
+ out << endl << "if (v > " << e->maxValue() << ")" << endl;
+ out << "{" << endl;
+ out << " qDebug() << \"" << setFunction(n);
+ out << ": value \" << v << \" is greater than the maximum value of ";
+ out << e->maxValue() << "\";" << endl;
+ out << " v = " << e->maxValue() << ";" << endl;
+ out << "}" << endl << endl;
+ }
+
+ out << "if (!" << This << "isImmutable( QString::fromLatin1( \"";
+ if (!e->param().isEmpty()) {
+ out << e->paramName().replace("$(" + e->param() + ")", "%1") << "\" ).arg( ";
+ if (e->paramType() == "Enum") {
+ out << "QLatin1String( ";
+ if (cfg.globalEnums) {
+ out << enumName(e->param()) << "ToString[i]";
+ } else {
+ out << enumName(e->param()) << "::enumToString[i]";
+ }
+
+ out << " )";
+ } else {
+ out << "i";
+ }
out << " )";
+ } else {
+ out << n << "\" )";
}
- else
- {
- out << "i";
- }
- out << " )";
- }
- else
- {
- out << n << "\" )";
- }
- out << " ))" << (!e->signalList().empty() ? " {" : "") << endl;
- out << " " << This << varPath(n, cfg);
- if (!e->param().isEmpty())
- out << "[i]";
- out << " = v;" << endl;
-
- if ( !e->signalList().empty() ) {
- Q_FOREACH(const Signal &signal, e->signalList()) {
- out << " " << This << varPath("settingsChanged", cfg) << " |= " << signalEnumName(signal.name) << ";" << endl;
- }
- out << "}" << endl;
- }
-
- return result;
+ out << " ))" << (!e->signalList().empty() ? " {" : "") << endl;
+ out << " " << This << varPath(n, cfg);
+ if (!e->param().isEmpty()) {
+ out << "[i]";
+ }
+ out << " = v;" << endl;
+
+ if (!e->signalList().empty()) {
+ Q_FOREACH (const Signal &signal, e->signalList()) {
+ out << " " << This << varPath("settingsChanged", cfg) << " |= " << signalEnumName(signal.name) << ";" << endl;
+ }
+ out << "}" << endl;
+ }
+
+ return result;
}
// returns the member get default implementation
// which should go in the h file if inline
// or the cpp file if not inline
-QString memberGetDefaultBody( CfgEntry *e )
+QString memberGetDefaultBody(CfgEntry *e)
{
- QString result = e->code();
- QTextStream out(&result, QIODevice::WriteOnly);
- out << endl;
-
- if (!e->param().isEmpty()) {
- out << " switch (i) {" << endl;
- for (int i = 0; i <= e->paramMax(); ++i) {
- if (!e->paramDefaultValue(i).isEmpty()) {
- out << " case " << i << ": return " << e->paramDefaultValue(i) << ';' << endl;
- }
- }
- out << " default:" << endl;
- out << " return " << e->defaultValue().replace("$("+e->param()+')', "i") << ';' << endl;
- out << " }" << endl;
- } else {
- out << " return " << e->defaultValue() << ';';
- }
-
- return result;
+ QString result = e->code();
+ QTextStream out(&result, QIODevice::WriteOnly);
+ out << endl;
+
+ if (!e->param().isEmpty()) {
+ out << " switch (i) {" << endl;
+ for (int i = 0; i <= e->paramMax(); ++i) {
+ if (!e->paramDefaultValue(i).isEmpty()) {
+ out << " case " << i << ": return " << e->paramDefaultValue(i) << ';' << endl;
+ }
+ }
+ out << " default:" << endl;
+ out << " return " << e->defaultValue().replace("$(" + e->param() + ')', "i") << ';' << endl;
+ out << " }" << endl;
+ } else {
+ out << " return " << e->defaultValue() << ';';
+ }
+
+ return result;
}
// returns the item accesor implementation
// which should go in the h file if inline
// or the cpp file if not inline
-QString itemAccessorBody( CfgEntry *e, const CfgConfig &cfg )
+QString itemAccessorBody(CfgEntry *e, const CfgConfig &cfg)
{
QString result;
QTextStream out(&result, QIODevice::WriteOnly);
out << "return " << itemPath(e, cfg);
- if (!e->param().isEmpty()) out << "[i]";
+ if (!e->param().isEmpty()) {
+ out << "[i]";
+ }
out << ";" << endl;
return result;
@@ -1320,13 +1505,13 @@ QString indent(QString text, int spaces)
QTextStream out(&result, QIODevice::WriteOnly);
QTextStream in(&text, QIODevice::ReadOnly);
QString currLine;
- while ( !in.atEnd() )
- {
- currLine = in.readLine();
- if (!currLine.isEmpty())
- for (int i=0; i < spaces; i++)
- out << " ";
- out << currLine << endl;
+ while (!in.atEnd()) {
+ currLine = in.readLine();
+ if (!currLine.isEmpty())
+ for (int i = 0; i < spaces; i++) {
+ out << " ";
+ }
+ out << currLine << endl;
}
return result;
}
@@ -1335,1004 +1520,1040 @@ QString indent(QString text, int spaces)
// there are namespaces in p_ns
void beginNamespaces(const QString &p_ns, QTextStream &p_out)
{
- if ( !p_ns.isEmpty() ) {
- const QStringList nameSpaces = p_ns.split( "::" );
- foreach (const QString &ns, nameSpaces )
- p_out << "namespace " << ns << " {" << endl;
- p_out << endl;
- }
+ if (!p_ns.isEmpty()) {
+ const QStringList nameSpaces = p_ns.split("::");
+ foreach (const QString &ns, nameSpaces) {
+ p_out << "namespace " << ns << " {" << endl;
+ }
+ p_out << endl;
+ }
}
// adds as many '}' lines to p_out as
// there are namespaces in p_ns
void endNamespaces(const QString &p_ns, QTextStream &p_out)
{
- if ( !p_ns.isEmpty() ) {
- const int namespaceCount = p_ns.count( "::" ) + 1;
- for ( int i = 0; i < namespaceCount; ++i )
- p_out << "}" << endl;
- p_out << endl;
- }
+ if (!p_ns.isEmpty()) {
+ const int namespaceCount = p_ns.count("::") + 1;
+ for (int i = 0; i < namespaceCount; ++i) {
+ p_out << "}" << endl;
+ }
+ p_out << endl;
+ }
}
-
-int main( int argc, char **argv )
+int main(int argc, char **argv)
{
- QCoreApplication app(argc, argv);
+ QCoreApplication app(argc, argv);
- validNameRegexp = new QRegExp("[a-zA-Z_][a-zA-Z0-9_]*");
+ validNameRegexp = new QRegExp("[a-zA-Z_][a-zA-Z0-9_]*");
- QString directoryName, inputFilename, codegenFilename;
- parseArgs(app.arguments(), directoryName, inputFilename, codegenFilename);
+ QString directoryName, inputFilename, codegenFilename;
+ parseArgs(app.arguments(), directoryName, inputFilename, codegenFilename);
- QString baseDir = directoryName;
+ QString baseDir = directoryName;
#ifdef Q_OS_WIN
- if (!baseDir.endsWith('/') && !baseDir.endsWith('\\'))
+ if (!baseDir.endsWith('/') && !baseDir.endsWith('\\'))
#else
- if (!baseDir.endsWith('/'))
+ if (!baseDir.endsWith('/'))
#endif
- baseDir.append("/");
-
- if (!codegenFilename.endsWith(QLatin1String(".kcfgc")))
- {
- cerr << "Codegen options file must have extension .kcfgc" << endl;
- return 1;
- }
- QString baseName = QFileInfo(codegenFilename).fileName();
- baseName = baseName.left(baseName.length() - 6);
-
- CfgConfig cfg = CfgConfig( codegenFilename );
-
- QFile input( inputFilename );
-
- QDomDocument doc;
- QString errorMsg;
- int errorRow;
- int errorCol;
- if ( !doc.setContent( &input, &errorMsg, &errorRow, &errorCol ) ) {
- cerr << "Unable to load document." << endl;
- cerr << "Parse error in " << inputFilename << ", line " << errorRow << ", col " << errorCol << ": " << errorMsg << endl;
- return 1;
- }
-
- QDomElement cfgElement = doc.documentElement();
-
- if ( cfgElement.isNull() ) {
- cerr << "No document in kcfg file" << endl;
- return 1;
- }
-
- QString cfgFileName;
- bool cfgFileNameArg = false;
- QList<Param> parameters;
- QList<Signal> signalList;
- QStringList includes;
- bool hasSignals = false;
-
- QList<CfgEntry*> entries;
-
- for ( QDomElement e = cfgElement.firstChildElement(); !e.isNull(); e = e.nextSiblingElement() ) {
- QString tag = e.tagName();
-
- if ( tag == "include" ) {
- QString includeFile = e.text();
- if (!includeFile.isEmpty())
- includes.append(includeFile);
-
- } else if ( tag == "kcfgfile" ) {
- cfgFileName = e.attribute( "name" );
- cfgFileNameArg = e.attribute( "arg" ).toLower() == "true";
- for( QDomElement e2 = e.firstChildElement(); !e2.isNull(); e2 = e2.nextSiblingElement() ) {
- if ( e2.tagName() == "parameter" ) {
- Param p;
- p.name = e2.attribute( "name" );
- p.type = e2.attribute( "type" );
- if (p.type.isEmpty())
- p.type = "String";
- parameters.append( p );
- }
- }
-
- } else if ( tag == "group" ) {
- QString group = e.attribute( "name" );
- if ( group.isEmpty() ) {
- cerr << "Group without name" << endl;
+ baseDir.append("/");
+
+ if (!codegenFilename.endsWith(QLatin1String(".kcfgc"))) {
+ cerr << "Codegen options file must have extension .kcfgc" << endl;
return 1;
- }
- for( QDomElement e2 = e.firstChildElement(); !e2.isNull(); e2 = e2.nextSiblingElement() ) {
- if ( e2.tagName() != "entry" ) continue;
- CfgEntry *entry = parseEntry( group, e2, cfg );
- if ( entry ) entries.append( entry );
- else {
- cerr << "Can not parse entry." << endl;
- return 1;
+ }
+ QString baseName = QFileInfo(codegenFilename).fileName();
+ baseName = baseName.left(baseName.length() - 6);
+
+ CfgConfig cfg = CfgConfig(codegenFilename);
+
+ QFile input(inputFilename);
+
+ QDomDocument doc;
+ QString errorMsg;
+ int errorRow;
+ int errorCol;
+ if (!doc.setContent(&input, &errorMsg, &errorRow, &errorCol)) {
+ cerr << "Unable to load document." << endl;
+ cerr << "Parse error in " << inputFilename << ", line " << errorRow << ", col " << errorCol << ": " << errorMsg << endl;
+ return 1;
+ }
+
+ QDomElement cfgElement = doc.documentElement();
+
+ if (cfgElement.isNull()) {
+ cerr << "No document in kcfg file" << endl;
+ return 1;
+ }
+
+ QString cfgFileName;
+ bool cfgFileNameArg = false;
+ QList<Param> parameters;
+ QList<Signal> signalList;
+ QStringList includes;
+ bool hasSignals = false;
+
+ QList<CfgEntry *> entries;
+
+ for (QDomElement e = cfgElement.firstChildElement(); !e.isNull(); e = e.nextSiblingElement()) {
+ QString tag = e.tagName();
+
+ if (tag == "include") {
+ QString includeFile = e.text();
+ if (!includeFile.isEmpty()) {
+ includes.append(includeFile);
+ }
+
+ } else if (tag == "kcfgfile") {
+ cfgFileName = e.attribute("name");
+ cfgFileNameArg = e.attribute("arg").toLower() == "true";
+ for (QDomElement e2 = e.firstChildElement(); !e2.isNull(); e2 = e2.nextSiblingElement()) {
+ if (e2.tagName() == "parameter") {
+ Param p;
+ p.name = e2.attribute("name");
+ p.type = e2.attribute("type");
+ if (p.type.isEmpty()) {
+ p.type = "String";
+ }
+ parameters.append(p);
+ }
+ }
+
+ } else if (tag == "group") {
+ QString group = e.attribute("name");
+ if (group.isEmpty()) {
+ cerr << "Group without name" << endl;
+ return 1;
+ }
+ for (QDomElement e2 = e.firstChildElement(); !e2.isNull(); e2 = e2.nextSiblingElement()) {
+ if (e2.tagName() != "entry") {
+ continue;
+ }
+ CfgEntry *entry = parseEntry(group, e2, cfg);
+ if (entry) {
+ entries.append(entry);
+ } else {
+ cerr << "Can not parse entry." << endl;
+ return 1;
+ }
+ }
+ } else if (tag == "signal") {
+ QString signalName = e.attribute("name");
+ if (signalName.isEmpty()) {
+ cerr << "Signal without name." << endl;
+ return 1;
+ }
+ Signal theSignal;
+ theSignal.name = signalName;
+
+ for (QDomElement e2 = e.firstChildElement(); !e2.isNull(); e2 = e2.nextSiblingElement()) {
+ if (e2.tagName() == "argument") {
+ SignalArguments argument;
+ argument.type = e2.attribute("type");
+ if (argument.type.isEmpty()) {
+ cerr << "Signal argument without type." << endl;
+ return 1;
+ }
+ argument.variableName = e2.text();
+ theSignal.arguments.append(argument);
+ } else if (e2.tagName() == "label") {
+ theSignal.label = e2.text();
+ }
+ }
+ signalList.append(theSignal);
}
- }
}
- else if ( tag == "signal" ) {
- QString signalName = e.attribute( "name" );
- if ( signalName.isEmpty() ) {
- cerr << "Signal without name." << endl;
+
+ if (cfg.className.isEmpty()) {
+ cerr << "Class name missing" << endl;
return 1;
- }
- Signal theSignal;
- theSignal.name = signalName;
-
- for( QDomElement e2 = e.firstChildElement(); !e2.isNull(); e2 = e2.nextSiblingElement() ) {
- if ( e2.tagName() == "argument") {
- SignalArguments argument;
- argument.type = e2.attribute("type");
- if ( argument.type.isEmpty() ) {
- cerr << "Signal argument without type." << endl;
- return 1;
- }
- argument.variableName = e2.text();
- theSignal.arguments.append(argument);
- }
- else if( e2.tagName() == "label") {
- theSignal.label = e2.text();
- }
- }
- signalList.append(theSignal);
- }
- }
-
- if ( cfg.className.isEmpty() ) {
- cerr << "Class name missing" << endl;
- return 1;
- }
-
- if ( cfg.singleton && !parameters.isEmpty() ) {
- cerr << "Singleton class can not have parameters" << endl;
- return 1;
- }
-
- if ( !cfgFileName.isEmpty() && cfgFileNameArg)
- {
- cerr << "Having both a fixed filename and a filename as argument is not possible." << endl;
- return 1;
- }
-
- if ( entries.isEmpty() ) {
- cerr << "No entries." << endl;
- }
+ }
+
+ if (cfg.singleton && !parameters.isEmpty()) {
+ cerr << "Singleton class can not have parameters" << endl;
+ return 1;
+ }
+
+ if (!cfgFileName.isEmpty() && cfgFileNameArg) {
+ cerr << "Having both a fixed filename and a filename as argument is not possible." << endl;
+ return 1;
+ }
+
+ if (entries.isEmpty()) {
+ cerr << "No entries." << endl;
+ }
#if 0
- CfgEntry *cfg;
- for( cfg = entries.first(); cfg; cfg = entries.next() ) {
- cfg->dump();
- }
+ CfgEntry *cfg;
+ for (cfg = entries.first(); cfg; cfg = entries.next()) {
+ cfg->dump();
+ }
#endif
- hasSignals = !signalList.empty();
- QString headerFileName = baseName + ".h";
- QString implementationFileName = baseName + ".cpp";
- QString mocFileName = baseName + ".moc";
- QString cppPreamble; // code to be inserted at the beginnin of the cpp file, e.g. initialization of static values
-
- QFile header( baseDir + headerFileName );
- if ( !header.open( QIODevice::WriteOnly ) ) {
- cerr << "Can not open '" << baseDir << headerFileName << "for writing." << endl;
- return 1;
- }
-
- QTextStream h( &header );
-
- h << "// This file is generated by kconfig_compiler from " << QFileInfo(inputFilename).fileName() << "." << endl;
- h << "// All changes you do to this file will be lost." << endl;
-
- h << "#ifndef " << ( !cfg.nameSpace.isEmpty() ? QString (QString(cfg.nameSpace).replace( "::", "_" ).toUpper() + '_') : "" )
- << cfg.className.toUpper() << "_H" << endl;
- h << "#define " << ( !cfg.nameSpace.isEmpty() ? QString (QString(cfg.nameSpace).replace( "::", "_" ).toUpper() + '_') : "" )
- << cfg.className.toUpper() << "_H" << endl << endl;
-
- // Includes
- QStringList::ConstIterator it;
- for( it = cfg.headerIncludes.constBegin(); it != cfg.headerIncludes.constEnd(); ++it ) {
- if ( (*it).startsWith('"') )
- h << "#include " << *it << endl;
- else
- h << "#include <" << *it << ">" << endl;
- }
-
- if ( cfg.headerIncludes.count() > 0 ) h << endl;
-
- if ( !cfg.singleton && parameters.isEmpty() )
- h << "#include <qglobal.h>" << endl;
-
- if ( cfg.inherits=="KCoreConfigSkeleton" ) {
- h << "#include <kcoreconfigskeleton.h>" << endl;
- } else {
- h << "#include <kconfigskeleton.h>" << endl;
- }
-
- h << "#include <QCoreApplication>" << endl;
- h << "#include <QDebug>" << endl << endl;
-
- // Includes
- for( it = includes.constBegin(); it != includes.constEnd(); ++it ) {
- if ( (*it).startsWith('"') )
- h << "#include " << *it << endl;
- else
- h << "#include <" << *it << ">" << endl;
- }
-
- beginNamespaces(cfg.nameSpace, h);
-
- // Private class declaration
- if ( cfg.dpointer )
- h << "class " << cfg.className << "Private;" << endl << endl;
-
- // Class declaration header
- h << "class " << cfg.visibility << cfg.className << " : public " << cfg.inherits << endl;
-
- h << "{" << endl;
- // Add Q_OBJECT macro if the config need signals.
- if( hasSignals )
- h << " Q_OBJECT" << endl;
- h << " public:" << endl;
-
- // enums
- QList<CfgEntry*>::ConstIterator itEntry;
- for( itEntry = entries.constBegin(); itEntry != entries.constEnd(); ++itEntry ) {
- const CfgEntry::Choices &choices = (*itEntry)->choices();
- const QList<CfgEntry::Choice> chlist = choices.choices;
- if ( !chlist.isEmpty() ) {
- QStringList values;
- QList<CfgEntry::Choice>::ConstIterator itChoice;
- for( itChoice = chlist.constBegin(); itChoice != chlist.constEnd(); ++itChoice ) {
- values.append( choices.prefix + (*itChoice).name );
- }
- if ( choices.name().isEmpty() ) {
- if ( cfg.globalEnums ) {
- h << " enum " << enumName( (*itEntry)->name(), (*itEntry)->choices() ) << " { " << values.join( ", " ) << " };" << endl;
+ hasSignals = !signalList.empty();
+ QString headerFileName = baseName + ".h";
+ QString implementationFileName = baseName + ".cpp";
+ QString mocFileName = baseName + ".moc";
+ QString cppPreamble; // code to be inserted at the beginnin of the cpp file, e.g. initialization of static values
+
+ QFile header(baseDir + headerFileName);
+ if (!header.open(QIODevice::WriteOnly)) {
+ cerr << "Can not open '" << baseDir << headerFileName << "for writing." << endl;
+ return 1;
+ }
+
+ QTextStream h(&header);
+
+ h << "// This file is generated by kconfig_compiler from " << QFileInfo(inputFilename).fileName() << "." << endl;
+ h << "// All changes you do to this file will be lost." << endl;
+
+ h << "#ifndef " << (!cfg.nameSpace.isEmpty() ? QString(QString(cfg.nameSpace).replace("::", "_").toUpper() + '_') : "")
+ << cfg.className.toUpper() << "_H" << endl;
+ h << "#define " << (!cfg.nameSpace.isEmpty() ? QString(QString(cfg.nameSpace).replace("::", "_").toUpper() + '_') : "")
+ << cfg.className.toUpper() << "_H" << endl << endl;
+
+ // Includes
+ QStringList::ConstIterator it;
+ for (it = cfg.headerIncludes.constBegin(); it != cfg.headerIncludes.constEnd(); ++it) {
+ if ((*it).startsWith('"')) {
+ h << "#include " << *it << endl;
} else {
- // Create an automatically named enum
- h << " class " << enumName( (*itEntry)->name(), (*itEntry)->choices() ) << endl;
- h << " {" << endl;
- h << " public:" << endl;
- h << " enum type { " << values.join( ", " ) << ", COUNT };" << endl;
- h << " };" << endl;
- }
- } else if ( !choices.external() ) {
- // Create a named enum
- h << " enum " << enumName( (*itEntry)->name(), (*itEntry)->choices() ) << " { " << values.join( ", " ) << " };" << endl;
- }
- }
- const QStringList values = (*itEntry)->paramValues();
- if ( !values.isEmpty() ) {
- if ( cfg.globalEnums ) {
- // ### FIXME!!
- // make the following string table an index-based string search!
- // ###
- h << " enum " << enumName( (*itEntry)->param() ) << " { " << values.join( ", " ) << " };" << endl;
- h << " static const char* const " << enumName( (*itEntry)->param() ) << "ToString[];" << endl;
- cppPreamble += "const char* const " + cfg.className + "::" + enumName( (*itEntry)->param() ) +
- "ToString[] = { \"" + values.join( "\", \"" ) + "\" };\n";
- } else {
- h << " class " << enumName( (*itEntry)->param() ) << endl;
- h << " {" << endl;
- h << " public:" << endl;
- h << " enum type { " << values.join( ", " ) << ", COUNT };" << endl;
- h << " static const char* const enumToString[];" << endl;
- h << " };" << endl;
- cppPreamble += "const char* const " + cfg.className + "::" + enumName( (*itEntry)->param() ) +
- "::enumToString[] = { \"" + values.join( "\", \"" ) + "\" };\n";
- }
- }
- }
- if ( hasSignals ) {
- h << "\n enum {" << endl;
- unsigned val = 1;
- QList<Signal>::ConstIterator it, itEnd = signalList.constEnd();
- for ( it = signalList.constBegin(); it != itEnd; val <<= 1) {
- if ( !val ) {
- cerr << "Too many signals to create unique bit masks" << endl;
- exit(1);
- }
- Signal signal = *it;
- h << " " << signalEnumName(signal.name) << " = 0x" << hex << val;
- if ( ++it != itEnd )
- h << ",";
- h << endl;
- }
- h << " };" << dec << endl;
- }
- h << endl;
- // Constructor or singleton accessor
- if ( !cfg.singleton ) {
- h << " " << cfg.className << "(";
- if (cfgFileNameArg)
- {
- if(cfg.forceStringFilename)
- h << " const QString &cfgfilename"
- << (parameters.isEmpty() ? " = QString()" : ", ");
- else
- h << " KSharedConfig::Ptr config"
- << (parameters.isEmpty() ? " = KSharedConfig::openConfig()" : ", ");
+ h << "#include <" << *it << ">" << endl;
+ }
}
- for (QList<Param>::ConstIterator it = parameters.constBegin();
- it != parameters.constEnd(); ++it)
- {
- if (it != parameters.constBegin())
- h << ",";
- h << " " << param((*it).type) << " " << (*it).name;
- }
- h << " );" << endl;
- } else {
- h << " static " << cfg.className << " *self();" << endl;
- if (cfgFileNameArg)
- {
- h << " static void instance(const QString& cfgfilename);" << endl;
+
+ if (cfg.headerIncludes.count() > 0) {
+ h << endl;
}
- }
- // Destructor
- h << " ~" << cfg.className << "();" << endl << endl;
+ if (!cfg.singleton && parameters.isEmpty()) {
+ h << "#include <qglobal.h>" << endl;
+ }
- // global variables
- if (cfg.staticAccessors)
- This = "self()->";
- else
- Const = " const";
+ if (cfg.inherits == "KCoreConfigSkeleton") {
+ h << "#include <kcoreconfigskeleton.h>" << endl;
+ } else {
+ h << "#include <kconfigskeleton.h>" << endl;
+ }
- for( itEntry = entries.constBegin(); itEntry != entries.constEnd(); ++itEntry ) {
- QString n = (*itEntry)->name();
- QString t = (*itEntry)->type();
+ h << "#include <QCoreApplication>" << endl;
+ h << "#include <QDebug>" << endl << endl;
- // Manipulator
- if (cfg.allMutators || cfg.mutators.contains(n))
- {
- h << " /**" << endl;
- h << " Set " << (*itEntry)->label() << endl;
- h << " */" << endl;
- if (cfg.staticAccessors)
- h << " static" << endl;
- h << " void " << setFunction(n) << "( ";
- if (!(*itEntry)->param().isEmpty())
- h << cppType((*itEntry)->paramType()) << " i, ";
- if (cfg.useEnumTypes && t == "Enum")
- h << enumType(*itEntry, cfg.globalEnums);
- else
- h << param( t );
- h << " v )";
- // function body inline only if not using dpointer
- // for BC mode
- if ( !cfg.dpointer )
- {
- h << endl << " {" << endl;
- h << indent(memberMutatorBody(*itEntry, cfg), 6 );
- h << " }" << endl;
- }
- else
- {
- h << ";" << endl;
- }
- }
- h << endl;
- // Accessor
- h << " /**" << endl;
- h << " Get " << (*itEntry)->label() << endl;
- h << " */" << endl;
- if (cfg.staticAccessors)
- h << " static" << endl;
- h << " ";
- if (cfg.useEnumTypes && t == "Enum")
- h << enumType(*itEntry, cfg.globalEnums);
- else
- h << cppType(t);
- h << " " << getFunction(n) << "(";
- if (!(*itEntry)->param().isEmpty())
- h << " " << cppType((*itEntry)->paramType()) <<" i ";
- h << ")" << Const;
- // function body inline only if not using dpointer
- // for BC mode
- if ( !cfg.dpointer )
- {
- h << endl << " {" << endl;
- h << indent(memberAccessorBody(*itEntry, cfg.globalEnums, cfg), 6 );
- h << " }" << endl;
+ // Includes
+ for (it = includes.constBegin(); it != includes.constEnd(); ++it) {
+ if ((*it).startsWith('"')) {
+ h << "#include " << *it << endl;
+ } else {
+ h << "#include <" << *it << ">" << endl;
+ }
}
- else
- {
- h << ";" << endl;
- }
-
- // Default value Accessor
- if ((cfg.allDefaultGetters || cfg.defaultGetters.contains(n)) && !(*itEntry)->defaultValue().isEmpty()) {
- h << endl;
- h << " /**" << endl;
- h << " Get " << (*itEntry)->label() << " default value" << endl;
- h << " */" << endl;
- if (cfg.staticAccessors)
- h << " static" << endl;
- h << " ";
- if (cfg.useEnumTypes && t == "Enum")
- h << enumType(*itEntry, cfg.globalEnums);
- else
- h << cppType(t);
- h << " " << getDefaultFunction(n) << "(";
- if ( !(*itEntry)->param().isEmpty() )
- h << " " << cppType( (*itEntry)->paramType() ) <<" i ";
- h << ")" << Const << endl;
- h << " {" << endl;
- h << " return ";
- if (cfg.useEnumTypes && t == "Enum")
- h << "static_cast<" << enumType(*itEntry, cfg.globalEnums) << ">(";
- h << getDefaultFunction(n) << "_helper(";
- if ( !(*itEntry)->param().isEmpty() )
- h << " i ";
- h << ")";
- if (cfg.useEnumTypes && t == "Enum")
- h << ")";
- h << ";" << endl;
- h << " }" << endl;
- }
-
- // Item accessor
- if ( cfg.itemAccessors ) {
- h << endl;
- h << " /**" << endl;
- h << " Get Item object corresponding to " << n << "()"
- << endl;
- h << " */" << endl;
- h << " Item" << itemType( (*itEntry)->type() ) << " *"
- << getFunction( n ) << "Item(";
- if (!(*itEntry)->param().isEmpty()) {
- h << " " << cppType((*itEntry)->paramType()) << " i ";
- }
- h << ")";
- if ( !cfg.dpointer )
- {
- h << endl << " {" << endl;
- h << indent( itemAccessorBody((*itEntry), cfg), 6);
- h << " }" << endl;
- }
- else
- {
- h << ";" << endl;
- }
+
+ beginNamespaces(cfg.nameSpace, h);
+
+ // Private class declaration
+ if (cfg.dpointer) {
+ h << "class " << cfg.className << "Private;" << endl << endl;
}
+ // Class declaration header
+ h << "class " << cfg.visibility << cfg.className << " : public " << cfg.inherits << endl;
+
+ h << "{" << endl;
+ // Add Q_OBJECT macro if the config need signals.
+ if (hasSignals) {
+ h << " Q_OBJECT" << endl;
+ }
+ h << " public:" << endl;
+
+ // enums
+ QList<CfgEntry *>::ConstIterator itEntry;
+ for (itEntry = entries.constBegin(); itEntry != entries.constEnd(); ++itEntry) {
+ const CfgEntry::Choices &choices = (*itEntry)->choices();
+ const QList<CfgEntry::Choice> chlist = choices.choices;
+ if (!chlist.isEmpty()) {
+ QStringList values;
+ QList<CfgEntry::Choice>::ConstIterator itChoice;
+ for (itChoice = chlist.constBegin(); itChoice != chlist.constEnd(); ++itChoice) {
+ values.append(choices.prefix + (*itChoice).name);
+ }
+ if (choices.name().isEmpty()) {
+ if (cfg.globalEnums) {
+ h << " enum " << enumName((*itEntry)->name(), (*itEntry)->choices()) << " { " << values.join(", ") << " };" << endl;
+ } else {
+ // Create an automatically named enum
+ h << " class " << enumName((*itEntry)->name(), (*itEntry)->choices()) << endl;
+ h << " {" << endl;
+ h << " public:" << endl;
+ h << " enum type { " << values.join(", ") << ", COUNT };" << endl;
+ h << " };" << endl;
+ }
+ } else if (!choices.external()) {
+ // Create a named enum
+ h << " enum " << enumName((*itEntry)->name(), (*itEntry)->choices()) << " { " << values.join(", ") << " };" << endl;
+ }
+ }
+ const QStringList values = (*itEntry)->paramValues();
+ if (!values.isEmpty()) {
+ if (cfg.globalEnums) {
+ // ### FIXME!!
+ // make the following string table an index-based string search!
+ // ###
+ h << " enum " << enumName((*itEntry)->param()) << " { " << values.join(", ") << " };" << endl;
+ h << " static const char* const " << enumName((*itEntry)->param()) << "ToString[];" << endl;
+ cppPreamble += "const char* const " + cfg.className + "::" + enumName((*itEntry)->param()) +
+ "ToString[] = { \"" + values.join("\", \"") + "\" };\n";
+ } else {
+ h << " class " << enumName((*itEntry)->param()) << endl;
+ h << " {" << endl;
+ h << " public:" << endl;
+ h << " enum type { " << values.join(", ") << ", COUNT };" << endl;
+ h << " static const char* const enumToString[];" << endl;
+ h << " };" << endl;
+ cppPreamble += "const char* const " + cfg.className + "::" + enumName((*itEntry)->param()) +
+ "::enumToString[] = { \"" + values.join("\", \"") + "\" };\n";
+ }
+ }
+ }
+ if (hasSignals) {
+ h << "\n enum {" << endl;
+ unsigned val = 1;
+ QList<Signal>::ConstIterator it, itEnd = signalList.constEnd();
+ for (it = signalList.constBegin(); it != itEnd; val <<= 1) {
+ if (!val) {
+ cerr << "Too many signals to create unique bit masks" << endl;
+ exit(1);
+ }
+ Signal signal = *it;
+ h << " " << signalEnumName(signal.name) << " = 0x" << hex << val;
+ if (++it != itEnd) {
+ h << ",";
+ }
+ h << endl;
+ }
+ h << " };" << dec << endl;
+ }
h << endl;
- }
+ // Constructor or singleton accessor
+ if (!cfg.singleton) {
+ h << " " << cfg.className << "(";
+ if (cfgFileNameArg) {
+ if (cfg.forceStringFilename)
+ h << " const QString &cfgfilename"
+ << (parameters.isEmpty() ? " = QString()" : ", ");
+ else
+ h << " KSharedConfig::Ptr config"
+ << (parameters.isEmpty() ? " = KSharedConfig::openConfig()" : ", ");
+ }
+ for (QList<Param>::ConstIterator it = parameters.constBegin();
+ it != parameters.constEnd(); ++it) {
+ if (it != parameters.constBegin()) {
+ h << ",";
+ }
+ h << " " << param((*it).type) << " " << (*it).name;
+ }
+ h << " );" << endl;
+ } else {
+ h << " static " << cfg.className << " *self();" << endl;
+ if (cfgFileNameArg) {
+ h << " static void instance(const QString& cfgfilename);" << endl;
+ }
+ }
+ // Destructor
+ h << " ~" << cfg.className << "();" << endl << endl;
- // Signal definition.
- if( hasSignals ) {
- h << endl;
- h << " Q_SIGNALS:";
- Q_FOREACH(const Signal &signal, signalList) {
- h << endl;
- if ( !signal.label.isEmpty() ) {
+ // global variables
+ if (cfg.staticAccessors) {
+ This = "self()->";
+ } else {
+ Const = " const";
+ }
+
+ for (itEntry = entries.constBegin(); itEntry != entries.constEnd(); ++itEntry) {
+ QString n = (*itEntry)->name();
+ QString t = (*itEntry)->type();
+
+ // Manipulator
+ if (cfg.allMutators || cfg.mutators.contains(n)) {
+ h << " /**" << endl;
+ h << " Set " << (*itEntry)->label() << endl;
+ h << " */" << endl;
+ if (cfg.staticAccessors) {
+ h << " static" << endl;
+ }
+ h << " void " << setFunction(n) << "( ";
+ if (!(*itEntry)->param().isEmpty()) {
+ h << cppType((*itEntry)->paramType()) << " i, ";
+ }
+ if (cfg.useEnumTypes && t == "Enum") {
+ h << enumType(*itEntry, cfg.globalEnums);
+ } else {
+ h << param(t);
+ }
+ h << " v )";
+ // function body inline only if not using dpointer
+ // for BC mode
+ if (!cfg.dpointer) {
+ h << endl << " {" << endl;
+ h << indent(memberMutatorBody(*itEntry, cfg), 6);
+ h << " }" << endl;
+ } else {
+ h << ";" << endl;
+ }
+ }
+ h << endl;
+ // Accessor
h << " /**" << endl;
- h << " " << signal.label << endl;
+ h << " Get " << (*itEntry)->label() << endl;
h << " */" << endl;
- }
- h << " void " << signal.name << "(";
- QList<SignalArguments>::ConstIterator it, itEnd = signal.arguments.constEnd();
- for ( it = signal.arguments.constBegin(); it != itEnd; ) {
- SignalArguments argument = *it;
- QString type = param(argument.type);
- if ( cfg.useEnumTypes && argument.type == "Enum" ) {
- for ( int i = 0, end = entries.count(); i < end; ++i ) {
- if ( entries[i]->name() == argument.variableName ) {
- type = enumType(entries[i], cfg.globalEnums);
- break;
+ if (cfg.staticAccessors) {
+ h << " static" << endl;
+ }
+ h << " ";
+ if (cfg.useEnumTypes && t == "Enum") {
+ h << enumType(*itEntry, cfg.globalEnums);
+ } else {
+ h << cppType(t);
+ }
+ h << " " << getFunction(n) << "(";
+ if (!(*itEntry)->param().isEmpty()) {
+ h << " " << cppType((*itEntry)->paramType()) << " i ";
+ }
+ h << ")" << Const;
+ // function body inline only if not using dpointer
+ // for BC mode
+ if (!cfg.dpointer) {
+ h << endl << " {" << endl;
+ h << indent(memberAccessorBody(*itEntry, cfg.globalEnums, cfg), 6);
+ h << " }" << endl;
+ } else {
+ h << ";" << endl;
+ }
+
+ // Default value Accessor
+ if ((cfg.allDefaultGetters || cfg.defaultGetters.contains(n)) && !(*itEntry)->defaultValue().isEmpty()) {
+ h << endl;
+ h << " /**" << endl;
+ h << " Get " << (*itEntry)->label() << " default value" << endl;
+ h << " */" << endl;
+ if (cfg.staticAccessors) {
+ h << " static" << endl;
+ }
+ h << " ";
+ if (cfg.useEnumTypes && t == "Enum") {
+ h << enumType(*itEntry, cfg.globalEnums);
+ } else {
+ h << cppType(t);
+ }
+ h << " " << getDefaultFunction(n) << "(";
+ if (!(*itEntry)->param().isEmpty()) {
+ h << " " << cppType((*itEntry)->paramType()) << " i ";
+ }
+ h << ")" << Const << endl;
+ h << " {" << endl;
+ h << " return ";
+ if (cfg.useEnumTypes && t == "Enum") {
+ h << "static_cast<" << enumType(*itEntry, cfg.globalEnums) << ">(";
+ }
+ h << getDefaultFunction(n) << "_helper(";
+ if (!(*itEntry)->param().isEmpty()) {
+ h << " i ";
+ }
+ h << ")";
+ if (cfg.useEnumTypes && t == "Enum") {
+ h << ")";
}
- }
+ h << ";" << endl;
+ h << " }" << endl;
}
- h << type << " " << argument.variableName;
- if ( ++it != itEnd ) {
- h << ", ";
+
+ // Item accessor
+ if (cfg.itemAccessors) {
+ h << endl;
+ h << " /**" << endl;
+ h << " Get Item object corresponding to " << n << "()"
+ << endl;
+ h << " */" << endl;
+ h << " Item" << itemType((*itEntry)->type()) << " *"
+ << getFunction(n) << "Item(";
+ if (!(*itEntry)->param().isEmpty()) {
+ h << " " << cppType((*itEntry)->paramType()) << " i ";
+ }
+ h << ")";
+ if (!cfg.dpointer) {
+ h << endl << " {" << endl;
+ h << indent(itemAccessorBody((*itEntry), cfg), 6);
+ h << " }" << endl;
+ } else {
+ h << ";" << endl;
+ }
}
- }
- h << ");" << endl;
+
+ h << endl;
}
- h << endl;
- }
-
- h << " protected:" << endl;
-
- // Private constructor for singleton
- if ( cfg.singleton ) {
- h << " " << cfg.className << "(";
- if ( cfgFileNameArg )
- h << "const QString& arg";
- h << ");" << endl;
- h << " friend class " << cfg.className << "Helper;" << endl << endl;
- }
-
- if ( hasSignals ) {
- h << " virtual bool usrWriteConfig();" << endl;
- }
-
- // Member variables
- if ( !cfg.memberVariables.isEmpty() && cfg.memberVariables != "private" && cfg.memberVariables != "dpointer") {
- h << " " << cfg.memberVariables << ":" << endl;
- }
-
- // Class Parameters
- for (QList<Param>::ConstIterator it = parameters.constBegin();
- it != parameters.constEnd(); ++it)
- {
- h << " " << cppType((*it).type) << " mParam" << (*it).name << ";" << endl;
- }
-
- if ( cfg.memberVariables != "dpointer" )
- {
- QString group;
- for( itEntry = entries.constBegin(); itEntry != entries.constEnd(); ++itEntry ) {
- if ( (*itEntry)->group() != group ) {
- group = (*itEntry)->group();
+
+ // Signal definition.
+ if (hasSignals) {
+ h << endl;
+ h << " Q_SIGNALS:";
+ Q_FOREACH (const Signal &signal, signalList) {
+ h << endl;
+ if (!signal.label.isEmpty()) {
+ h << " /**" << endl;
+ h << " " << signal.label << endl;
+ h << " */" << endl;
+ }
+ h << " void " << signal.name << "(";
+ QList<SignalArguments>::ConstIterator it, itEnd = signal.arguments.constEnd();
+ for (it = signal.arguments.constBegin(); it != itEnd;) {
+ SignalArguments argument = *it;
+ QString type = param(argument.type);
+ if (cfg.useEnumTypes && argument.type == "Enum") {
+ for (int i = 0, end = entries.count(); i < end; ++i) {
+ if (entries[i]->name() == argument.variableName) {
+ type = enumType(entries[i], cfg.globalEnums);
+ break;
+ }
+ }
+ }
+ h << type << " " << argument.variableName;
+ if (++it != itEnd) {
+ h << ", ";
+ }
+ }
+ h << ");" << endl;
+ }
h << endl;
- h << " // " << group << endl;
- }
- h << " " << cppType( (*itEntry)->type() ) << " " << varName( (*itEntry)->name(), cfg );
- if ( !(*itEntry)->param().isEmpty() )
- {
- h << QString("[%1]").arg( (*itEntry)->paramMax()+1 );
- }
- h << ";" << endl;
-
- if ( cfg.allDefaultGetters || cfg.defaultGetters.contains((*itEntry)->name()) )
- {
- h << " ";
- if (cfg.staticAccessors)
- h << "static ";
- h << cppType((*itEntry)->type()) << " " << getDefaultFunction((*itEntry)->name()) << "_helper(";
- if ( !(*itEntry)->param().isEmpty() )
- h << " " << cppType( (*itEntry)->paramType() ) <<" i ";
- h << ")" << Const << ";" << endl;
- }
- }
-
- h << endl << " private:" << endl;
- if ( cfg.itemAccessors ) {
- for( itEntry = entries.constBegin(); itEntry != entries.constEnd(); ++itEntry ) {
- h << " Item" << itemType( (*itEntry)->type() ) << " *" << itemVar( *itEntry, cfg );
- if ( !(*itEntry)->param().isEmpty() ) h << QString("[%1]").arg( (*itEntry)->paramMax()+1 );
- h << ";" << endl;
- }
- }
- if ( hasSignals )
- h << " uint " << varName("settingsChanged", cfg) << ";" << endl;
-
- }
- else
- {
- // use a private class for both member variables and items
- h << " private:" << endl;
- for( itEntry = entries.constBegin(); itEntry != entries.constEnd(); ++itEntry ) {
- if ( cfg.allDefaultGetters || cfg.defaultGetters.contains((*itEntry)->name()) ) {
- h << " ";
- if (cfg.staticAccessors)
- h << "static ";
- h << cppType((*itEntry)->type()) << " " << getDefaultFunction((*itEntry)->name()) << "_helper(";
- if ( !(*itEntry)->param().isEmpty() )
- h << " " << cppType( (*itEntry)->paramType() ) <<" i ";
- h << ")" << Const << ";" << endl;
- }
}
- h << " " + cfg.className + "Private *d;" << endl;
- }
- if (cfg.customAddons)
- {
- h << " // Include custom additions" << endl;
- h << " #include \"" << filenameOnly(baseName) << "_addons.h\"" <<endl;
- }
+ h << " protected:" << endl;
- h << "};" << endl << endl;
+ // Private constructor for singleton
+ if (cfg.singleton) {
+ h << " " << cfg.className << "(";
+ if (cfgFileNameArg) {
+ h << "const QString& arg";
+ }
+ h << ");" << endl;
+ h << " friend class " << cfg.className << "Helper;" << endl << endl;
+ }
- endNamespaces(cfg.nameSpace, h);
+ if (hasSignals) {
+ h << " virtual bool usrWriteConfig();" << endl;
+ }
- h << "#endif" << endl << endl;
+ // Member variables
+ if (!cfg.memberVariables.isEmpty() && cfg.memberVariables != "private" && cfg.memberVariables != "dpointer") {
+ h << " " << cfg.memberVariables << ":" << endl;
+ }
+ // Class Parameters
+ for (QList<Param>::ConstIterator it = parameters.constBegin();
+ it != parameters.constEnd(); ++it) {
+ h << " " << cppType((*it).type) << " mParam" << (*it).name << ";" << endl;
+ }
- header.close();
+ if (cfg.memberVariables != "dpointer") {
+ QString group;
+ for (itEntry = entries.constBegin(); itEntry != entries.constEnd(); ++itEntry) {
+ if ((*itEntry)->group() != group) {
+ group = (*itEntry)->group();
+ h << endl;
+ h << " // " << group << endl;
+ }
+ h << " " << cppType((*itEntry)->type()) << " " << varName((*itEntry)->name(), cfg);
+ if (!(*itEntry)->param().isEmpty()) {
+ h << QString("[%1]").arg((*itEntry)->paramMax() + 1);
+ }
+ h << ";" << endl;
+
+ if (cfg.allDefaultGetters || cfg.defaultGetters.contains((*itEntry)->name())) {
+ h << " ";
+ if (cfg.staticAccessors) {
+ h << "static ";
+ }
+ h << cppType((*itEntry)->type()) << " " << getDefaultFunction((*itEntry)->name()) << "_helper(";
+ if (!(*itEntry)->param().isEmpty()) {
+ h << " " << cppType((*itEntry)->paramType()) << " i ";
+ }
+ h << ")" << Const << ";" << endl;
+ }
+ }
- QFile implementation( baseDir + implementationFileName );
- if ( !implementation.open( QIODevice::WriteOnly ) ) {
- cerr << "Can not open '" << implementationFileName << "for writing."
- << endl;
- return 1;
- }
+ h << endl << " private:" << endl;
+ if (cfg.itemAccessors) {
+ for (itEntry = entries.constBegin(); itEntry != entries.constEnd(); ++itEntry) {
+ h << " Item" << itemType((*itEntry)->type()) << " *" << itemVar(*itEntry, cfg);
+ if (!(*itEntry)->param().isEmpty()) {
+ h << QString("[%1]").arg((*itEntry)->paramMax() + 1);
+ }
+ h << ";" << endl;
+ }
+ }
+ if (hasSignals) {
+ h << " uint " << varName("settingsChanged", cfg) << ";" << endl;
+ }
- QTextStream cpp( &implementation );
+ } else {
+ // use a private class for both member variables and items
+ h << " private:" << endl;
+ for (itEntry = entries.constBegin(); itEntry != entries.constEnd(); ++itEntry) {
+ if (cfg.allDefaultGetters || cfg.defaultGetters.contains((*itEntry)->name())) {
+ h << " ";
+ if (cfg.staticAccessors) {
+ h << "static ";
+ }
+ h << cppType((*itEntry)->type()) << " " << getDefaultFunction((*itEntry)->name()) << "_helper(";
+ if (!(*itEntry)->param().isEmpty()) {
+ h << " " << cppType((*itEntry)->paramType()) << " i ";
+ }
+ h << ")" << Const << ";" << endl;
+ }
+ }
+ h << " " + cfg.className + "Private *d;" << endl;
+ }
+ if (cfg.customAddons) {
+ h << " // Include custom additions" << endl;
+ h << " #include \"" << filenameOnly(baseName) << "_addons.h\"" << endl;
+ }
- cpp << "// This file is generated by kconfig_compiler from " << QFileInfo(inputFilename).fileName() << "." << endl;
- cpp << "// All changes you do to this file will be lost." << endl << endl;
+ h << "};" << endl << endl;
- cpp << "#include \"" << headerFileName << "\"" << endl << endl;
+ endNamespaces(cfg.nameSpace, h);
- for( it = cfg.sourceIncludes.constBegin(); it != cfg.sourceIncludes.constEnd(); ++it ) {
- if ( (*it).startsWith('"') )
- cpp << "#include " << *it << endl;
- else
- cpp << "#include <" << *it << ">" << endl;
- }
+ h << "#endif" << endl << endl;
- if ( cfg.sourceIncludes.count() > 0 ) cpp << endl;
+ header.close();
- if ( cfg.setUserTexts && cfg.translationSystem==CfgConfig::KdeTranslation)
- cpp << "#include <klocalizedstring.h>" << endl << endl;
+ QFile implementation(baseDir + implementationFileName);
+ if (!implementation.open(QIODevice::WriteOnly)) {
+ cerr << "Can not open '" << implementationFileName << "for writing."
+ << endl;
+ return 1;
+ }
- // Header required by singleton implementation
- if ( cfg.singleton )
- cpp << "#include <qglobal.h>" << endl << "#include <QtCore/QFile>" << endl << endl;
- if ( cfg.singleton && cfgFileNameArg )
- cpp << "#include <QDebug>" << endl << endl;
+ QTextStream cpp(&implementation);
- if ( !cfg.nameSpace.isEmpty() )
- cpp << "using namespace " << cfg.nameSpace << ";" << endl << endl;
+ cpp << "// This file is generated by kconfig_compiler from " << QFileInfo(inputFilename).fileName() << "." << endl;
+ cpp << "// All changes you do to this file will be lost." << endl << endl;
- QString group;
+ cpp << "#include \"" << headerFileName << "\"" << endl << endl;
- // private class implementation
- if ( cfg.dpointer )
- {
- beginNamespaces(cfg.nameSpace, cpp);
- cpp << "class " << cfg.className << "Private" << endl;
- cpp << "{" << endl;
- cpp << " public:" << endl;
- for( itEntry = entries.constBegin(); itEntry != entries.constEnd(); ++itEntry ) {
- if ( (*itEntry)->group() != group ) {
- group = (*itEntry)->group();
+ for (it = cfg.sourceIncludes.constBegin(); it != cfg.sourceIncludes.constEnd(); ++it) {
+ if ((*it).startsWith('"')) {
+ cpp << "#include " << *it << endl;
+ } else {
+ cpp << "#include <" << *it << ">" << endl;
+ }
+ }
+
+ if (cfg.sourceIncludes.count() > 0) {
cpp << endl;
- cpp << " // " << group << endl;
- }
- cpp << " " << cppType( (*itEntry)->type() ) << " " << varName( (*itEntry)->name(), cfg );
- if ( !(*itEntry)->param().isEmpty() )
- {
- cpp << QString("[%1]").arg( (*itEntry)->paramMax()+1 );
- }
- cpp << ";" << endl;
- }
- cpp << endl << " // items" << endl;
- for( itEntry = entries.constBegin(); itEntry != entries.constEnd(); ++itEntry ) {
- cpp << " "+cfg.inherits+"::Item" << itemType( (*itEntry)->type() ) << " *" << itemVar( *itEntry, cfg );
- if ( !(*itEntry)->param().isEmpty() ) cpp << QString("[%1]").arg( (*itEntry)->paramMax()+1 );
- cpp << ";" << endl;
- }
- if ( hasSignals ) {
- cpp << " uint " << varName("settingsChanged", cfg) << ";" << endl;
- }
-
- cpp << "};" << endl << endl;
- endNamespaces(cfg.nameSpace, cpp);
- }
-
- // Singleton implementation
- if ( cfg.singleton ) {
- beginNamespaces(cfg.nameSpace, cpp);
- cpp << "class " << cfg.className << "Helper" << endl;
- cpp << '{' << endl;
- cpp << " public:" << endl;
- cpp << " " << cfg.className << "Helper() : q(0) {}" << endl;
- cpp << " ~" << cfg.className << "Helper() { delete q; }" << endl;
- cpp << " " << cfg.className << " *q;" << endl;
- cpp << "};" << endl;
- endNamespaces(cfg.nameSpace, cpp);
- cpp << "Q_GLOBAL_STATIC(" << cfg.className << "Helper, s_global" << cfg.className << ")" << endl;
-
- cpp << cfg.className << " *" << cfg.className << "::self()" << endl;
- cpp << "{" << endl;
- if ( cfgFileNameArg ) {
- cpp << " if (!s_global" << cfg.className << "()->q)" << endl;
- cpp << " qFatal(\"you need to call " << cfg.className << "::instance before using\");" << endl;
- } else {
- cpp << " if (!s_global" << cfg.className << "()->q) {" << endl;
- cpp << " new " << cfg.className << ';' << endl;
- cpp << " s_global" << cfg.className << "()->q->readConfig();" << endl;
- cpp << " }" << endl << endl;
}
- cpp << " return s_global" << cfg.className << "()->q;" << endl;
- cpp << "}" << endl << endl;
- if ( cfgFileNameArg ) {
- cpp << "void " << cfg.className << "::instance(const QString& cfgfilename)" << endl;
- cpp << "{" << endl;
- cpp << " if (s_global" << cfg.className << "()->q) {" << endl;
- cpp << " qDebug() << \"" << cfg.className << "::instance called after the first use - ignoring\";" << endl;
- cpp << " return;" << endl;
- cpp << " }" << endl;
- cpp << " new " << cfg.className << "(cfgfilename);" << endl;
- cpp << " s_global" << cfg.className << "()->q->readConfig();" << endl;
- cpp << "}" << endl << endl;
- }
- }
-
- if ( !cppPreamble.isEmpty() )
- cpp << cppPreamble << endl;
-
- // Constructor
- cpp << cfg.className << "::" << cfg.className << "( ";
- if ( cfgFileNameArg ) {
- if ( !cfg.singleton && ! cfg.forceStringFilename)
- cpp << " KSharedConfig::Ptr config";
- else
- cpp << " const QString& config";
- cpp << (parameters.isEmpty() ? " " : ", ");
- }
-
- for (QList<Param>::ConstIterator it = parameters.constBegin();
- it != parameters.constEnd(); ++it)
- {
- if (it != parameters.constBegin())
- cpp << ",";
- cpp << " " << param((*it).type) << " " << (*it).name;
- }
- cpp << " )" << endl;
-
- cpp << " : " << cfg.inherits << "(";
- if ( !cfgFileName.isEmpty() ) cpp << " QLatin1String( \"" << cfgFileName << "\" ";
- if ( cfgFileNameArg ) cpp << " config ";
- if ( !cfgFileName.isEmpty() ) cpp << ") ";
- cpp << ")" << endl;
-
- // Store parameters
- for (QList<Param>::ConstIterator it = parameters.constBegin();
- it != parameters.constEnd(); ++it)
- {
- cpp << " , mParam" << (*it).name << "(" << (*it).name << ")" << endl;
- }
-
- if ( hasSignals && !cfg.dpointer )
- cpp << " , " << varName("settingsChanged", cfg) << "(0)" << endl;
-
- cpp << "{" << endl;
-
- if (cfg.dpointer)
- {
- cpp << " d = new " + cfg.className + "Private;" << endl;
- if (hasSignals)
- cpp << " " << varPath("settingsChanged", cfg) << " = 0;" << endl;
- }
- // Needed in case the singleton class is used as baseclass for
- // another singleton.
- if (cfg.singleton) {
- cpp << " Q_ASSERT(!s_global" << cfg.className << "()->q);" << endl;
- cpp << " s_global" << cfg.className << "()->q = this;" << endl;
- }
-
- group.clear();
-
- for( itEntry = entries.constBegin(); itEntry != entries.constEnd(); ++itEntry ) {
- if ( (*itEntry)->group() != group ) {
- if ( !group.isEmpty() ) cpp << endl;
- group = (*itEntry)->group();
- cpp << " setCurrentGroup( " << paramString(group, parameters) << " );" << endl << endl;
- }
-
- QString key = paramString( (*itEntry)->key(), parameters );
- if ( !(*itEntry)->code().isEmpty() ) {
- cpp << (*itEntry)->code() << endl;
- }
- if ( (*itEntry)->type() == "Enum" ) {
- cpp << " QList<"+cfg.inherits+"::ItemEnum::Choice> values"
- << (*itEntry)->name() << ";" << endl;
- const QList<CfgEntry::Choice> choices = (*itEntry)->choices().choices;
- QList<CfgEntry::Choice>::ConstIterator it;
- for( it = choices.constBegin(); it != choices.constEnd(); ++it ) {
- cpp << " {" << endl;
- cpp << " "+cfg.inherits+"::ItemEnum::Choice choice;" << endl;
- cpp << " choice.name = QLatin1String(\"" << (*it).name << "\");" << endl;
- if ( cfg.setUserTexts ) {
- if ( !(*it).label.isEmpty() ) {
- cpp << " choice.label = "
- << translatedString(cfg, (*it).label, (*it).context)
- << ";" << endl;
- }
- if ( !(*it).toolTip.isEmpty() ) {
- cpp << " choice.toolTip = "
- << translatedString(cfg, (*it).toolTip, (*it).context)
- << ";" << endl;
- }
- if ( !(*it).whatsThis.isEmpty() ) {
- cpp << " choice.whatsThis = "
- << translatedString(cfg, (*it).whatsThis, (*it).context)
- << ";" << endl;
- }
- }
- cpp << " values" << (*itEntry)->name() << ".append( choice );" << endl;
- cpp << " }" << endl;
- }
- }
-
- if (!cfg.dpointer)
- cpp << itemDeclaration( *itEntry, cfg );
-
- if ( (*itEntry)->param().isEmpty() )
- {
- // Normal case
- cpp << " " << itemPath( *itEntry, cfg ) << " = "
- << newItem( (*itEntry)->type(), (*itEntry)->name(), key, (*itEntry)->defaultValue(), cfg ) << endl;
+ if (cfg.setUserTexts && cfg.translationSystem == CfgConfig::KdeTranslation) {
+ cpp << "#include <klocalizedstring.h>" << endl << endl;
+ }
- if ( !(*itEntry)->minValue().isEmpty() )
- cpp << " " << itemPath( *itEntry, cfg ) << "->setMinValue(" << (*itEntry)->minValue() << ");" << endl;
- if ( !(*itEntry)->maxValue().isEmpty() )
- cpp << " " << itemPath( *itEntry, cfg ) << "->setMaxValue(" << (*itEntry)->maxValue() << ");" << endl;
+ // Header required by singleton implementation
+ if (cfg.singleton) {
+ cpp << "#include <qglobal.h>" << endl << "#include <QtCore/QFile>" << endl << endl;
+ }
+ if (cfg.singleton && cfgFileNameArg) {
+ cpp << "#include <QDebug>" << endl << endl;
+ }
+
+ if (!cfg.nameSpace.isEmpty()) {
+ cpp << "using namespace " << cfg.nameSpace << ";" << endl << endl;
+ }
+
+ QString group;
- if ( cfg.setUserTexts )
- cpp << userTextsFunctions( (*itEntry), cfg );
+ // private class implementation
+ if (cfg.dpointer) {
+ beginNamespaces(cfg.nameSpace, cpp);
+ cpp << "class " << cfg.className << "Private" << endl;
+ cpp << "{" << endl;
+ cpp << " public:" << endl;
+ for (itEntry = entries.constBegin(); itEntry != entries.constEnd(); ++itEntry) {
+ if ((*itEntry)->group() != group) {
+ group = (*itEntry)->group();
+ cpp << endl;
+ cpp << " // " << group << endl;
+ }
+ cpp << " " << cppType((*itEntry)->type()) << " " << varName((*itEntry)->name(), cfg);
+ if (!(*itEntry)->param().isEmpty()) {
+ cpp << QString("[%1]").arg((*itEntry)->paramMax() + 1);
+ }
+ cpp << ";" << endl;
+ }
+ cpp << endl << " // items" << endl;
+ for (itEntry = entries.constBegin(); itEntry != entries.constEnd(); ++itEntry) {
+ cpp << " " + cfg.inherits + "::Item" << itemType((*itEntry)->type()) << " *" << itemVar(*itEntry, cfg);
+ if (!(*itEntry)->param().isEmpty()) {
+ cpp << QString("[%1]").arg((*itEntry)->paramMax() + 1);
+ }
+ cpp << ";" << endl;
+ }
+ if (hasSignals) {
+ cpp << " uint " << varName("settingsChanged", cfg) << ";" << endl;
+ }
- cpp << " addItem( " << itemPath( *itEntry, cfg );
- QString quotedName = (*itEntry)->name();
- addQuotes( quotedName );
- if ( quotedName != key ) cpp << ", QLatin1String( \"" << (*itEntry)->name() << "\" )";
- cpp << " );" << endl;
+ cpp << "};" << endl << endl;
+ endNamespaces(cfg.nameSpace, cpp);
}
- else
- {
- // Indexed
- for(int i = 0; i <= (*itEntry)->paramMax(); i++)
- {
- QString defaultStr;
- QString itemVarStr(itemPath( *itEntry, cfg )+QString("[%1]").arg(i));
-
- if ( !(*itEntry)->paramDefaultValue(i).isEmpty() )
- defaultStr = (*itEntry)->paramDefaultValue(i);
- else if ( !(*itEntry)->defaultValue().isEmpty() )
- defaultStr = paramString( (*itEntry)->defaultValue(), (*itEntry), i );
- else
- defaultStr = defaultValue( (*itEntry)->type() );
-
- cpp << " " << itemVarStr << " = "
- << newItem( (*itEntry)->type(), (*itEntry)->name(), paramString(key, *itEntry, i), defaultStr,cfg, QString("[%1]").arg(i) )
- << endl;
-
- if ( cfg.setUserTexts )
- cpp << userTextsFunctions( *itEntry, cfg, itemVarStr, (*itEntry)->paramName() );
-
- // Make mutators for enum parameters work by adding them with $(..) replaced by the
- // param name. The check for isImmutable in the set* functions doesn't have the param
- // name available, just the corresponding enum value (int), so we need to store the
- // param names in a separate static list!.
- cpp << " addItem( " << itemVarStr << ", QLatin1String( \"";
- if ( (*itEntry)->paramType()=="Enum" )
- cpp << (*itEntry)->paramName().replace( "$("+(*itEntry)->param()+')', "%1").arg((*itEntry)->paramValues()[i] );
- else
- cpp << (*itEntry)->paramName().replace( "$("+(*itEntry)->param()+')', "%1").arg(i);
- cpp << "\" ) );" << endl;
- }
- }
- }
-
- cpp << "}" << endl << endl;
-
- if (cfg.dpointer)
- {
- // setters and getters go in Cpp if in dpointer mode
- for( itEntry = entries.constBegin(); itEntry != entries.constEnd(); ++itEntry ) {
- QString n = (*itEntry)->name();
- QString t = (*itEntry)->type();
-
- // Manipulator
- if (cfg.allMutators || cfg.mutators.contains(n))
- {
- cpp << "void " << setFunction(n, cfg.className) << "( ";
- if ( !(*itEntry)->param().isEmpty() )
- cpp << cppType( (*itEntry)->paramType() ) << " i, ";
- if (cfg.useEnumTypes && t == "Enum")
- cpp << enumType(*itEntry, cfg.globalEnums);
- else
- cpp << param( t );
- cpp << " v )" << endl;
- // function body inline only if not using dpointer
- // for BC mode
+
+ // Singleton implementation
+ if (cfg.singleton) {
+ beginNamespaces(cfg.nameSpace, cpp);
+ cpp << "class " << cfg.className << "Helper" << endl;
+ cpp << '{' << endl;
+ cpp << " public:" << endl;
+ cpp << " " << cfg.className << "Helper() : q(0) {}" << endl;
+ cpp << " ~" << cfg.className << "Helper() { delete q; }" << endl;
+ cpp << " " << cfg.className << " *q;" << endl;
+ cpp << "};" << endl;
+ endNamespaces(cfg.nameSpace, cpp);
+ cpp << "Q_GLOBAL_STATIC(" << cfg.className << "Helper, s_global" << cfg.className << ")" << endl;
+
+ cpp << cfg.className << " *" << cfg.className << "::self()" << endl;
cpp << "{" << endl;
- cpp << indent(memberMutatorBody( *itEntry, cfg ), 6);
+ if (cfgFileNameArg) {
+ cpp << " if (!s_global" << cfg.className << "()->q)" << endl;
+ cpp << " qFatal(\"you need to call " << cfg.className << "::instance before using\");" << endl;
+ } else {
+ cpp << " if (!s_global" << cfg.className << "()->q) {" << endl;
+ cpp << " new " << cfg.className << ';' << endl;
+ cpp << " s_global" << cfg.className << "()->q->readConfig();" << endl;
+ cpp << " }" << endl << endl;
+ }
+ cpp << " return s_global" << cfg.className << "()->q;" << endl;
cpp << "}" << endl << endl;
- }
-
- // Accessor
- if (cfg.useEnumTypes && t == "Enum")
- cpp << enumType(*itEntry, cfg.globalEnums);
- else
- cpp << cppType(t);
- cpp << " " << getFunction(n, cfg.className) << "(";
- if ( !(*itEntry)->param().isEmpty() )
- cpp << " " << cppType( (*itEntry)->paramType() ) <<" i ";
- cpp << ")" << Const << endl;
- // function body inline only if not using dpointer
- // for BC mode
- cpp << "{" << endl;
- cpp << indent(memberAccessorBody( *itEntry, cfg.globalEnums, cfg ), 2);
- cpp << "}" << endl << endl;
-
- // Default value Accessor -- written by the loop below
-
- // Item accessor
- if ( cfg.itemAccessors )
- {
- cpp << endl;
- cpp << cfg.inherits+"::Item" << itemType( (*itEntry)->type() ) << " *"
- << getFunction( n, cfg.className ) << "Item(";
- if ( !(*itEntry)->param().isEmpty() ) {
- cpp << " " << cppType( (*itEntry)->paramType() ) << " i ";
+
+ if (cfgFileNameArg) {
+ cpp << "void " << cfg.className << "::instance(const QString& cfgfilename)" << endl;
+ cpp << "{" << endl;
+ cpp << " if (s_global" << cfg.className << "()->q) {" << endl;
+ cpp << " qDebug() << \"" << cfg.className << "::instance called after the first use - ignoring\";" << endl;
+ cpp << " return;" << endl;
+ cpp << " }" << endl;
+ cpp << " new " << cfg.className << "(cfgfilename);" << endl;
+ cpp << " s_global" << cfg.className << "()->q->readConfig();" << endl;
+ cpp << "}" << endl << endl;
}
- cpp << ")" << endl;
- cpp << "{" << endl;
- cpp << indent(itemAccessorBody( *itEntry, cfg ), 2);
- cpp << "}" << endl;
- }
-
- cpp << endl;
- }
- }
-
- // default value getters always go in Cpp
- for( itEntry = entries.constBegin(); itEntry != entries.constEnd(); ++itEntry ) {
- QString n = (*itEntry)->name();
- QString t = (*itEntry)->type();
-
- // Default value Accessor, as "helper" function
- if (( cfg.allDefaultGetters || cfg.defaultGetters.contains(n) ) && !(*itEntry)->defaultValue().isEmpty() ) {
- cpp << cppType(t) << " " << getDefaultFunction(n, cfg.className) << "_helper(";
- if ( !(*itEntry)->param().isEmpty() )
- cpp << " " << cppType( (*itEntry)->paramType() ) <<" i ";
- cpp << ")" << Const << endl;
- cpp << "{" << endl;
- cpp << memberGetDefaultBody(*itEntry) << endl;
- cpp << "}" << endl << endl;
- }
- }
-
- // Destructor
- cpp << cfg.className << "::~" << cfg.className << "()" << endl;
- cpp << "{" << endl;
- if ( cfg.singleton ) {
- if ( cfg.dpointer )
- cpp << " delete d;" << endl;
- cpp << " s_global" << cfg.className << "()->q = 0;" << endl;
- }
- cpp << "}" << endl << endl;
-
- if ( hasSignals ) {
- cpp << "bool " << cfg.className << "::" << "usrWriteConfig()" << endl;
+ }
+
+ if (!cppPreamble.isEmpty()) {
+ cpp << cppPreamble << endl;
+ }
+
+ // Constructor
+ cpp << cfg.className << "::" << cfg.className << "( ";
+ if (cfgFileNameArg) {
+ if (!cfg.singleton && ! cfg.forceStringFilename) {
+ cpp << " KSharedConfig::Ptr config";
+ } else {
+ cpp << " const QString& config";
+ }
+ cpp << (parameters.isEmpty() ? " " : ", ");
+ }
+
+ for (QList<Param>::ConstIterator it = parameters.constBegin();
+ it != parameters.constEnd(); ++it) {
+ if (it != parameters.constBegin()) {
+ cpp << ",";
+ }
+ cpp << " " << param((*it).type) << " " << (*it).name;
+ }
+ cpp << " )" << endl;
+
+ cpp << " : " << cfg.inherits << "(";
+ if (!cfgFileName.isEmpty()) {
+ cpp << " QLatin1String( \"" << cfgFileName << "\" ";
+ }
+ if (cfgFileNameArg) {
+ cpp << " config ";
+ }
+ if (!cfgFileName.isEmpty()) {
+ cpp << ") ";
+ }
+ cpp << ")" << endl;
+
+ // Store parameters
+ for (QList<Param>::ConstIterator it = parameters.constBegin();
+ it != parameters.constEnd(); ++it) {
+ cpp << " , mParam" << (*it).name << "(" << (*it).name << ")" << endl;
+ }
+
+ if (hasSignals && !cfg.dpointer) {
+ cpp << " , " << varName("settingsChanged", cfg) << "(0)" << endl;
+ }
+
+ cpp << "{" << endl;
+
+ if (cfg.dpointer) {
+ cpp << " d = new " + cfg.className + "Private;" << endl;
+ if (hasSignals) {
+ cpp << " " << varPath("settingsChanged", cfg) << " = 0;" << endl;
+ }
+ }
+ // Needed in case the singleton class is used as baseclass for
+ // another singleton.
+ if (cfg.singleton) {
+ cpp << " Q_ASSERT(!s_global" << cfg.className << "()->q);" << endl;
+ cpp << " s_global" << cfg.className << "()->q = this;" << endl;
+ }
+
+ group.clear();
+
+ for (itEntry = entries.constBegin(); itEntry != entries.constEnd(); ++itEntry) {
+ if ((*itEntry)->group() != group) {
+ if (!group.isEmpty()) {
+ cpp << endl;
+ }
+ group = (*itEntry)->group();
+ cpp << " setCurrentGroup( " << paramString(group, parameters) << " );" << endl << endl;
+ }
+
+ QString key = paramString((*itEntry)->key(), parameters);
+ if (!(*itEntry)->code().isEmpty()) {
+ cpp << (*itEntry)->code() << endl;
+ }
+ if ((*itEntry)->type() == "Enum") {
+ cpp << " QList<" + cfg.inherits + "::ItemEnum::Choice> values"
+ << (*itEntry)->name() << ";" << endl;
+ const QList<CfgEntry::Choice> choices = (*itEntry)->choices().choices;
+ QList<CfgEntry::Choice>::ConstIterator it;
+ for (it = choices.constBegin(); it != choices.constEnd(); ++it) {
+ cpp << " {" << endl;
+ cpp << " " + cfg.inherits + "::ItemEnum::Choice choice;" << endl;
+ cpp << " choice.name = QLatin1String(\"" << (*it).name << "\");" << endl;
+ if (cfg.setUserTexts) {
+ if (!(*it).label.isEmpty()) {
+ cpp << " choice.label = "
+ << translatedString(cfg, (*it).label, (*it).context)
+ << ";" << endl;
+ }
+ if (!(*it).toolTip.isEmpty()) {
+ cpp << " choice.toolTip = "
+ << translatedString(cfg, (*it).toolTip, (*it).context)
+ << ";" << endl;
+ }
+ if (!(*it).whatsThis.isEmpty()) {
+ cpp << " choice.whatsThis = "
+ << translatedString(cfg, (*it).whatsThis, (*it).context)
+ << ";" << endl;
+ }
+ }
+ cpp << " values" << (*itEntry)->name() << ".append( choice );" << endl;
+ cpp << " }" << endl;
+ }
+ }
+
+ if (!cfg.dpointer) {
+ cpp << itemDeclaration(*itEntry, cfg);
+ }
+
+ if ((*itEntry)->param().isEmpty()) {
+ // Normal case
+ cpp << " " << itemPath(*itEntry, cfg) << " = "
+ << newItem((*itEntry)->type(), (*itEntry)->name(), key, (*itEntry)->defaultValue(), cfg) << endl;
+
+ if (!(*itEntry)->minValue().isEmpty()) {
+ cpp << " " << itemPath(*itEntry, cfg) << "->setMinValue(" << (*itEntry)->minValue() << ");" << endl;
+ }
+ if (!(*itEntry)->maxValue().isEmpty()) {
+ cpp << " " << itemPath(*itEntry, cfg) << "->setMaxValue(" << (*itEntry)->maxValue() << ");" << endl;
+ }
+
+ if (cfg.setUserTexts) {
+ cpp << userTextsFunctions((*itEntry), cfg);
+ }
+
+ cpp << " addItem( " << itemPath(*itEntry, cfg);
+ QString quotedName = (*itEntry)->name();
+ addQuotes(quotedName);
+ if (quotedName != key) {
+ cpp << ", QLatin1String( \"" << (*itEntry)->name() << "\" )";
+ }
+ cpp << " );" << endl;
+ } else {
+ // Indexed
+ for (int i = 0; i <= (*itEntry)->paramMax(); i++) {
+ QString defaultStr;
+ QString itemVarStr(itemPath(*itEntry, cfg) + QString("[%1]").arg(i));
+
+ if (!(*itEntry)->paramDefaultValue(i).isEmpty()) {
+ defaultStr = (*itEntry)->paramDefaultValue(i);
+ } else if (!(*itEntry)->defaultValue().isEmpty()) {
+ defaultStr = paramString((*itEntry)->defaultValue(), (*itEntry), i);
+ } else {
+ defaultStr = defaultValue((*itEntry)->type());
+ }
+
+ cpp << " " << itemVarStr << " = "
+ << newItem((*itEntry)->type(), (*itEntry)->name(), paramString(key, *itEntry, i), defaultStr, cfg, QString("[%1]").arg(i))
+ << endl;
+
+ if (cfg.setUserTexts) {
+ cpp << userTextsFunctions(*itEntry, cfg, itemVarStr, (*itEntry)->paramName());
+ }
+
+ // Make mutators for enum parameters work by adding them with $(..) replaced by the
+ // param name. The check for isImmutable in the set* functions doesn't have the param
+ // name available, just the corresponding enum value (int), so we need to store the
+ // param names in a separate static list!.
+ cpp << " addItem( " << itemVarStr << ", QLatin1String( \"";
+ if ((*itEntry)->paramType() == "Enum") {
+ cpp << (*itEntry)->paramName().replace("$(" + (*itEntry)->param() + ')', "%1").arg((*itEntry)->paramValues()[i]);
+ } else {
+ cpp << (*itEntry)->paramName().replace("$(" + (*itEntry)->param() + ')', "%1").arg(i);
+ }
+ cpp << "\" ) );" << endl;
+ }
+ }
+ }
+
+ cpp << "}" << endl << endl;
+
+ if (cfg.dpointer) {
+ // setters and getters go in Cpp if in dpointer mode
+ for (itEntry = entries.constBegin(); itEntry != entries.constEnd(); ++itEntry) {
+ QString n = (*itEntry)->name();
+ QString t = (*itEntry)->type();
+
+ // Manipulator
+ if (cfg.allMutators || cfg.mutators.contains(n)) {
+ cpp << "void " << setFunction(n, cfg.className) << "( ";
+ if (!(*itEntry)->param().isEmpty()) {
+ cpp << cppType((*itEntry)->paramType()) << " i, ";
+ }
+ if (cfg.useEnumTypes && t == "Enum") {
+ cpp << enumType(*itEntry, cfg.globalEnums);
+ } else {
+ cpp << param(t);
+ }
+ cpp << " v )" << endl;
+ // function body inline only if not using dpointer
+ // for BC mode
+ cpp << "{" << endl;
+ cpp << indent(memberMutatorBody(*itEntry, cfg), 6);
+ cpp << "}" << endl << endl;
+ }
+
+ // Accessor
+ if (cfg.useEnumTypes && t == "Enum") {
+ cpp << enumType(*itEntry, cfg.globalEnums);
+ } else {
+ cpp << cppType(t);
+ }
+ cpp << " " << getFunction(n, cfg.className) << "(";
+ if (!(*itEntry)->param().isEmpty()) {
+ cpp << " " << cppType((*itEntry)->paramType()) << " i ";
+ }
+ cpp << ")" << Const << endl;
+ // function body inline only if not using dpointer
+ // for BC mode
+ cpp << "{" << endl;
+ cpp << indent(memberAccessorBody(*itEntry, cfg.globalEnums, cfg), 2);
+ cpp << "}" << endl << endl;
+
+ // Default value Accessor -- written by the loop below
+
+ // Item accessor
+ if (cfg.itemAccessors) {
+ cpp << endl;
+ cpp << cfg.inherits + "::Item" << itemType((*itEntry)->type()) << " *"
+ << getFunction(n, cfg.className) << "Item(";
+ if (!(*itEntry)->param().isEmpty()) {
+ cpp << " " << cppType((*itEntry)->paramType()) << " i ";
+ }
+ cpp << ")" << endl;
+ cpp << "{" << endl;
+ cpp << indent(itemAccessorBody(*itEntry, cfg), 2);
+ cpp << "}" << endl;
+ }
+
+ cpp << endl;
+ }
+ }
+
+ // default value getters always go in Cpp
+ for (itEntry = entries.constBegin(); itEntry != entries.constEnd(); ++itEntry) {
+ QString n = (*itEntry)->name();
+ QString t = (*itEntry)->type();
+
+ // Default value Accessor, as "helper" function
+ if ((cfg.allDefaultGetters || cfg.defaultGetters.contains(n)) && !(*itEntry)->defaultValue().isEmpty()) {
+ cpp << cppType(t) << " " << getDefaultFunction(n, cfg.className) << "_helper(";
+ if (!(*itEntry)->param().isEmpty()) {
+ cpp << " " << cppType((*itEntry)->paramType()) << " i ";
+ }
+ cpp << ")" << Const << endl;
+ cpp << "{" << endl;
+ cpp << memberGetDefaultBody(*itEntry) << endl;
+ cpp << "}" << endl << endl;
+ }
+ }
+
+ // Destructor
+ cpp << cfg.className << "::~" << cfg.className << "()" << endl;
cpp << "{" << endl;
- cpp << " const bool res = " << cfg.inherits << "::usrWriteConfig();" << endl;
- cpp << " if (!res) return false;" << endl << endl;
- Q_FOREACH(const Signal &signal, signalList) {
- cpp << " if ( " << varPath("settingsChanged", cfg) << " & " << signalEnumName(signal.name) << " ) " << endl;
- cpp << " emit " << signal.name << "(";
- QList<SignalArguments>::ConstIterator it, itEnd = signal.arguments.constEnd();
- for ( it = signal.arguments.constBegin(); it != itEnd; ) {
- SignalArguments argument = *it;
- bool cast = false;
- if ( cfg.useEnumTypes && argument.type == "Enum" ) {
- for ( int i = 0, end = entries.count(); i < end; ++i ) {
- if ( entries[i]->name() == argument.variableName ) {
- cpp << "static_cast<" << enumType(entries[i], cfg.globalEnums) << ">(";
- cast = true;
- break;
+ if (cfg.singleton) {
+ if (cfg.dpointer) {
+ cpp << " delete d;" << endl;
+ }
+ cpp << " s_global" << cfg.className << "()->q = 0;" << endl;
+ }
+ cpp << "}" << endl << endl;
+
+ if (hasSignals) {
+ cpp << "bool " << cfg.className << "::" << "usrWriteConfig()" << endl;
+ cpp << "{" << endl;
+ cpp << " const bool res = " << cfg.inherits << "::usrWriteConfig();" << endl;
+ cpp << " if (!res) return false;" << endl << endl;
+ Q_FOREACH (const Signal &signal, signalList) {
+ cpp << " if ( " << varPath("settingsChanged", cfg) << " & " << signalEnumName(signal.name) << " ) " << endl;
+ cpp << " emit " << signal.name << "(";
+ QList<SignalArguments>::ConstIterator it, itEnd = signal.arguments.constEnd();
+ for (it = signal.arguments.constBegin(); it != itEnd;) {
+ SignalArguments argument = *it;
+ bool cast = false;
+ if (cfg.useEnumTypes && argument.type == "Enum") {
+ for (int i = 0, end = entries.count(); i < end; ++i) {
+ if (entries[i]->name() == argument.variableName) {
+ cpp << "static_cast<" << enumType(entries[i], cfg.globalEnums) << ">(";
+ cast = true;
+ break;
+ }
+ }
+ }
+ cpp << varPath(argument.variableName, cfg);
+ if (cast) {
+ cpp << ")";
+ }
+ if (++it != itEnd) {
+ cpp << ", ";
+ }
}
- }
- }
- cpp << varPath(argument.variableName, cfg);
- if ( cast )
- cpp << ")";
- if ( ++it != itEnd )
- cpp << ", ";
- }
- cpp << ");" << endl << endl;
- }
- cpp << " " << varPath("settingsChanged", cfg) << " = 0;" << endl;
- cpp << " return true;" << endl;
- cpp << "}" << endl;
- }
-
- // Add includemoc if they are signals defined.
- if( hasSignals ) {
- cpp << endl;
- cpp << "#include \"" << mocFileName << "\"" << endl;
- cpp << endl;
- }
-
- // clear entries list
- qDeleteAll( entries );
-
- implementation.close();
+ cpp << ");" << endl << endl;
+ }
+ cpp << " " << varPath("settingsChanged", cfg) << " = 0;" << endl;
+ cpp << " return true;" << endl;
+ cpp << "}" << endl;
+ }
+
+ // Add includemoc if they are signals defined.
+ if (hasSignals) {
+ cpp << endl;
+ cpp << "#include \"" << mocFileName << "\"" << endl;
+ cpp << endl;
+ }
+
+ // clear entries list
+ qDeleteAll(entries);
+
+ implementation.close();
}