23 #ifndef _KCONFIGBASE_H
24 #define _KCONFIGBASE_H
29 #include <tqdatetime.h>
30 #include <tqstrlist.h>
31 #include <tqstringlist.h>
32 #include <tqvariant.h>
35 #include "kconfigdata.h"
36 #include "kdelibs_export.h"
39 class KConfigBasePrivate;
100 void setGroup(
const TQString& group );
106 void setDesktopGroup();
114 TQString group()
const;
122 bool hasGroup(
const TQString &group)
const;
147 const TQString& aDefault = TQString::null )
const;
157 const TQString& aDefault = TQString::null )
const;
205 const TQVariant &aDefault)
const;
222 const TQVariant &aDefault)
const;
234 int readListEntry(
const TQString& pKey, TQStrList &list,
char sep =
',' )
const;
246 int readListEntry(
const char *pKey, TQStrList &list,
char sep =
',' )
const;
255 TQStringList
readListEntry(
const TQString& pKey,
char sep =
',' )
const;
264 TQStringList
readListEntry(
const char *pKey,
char sep =
',' )
const;
275 TQStringList
readListEntry(
const char* pKey,
const TQStringList& aDefault,
276 char sep =
',' )
const;
305 TQString
readPathEntry(
const TQString& pKey,
const TQString & aDefault = TQString::null )
const;
318 TQString
readPathEntry(
const char *pKey,
const TQString & aDefault = TQString::null )
const;
360 int readNumEntry(
const TQString& pKey,
int nDefault = 0 )
const;
373 int readNumEntry(
const char *pKey,
int nDefault = 0 )
const;
465 TQ_INT64
readNum64Entry(
const TQString& pKey, TQ_INT64 nDefault = 0 )
const;
478 TQ_INT64
readNum64Entry(
const char *pKey, TQ_INT64 nDefault = 0 )
const;
543 TQFont
readFontEntry(
const TQString& pKey,
const TQFont* pDefault = 0L )
const;
556 TQFont
readFontEntry(
const char *pKey,
const TQFont* pDefault = 0L )
const;
569 bool readBoolEntry(
const TQString& pKey,
bool bDefault =
false )
const;
582 bool readBoolEntry(
const char *pKey,
bool bDefault =
false )
const;
595 TQRect
readRectEntry(
const TQString& pKey,
const TQRect* pDefault = 0L )
const;
608 TQRect
readRectEntry(
const char *pKey,
const TQRect* pDefault = 0L )
const;
621 TQPoint
readPointEntry(
const TQString& pKey,
const TQPoint* pDefault = 0L )
const;
634 TQPoint
readPointEntry(
const char *pKey,
const TQPoint* pDefault = 0L )
const;
647 TQSize
readSizeEntry(
const TQString& pKey,
const TQSize* pDefault = 0L )
const;
660 TQSize
readSizeEntry(
const char *pKey,
const TQSize* pDefault = 0L )
const;
674 TQColor
readColorEntry(
const TQString& pKey,
const TQColor* pDefault = 0L )
const;
687 TQColor
readColorEntry(
const char *pKey,
const TQColor* pDefault = 0L )
const;
701 TQDateTime
readDateTimeEntry(
const TQString& pKey,
const TQDateTime* pDefault = 0L )
const;
715 TQDateTime
readDateTimeEntry(
const char *pKey,
const TQDateTime* pDefault = 0L )
const;
726 const TQString& aDefault = TQString::null )
const;
737 const TQString& aDefault = TQString::null )
const;
758 void writeEntry(
const TQString& pKey,
const TQString& pValue,
759 bool bPersistent =
true,
bool bGlobal =
false,
779 void writeEntry(
const char *pKey,
const TQString& pValue,
780 bool bPersistent =
true,
bool bGlobal =
false,
802 void writeEntry(
const TQString& pKey,
const TQVariant& rValue,
803 bool bPersistent =
true,
bool bGlobal =
false,
824 void writeEntry(
const char *pKey,
const TQVariant& rValue,
825 bool bPersistent =
true,
bool bGlobal =
false,
848 void writeEntry(
const TQString& pKey,
const TQStrList &rValue,
849 char sep =
',',
bool bPersistent =
true,
bool bGlobal =
false,
bool bNLS =
false );
870 void writeEntry(
const char *pKey,
const TQStrList &rValue,
871 char sep =
',',
bool bPersistent =
true,
bool bGlobal =
false,
bool bNLS =
false );
893 void writeEntry(
const TQString& pKey,
const TQStringList &rValue,
894 char sep =
',',
bool bPersistent =
true,
bool bGlobal =
false,
bool bNLS =
false );
915 void writeEntry(
const char *pKey,
const TQStringList &rValue,
916 char sep =
',',
bool bPersistent =
true,
bool bGlobal =
false,
bool bNLS =
false );
938 void writeEntry(
const TQString& pKey,
const TQValueList<int>& rValue,
939 bool bPersistent =
true,
bool bGlobal =
false,
bool bNLS =
false );
959 void writeEntry(
const char *pKey,
const TQValueList<int>& rValue,
960 bool bPersistent =
true,
bool bGlobal =
false,
bool bNLS =
false );
980 bool bPersistent =
true,
bool bGlobal =
false,
982 {
writeEntry(pKey, TQString::fromLatin1(pValue), bPersistent, bGlobal, bNLS); }
1001 bool bPersistent =
true,
bool bGlobal =
false,
1003 {
writeEntry(pKey, TQString::fromLatin1(pValue), bPersistent, bGlobal, bNLS); }
1020 void writeEntry(
const TQString& pKey,
int nValue,
1021 bool bPersistent =
true,
bool bGlobal =
false,
1022 bool bNLS =
false );
1038 void writeEntry(
const char *pKey,
int nValue,
1039 bool bPersistent =
true,
bool bGlobal =
false,
1040 bool bNLS =
false );
1057 void writeEntry(
const TQString& pKey,
unsigned int nValue,
1058 bool bPersistent =
true,
bool bGlobal =
false,
1059 bool bNLS =
false );
1075 void writeEntry(
const char *pKey,
unsigned int nValue,
1076 bool bPersistent =
true,
bool bGlobal =
false,
1077 bool bNLS =
false );
1093 void writeEntry(
const TQString& pKey,
long nValue,
1094 bool bPersistent =
true,
bool bGlobal =
false,
1095 bool bNLS =
false );
1110 void writeEntry(
const char *pKey,
long nValue,
1111 bool bPersistent =
true,
bool bGlobal =
false,
1112 bool bNLS =
false );
1128 void writeEntry(
const TQString& pKey,
unsigned long nValue,
1129 bool bPersistent =
true,
bool bGlobal =
false,
1130 bool bNLS =
false );
1145 void writeEntry(
const char *pKey,
unsigned long nValue,
1146 bool bPersistent =
true,
bool bGlobal =
false,
1147 bool bNLS =
false );
1163 void writeEntry(
const TQString& pKey, TQ_INT64 nValue,
1164 bool bPersistent =
true,
bool bGlobal =
false,
1165 bool bNLS =
false );
1180 void writeEntry(
const char *pKey, TQ_INT64 nValue,
1181 bool bPersistent =
true,
bool bGlobal =
false,
1182 bool bNLS =
false );
1198 void writeEntry(
const TQString& pKey, TQ_UINT64 nValue,
1199 bool bPersistent =
true,
bool bGlobal =
false,
1200 bool bNLS =
false );
1215 void writeEntry(
const char *pKey, TQ_UINT64 nValue,
1216 bool bPersistent =
true,
bool bGlobal =
false,
1217 bool bNLS =
false );
1236 void writeEntry(
const TQString& pKey,
double nValue,
1237 bool bPersistent =
true,
bool bGlobal =
false,
1238 char format =
'g',
int precision = 6,
1239 bool bNLS =
false );
1257 void writeEntry(
const char *pKey,
double nValue,
1258 bool bPersistent =
true,
bool bGlobal =
false,
1259 char format =
'g',
int precision = 6,
1260 bool bNLS =
false );
1276 void writeEntry(
const TQString& pKey,
bool bValue,
1277 bool bPersistent =
true,
bool bGlobal =
false,
1278 bool bNLS =
false );
1293 void writeEntry(
const char *pKey,
bool bValue,
1294 bool bPersistent =
true,
bool bGlobal =
false,
1295 bool bNLS =
false );
1311 void writeEntry(
const TQString& pKey,
const TQFont& rFont,
1312 bool bPersistent =
true,
bool bGlobal =
false,
1313 bool bNLS =
false );
1328 void writeEntry(
const char *pKey,
const TQFont& rFont,
1329 bool bPersistent =
true,
bool bGlobal =
false,
1330 bool bNLS =
false );
1349 void writeEntry(
const TQString& pKey,
const TQColor& rColor,
1350 bool bPersistent =
true,
bool bGlobal =
false,
1351 bool bNLS =
false );
1369 void writeEntry(
const char *pKey,
const TQColor& rColor,
1370 bool bPersistent =
true,
bool bGlobal =
false,
1371 bool bNLS =
false );
1390 void writeEntry(
const TQString& pKey,
const TQDateTime& rDateTime,
1391 bool bPersistent =
true,
bool bGlobal =
false,
1392 bool bNLS =
false );
1410 void writeEntry(
const char *pKey,
const TQDateTime& rDateTime,
1411 bool bPersistent =
true,
bool bGlobal =
false,
1412 bool bNLS =
false );
1432 void writeEntry(
const TQString& pKey,
const TQRect& rValue,
1433 bool bPersistent =
true,
bool bGlobal =
false,
1434 bool bNLS =
false );
1452 void writeEntry(
const char *pKey,
const TQRect& rValue,
1453 bool bPersistent =
true,
bool bGlobal =
false,
1454 bool bNLS =
false );
1473 void writeEntry(
const TQString& pKey,
const TQPoint& rValue,
1474 bool bPersistent =
true,
bool bGlobal =
false,
1475 bool bNLS =
false );
1493 void writeEntry(
const char *pKey,
const TQPoint& rValue,
1494 bool bPersistent =
true,
bool bGlobal =
false,
1495 bool bNLS =
false );
1514 void writeEntry(
const TQString& pKey,
const TQSize& rValue,
1515 bool bPersistent =
true,
bool bGlobal =
false,
1516 bool bNLS =
false );
1534 void writeEntry(
const char *pKey,
const TQSize& rValue,
1535 bool bPersistent =
true,
bool bGlobal =
false,
1536 bool bNLS =
false );
1555 void writePathEntry(
const TQString& pKey,
const TQString & path,
1556 bool bPersistent =
true,
bool bGlobal =
false,
1557 bool bNLS =
false );
1576 bool bPersistent =
true,
bool bGlobal =
false,
1577 bool bNLS =
false );
1602 void writePathEntry(
const TQString& pKey,
const TQStringList &rValue,
1603 char sep =
',',
bool bPersistent =
true,
bool bGlobal =
false,
bool bNLS =
false );
1627 void writePathEntry(
const char *pKey,
const TQStringList &rValue,
1628 char sep =
',',
bool bPersistent =
true,
bool bGlobal =
false,
bool bNLS =
false );
1640 bool bNLS =
false,
bool bGlobal =
false);
1650 bool bNLS =
false,
bool bGlobal =
false);
1669 bool deleteGroup(
const TQString& group,
bool bDeep =
true,
bool bGlobal =
false );
1702 virtual void rollback(
bool bDeep =
true );
1717 virtual void sync();
1750 bool hasKey(
const TQString& key )
const;
1762 virtual TQMap<TQString, TQString>
entryMap(
const TQString &group)
const = 0;
1971 virtual bool internalHasGroup(
const TQCString &group)
const = 0;
1981 void setGroup(
const TQCString &pGroup );
1982 void setGroup(
const char *pGroup );
1983 bool hasGroup(
const TQCString &_pGroup)
const;
1984 bool hasGroup(
const char *_pGroup)
const;
1985 bool hasKey(
const char *pKey )
const;
1988 TQCString readEntryUtf8(
const char *pKey)
const;
1989 bool hasTranslatedKey(
const char *pKey )
const;
2004 bool bLocaleInitialized;
2006 mutable bool bExpand;
2009 virtual void virtual_hook(
int id,
void* data );
2011 class KConfigBasePrivate;
2012 KConfigBasePrivate *d;
2014 void writeEntry(
const char *pKey,
const TQString &rValue,
2015 bool bPersistent,
bool bGlobal,
bool bNLS,
bool bExpand );
2016 void writeEntry(
const char *pKey,
const TQStringList &rValue,
2017 char sep,
bool bPersistent,
bool bGlobal,
bool bNLS,
bool bExpand );
2021 class KConfigGroupSaverPrivate;
2073 : _config(config), _oldgroup(config->group())
2074 { _config->setGroup( group ); }
2077 : _config(config), _oldgroup(config->group())
2078 { _config->setGroup( group ); }
2081 : _config(config), _oldgroup(config->group())
2082 { _config->setGroup( group ); }
2095 KConfigGroupSaverPrivate *d;
2098 class KConfigGroupPrivate;
2133 void deleteGroup(
bool bGlobal =
false);
2141 bool groupIsImmutable()
const;
2144 virtual void setDirty(
bool _bDirty);
2145 virtual void putData(
const KEntryKey &_key,
const KEntry &_data,
bool _checkGroup =
true);
2147 virtual void sync();
2152 void setDesktopGroup() { }
2155 void setReadOnly(
bool) { }
2159 virtual TQStringList groupList()
const {
return TQStringList(); }
2160 virtual void rollback(
bool) { }
2161 virtual void reparseConfiguration() { }
2162 virtual TQMap<TQString, TQString> entryMap(
const TQString &)
const
2163 {
return TQMap<TQString,TQString>(); }
2164 virtual KEntryMap internalEntryMap(
const TQString&)
const
2165 {
return KEntryMap(); }
2166 virtual KEntryMap internalEntryMap()
const
2167 {
return KEntryMap(); }
2168 virtual bool internalHasGroup(
const TQCString &)
const
2171 void getConfigState() { }
2175 virtual void virtual_hook(
int id,
void* data );
2177 KConfigGroupPrivate* d;
Abstract base class for KDE configuration file loading/saving.
KDE Configuration Management abstract base class.
virtual void setReadOnly(bool _ro)
Sets the config object's read-only status.
TQCString mGroup
The currently selected group.
int readListEntry(const TQString &pKey, TQStrList &list, char sep=',') const
Reads a list of strings.
bool entryIsImmutable(const TQString &key) const
Checks whether it is possible to change the given entry.
TQFont readFontEntry(const TQString &pKey, const TQFont *pDefault=0L) const
Reads a TQFont value.
virtual KEntryMap internalEntryMap() const =0
Returns a map (tree) of the entries in the tree.
virtual KEntryMap internalEntryMap(const TQString &pGroup) const =0
Returns a map (tree) of the entries in the specified group.
void setLocale()
Reads the locale and put in the configuration data struct.
TQString readEntryUntranslated(const TQString &pKey, const TQString &aDefault=TQString::null) const
Reads the value of an entry specified by pKey in the current group.
void revertToDefault(const TQString &key)
Reverts the entry with key key in the current group in the application specific config file to either...
TQCString aLocaleString
The locale to retrieve keys under if possible, i.e en_US or fr.
TQ_UINT64 readUnsignedNum64Entry(const TQString &pKey, TQ_UINT64 nDefault=0) const
Read an 64-bit unsigned numerical value.
TQValueList< int > readIntListEntry(const TQString &pKey) const
Reads a list of Integers.
bool readDefaults() const
TQString readPathEntry(const TQString &pKey, const TQString &aDefault=TQString::null) const
Reads a path.
TQSize readSizeEntry(const TQString &pKey, const TQSize *pDefault=0L) const
Reads a TQSize entry.
bool hasDefault(const TQString &key) const
Returns whether a default is specified for an entry in either the system wide configuration file or t...
bool isDollarExpansion() const
Returns whether dollar expansion is on or off.
unsigned long readUnsignedLongNumEntry(const TQString &pKey, unsigned long nDefault=0) const
Read an unsigned numerical value.
TQColor readColorEntry(const TQString &pKey, const TQColor *pDefault=0L) const
Reads a TQColor entry.
TQString readEntry(const TQString &pKey, const TQString &aDefault=TQString::null) const
Reads the value of an entry specified by pKey in the current group.
double readDoubleNumEntry(const TQString &pKey, double nDefault=0.0) const
Reads a floating point value.
unsigned int readUnsignedNumEntry(const TQString &pKey, unsigned int nDefault=0) const
Reads an unsigned numerical value.
void writeEntry(const TQString &pKey, const TQString &pValue, bool bPersistent=true, bool bGlobal=false, bool bNLS=false)
Writes a key/value pair.
void setDollarExpansion(bool _bExpand=true)
Turns on or off "dollar expansion" (see KConfigBase introduction) when reading config entries.
TQStringList readPathListEntry(const TQString &pKey, char sep=',') const
Reads a list of string paths.
long readLongNumEntry(const TQString &pKey, long nDefault=0) const
Reads a numerical value.
bool isDirty() const
Checks whether the config file has any dirty (modified) entries.
virtual void putData(const KEntryKey &_key, const KEntry &_data, bool _checkGroup=true)=0
Inserts a (key/value) pair into the internal storage mechanism of the configuration object.
TQString locale() const
Returns a the current locale.
virtual void setDirty(bool _bDirty=true)
Sets the global dirty flag of the config object.
TQRect readRectEntry(const TQString &pKey, const TQRect *pDefault=0L) const
Reads a TQRect entry.
KConfigBackEnd * backEnd
A back end for loading/saving to disk in a particular format.
KConfigBase()
Construct a KConfigBase object.
TQVariant readPropertyEntry(const TQString &pKey, TQVariant::Type) const
Reads the value of an entry specified by pKey in the current group.
virtual ~KConfigBase()
Destructs the KConfigBase object.
TQPoint readPointEntry(const TQString &pKey, const TQPoint *pDefault=0L) const
Reads a TQPoint entry.
bool checkConfigFilesWritable(bool warnUser)
Check whether the config files are writable.
void writeEntry(const char *pKey, const char *pValue, bool bPersistent=true, bool bGlobal=false, bool bNLS=false)
Write a (key/value) pair.
bool hasKey(const TQString &key) const
Checks whether the key has an entry in the currently active group.
bool isImmutable() const
Checks whether this configuration file can be modified.
bool isReadOnly() const
Returns the read-only status of the config object.
void setReadDefaults(bool b)
When set, all readEntry and readXXXEntry calls return the system wide (default) values instead of the...
ConfigState
Possible return values for getConfigState().
virtual KEntry lookupData(const KEntryKey &_key) const =0
Looks up an entry in the config object's internal structure.
bool bDirty
Indicates whether there are any dirty entries in the config object that need to be written back to di...
virtual void parseConfigFiles()
Parses all configuration files for a configuration object.
virtual TQStringList groupList() const =0
Returns a list of groups that are known about.
int readNumEntry(const TQString &pKey, int nDefault=0) const
Reads a numerical value.
void deleteEntry(const TQString &pKey, bool bNLS=false, bool bGlobal=false)
Deletes the entry specified by pKey in the current group.
virtual TQMap< TQString, TQString > entryMap(const TQString &group) const =0
Returns a map (tree) of entries for all entries in a particular group.
void writePathEntry(const TQString &pKey, const TQString &path, bool bPersistent=true, bool bGlobal=false, bool bNLS=false)
Writes a file path.
virtual void reparseConfiguration()=0
Reparses all configuration files.
void writeEntry(const TQString &pKey, const char *pValue, bool bPersistent=true, bool bGlobal=false, bool bNLS=false)
Write a (key/value) pair.
TQ_INT64 readNum64Entry(const TQString &pKey, TQ_INT64 nDefault=0) const
Reads a 64-bit numerical value.
bool readBoolEntry(const TQString &pKey, bool bDefault=false) const
Reads a boolean entry.
TQDateTime readDateTimeEntry(const TQString &pKey, const TQDateTime *pDefault=0L) const
Reads a TQDateTime entry.
Helper class to facilitate working with KConfig / KSimpleConfig groups.
KConfigGroupSaver(KConfigBase *config, TQString group)
Constructor.
A KConfigBase derived class for one specific group in a KConfig object.
void deleteGroup(bool bGlobal=false)
Delete all entries in the entire group.
bool groupIsImmutable() const
Checks whether it is possible to change this group.
virtual void sync()
Flushes all changes that currently reside only in memory back to disk / permanent storage.
Class for KDE INI-style configuration file loading/saving.
key structure holding both the actual key and the the group to which it belongs.
map/dict/list config node entry.