• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • kdecore
 

kdecore

  • kdecore
kconfigbase.h
1 /*
2  This file is part of the KDE libraries
3  Copyright (c) 1999 Preston Brown <pbrown@kde.org>
4  Copyright (c) 1997 Matthias Kalle Dalheimer <kalle@kde.org>
5  Copyright (c) 2001 Waldo Bastian <bastian@kde.org>
6 
7  This library is free software; you can redistribute it and/or
8  modify it under the terms of the GNU Library General Public
9  License as published by the Free Software Foundation; either
10  version 2 of the License, or (at your option) any later version.
11 
12  This library is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  Library General Public License for more details.
16 
17  You should have received a copy of the GNU Library General Public License
18  along with this library; see the file COPYING.LIB. If not, write to
19  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20  Boston, MA 02110-1301, USA.
21 */
22 
23 #ifndef _KCONFIGBASE_H
24 #define _KCONFIGBASE_H
25 
26 #include <tqobject.h>
27 #include <tqcolor.h>
28 #include <tqfont.h>
29 #include <tqdatetime.h>
30 #include <tqstrlist.h>
31 #include <tqstringlist.h>
32 #include <tqvariant.h>
33 #include <tqmap.h>
34 
35 #include "kconfigdata.h"
36 #include "kdelibs_export.h"
37 
38 class KConfigBackEnd;
39 class KConfigBasePrivate;
40 class KConfigGroup;
41 
70 class KDECORE_EXPORT KConfigBase : public TQObject
71 {
72  Q_OBJECT
73  TQ_OBJECT
74 
75  friend class KConfigBackEnd;
76  friend class KConfigINIBackEnd;
77  friend class KConfigGroup;
78 
79 public:
83  KConfigBase();
84 
88  virtual ~KConfigBase();
89 
100  void setGroup( const TQString& group );
101 
106  void setDesktopGroup();
107 
114  TQString group() const;
115 
122  bool hasGroup(const TQString &group) const;
123 
129  virtual TQStringList groupList() const = 0;
130 
136  TQString locale() const;
137 
146  TQString readEntry(const TQString& pKey,
147  const TQString& aDefault = TQString::null ) const;
148 
156  TQString readEntry(const char *pKey,
157  const TQString& aDefault = TQString::null ) const;
158 
172  TQVariant readPropertyEntry( const TQString& pKey, TQVariant::Type ) const;
173 
188  TQVariant readPropertyEntry( const char *pKey, TQVariant::Type ) const;
189 
204  TQVariant readPropertyEntry( const TQString& pKey,
205  const TQVariant &aDefault) const;
206 
221  TQVariant readPropertyEntry( const char *pKey,
222  const TQVariant &aDefault) const;
223 
234  int readListEntry( const TQString& pKey, TQStrList &list, char sep = ',' ) const;
235 
246  int readListEntry( const char *pKey, TQStrList &list, char sep = ',' ) const;
247 
255  TQStringList readListEntry( const TQString& pKey, char sep = ',' ) const;
256 
264  TQStringList readListEntry( const char *pKey, char sep = ',' ) const;
265 
275  TQStringList readListEntry( const char* pKey, const TQStringList& aDefault,
276  char sep = ',' ) const;
277 
284  TQValueList<int> readIntListEntry( const TQString& pKey ) const;
285 
292  TQValueList<int> readIntListEntry( const char *pKey ) const;
293 
305  TQString readPathEntry( const TQString& pKey, const TQString & aDefault = TQString::null ) const;
306 
318  TQString readPathEntry( const char *pKey, const TQString & aDefault = TQString::null ) const;
319 
332  TQStringList readPathListEntry( const TQString& pKey, char sep = ',' ) const;
333 
346  TQStringList readPathListEntry( const char *pKey, char sep = ',' ) const;
347 
348 
360  int readNumEntry( const TQString& pKey, int nDefault = 0 ) const;
361 
373  int readNumEntry( const char *pKey, int nDefault = 0 ) const;
374 
386  unsigned int readUnsignedNumEntry( const TQString& pKey, unsigned int nDefault = 0 ) const;
387 
399  unsigned int readUnsignedNumEntry( const char *pKey, unsigned int nDefault = 0 ) const;
400 
401 
413  long readLongNumEntry( const TQString& pKey, long nDefault = 0 ) const;
414 
426  long readLongNumEntry( const char *pKey, long nDefault = 0 ) const;
427 
439  unsigned long readUnsignedLongNumEntry( const TQString& pKey, unsigned long nDefault = 0 ) const;
440 
452  unsigned long readUnsignedLongNumEntry( const char *pKey, unsigned long nDefault = 0 ) const;
453 
465  TQ_INT64 readNum64Entry( const TQString& pKey, TQ_INT64 nDefault = 0 ) const;
466 
478  TQ_INT64 readNum64Entry( const char *pKey, TQ_INT64 nDefault = 0 ) const;
479 
491  TQ_UINT64 readUnsignedNum64Entry( const TQString& pKey, TQ_UINT64 nDefault = 0 ) const;
492 
504  TQ_UINT64 readUnsignedNum64Entry( const char *pKey, TQ_UINT64 nDefault = 0 ) const;
505 
517  double readDoubleNumEntry( const TQString& pKey, double nDefault = 0.0 ) const;
518 
530  double readDoubleNumEntry( const char *pKey, double nDefault = 0.0 ) const;
531 
543  TQFont readFontEntry( const TQString& pKey, const TQFont* pDefault = 0L ) const;
544 
556  TQFont readFontEntry( const char *pKey, const TQFont* pDefault = 0L ) const;
557 
569  bool readBoolEntry( const TQString& pKey, bool bDefault = false ) const;
570 
582  bool readBoolEntry( const char *pKey, bool bDefault = false ) const;
583 
595  TQRect readRectEntry( const TQString& pKey, const TQRect* pDefault = 0L ) const;
596 
608  TQRect readRectEntry( const char *pKey, const TQRect* pDefault = 0L ) const;
609 
621  TQPoint readPointEntry( const TQString& pKey, const TQPoint* pDefault = 0L ) const;
622 
634  TQPoint readPointEntry( const char *pKey, const TQPoint* pDefault = 0L ) const;
635 
647  TQSize readSizeEntry( const TQString& pKey, const TQSize* pDefault = 0L ) const;
648 
660  TQSize readSizeEntry( const char *pKey, const TQSize* pDefault = 0L ) const;
661 
662 
674  TQColor readColorEntry( const TQString& pKey, const TQColor* pDefault = 0L ) const;
675 
687  TQColor readColorEntry( const char *pKey, const TQColor* pDefault = 0L ) const;
688 
701  TQDateTime readDateTimeEntry( const TQString& pKey, const TQDateTime* pDefault = 0L ) const;
702 
715  TQDateTime readDateTimeEntry( const char *pKey, const TQDateTime* pDefault = 0L ) const;
716 
725  TQString readEntryUntranslated( const TQString& pKey,
726  const TQString& aDefault = TQString::null ) const;
727 
736  TQString readEntryUntranslated( const char *pKey,
737  const TQString& aDefault = TQString::null ) const;
738 
758  void writeEntry( const TQString& pKey, const TQString& pValue,
759  bool bPersistent = true, bool bGlobal = false,
760  bool bNLS = false );
761 
779  void writeEntry( const char *pKey, const TQString& pValue,
780  bool bPersistent = true, bool bGlobal = false,
781  bool bNLS = false );
782 
802  void writeEntry( const TQString& pKey, const TQVariant& rValue,
803  bool bPersistent = true, bool bGlobal = false,
804  bool bNLS = false );
824  void writeEntry( const char *pKey, const TQVariant& rValue,
825  bool bPersistent = true, bool bGlobal = false,
826  bool bNLS = false );
827 
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 );
872 
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 );
917 
918 
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 );
961 
979  void writeEntry( const TQString& pKey, const char *pValue,
980  bool bPersistent = true, bool bGlobal = false,
981  bool bNLS = false )
982  { writeEntry(pKey, TQString::fromLatin1(pValue), bPersistent, bGlobal, bNLS); }
1000  void writeEntry( const char *pKey, const char *pValue,
1001  bool bPersistent = true, bool bGlobal = false,
1002  bool bNLS = false )
1003  { writeEntry(pKey, TQString::fromLatin1(pValue), bPersistent, bGlobal, bNLS); }
1004 
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 );
1041 
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 );
1078 
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 );
1113 
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 );
1148 
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 );
1183 
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 );
1218 
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 );
1261 
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 );
1296 
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 );
1331 
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 );
1372 
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 );
1413 
1414 
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 );
1455 
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 );
1496 
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 );
1537 
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 );
1578 
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 );
1629 
1630 
1639  void deleteEntry( const TQString& pKey,
1640  bool bNLS = false, bool bGlobal = false);
1649  void deleteEntry( const char *pKey,
1650  bool bNLS = false, bool bGlobal = false);
1651 
1669  bool deleteGroup( const TQString& group, bool bDeep = true, bool bGlobal = false );
1670 
1671 
1679  void setDollarExpansion( bool _bExpand = true ) { bExpand = _bExpand; }
1680 
1686  bool isDollarExpansion() const { return bExpand; }
1687 
1702  virtual void rollback( bool bDeep = true );
1703 
1717  virtual void sync();
1718 
1723  bool isDirty() const { return bDirty; }
1724 
1732  virtual void setReadOnly(bool _ro) { bReadOnly = _ro; }
1733 
1739  bool isReadOnly() const { return bReadOnly; }
1740 
1750  bool hasKey( const TQString& key ) const;
1751 
1762  virtual TQMap<TQString, TQString> entryMap(const TQString &group) const = 0;
1763 
1776  virtual void reparseConfiguration() = 0;
1777 
1782  bool isImmutable() const;
1783 
1790  bool groupIsImmutable(const TQString &group) const;
1791 
1798  bool entryIsImmutable(const TQString &key) const;
1799 
1805  enum ConfigState { NoAccess, ReadOnly, ReadWrite };
1806 
1820  ConfigState getConfigState() const;
1821 
1828  bool checkConfigFilesWritable(bool warnUser);
1829 
1836  void setReadDefaults(bool b);
1837 
1843  bool readDefaults() const;
1844 
1856  void revertToDefault(const TQString &key);
1857 
1884  bool hasDefault(const TQString &key) const;
1885 
1886 protected:
1892  void setLocale();
1893 
1899  virtual void setDirty(bool _bDirty = true) { bDirty = _bDirty; }
1900 
1906  virtual void parseConfigFiles();
1907 
1923  virtual KEntryMap internalEntryMap( const TQString& pGroup ) const = 0;
1924 
1936  virtual KEntryMap internalEntryMap() const = 0;
1937 
1953  virtual void putData(const KEntryKey &_key, const KEntry &_data, bool _checkGroup = true) = 0;
1954 
1969  virtual KEntry lookupData(const KEntryKey &_key) const = 0;
1970 
1971  virtual bool internalHasGroup(const TQCString &group) const = 0;
1972 
1976  KConfigBackEnd *backEnd;
1977 public:
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;
1986 
1987 protected:
1988  TQCString readEntryUtf8( const char *pKey) const;
1989  bool hasTranslatedKey( const char *pKey ) const;
1990 
1993  TQCString mGroup;
1994 
1997  TQCString aLocaleString;
1998 
2002  bool bDirty;
2003 
2004  bool bLocaleInitialized;
2005  bool bReadOnly; // currently only used by KSimpleConfig
2006  mutable bool bExpand; // whether dollar expansion is used
2007 
2008 protected:
2009  virtual void virtual_hook( int id, void* data );
2010 private:
2011  class KConfigBasePrivate;
2012  KConfigBasePrivate *d;
2013 
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 );
2018 
2019 };
2020 
2021 class KConfigGroupSaverPrivate;
2022 
2059 class KDECORE_EXPORT KConfigGroupSaver // KDE4 remove
2060 {
2061 public:
2071  KConfigGroupSaver( KConfigBase* config, TQString group )
2072  /* KDE 4 : make the second parameter const TQString & */
2073  : _config(config), _oldgroup(config->group())
2074  { _config->setGroup( group ); }
2075 
2076  KConfigGroupSaver( KConfigBase* config, const char *group )
2077  : _config(config), _oldgroup(config->group())
2078  { _config->setGroup( group ); }
2079 
2080  KConfigGroupSaver( KConfigBase* config, const TQCString &group )
2081  : _config(config), _oldgroup(config->group())
2082  { _config->setGroup( group ); }
2083 
2084  ~KConfigGroupSaver() { _config->setGroup( _oldgroup ); }
2085 
2086  KConfigBase* config() { return _config; };
2087 
2088 private:
2089  KConfigBase* _config;
2090  TQString _oldgroup;
2091 
2092  KConfigGroupSaver(const KConfigGroupSaver&);
2093  KConfigGroupSaver& operator=(const KConfigGroupSaver&);
2094 
2095  KConfigGroupSaverPrivate *d;
2096 };
2097 
2098 class KConfigGroupPrivate;
2099 
2103 class KDECORE_EXPORT KConfigGroup: public KConfigBase
2104 {
2105 public:
2110  KConfigGroup(KConfigBase *master, const TQCString &group);
2117  KConfigGroup(KConfigBase *master, const TQString &group);
2125  KConfigGroup(KConfigBase *master, const char * group);
2126 
2133  void deleteGroup(bool bGlobal = false);
2134 
2141  bool groupIsImmutable() const;
2142 
2143  // The following functions are reimplemented:
2144  virtual void setDirty(bool _bDirty);
2145  virtual void putData(const KEntryKey &_key, const KEntry &_data, bool _checkGroup = true);
2146  virtual KEntry lookupData(const KEntryKey &_key) const;
2147  virtual void sync();
2148 
2149 private:
2150  // Hide the following members:
2151  void setGroup() { }
2152  void setDesktopGroup() { }
2153  void group() { }
2154  void hasGroup() { }
2155  void setReadOnly(bool) { }
2156  void isDirty() { }
2157 
2158  // The following members are not used.
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
2169  { return false; }
2170 
2171  void getConfigState() { }
2172 
2173  KConfigBase *mMaster;
2174 protected:
2175  virtual void virtual_hook( int id, void* data );
2176 private:
2177  KConfigGroupPrivate* d;
2178 };
2179 
2180 #endif

kdecore

Skip menu "kdecore"
  • Main Page
  • Modules
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

kdecore

Skip menu "kdecore"
  • arts
  • dcop
  • dnssd
  • interfaces
  •     interface
  •     library
  •   kspeech
  •   ktexteditor
  • kabc
  • kate
  • kcmshell
  • kdecore
  • kded
  • kdefx
  • kdeprint
  • kdesu
  • kdeui
  • kdoctools
  • khtml
  • kimgio
  • kinit
  • kio
  •   bookmarks
  •   httpfilter
  •   kfile
  •   kio
  •   kioexec
  •   kpasswdserver
  •   kssl
  • kioslave
  •   http
  • kjs
  • kmdi
  •   kmdi
  • knewstuff
  • kparts
  • krandr
  • kresources
  • kspell2
  • kunittest
  • kutils
  • kwallet
  • libkmid
  • libkscreensaver
Generated for kdecore by doxygen 1.8.3.1
This website is maintained by Timothy Pearson.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. |