summaryrefslogtreecommitdiffabout
path: root/microkde/kconfig.h
blob: 7b91e44b64e64b2dcc2d1088f8ebf21a7da62aa6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#ifndef MINIKDE_KCONFIG_H
#define MINIKDE_KCONFIG_H

#include <qstring.h>
#include <qstringlist.h>
#include <q3valuelist.h>
#include <qcolor.h>
#include <qfont.h>
#include <qmap.h>
#include <qdatetime.h>

class KConfig
{
  public:
    KConfig( const QString & );
    ~KConfig();
  
    void setTempGroup( const QString &group );
    QString tempGroup() const;

    void setGroup( const QString & );

//US
  /**
   * Returns the name of the group in which we are
   *  searching for keys and from which we are retrieving entries.
   *
   * @return The current group.
   */
    QString group() const;

//US I took the following deleteGroup method from a newer version from KDE.
/**
   * Deletes a configuration entry group
   *
   * If the group is not empty and bDeep is false, nothing gets
   * deleted and false is returned.
   * If this group is the current group and it is deleted, the
   * current group is undefined and should be set with setGroup()
   * before the next operation on the configuration object.
   *
   * @param group The name of the group
   *         returns true if we deleted at least one entry.
   */
    bool deleteGroup( const QString& group);
    
//US I took the following hasGroup method from a newer version from KDE.
  /**
   * Returns true if the specified group is known about.
   *
   * @param group The group to search for.
   * @return Whether the group exists.
   */
  bool hasGroup(const QString &group) const;
    
    
    QString getFileName();
    
//US added method readIntListEntry    
    Q3ValueList<int> readIntListEntry( const QString &);
    
    int readNumEntry( const QString &, int def=0 );
    QString readEntry( const QString &, const QString &def=QString::null );
    QStringList readListEntry( const QString & );
    bool readBoolEntry( const QString &, bool def=false );
    QColor readColorEntry( const QString &, QColor * );
    QFont readFontEntry( const QString &, QFont * );
    QDateTime readDateTimeEntry( const QString &, const QDateTime *pDefault = 0 );
    QSize readSizeEntry(const QString &, QSize* );
    bool hasKey( const QString &);
        
    void writeEntry( const QString &, const Q3ValueList<int>& );
    void writeEntry( const QString &, int );
    void writeEntry( const QString &key , unsigned int value) { writeEntry( key, int( value ) ); }
    void writeEntry( const char *key , unsigned int value) { writeEntry( QString( key ), value ); }
    void writeEntry( const char *key, int value ) { writeEntry( QString( key ), value ); } 
    void writeEntry( const QString &, const QString & );
    void writeEntry( const char *key, const QString &value ) { writeEntry( QString( key ), value ); }
    void writeEntry( const QString &, const QStringList & );
    void writeEntry( const QString &, bool );
    void writeEntry( const char *key, bool value ) { writeEntry( QString( key ), value ); } 
    void writeEntry( const QString &, const QColor & );
    void writeEntry( const QString &, const QFont & );
    void writeEntry( const QString &, const QDateTime & );
    void writeEntry( const QString &, const QSize & );

    void deleteEntry( const QString &);
        
    void load();
    void sync();

  private:  
    static QString mGroup;
    QString mTempGroup;
    
    QString mFileName;
    
    QMap<QString,bool> mBoolMap;
    QMap<QString,QString> mStringMap;
    QMap<QString,QDateTime> mDateTimeMap;
    
    bool mDirty;
};

#endif