23 #ifndef _TDECONFIGBASE_H
24 #define _TDECONFIGBASE_H
29 #include <tqdatetime.h>
30 #include <tqstrlist.h>
31 #include <tqstringlist.h>
32 #include <tqvariant.h>
35 #include "tdeconfigdata.h"
36 #include "tdelibs_export.h"
39 class TDEConfigBasePrivate;
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 );
1599 bool bPersistent,
bool bGlobal,
1600 bool bNLS,
bool expand );
1625 void writePathEntry(
const TQString& pKey,
const TQStringList &rValue,
1626 char sep =
',',
bool bPersistent =
true,
bool bGlobal =
false,
bool bNLS =
false );
1650 void writePathEntry(
const char *pKey,
const TQStringList &rValue,
1651 char sep =
',',
bool bPersistent =
true,
bool bGlobal =
false,
bool bNLS =
false );
1663 bool bNLS =
false,
bool bGlobal =
false);
1673 bool bNLS =
false,
bool bGlobal =
false);
1692 bool deleteGroup(
const TQString& group,
bool bDeep =
true,
bool bGlobal =
false );
1725 virtual void rollback(
bool bDeep =
true );
1740 virtual void sync();
1773 bool hasKey(
const TQString& key )
const;
1785 virtual TQMap<TQString, TQString>
entryMap(
const TQString &group)
const = 0;
1994 virtual bool internalHasGroup(
const TQCString &group)
const = 0;
2004 void setGroup(
const TQCString &pGroup );
2005 void setGroup(
const char *pGroup );
2006 bool hasGroup(
const TQCString &_pGroup)
const;
2007 bool hasGroup(
const char *_pGroup)
const;
2008 bool hasKey(
const char *pKey )
const;
2011 TQCString readEntryUtf8(
const char *pKey)
const;
2012 bool hasTranslatedKey(
const char *pKey )
const;
2027 bool bLocaleInitialized;
2029 mutable bool bExpand;
2032 virtual void virtual_hook(
int id,
void* data );
2034 class TDEConfigBasePrivate;
2035 TDEConfigBasePrivate *d;
2037 void writeEntry(
const char *pKey,
const TQString &rValue,
2038 bool bPersistent,
bool bGlobal,
bool bNLS,
bool bExpand );
2039 void writeEntry(
const char *pKey,
const TQStringList &rValue,
2040 char sep,
bool bPersistent,
bool bGlobal,
bool bNLS,
bool bExpand );
2044 class TDEConfigGroupSaverPrivate;
2096 : _config(config), _oldgroup(config->group())
2097 { _config->setGroup( group ); }
2100 : _config(config), _oldgroup(config->group())
2101 { _config->setGroup( group ); }
2104 : _config(config), _oldgroup(config->group())
2105 { _config->setGroup( group ); }
2118 TDEConfigGroupSaverPrivate *d;
2121 class TDEConfigGroupPrivate;
2156 void deleteGroup(
bool bGlobal =
false);
2164 bool groupIsImmutable()
const;
2167 virtual void setDirty(
bool _bDirty);
2168 virtual void putData(
const KEntryKey &_key,
const KEntry &_data,
bool _checkGroup =
true);
2170 virtual void sync();
2175 void setDesktopGroup() { }
2178 void setReadOnly(
bool) { }
2182 virtual TQStringList groupList()
const {
return TQStringList(); }
2183 virtual void rollback(
bool) { }
2184 virtual void reparseConfiguration() { }
2185 virtual TQMap<TQString, TQString> entryMap(
const TQString &)
const
2186 {
return TQMap<TQString,TQString>(); }
2187 virtual KEntryMap internalEntryMap(
const TQString&)
const
2188 {
return KEntryMap(); }
2189 virtual KEntryMap internalEntryMap()
const
2190 {
return KEntryMap(); }
2191 virtual bool internalHasGroup(
const TQCString &)
const
2194 void getConfigState() { }
2198 virtual void virtual_hook(
int id,
void* data );
2200 TDEConfigGroupPrivate* d;
Abstract base class for KDE configuration file loading/saving.
KDE Configuration Management abstract base class.
unsigned long readUnsignedLongNumEntry(const TQString &pKey, unsigned long nDefault=0) const
Read an unsigned numerical value.
bool hasDefault(const TQString &key) const
Returns whether a default is specified for an entry in either the system wide configuration file or t...
void setReadDefaults(bool b)
When set, all readEntry and readXXXEntry calls return the system wide (default) values instead of the...
TQString readEntry(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...
bool isImmutable() const
Checks whether this configuration file can be modified.
TQColor readColorEntry(const TQString &pKey, const TQColor *pDefault=0L) const
Reads a TQColor entry.
virtual KEntry lookupData(const KEntryKey &_key) const =0
Looks up an entry in the config object's internal structure.
virtual KEntryMap internalEntryMap() const =0
Returns a map (tree) of the entries in the tree.
void writeEntry(const char *pKey, const char *pValue, bool bPersistent=true, bool bGlobal=false, bool bNLS=false)
Write a (key/value) pair.
virtual TQStringList groupList() const =0
Returns a list of groups that are known about.
TQ_UINT64 readUnsignedNum64Entry(const TQString &pKey, TQ_UINT64 nDefault=0) const
Read an 64-bit unsigned numerical value.
TQ_INT64 readNum64Entry(const TQString &pKey, TQ_INT64 nDefault=0) const
Reads a 64-bit numerical value.
int readNumEntry(const TQString &pKey, int nDefault=0) const
Reads a numerical value.
bool readBoolEntry(const TQString &pKey, bool bDefault=false) const
Reads a boolean entry.
TQSize readSizeEntry(const TQString &pKey, const TQSize *pDefault=0L) const
Reads a TQSize entry.
void writePathEntry(const TQString &pKey, const TQString &path, bool bPersistent=true, bool bGlobal=false, bool bNLS=false)
Writes a file path.
bool entryIsImmutable(const TQString &key) const
Checks whether it is possible to change the given entry.
TDEConfigBackEnd * backEnd
A back end for loading/saving to disk in a particular format.
unsigned int readUnsignedNumEntry(const TQString &pKey, unsigned int nDefault=0) const
Reads an unsigned numerical value.
virtual void reparseConfiguration()=0
Reparses all configuration files.
void setDollarExpansion(bool _bExpand=true)
Turns on or off "dollar expansion" (see TDEConfigBase introduction) when reading config entries.
void deleteEntry(const TQString &pKey, bool bNLS=false, bool bGlobal=false)
Deletes the entry specified by pKey in the current group.
double readDoubleNumEntry(const TQString &pKey, double nDefault=0.0) const
Reads a floating point value.
bool isReadOnly() const
Returns the read-only status of the config object.
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.
TQCString aLocaleString
The locale to retrieve keys under if possible, i.e en_US or fr.
virtual ~TDEConfigBase()
Destructs the TDEConfigBase object.
TQString readEntryUntranslated(const TQString &pKey, const TQString &aDefault=TQString::null) const
Reads the value of an entry specified by pKey in the current group.
virtual void parseConfigFiles()
Parses all configuration files for a configuration object.
bool isDirty() const
Checks whether the config file has any dirty (modified) entries.
TQValueList< int > readIntListEntry(const TQString &pKey) const
Reads a list of Integers.
TQPoint readPointEntry(const TQString &pKey, const TQPoint *pDefault=0L) const
Reads a TQPoint entry.
void writeEntry(const TQString &pKey, const char *pValue, bool bPersistent=true, bool bGlobal=false, bool bNLS=false)
Write a (key/value) pair.
ConfigState
Possible return values for getConfigState().
bool isDollarExpansion() const
Returns whether dollar expansion is on or off.
TQRect readRectEntry(const TQString &pKey, const TQRect *pDefault=0L) const
Reads a TQRect entry.
int readListEntry(const TQString &pKey, TQStrList &list, char sep=',') const
Reads a list of strings.
virtual void setDirty(bool _bDirty=true)
Sets the global dirty flag of the config object.
void setLocale()
Reads the locale and put in the configuration data struct.
TDEConfigBase()
Construct a TDEConfigBase object.
virtual TQMap< TQString, TQString > entryMap(const TQString &group) const =0
Returns a map (tree) of entries for all entries in a particular group.
TQStringList readPathListEntry(const TQString &pKey, char sep=',') const
Reads a list of string paths.
bool checkConfigFilesWritable(bool warnUser)
Check whether the config files are writable.
long readLongNumEntry(const TQString &pKey, long nDefault=0) const
Reads a numerical value.
virtual void setReadOnly(bool _ro)
Sets the config object's read-only status.
virtual KEntryMap internalEntryMap(const TQString &pGroup) const =0
Returns a map (tree) of the entries in the specified group.
bool hasKey(const TQString &key) const
Checks whether the key has an entry in the currently active group.
void writeEntry(const TQString &pKey, const TQString &pValue, bool bPersistent=true, bool bGlobal=false, bool bNLS=false)
Writes a key/value pair.
TQDateTime readDateTimeEntry(const TQString &pKey, const TQDateTime *pDefault=0L) const
Reads a TQDateTime entry.
TQString readPathEntry(const TQString &pKey, const TQString &aDefault=TQString::null) const
Reads a path.
TQFont readFontEntry(const TQString &pKey, const TQFont *pDefault=0L) const
Reads a TQFont value.
bool bDirty
Indicates whether there are any dirty entries in the config object that need to be written back to di...
TQCString mGroup
The currently selected group.
TQVariant readPropertyEntry(const TQString &pKey, TQVariant::Type) const
Reads the value of an entry specified by pKey in the current group.
bool readDefaults() const
TQString locale() const
Returns a the current locale.
Helper class to facilitate working with TDEConfig / KSimpleConfig groups.
TDEConfigGroupSaver(TDEConfigBase *config, TQString group)
Constructor.
A TDEConfigBase derived class for one specific group in a TDEConfig 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.