kdecore Library API Documentation

KRootProp Class Reference

Access KDE desktop resources stored on the root window. More...

#include <krootprop.h>

List of all members.

Public Methods

 KRootProp (const QString &rProp=QString::null)
 Constructs a KRootProp object for the property rProp.

 ~KRootProp ()
 Destructs the KRootProp object.

void setProp (const QString &rProp="")
 Sets the property in which keys will be searched.

QString prop () const
 Returns the name of the property under which keys are searched.

void destroy ()
 Destroys the property completely.

QString readEntry (const QString &rKey, const QString &pDefault=QString::null) const
 Reads the value of an entry specified by rKey in the current property.

int readNumEntry (const QString &rKey, int nDefault=0) const
 Reads a numerical value.

QFont readFontEntry (const QString &rKey, const QFont *pDefault=0) const
 Reads a QFont value.

QColor readColorEntry (const QString &rKey, const QColor *pDefault=0) const
 Reads a QColor.

QString writeEntry (const QString &rKey, const QString &rValue)
 Writes a (key/value) pair.

QString writeEntry (const QString &rKey, int nValue)
 Writes the (key/value) pair.

QString writeEntry (const QString &rKey, const QFont &rFont)
 Writes the (key/value) pair.

QString writeEntry (const QString &rKey, const QColor &rColor)
 Writes the (key/value) pair.

QString removeEntry (const QString &rKey)
 Removes an entry.

QStringList listEntries () const
 Returns a list of all keys.

void sync ()
 Flushes the entry cache.


Detailed Description

Access KDE desktop resources stored on the root window.

A companion to the KConfig class.

The 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 also:
KConfig::KConfig
Author:
Mark Donohoe (donohe@kde.org)
Version:
Id:
krootprop.h,v 1.20 2002/09/19 20:05:11 tjansen Exp

Definition at line 45 of file krootprop.h.


Constructor & Destructor Documentation

KRootProp::KRootProp const QString   rProp = QString::null
 

Constructs a KRootProp object for the property rProp.

Parameters:
rProp  the property that will be searched, null to do nothing
See also:
setProp()

Definition at line 32 of file krootprop.cpp.

References setProp().

KRootProp::~KRootProp  
 

Destructs the KRootProp object.

Writes back any dirty configuration entries.

Definition at line 39 of file krootprop.cpp.

References QMap< QString, QString >::clear(), and sync().


Member Function Documentation

void KRootProp::setProp const QString   rProp = ""
 

Sets the property in which keys will be searched.

Parameters:
rProp  the property that will be searched

Definition at line 71 of file krootprop.cpp.

References QString::find(), QString::fromUtf8(), QMap< QString, QString >::insert(), QString::isEmpty(), KStdAccel::key(), QString::left(), QString::length(), QString::mid(), QString::remove(), QString::simplifyWhiteSpace(), sync(), and QString::utf8().

Referenced by KRootProp().

QString KRootProp::prop  
 

Returns the name of the property under which keys are searched.

Returns:
the property that will be searched

Definition at line 141 of file krootprop.cpp.

void KRootProp::destroy  
 

Destroys the property completely.

I.e. all entries will be cleared and the property will be removed from the root window.

Definition at line 146 of file krootprop.cpp.

References QMap< QString, QString >::clear().

QString KRootProp::readEntry const QString   rKey,
const QString   pDefault = QString::null
const
 

Reads the value of an entry specified by rKey in the current property.

Parameters:
rKey  The key to search for.
pDefault  A default value returned if the key was not found.
Returns:
The value for this key or the default if no value was found.

Definition at line 156 of file krootprop.cpp.

References QMap< QString, QString >::contains().

Referenced by readColorEntry(), readFontEntry(), and readNumEntry().

int KRootProp::readNumEntry const QString   rKey,
int    nDefault = 0
const
 

Reads a numerical value.

Reads the value of an entry specified by rKey in the current property and interprets it numerically.

Parameters:
rKey  The key to search for.
nDefault  A default value returned if the key was not found.
Returns:
The value for this key or the default if no value was found.

Definition at line 165 of file krootprop.cpp.

References QString::isNull(), readEntry(), and QString::toInt().

QFont KRootProp::readFontEntry const QString   rKey,
const QFont   pDefault = 0
const
 

Reads a QFont value.

Reads the value of an entry specified by rKey in the current property and interpret it as a font object.

Parameters:
rKey  The key to search for.
pDefault  A default value returned if the key was not found.
Returns:
The value for this key or a default font if no value was found.

Definition at line 181 of file krootprop.cpp.

References QFont::fromString(), QString::isNull(), and readEntry().

QColor KRootProp::readColorEntry const QString   rKey,
const QColor   pDefault = 0
const
 

Reads a QColor.

Reads the value of an entry specified by rKey in the current property and interprets it as a color.

Parameters:
rKey  The key to search for.
pDefault  A default value returned if the key was not found.
Returns:
The value for this key or a default color if no value was found.

Definition at line 201 of file krootprop.cpp.

References QString::find(), QString::isNull(), QString::left(), QString::mid(), readEntry(), QColor::setNamedColor(), and QColor::setRgb().

QString KRootProp::writeEntry const QString   rKey,
const QString   rValue
 

Writes a (key/value) pair.

This is stored to the current property when destroying the config object or when calling sync().

Parameters:
rKey  The key to write.
rValue  The value to write.
Returns:
The old value for this key. If this key did not exist, a null string is returned.

Definition at line 242 of file krootprop.cpp.

References QMap< QString, QString >::contains(), QMap< QString, QString >::insert(), and QString::replace().

Referenced by writeEntry().

QString KRootProp::writeEntry const QString   rKey,
int    nValue
 

Writes the (key/value) pair.

Same as above, but writes a numerical value.

Parameters:
rKey  The key to write.
nValue  The value to write.
Returns:
The old value for this key. If this key did not exist, a null string is returned.

Definition at line 256 of file krootprop.cpp.

References QString::setNum(), and writeEntry().

QString KRootProp::writeEntry const QString   rKey,
const QFont   rFont
 

Writes the (key/value) pair.

Same as above, but writes a font.

Parameters:
rKey  The key to write.
rValue  The value to write.
Returns:
The old value for this key. If this key did not exist, a null string is returned.

Definition at line 265 of file krootprop.cpp.

References QFont::toString(), and writeEntry().

QString KRootProp::writeEntry const QString   rKey,
const QColor   rColor
 

Writes the (key/value) pair.

Same as above, but writes a color.

Parameters:
rKey  The key to write.
rValue  The value to write.
Returns:
The old value for this key. If this key did not exist, a null string is returned.

Definition at line 270 of file krootprop.cpp.

References QString::arg(), QColor::blue(), QColor::green(), QColor::red(), and writeEntry().

QString KRootProp::removeEntry const QString   rKey
 

Removes an entry.

Parameters:
rKey  The key to remove.
Returns:
The old value for this key. If this key did not exist, a null string is returned.

Definition at line 277 of file krootprop.cpp.

References QMap< QString, QString >::contains(), and QString::remove().

QStringList KRootProp::listEntries  
 

Returns a list of all keys.

Returns:
A QStringList containing all the keys.

Definition at line 288 of file krootprop.cpp.

References QMap< QString, QString >::begin(), and QMap< QString, QString >::end().

void KRootProp::sync  
 

Flushes the entry cache.

Writes back dirty configuration entries to the current property, This is called automatically from the destructor.

Definition at line 45 of file krootprop.cpp.

References QString::arg(), QMap< QString, QString >::begin(), QMap< QString, QString >::end(), QMap< QString, QString >::isEmpty(), QString::length(), and QString::utf8().

Referenced by setProp(), and ~KRootProp().


The documentation for this class was generated from the following files:
KDE Logo
This file is part of the documentation for kdelibs Version 3.1.0.
Documentation copyright © 1996-2002 the KDE developers.
Generated on Wed Oct 8 12:20:46 2003 by doxygen 1.2.18 written by Dimitri van Heesch, © 1997-2001