kconfigbase.h
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
#ifndef _KCONFIGBASE_H
00026
#define _KCONFIGBASE_H
00027
00028
#include <qobject.h>
00029
#include <qcolor.h>
00030
#include <qfont.h>
00031
#include <qdatetime.h>
00032
#include <qstrlist.h>
00033
#include <qstringlist.h>
00034
#include <qvariant.h>
00035
#include <qmap.h>
00036
00037
#include "kconfigdata.h"
00038
00039
class KConfigBackEnd;
00040
class KConfigBasePrivate;
00041
class KConfigGroup;
00042
00070 class KConfigBase :
public QObject
00071 {
00072 Q_OBJECT
00073
00074
friend class KConfigBackEnd;
00075
friend class KConfigINIBackEnd;
00076
friend class KConfigGroup;
00077
00078
public:
00082
KConfigBase();
00083
00087
virtual ~KConfigBase();
00088
00099
void setGroup(
const QString&
group );
00100
00105
void setDesktopGroup();
00106
00113
QString group()
const;
00114
00121
bool hasGroup(
const QString &group)
const;
00122
00128
virtual QStringList groupList()
const = 0;
00129
00135
QString locale()
const;
00136
00144
QString readEntry(
const QString& pKey,
00145
const QString& aDefault = QString::null )
const;
00146
00154
QString readEntry(
const char *pKey,
00155
const QString& aDefault = QString::null )
const;
00156
00170
QVariant readPropertyEntry(
const QString& pKey, QVariant::Type )
const;
00171
00186
QVariant readPropertyEntry(
const char *pKey, QVariant::Type )
const;
00187
00202
QVariant readPropertyEntry(
const QString& pKey,
00203
const QVariant &aDefault)
const;
00204
00219
QVariant readPropertyEntry(
const char *pKey,
00220
const QVariant &aDefault)
const;
00221
00232
int readListEntry(
const QString& pKey,
QStrList &list,
char sep =
',' )
const;
00233
00244
int readListEntry(
const char *pKey,
QStrList &list,
char sep =
',' )
const;
00245
00253
QStringList readListEntry(
const QString& pKey,
char sep =
',' )
const;
00254
00262
QStringList readListEntry(
const char *pKey,
char sep =
',' )
const;
00263
00270
QValueList<int> readIntListEntry(
const QString& pKey )
const;
00271
00278
QValueList<int> readIntListEntry(
const char *pKey )
const;
00279
00291
QString readPathEntry(
const QString& pKey,
const QString & aDefault = QString::null )
const;
00292
00304
QString readPathEntry(
const char *pKey,
const QString & aDefault = QString::null )
const;
00305
00318
QStringList readPathListEntry(
const QString& pKey,
char sep =
',' )
const;
00319
00332
QStringList readPathListEntry(
const char *pKey,
char sep =
',' )
const;
00333
00334
00346
int readNumEntry(
const QString& pKey,
int nDefault = 0 )
const;
00347
00359
int readNumEntry(
const char *pKey,
int nDefault = 0 )
const;
00360
00372
unsigned int readUnsignedNumEntry(
const QString& pKey,
unsigned int nDefault = 0 )
const;
00373
00385
unsigned int readUnsignedNumEntry(
const char *pKey,
unsigned int nDefault = 0 )
const;
00386
00387
00399
long readLongNumEntry(
const QString& pKey,
long nDefault = 0 )
const;
00400
00412
long readLongNumEntry(
const char *pKey,
long nDefault = 0 )
const;
00413
00425
unsigned long readUnsignedLongNumEntry(
const QString& pKey,
unsigned long nDefault = 0 )
const;
00426
00438
unsigned long readUnsignedLongNumEntry(
const char *pKey,
unsigned long nDefault = 0 )
const;
00439
00451 Q_INT64
readNum64Entry(
const QString& pKey, Q_INT64 nDefault = 0 )
const;
00452
00464 Q_INT64 readNum64Entry(
const char *pKey, Q_INT64 nDefault = 0 )
const;
00465
00477 Q_UINT64
readUnsignedNum64Entry(
const QString& pKey, Q_UINT64 nDefault = 0 )
const;
00478
00490 Q_UINT64 readUnsignedNum64Entry(
const char *pKey, Q_UINT64 nDefault = 0 )
const;
00491
00503
double readDoubleNumEntry(
const QString& pKey,
double nDefault = 0.0 )
const;
00504
00516
double readDoubleNumEntry(
const char *pKey,
double nDefault = 0.0 )
const;
00517
00529
QFont readFontEntry(
const QString& pKey,
const QFont* pDefault = 0L )
const;
00530
00542
QFont readFontEntry(
const char *pKey,
const QFont* pDefault = 0L )
const;
00543
00555
bool readBoolEntry(
const QString& pKey,
const bool bDefault =
false )
const;
00556
00568
bool readBoolEntry(
const char *pKey,
const bool bDefault =
false )
const;
00569
00581
QRect readRectEntry(
const QString& pKey,
const QRect* pDefault = 0L )
const;
00582
00594
QRect readRectEntry(
const char *pKey,
const QRect* pDefault = 0L )
const;
00595
00607
QPoint readPointEntry(
const QString& pKey,
const QPoint* pDefault = 0L )
const;
00608
00620
QPoint readPointEntry(
const char *pKey,
const QPoint* pDefault = 0L )
const;
00621
00633
QSize readSizeEntry(
const QString& pKey,
const QSize* pDefault = 0L )
const;
00634
00646
QSize readSizeEntry(
const char *pKey,
const QSize* pDefault = 0L )
const;
00647
00648
00660
QColor readColorEntry(
const QString& pKey,
const QColor* pDefault = 0L )
const;
00661
00673
QColor readColorEntry(
const char *pKey,
const QColor* pDefault = 0L )
const;
00674
00687
QDateTime readDateTimeEntry(
const QString& pKey,
const QDateTime* pDefault = 0L )
const;
00688
00701
QDateTime readDateTimeEntry(
const char *pKey,
const QDateTime* pDefault = 0L )
const;
00702
00711
QString readEntryUntranslated(
const QString& pKey,
00712
const QString& aDefault = QString::null )
const;
00713
00722
QString readEntryUntranslated(
const char *pKey,
00723
const QString& aDefault = QString::null )
const;
00724
00742
void writeEntry(
const QString& pKey,
const QString& pValue,
00743
bool bPersistent =
true,
bool bGlobal =
false,
00744
bool bNLS =
false );
00745
00763
void writeEntry(
const char *pKey,
const QString& pValue,
00764
bool bPersistent =
true,
bool bGlobal =
false,
00765
bool bNLS =
false );
00766
00786
void writeEntry(
const QString& pKey,
const QVariant& rValue,
00787
bool bPersistent =
true,
bool bGlobal =
false,
00788
bool bNLS =
false );
00808
void writeEntry(
const char *pKey,
const QVariant& rValue,
00809
bool bPersistent =
true,
bool bGlobal =
false,
00810
bool bNLS =
false );
00811
00832
void writeEntry(
const QString& pKey,
const QStrList &rValue,
00833
char sep =
',',
bool bPersistent =
true,
bool bGlobal =
false,
bool bNLS =
false );
00854
void writeEntry(
const char *pKey,
const QStrList &rValue,
00855
char sep =
',',
bool bPersistent =
true,
bool bGlobal =
false,
bool bNLS =
false );
00856
00877
void writeEntry(
const QString& pKey,
const QStringList &rValue,
00878
char sep =
',',
bool bPersistent =
true,
bool bGlobal =
false,
bool bNLS =
false );
00899
void writeEntry(
const char *pKey,
const QStringList &rValue,
00900
char sep =
',',
bool bPersistent =
true,
bool bGlobal =
false,
bool bNLS =
false );
00901
00902
00922
void writeEntry(
const QString& pKey,
const QValueList<int>& rValue,
00923
bool bPersistent =
true,
bool bGlobal =
false,
bool bNLS =
false );
00943
void writeEntry(
const char *pKey,
const QValueList<int>& rValue,
00944
bool bPersistent =
true,
bool bGlobal =
false,
bool bNLS =
false );
00945
00963 void writeEntry(
const QString& pKey,
const char *pValue,
00964
bool bPersistent =
true,
bool bGlobal =
false,
00965
bool bNLS =
false )
00966 { writeEntry(pKey, QString::fromLatin1(pValue), bPersistent, bGlobal, bNLS); }
00984 void writeEntry(
const char *pKey,
const char *pValue,
00985
bool bPersistent =
true,
bool bGlobal =
false,
00986
bool bNLS =
false )
00987 { writeEntry(pKey, QString::fromLatin1(pValue), bPersistent, bGlobal, bNLS); }
00988
01004
void writeEntry(
const QString& pKey,
int nValue,
01005
bool bPersistent =
true,
bool bGlobal =
false,
01006
bool bNLS =
false );
01022
void writeEntry(
const char *pKey,
int nValue,
01023
bool bPersistent =
true,
bool bGlobal =
false,
01024
bool bNLS =
false );
01025
01041
void writeEntry(
const QString& pKey,
unsigned int nValue,
01042
bool bPersistent =
true,
bool bGlobal =
false,
01043
bool bNLS =
false );
01059
void writeEntry(
const char *pKey,
unsigned int nValue,
01060
bool bPersistent =
true,
bool bGlobal =
false,
01061
bool bNLS =
false );
01062
01077
void writeEntry(
const QString& pKey,
long nValue,
01078
bool bPersistent =
true,
bool bGlobal =
false,
01079
bool bNLS =
false );
01094
void writeEntry(
const char *pKey,
long nValue,
01095
bool bPersistent =
true,
bool bGlobal =
false,
01096
bool bNLS =
false );
01097
01112
void writeEntry(
const QString& pKey,
unsigned long nValue,
01113
bool bPersistent =
true,
bool bGlobal =
false,
01114
bool bNLS =
false );
01129
void writeEntry(
const char *pKey,
unsigned long nValue,
01130
bool bPersistent =
true,
bool bGlobal =
false,
01131
bool bNLS =
false );
01132
01147
void writeEntry(
const QString& pKey, Q_LLONG nValue,
01148
bool bPersistent =
true,
bool bGlobal =
false,
01149
bool bNLS =
false );
01164
void writeEntry(
const char *pKey, Q_LLONG nValue,
01165
bool bPersistent =
true,
bool bGlobal =
false,
01166
bool bNLS =
false );
01167
01182
void writeEntry(
const QString& pKey, Q_ULLONG nValue,
01183
bool bPersistent =
true,
bool bGlobal =
false,
01184
bool bNLS =
false );
01199
void writeEntry(
const char *pKey, Q_ULLONG nValue,
01200
bool bPersistent =
true,
bool bGlobal =
false,
01201
bool bNLS =
false );
01202
01220
void writeEntry(
const QString& pKey,
double nValue,
01221
bool bPersistent =
true,
bool bGlobal =
false,
01222
char format =
'g',
int precision = 6,
01223
bool bNLS =
false );
01241
void writeEntry(
const char *pKey,
double nValue,
01242
bool bPersistent =
true,
bool bGlobal =
false,
01243
char format =
'g',
int precision = 6,
01244
bool bNLS =
false );
01245
01260
void writeEntry(
const QString& pKey,
bool bValue,
01261
bool bPersistent =
true,
bool bGlobal =
false,
01262
bool bNLS =
false );
01277
void writeEntry(
const char *pKey,
bool bValue,
01278
bool bPersistent =
true,
bool bGlobal =
false,
01279
bool bNLS =
false );
01280
01295
void writeEntry(
const QString& pKey,
const QFont& rFont,
01296
bool bPersistent =
true,
bool bGlobal =
false,
01297
bool bNLS =
false );
01312
void writeEntry(
const char *pKey,
const QFont& rFont,
01313
bool bPersistent =
true,
bool bGlobal =
false,
01314
bool bNLS =
false );
01315
01333
void writeEntry(
const QString& pKey,
const QColor& rColor,
01334
bool bPersistent =
true,
bool bGlobal =
false,
01335
bool bNLS =
false );
01353
void writeEntry(
const char *pKey,
const QColor& rColor,
01354
bool bPersistent =
true,
bool bGlobal =
false,
01355
bool bNLS =
false );
01356
01374
void writeEntry(
const QString& pKey,
const QDateTime& rDateTime,
01375
bool bPersistent =
true,
bool bGlobal =
false,
01376
bool bNLS =
false );
01394
void writeEntry(
const char *pKey,
const QDateTime& rDateTime,
01395
bool bPersistent =
true,
bool bGlobal =
false,
01396
bool bNLS =
false );
01397
01398
01416
void writeEntry(
const QString& pKey,
const QRect& rValue,
01417
bool bPersistent =
true,
bool bGlobal =
false,
01418
bool bNLS =
false );
01436
void writeEntry(
const char *pKey,
const QRect& rValue,
01437
bool bPersistent =
true,
bool bGlobal =
false,
01438
bool bNLS =
false );
01439
01457
void writeEntry(
const QString& pKey,
const QPoint& rValue,
01458
bool bPersistent =
true,
bool bGlobal =
false,
01459
bool bNLS =
false );
01477
void writeEntry(
const char *pKey,
const QPoint& rValue,
01478
bool bPersistent =
true,
bool bGlobal =
false,
01479
bool bNLS =
false );
01480
01498
void writeEntry(
const QString& pKey,
const QSize& rValue,
01499
bool bPersistent =
true,
bool bGlobal =
false,
01500
bool bNLS =
false );
01518
void writeEntry(
const char *pKey,
const QSize& rValue,
01519
bool bPersistent =
true,
bool bGlobal =
false,
01520
bool bNLS =
false );
01521
01539
void writePathEntry(
const QString& pKey,
const QString & path,
01540
bool bPersistent =
true,
bool bGlobal =
false,
01541
bool bNLS =
false );
01559
void writePathEntry(
const char *pKey,
const QString & path,
01560
bool bPersistent =
true,
bool bGlobal =
false,
01561
bool bNLS =
false );
01562
01586
void writePathEntry(
const QString& pKey,
const QStringList &rValue,
01587
char sep =
',',
bool bPersistent =
true,
bool bGlobal =
false,
bool bNLS =
false );
01611
void writePathEntry(
const char *pKey,
const QStringList &rValue,
01612
char sep =
',',
bool bPersistent =
true,
bool bGlobal =
false,
bool bNLS =
false );
01613
01614
01623
void deleteEntry(
const QString& pKey,
01624
bool bNLS =
false,
bool bGlobal =
false);
01633
void deleteEntry(
const char *pKey,
01634
bool bNLS =
false,
bool bGlobal =
false);
01635
01653
bool deleteGroup(
const QString& group,
bool bDeep =
true,
bool bGlobal =
false );
01654
01655
01663 void setDollarExpansion(
bool _bExpand =
true ) { bExpand = _bExpand; }
01664
01670 bool isDollarExpansion()
const {
return bExpand; }
01671
01686
virtual void rollback(
bool bDeep =
true );
01687
01701
virtual void sync();
01702
01707 bool isDirty()
const {
return bDirty; }
01708
01716 virtual void setReadOnly(
bool _ro) { bReadOnly = _ro; }
01717
01723 bool isReadOnly()
const {
return bReadOnly; }
01724
01734
bool hasKey(
const QString& key )
const;
01735
01746
virtual QMap<QString, QString> entryMap(
const QString &group)
const = 0;
01747
01760
virtual void reparseConfiguration() = 0;
01761
01766
bool isImmutable() const;
01767
01774
bool groupIsImmutable(const
QString &group) const;
01775
01782
bool entryIsImmutable(const
QString &key) const;
01783
01789 enum ConfigState { NoAccess, ReadOnly, ReadWrite };
01790
01804 ConfigState
getConfigState() const;
01805
01812
bool checkConfigFilesWritable(
bool warnUser);
01813
01820
void setReadDefaults(
bool b);
01821
01827
bool readDefaults() const;
01828
01840
void revertToDefault(const
QString &key);
01841
01862
bool hasDefault(const
QString &key) const;
01863
01864 protected:
01870
void setLocale();
01871
01877 virtual
void setDirty(
bool _bDirty = true) {
bDirty = _bDirty; }
01878
01884
virtual void parseConfigFiles();
01885
01901
virtual KEntryMap internalEntryMap(
const QString& pGroup )
const = 0;
01902
01914
virtual KEntryMap internalEntryMap() const = 0;
01915
01931 virtual
void putData(const
KEntryKey &_key, const
KEntry &_data,
bool _checkGroup = true) = 0;
01932
01947 virtual
KEntry lookupData(const
KEntryKey &_key) const = 0;
01948
01949 virtual
bool internalHasGroup(const
QCString &group) const = 0;
01950
01954 KConfigBackEnd *backEnd;
01955 public:
01959
void setGroup( const
QCString &pGroup );
01960
void setGroup( const
char *pGroup );
01961
bool hasGroup(const
QCString &_pGroup) const;
01962
bool hasGroup(const
char *_pGroup) const;
01963
bool hasKey( const
char *pKey ) const;
01964
01965 protected:
01966
QCString readEntryUtf8( const
char *pKey) const;
01967
01970 QCString mGroup;
01971
01974 QCString aLocaleString;
01975
01979 bool bDirty;
01980
01981
bool bLocaleInitialized;
01982
bool bReadOnly;
01983 mutable
bool bExpand;
01984
01985 protected:
01986 virtual
void virtual_hook(
int id,
void* data );
01987 private:
01988 class KConfigBasePrivate;
01989 KConfigBasePrivate *d;
01990 };
01991
01992 class KConfigGroupSaverPrivate;
01993
02027 class
KConfigGroupSaver
02028 {
02029
public:
02039 KConfigGroupSaver(
KConfigBase* config,
QString group )
02040
02041 : _config(config), _oldgroup(config->group())
02042 { _config->setGroup( group ); }
02043
02044 KConfigGroupSaver(
KConfigBase* config,
const char *group )
02045 : _config(config), _oldgroup(config->group())
02046 { _config->setGroup( group ); }
02047
02048 KConfigGroupSaver(
KConfigBase* config,
const QCString &group )
02049 : _config(config), _oldgroup(config->group())
02050 { _config->setGroup( group ); }
02051
02052 ~KConfigGroupSaver() { _config->setGroup( _oldgroup ); }
02053
02054
KConfigBase* config() {
return _config; };
02055
02056
private:
02057
KConfigBase* _config;
02058
QString _oldgroup;
02059
02060 KConfigGroupSaver(
const KConfigGroupSaver&);
02061 KConfigGroupSaver& operator=(
const KConfigGroupSaver&);
02062
02063 KConfigGroupSaverPrivate *d;
02064 };
02065
02066
class KConfigGroupPrivate;
02067
02071 class KConfigGroup:
public KConfigBase
02072 {
02073
public:
02078
KConfigGroup(
KConfigBase *master,
const QCString &group);
02085
KConfigGroup(
KConfigBase *master,
const QString &group);
02093
KConfigGroup(
KConfigBase *master,
const char * group);
02094
02101
void deleteGroup(
bool bGlobal =
false);
02102
02103
02104
virtual void setDirty(
bool b);
02105
virtual void putData(
const KEntryKey &_key,
const KEntry &_data,
bool _checkGroup =
true);
02106
virtual KEntry lookupData(
const KEntryKey &_key)
const;
02107
virtual void sync();
02108
02109
private:
02110
02111
void setGroup() { }
02112
void setDesktopGroup() { }
02113
void group() { }
02114
void hasGroup() { }
02115
void setReadOnly(
bool) { }
02116
void isDirty() { }
02117
02118
02119
virtual QStringList groupList()
const {
return QStringList(); }
02120
virtual void rollback(
bool) { }
02121
virtual void reparseConfiguration() { }
02122
virtual QMap<QString, QString> entryMap(
const QString &)
const
02123
{
return QMap<QString,QString>(); }
02124
virtual KEntryMap internalEntryMap(
const QString&)
const
02125
{
return KEntryMap(); }
02126
virtual KEntryMap internalEntryMap()
const
02127
{
return KEntryMap(); }
02128
virtual bool internalHasGroup(
const QCString &)
const
02129
{
return false; }
02130
02131
void getConfigState() { }
02132
02133
KConfigBase *mMaster;
02134
protected:
02135
virtual void virtual_hook(
int id,
void* data );
02136
private:
02137 KConfigGroupPrivate* d;
02138 };
02139
02140
#endif
This file is part of the documentation for kdecore Library Version 3.2.3.