File: krootprop.h

package info (click to toggle)
kdelibs 4%3A2.2.2-13.woody.14
  • links: PTS
  • area: main
  • in suites: woody
  • size: 36,832 kB
  • ctags: 40,077
  • sloc: cpp: 313,284; ansic: 20,558; xml: 11,448; sh: 11,318; makefile: 2,426; perl: 2,084; yacc: 1,663; java: 1,538; lex: 629; python: 300
file content (205 lines) | stat: -rw-r--r-- 5,926 bytes parent folder | download
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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
/* This file is part of the KDE libraries
    Copyright (C) 1997 Mark Donohoe (donohoe@kde.org)

    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Library General Public
    License as published by the Free Software Foundation; either
    version 2 of the License, or (at your option) any later version.

    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Library General Public License for more details.

    You should have received a copy of the GNU Library General Public License
    along with this library; see the file COPYING.LIB.  If not, write to
    the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.
*/
#ifndef _KROOTPROP_H
#define _KROOTPROP_H

typedef unsigned long Atom;

#include <qcolor.h>
#include <qfont.h>
#include <qstring.h>
#include <qmap.h>
#include <qstringlist.h>
#include <kapp.h>

class KRootPropPrivate;

/**
* Access KDE desktop resources stored on the root window.
*
* A companion to the @ref KConfig class.
*
* The @ref KRootProp class is used for reading and writing configuration entries
* to properties on the root window.
*
* All configuration entries are of the form "key=value".
*
* @see  KConfig::KConfig
* @author Mark Donohoe (donohe@kde.org)
* @version $Id: krootprop.h,v 1.15 2001/04/04 15:10:45 mueller Exp $
*/
class KRootProp
{
private:	
  Atom atom;
  QMap<QString,QString> propDict;
  QString property_;
  bool dirty;
  KRootPropPrivate *d;

protected:

public:
  /**
   * Construct a @ref KRootProp object for the property @p rProp.
   *
   **/
   KRootProp( const QString& rProp = QString::null );

/**
 * Destructor.
 *
 * Writes back any dirty configuration entries.
 **/
   ~KRootProp();
   
/**
 * Specify the property in which keys will be searched.
 *
 **/	
   void setProp(const QString& rProp="");
   
   
   /**
    * Retrieve the name of the property under which keys are searched.
    **/
   QString prop() const;
   
   /**
    * Destroy the property completely.
    *
    * I.e. all entries will be cleared
    * and the property will be removed from the root window.
    **/
 void destroy();

 /**
  * Read the value of an entry specified by @p rKey in the current property
  *
  * @param rKey	The key to search for.
  * @param pDefault A default value returned if the key was not found.
  * @return The value for this key or the default if no value
  *	  was found.
  **/	
 QString readEntry( const QString& rKey,
		    const QString& pDefault = QString::null ) const ;
					
 /**
  * Read a numerical value.
  *
  * Read the value of an entry specified by @p rKey in the current property
  * and interpret it numerically.
  *
  * @param rKey The key to search for.
  * @param nDefault A default value returned if the key was not found.
  * @return The value for this key or the default if no value was found.
  */
 int readNumEntry( const QString& rKey, int nDefault = 0 ) const;
 
 /**
  * Read a @ref QFont.
  *
  * Read the value of an entry specified by @p rKey in the current property
  * and interpret it as a font object.
  *
  * @param rKey		The key to search for.
  * @param pDefault	A default value returned if the key was not found.
  * @return The value for this key or a default font if no value was found.
  */
 QFont readFontEntry( const QString& rKey,
		      const QFont* pDefault = 0 ) const;
 
 /**
  * Read a @ref QColor.
  *
  * Read the value of an entry specified by @p rKey in the current property
  * and interpret it as a color.
  *
  * @param rKey		The key to search for.
  * @param pDefault	A default value returned if the key was not found.
  * @return The value for this key or a default color if no value
  * was found.
  */					
 QColor readColorEntry( const QString& rKey,
			const QColor* pDefault = 0 ) const;
							
	
 /**
  * @ref writeEntry() overridden to accept a const @ref QString& argument.
  *
  * This is stored to the current property when destroying the
  * config object or when calling @ref sync().
  *
  * @param rKey		The key to write.
  * @param rValue		The value to write.
  * @return The old value for this key. If this key did not exist,
  *	  a null string is returned.	
  *
  **/				
 QString writeEntry( const QString& rKey, const QString& rValue );

 /** Write the key value pair.
  * Same as above, but write a numerical value.
  * @param rKey The key to write.
  * @param nValue The value to write.
  * @return The old value for this key. If this key did not
  * exist, a null string is returned.	
  **/
 QString writeEntry( const QString& rKey, int nValue );

 /** Write the key value pair.
  * Same as above, but write a font.
  * @param rKey The key to write.
  * @param rValue The value to write.
  * @return The old value for this key. If this key did not
  * exist, a null string is returned.	
  **/
  QString writeEntry( const QString& rKey, const QFont& rFont );
 
  /** Write the key value pair.
   * Same as above, but write a color.
   * @param rKey The key to write.
   * @param rValue The value to write.
   * @return The old value for this key. If this key did not
   *  exist, a null string is returned.	
   **/
  QString writeEntry( const QString& rKey, const QColor& rColor );
  
  /**
   * Remove an entry.
   * @param rKey The key to remove.
   * @return The old value for this key. If this key did not
   *  exist, a null string is returned.
   **/
  QString removeEntry(const QString& rKey);

  /**
   * Get a list of all keys.
   * @return A @ref QStringList containing all the keys.
   **/
  QStringList listEntries() const;

  /** Flush the entry cache.
   * Write back dirty configuration entries to the current property,
   *  This is called automatically from the destructor.
   **/	
  void sync();
};

#endif