23#ifndef _TDECONFIGBASE_H
24#define _TDECONFIGBASE_H
29#include <tqdatetime.h>
31#include <tqstringlist.h>
35#include "tdeconfigdata.h"
36#include "tdelibs_export.h"
39class TDEConfigBasePrivate;
75 friend class TDEConfigBackEnd;
76 friend class TDEConfigINIBackEnd;
77 friend class TDEConfigGroup;
114 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 );
1575 void writePathEntry(
const char *pKey,
const TQString & path,
1576 bool bPersistent =
true,
bool bGlobal =
false,
1577 bool bNLS =
false );
1598 void writePathEntry(
const char *pKey,
const TQString & path,
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 );
1662 void deleteEntry(
const TQString& pKey,
1663 bool bNLS =
false,
bool bGlobal =
false);
1672 void deleteEntry(
const char *pKey,
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;
1843 ConfigState getConfigState()
const;
1851 bool checkConfigFilesWritable(
bool warnUser);
1859 void setReadDefaults(
bool b);
1866 bool readDefaults()
const;
1879 void revertToDefault(
const TQString &key);
1907 bool hasDefault(
const TQString &key)
const;
1929 virtual void parseConfigFiles();
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 );
2044class TDEConfigGroupSaverPrivate;
2096 : _config(config), _oldgroup(config->group())
2097 { _config->setGroup( group ); }
2100 : _config(config), _oldgroup(config->group())
2101 { _config->setGroup( group ); }
2103 TDEConfigGroupSaver( TDEConfigBase* config,
const TQCString &group )
2104 : _config(config), _oldgroup(config->group())
2105 { _config->setGroup( group ); }
2107 ~TDEConfigGroupSaver() { _config->setGroup( _oldgroup ); }
2109 TDEConfigBase* config() {
return _config; };
2112 TDEConfigBase* _config;
2115 TDEConfigGroupSaver(
const TDEConfigGroupSaver&);
2116 TDEConfigGroupSaver& operator=(
const TDEConfigGroupSaver&);
2118 TDEConfigGroupSaverPrivate *d;
2121class TDEConfigGroupPrivate;
2167 virtual void setDirty(
bool _bDirty);
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.
TQString readEntry(const TQString &pKey, const TQString &aDefault=TQString::null) const
Reads the value of an entry specified by pKey in the current group.
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.
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.
double readDoubleNumEntry(const TQString &pKey, double nDefault=0.0) const
Reads a floating point value.
void setDesktopGroup()
Sets the group to the "Desktop Entry" group used for desktop configuration files for applications,...
bool isReadOnly() const
Returns the read-only status of the config object.
bool groupIsImmutable(const TQString &group) const
Checks whether it is possible to change the given group.
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.
bool hasGroup(const TQString &group) const
Returns true if the specified group is known about.
TQString readEntryUntranslated(const TQString &pKey, const TQString &aDefault=TQString::null) const
Reads the value of an entry specified by pKey in the current group.
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.
TQString group() const
Returns the name of the group in which we are searching for keys and from which we are retrieving ent...
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.
TDEConfigBase()
Construct a TDEConfigBase object.
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.
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.
void setGroup(const TQString &group)
Specifies the group in which keys will be read and written.
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.
virtual TQMap< TQString, TQString > entryMap(const TQString &group) const =0
Returns a map (tree) of entries for all entries in a particular group.
TQVariant readPropertyEntry(const TQString &pKey, TQVariant::Type) const
Reads the value of an entry specified by pKey in the current group.
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.
TDEConfigGroup(TDEConfigBase *master, const TQCString &group)
Construct a config group corresponding to group in master.
virtual KEntry lookupData(const KEntryKey &_key) const
Looks up an entry in the config object's internal structure.
virtual void setDirty(bool _bDirty)
Sets the global dirty flag of the config object.
virtual void putData(const KEntryKey &_key, const KEntry &_data, bool _checkGroup=true)
Inserts a (key/value) pair into the internal storage mechanism of the configuration object.
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.
key structure holding both the actual key and the the group to which it belongs.
map/dict/list config node entry.