Source Code (Use browser search to find items of interest.)
Class Index
kdelibs'KConfigBase (./kdelibs/kdecore/kconfigbase.h:64)
class KConfigBase : public QObject
{
Q_OBJECT
friend class KConfigBackEnd;
friend class KConfigINIBackEnd;
public:
/**
* Construct a KConfigBase object.
*/
KConfigBase();
/**
* Destructor.
*/
virtual ~KConfigBase();
/**
* Specify the group in which keys will be searched.
*
* Subsequent
* calls to @ref readEntry() will only look for keys in the currently
* activated group.
*
* Switch back to the default group by passing an empty string.
* @param pGroup The name of the new group.
*/
void setGroup( const QString& pGroup );
/**
* Set the group to the "Desktop Entry" group used for
* desktop configuration files for applications, mime types, etc.
*/
void setDesktopGroup();
/**
* Retrieve 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 { return aGroup; }
/**
* Returns @p true if the specified group is known about.
*
* @param _pGroup The group to search for.
* @returns Whether or not the group exists.
*/
virtual bool hasGroup(const QString &_pGroup) const = 0;
/**
* Retrieve a list of groups that are known about.
*
* @returns The list of groups.
**/
virtual QStringList groupList() const = 0;
/**
* Retrieve a the current locale.
*
* @return A string representing the current locale.
*/
QString locale() const { return aLocaleString; }
/**
* Read the value of an entry specified by @p rKey in the current group.
*
* @param aKey The key to search for.
* @param aDefault A default value returned if the key was not found.
* @return The value for this key or a null string if no value
* was found.
*/
QString readEntry( const QString& aKey,
const QString& aDefault = QString::null ) const;
/**
* Read the value of an entry specified by @p aKey in the current group.
* The value is treated as if it is of the given type.
*
* @return An empty property on error.
*/
QVariant readPropertyEntry( const QString& aKey, QVariant::Type ) const;
/**
* Read a list of strings.
*
* @deprecated
*
* @param pKey The key to search for
* @param list In this object, the read list will be returned.
* @param sep The list separator (default ";")
* @return The number of entries in the list.
*/
int readListEntry( const QString& pKey, QStrList &list,
char sep = ',' ) const;
/**
* Read a list of strings.
*
* @param pKey The key to search for.
* @param sep The list separator (default is ";").
* @return The list.
*/
QStringList readListEntry( const QString& pKey, char sep = ',' ) const;
/**
* Read a list of Integers.
*
* @param pKey The key to search for.
* @return The list.
*/
QValueList<int> readIntListEntry( const QString& key ) const;
/**
* Read a numerical value.
*
* Read the value of an entry specified by @p rKey in the current group
* and interpret it numerically.
*
* @param pKey The key to search for.
* @param nDefault A default value returned if the key was not found.
* @return The value for this key or 0 if no value was found.
*/
int readNumEntry( const QString& pKey, int nDefault = 0 ) const;
/**
* Read a numerical value.
*
* Read the value of an entry specified by @p rKey in the current group
* and interpret it numerically.
*
* @param pKey The key to search for.
* @param nDefault A default value returned if the key was not found.
* @return The value for this key or 0 if no value was found.
*/
unsigned int readUnsignedNumEntry( const QString& pKey,
unsigned int nDefault = 0 ) const;
/**
* Read a numerical value.
*
* Read the value of an entry specified by @p rKey in the current group
* and interpret it numerically.
*
* @param pKey The key to search for.
* @param nDefault A default value returned if the key was not found.
* @return The value for this key or 0 if no value was found.
*/
long readLongNumEntry( const QString& pKey, long nDefault = 0 ) const;
/**
* Read a numerical value.
*
* Read the value of an entry specified by @p rKey in the current group
* and interpret it numerically.
*
* @param pKey The key to search for.
* @param nDefault A default value returned if the key was not found.
* @return The value for this key or 0 if no value was found.
*/
unsigned long readUnsignedLongNumEntry( const QString& pKey,
unsigned long nDefault = 0 ) const;
/**
* Read a numerical value.
*
* Read the value of an entry specified by @p rKey in the current group
* and interpret it numerically.
*
* @param pKey The key to search for.
* @param nDefault A default value returned if the key was not found.
* @return The value for this key or 0 if no value was found.
*/
double readDoubleNumEntry( const QString& pKey, double nDefault = 0.0 ) const;
/**
* Read a @ref QFont.
*
* Read the value of an entry specified by @p rKey in the current group
* and interpret it as a font object.
*
* @param pKey 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& pKey,
const QFont* pDefault = 0L ) const;
/**
* Read a boolean entry.
*
* Read the value of an entry specified by @p pKey in the current group
* and interpret it as a boolean value. Currently "on" and "true" are
* accepted as true, everything else if false.
*
* @param pKey The key to search for
* @param bDefault A default value returned if the key was not
* found.
* @return The value for this key or a default value if no value was
* found.
*/
bool readBoolEntry( const QString& pKey, const bool bDefault = false ) const;
/**
* Read a rect entry.
*
* Read the value of an entry specified by pKey in the current group
* and interpret it as a @ref QRect object.
*
* @param pKey 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 rectangle if no value
* was found.
*/
QRect readRectEntry( const QString& pKey, const QRect* pDefault = 0L ) const;
/**
* Read a point entry.
*
* Read the value of an entry specified by @p pKey in the current group
* and interpret it as a @ref QPoint object.
*
* @param pKey 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 point if no value
* was found.
*/
QPoint readPointEntry( const QString& pKey, const QPoint* pDefault = 0L ) const;
/**
* Read a size entry.
*
* Read the value of an entry specified by @p pKey in the current group
* and interpret it as a @ref QSize object.
*
* @param pKey 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 point if no value
* was found.
*/
QSize readSizeEntry( const QString& pKey, const QSize* pDefault = 0L ) const;
/**
* Read a @ref QColor.
*
* Read the value of an entry specified by @p rKey in the current group
* and interpret it as a color.
*
* @param pKey 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& pKey,
const QColor* pDefault = 0L ) const;
/**
* Read a @ref QDateTime.
*
* Read the value of an entry specified by @p rKey in the current group
* and interpret it as a date and time.
*
* @param pKey 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 @ref currentDateTime()
* (Qt global function) if no value was found.
*/
QDateTime readDateTimeEntry( const QString& pKey,
const QDateTime* pDefault = 0L ) const;
/**
* Write the key/value pair.
*
* This is stored in the most specific config file when destroying the
* config object or when calling @ref sync().
*
* @param pKey The key to write.
* @param pValue The value to write.
* @param bPersistent If @p bPersistent is false, the entry's dirty
* flag will not be set and thus the entry will
* not be written to disk at deletion time.
* @param bGlobal If @p bGlobal is true, the pair is not saved to the
* application specific config file, but to the
* global KDE config file.
* @param bNLS If @p bNLS is true, the locale tag is added to the key
* when writing it back.
* @return The old value for this key. If this key did not
* exist, a null string is returned.
*/
QString writeEntry( const QString& pKey, const QString& pValue,
bool bPersistent = true, bool bGlobal = false,
bool bNLS = false );
/**
* @ref writeEntry() overridden to accept a property.
*
* Note: Unlike the other @ref writeEntry() functions, the old value is
* _not_ returned here!
*
* @param rKey The key to write
* @param rValue The property to write
* @param bPersistent If @p bPersistent is false, the entry's dirty flag
* will not be set and thus the entry will not be
* written to disk at deletion time.
* @param bGlobal If @p bGlobal is true, the pair is not saved to the
* application specific config file, but to the
* global KDE config file.
* @param bNLS If @p bNLS is true, the locale tag is added to the key
* when writing it back.
*
* @see writeEntry()
*/
void writeEntry( const QString& rKey, const QVariant& rValue,
bool bPersistent = true, bool bGlobal = false,
bool bNLS = false );
/**
* @ref writeEntry() overriden to accept a list of strings.
*
* Note: Unlike the other @ref writeEntry() functions, the old value is
* _not_ returned here!
*
* @param rKey The key to write
* @param rValue The list to write
* @param bPersistent If @p bPersistent is false, the entry's dirty flag
* will not be set and thus the entry will not be
* written to disk at deletion time.
* @param bGlobal If @p bGlobal is true, the pair is not saved to the
* application specific config file, but to the
* global KDE config file.
* @param bNLS If @p bNLS is true, the locale tag is added to the key
* when writing it back.
*
* @see writeEntry()
*/
void writeEntry( const QString& pKey, const QStrList &rValue,
char sep = ',', bool bPersistent = true, bool bGlobal = false, bool bNLS = false );
/**
* @ref writeEntry() overridden to accept a list of strings.
*
* Note: Unlike the other @ref writeEntry() functions, the old value is
* _not_ returned here!
*
* @param rKey The key to write
* @param rValue The list to write
* @param bPersistent If @p bPersistent is false, the entry's dirty flag
* will not be set and thus the entry will not be
* written to disk at deletion time.
* @param bGlobal If @p bGlobal is true, the pair is not saved to the
* application specific config file, but to the
* global KDE config file.
* @param bNLS If @p bNLS is true, the locale tag is added to the key
* when writing it back.
*
* @see writeEntry()
*/
void writeEntry( const QString& pKey, const QStringList &rValue,
char sep = ',', bool bPersistent = true, bool bGlobal = false, bool bNLS = false );
/**
* @ref writeEntry() overridden to accept a list of Integers.
*
* Note: Unlike the other @ref writeEntry() functions, the old value is
* _not_ returned here!
*
* @param rKey The key to write
* @param rValue The list to write
* @param bPersistent If @p bPersistent is false, the entry's dirty flag
* will not be set and thus the entry will not be
* written to disk at deletion time.
* @param bGlobal If @p bGlobal is true, the pair is not saved to the
* application specific config file, but to the
* global KDE config file.
* @param bNLS If @p bNLS is true, the locale tag is added to the key
* when writing it back.
*
* @see writeEntry()
*/
void writeEntry( const QString& pKey, const QValueList<int>& rValue,
bool bPersistent = true, bool bGlobal = false, bool bNLS = false );
/**
* Write the key/value pair.
*
* This is stored to the most specific config file when destroying the
* config object or when calling @ref sync().
*
* @param pKey The key to write.
* @param pValue The value to write.
* @param bPersistent If @p bPersistent is false, the entry's dirty
* flag will not be set and thus the entry will
* not be written to disk at deletion time.
* @param bGlobal If @p bGlobal is true, the pair is not saved to the
* application specific config file, but to the
* global KDE config file.
* @param bNLS If @p bNLS is true, the locale tag is added to the key
* when writing it back.
* @return The old value for this key. If this key did not
* exist, a null string is returned.
*/
QString writeEntry( const QString& pKey, const char *pValue,
bool bPersistent = true, bool bGlobal = false,
bool bNLS = false )
{ return writeEntry(pKey, QString::fromLatin1(pValue), bPersistent, bGlobal, bNLS); }
/**
* Write the key value pair.
* Same as above, but write a numerical value.
*
* @param pKey The key to write.
* @param nValue The value to write.
* @param bPersistent If @p bPersistent is false, the entry's dirty
* flag will not be set and thus the entry will not be written to
* disk at deletion time.
* @param bGlobal If @p bGlobal is true, the pair is not saved to the
* application specific config file, but to the
* global KDE config file.
* @param bNLS If @p bNLS is true, the locale tag is added to the key
* when writing it back.
* @return The old value for this key. If this key did not
* exist, a null string is returned.
*/
QString writeEntry( const QString& pKey, int nValue,
bool bPersistent = true, bool bGlobal = false,
bool bNLS = false );
/**
* Write the key value pair.
* Same as above, but write an unsigned numerical value.
*
* @param pKey The key to write.
* @param nValue The value to write.
* @param bPersistent If @p bPersistent is false, the entry's dirty
* flag will not be set and thus the entry will not be written to
* disk at deletion time.
* @param bGlobal If @p bGlobal is true, the pair is not saved to the
* application specific config file, but to the
* global KDE config file.
* @param bNLS If @p bNLS is true, the locale tag is added to the key
* when writing it back.
* @return The old value for this key. If this key did not
* exist, a null string is returned.
*/
QString writeEntry( const QString& pKey, unsigned int nValue,
bool bPersistent = true, bool bGlobal = false,
bool bNLS = false );
/**
* Write the key value pair.
* Same as above, but write a long numerical value.
*
* @param pKey The key to write.
* @param nValue The value to write.
* @param bPersistent If @p bPersistent is false, the entry's dirty
* flag will not be set and thus the entry will not be written to
* disk at deletion time.
* @param bGlobal If @p bGlobal is true, the pair is not saved to the
* application specific config file, but to the global KDE config file.
* @param bNLS If @p bNLS is true, the locale tag is added to the key
* when writing it back.
* @return The old value for this key. If this key did not
* exist, a null string is returned.
*/
QString writeEntry( const QString& pKey, long nValue,
bool bPersistent = true, bool bGlobal = false,
bool bNLS = false );
/**
* Write the key value pair.
* Same as above, but write an unsigned long numerical value.
*
* @param pKey The key to write.
* @param nValue The value to write.
* @param bPersistent If @p bPersistent is false, the entry's dirty
* flag will not be set and thus the entry will not be written to
* disk at deletion time.
* @param bGlobal If @p bGlobal is true, the pair is not saved to the
* application specific config file, but to the global KDE config file.
* @param bNLS If @p bNLS is true, the locale tag is added to the key
* when writing it back.
* @return The old value for this key. If this key did not
* exist, a null string is returned.
*/
QString writeEntry( const QString& pKey, unsigned long nValue,
bool bPersistent = true, bool bGlobal = false,
bool bNLS = false );
/**
* Write the key value pair.
* Same as above, but write a floating-point value.*
* @param pKey The key to write.
* @param nValue The value to write.
* @param bPersistent If @p bPersistent is false, the entry's dirty
* flag will not be set and thus the entry will not be written to
* disk at deletion time.
* @param bGlobal If @p bGlobal is true, the pair is not saved to the
* application specific config file, but to the global KDE config file.
* @param format @p format determines the format to which the value
* is converted. Default is 'g'.
* @param precision @p precision sets the precision with which the
* value is converted. Default is 6 as in QString.
* @param bNLS If @p bNLS is true, the locale tag is added to the key
* when writing it back.
* @return The old value for this key. If this key did not
* exist, a null string is returned.
*/
QString writeEntry( const QString& pKey, double nValue,
bool bPersistent = true, bool bGlobal = false,
char format = 'g', int precision = 6,
bool bNLS = false );
/**
* Write the key value pair.
* Same as above, but write a boolean value.
*
* @param pKey The key to write.
* @param bValue The value to write.
* @param bPersistent If @p bPersistent is false, the entry's dirty
* flag will not be set and thus the entry will not be written to
* disk at deletion time.
* @param bGlobal If @p bGlobal is true, the pair is not saved to the
* application specific config file, but to the global KDE config file.
* @param bNLS If @p bNLS is true, the locale tag is added to the key
* when writing it back.
* @return The old value for this key. If this key did not
* exist, a null string is returned.
*/
QString writeEntry( const QString& pKey, bool bValue,
bool bPersistent = true, bool bGlobal = false,
bool bNLS = false );
/**
* Write the key value pair.
* Same as above, but write a font
*
* @param pKey The key to write.
* @param rFont The font value to write.
* @param bPersistent If @p bPersistent is false, the entry's dirty
* flag will not be set and thus the entry will not be written to
* disk at deletion time.
* @param bGlobal If @p bGlobal is true, the pair is not saved to the
* application specific config file, but to the global KDE config file.
* @param bNLS If @p bNLS is true, the locale tag is added to the key
* when writing it back.
* @return The old value for this key. If this key did not
* exist, a null string is returned.
*/
QString writeEntry( const QString& pKey, const QFont& rFont,
bool bPersistent = true, bool bGlobal = false,
bool bNLS = false );
/**
* Write the key value pair.
* Same as above, but write a color.
*
* Note: Unlike the other @ref writeEntry() functions, the old value is
* _not_ returned here!
*
* @param pKey The key to write.
* @param rValue The color value to write.
* @param bPersistent If @p bPersistent is false, the entry's dirty
* flag will not be set and thus the entry will not be written to
* disk at deletion time.
* @param bGlobal If @p bGlobal is true, the pair is not saved to the
* application specific config file, but to the global KDE config file.
* @param bNLS If @p bNLS is true, the locale tag is added to the key
* when writing it back.
*/
void writeEntry( const QString& pKey, const QColor& rColor,
bool bPersistent = true, bool bGlobal = false,
bool bNLS = false );
/**
* Write the key value pair.
* Same as above, but write a data & time.
*
* Note: Unlike the other @ref writeEntry() functions, the old value is
* _not_ returned here!
*
* @param pKey The key to write.
* @param rValue The date & time value to write.
* @param bPersistent If @p bPersistent is false, the entry's dirty
* flag will not be set and thus the entry will not be written to
* disk at deletion time.
* @param bGlobal If @p bGlobal is true, the pair is not saved to the
* application specific config file, but to the global KDE config file.
* @param bNLS If @p bNLS is true, the locale tag is added to the key
* when writing it back.
*/
void writeEntry( const QString& pKey, const QDateTime& rDateTime,
bool bPersistent = true, bool bGlobal = false,
bool bNLS = false );
/**
* Write the key value pair.
* Same as above, but write a rectangle.
*
* Note: Unlike the other @ref writeEntry() functions, the old value is
* _not_ returned here!
*
* @param pKey The key to write.
* @param rValue The rectangle value to write.
* @param bPersistent If @p bPersistent is false, the entry's dirty
* flag will not be set and thus the entry will not be written to
* disk at deletion time.
* @param bGlobal If @p bGlobal is true, the pair is not saved to the
* application specific config file, but to the global KDE config file.
* @param bNLS If @p bNLS is true, the locale tag is added to the key
* when writing it back.
*/
void writeEntry( const QString& pKey, const QRect& rColor,
bool bPersistent = true, bool bGlobal = false,
bool bNLS = false );
/**
* Write the key value pair.
* Same as above, but write a point.
*
* Note: Unlike the other @ref writeEntry() functions, the old value is
* _not_ returned here!
*
* @param pKey The key to write.
* @param rValue The point value to write.
* @param bPersistent If @p bPersistent is false, the entry's dirty
* flag will not be set and thus the entry will not be written to
* disk at deletion time.
* @param bGlobal If @p bGlobal is true, the pair is not saved to the
* application specific config file, but to the global KDE config file.
* @param bNLS If @p bNLS is true, the locale tag is added to the key
* when writing it back.
*/
void writeEntry( const QString& pKey, const QPoint& rColor,
bool bPersistent = true, bool bGlobal = false,
bool bNLS = false );
/**
* Write the key value pair.
* Same as above, but write a size.
*
* Note: Unlike the other @ref writeEntry() functions, the old value is
* _not_ returned here!
*
* @param pKey The key to write.
* @param rValue The size value to write.
* @param bPersistent If @p bPersistent is false, the entry's dirty
* flag will not be set and thus the entry will not be written to
* disk at deletion time.
* @param bGlobal If @p bGlobal is true, the pair is not saved to the
* application specific config file, but to the global KDE config file.
* @param bNLS If @p bNLS is true, the locale tag is added to the key
* when writing it back.
*/
void writeEntry( const QString& pKey, const QSize& rColor,
bool bPersistent = true, bool bGlobal = false,
bool bNLS = false );
/**
* Turns on or off "dollar expansion" (see @ref KConfigBase introduction)
* when reading config entries.
* Dollar sign expansion is initially ON.
*
* @param _bExpand Tf true, dollar expansion is turned on.
*/
void setDollarExpansion( bool _bExpand = true ) { bExpand = _bExpand; }
/**
* Returns whether dollar expansion is on or off. It is initially ON.
*
* @return true if dollar expansion is on.
*/
bool isDollarExpansion() const { return bExpand; }
/**
* Mark the config object as "clean," i.e. don't write dirty entries
* at destruction time. If @p bDeep is false, only the global dirty
* flag of the KConfig object gets cleared. If you then call
* @ref writeEntry() again, the global dirty flag is set again and all
* dirty entries will be written at a subsequent @ref sync() call.
*
* Classes which derive from @ref KConfigObject should override this
* method and implement storage-specific behaviour, as well as
* calling the @ref KConfigBase::rollback() explicitly in the initializer.
*
* @param bDeep if true, the dirty flags of all entries are cleared,
* as well as the global dirty flag.
*/
virtual void rollback( bool bDeep = true );
/**
* Flush all changes that currently reside only in memory
* back to disk / permanent storage. Dirty configuration entries are
* written to the the most specific file available.
*
* Asks the back end to flush out all pending writes, and then calls
* @ref rollback(). No changes are made if the object has @p readOnly
* status.
*
* You should call this from your destructor in derivative classes.
*
* @see rollback(), isReadOnly()
*/
virtual void sync();
/**
* @returns @p true if the config file has any dirty (modified) entries.
*/
bool isDirty() const { return bDirty; }
/**
* Set the config object's read-only status.
*
* @param _ro If @p true, the config object will not write out any
* changes to disk even if it is destroyed or @ref sync() is called.
*
*/
void setReadOnly(bool _ro) { bReadOnly = _ro; }
/**
* Queries the read-only status of the config object.
*
* @return The read-only status.
*/
bool isReadOnly() const { return bReadOnly; }
/**
* Check if the key has an entry in the currently active group.
* Use this to determine if a key is not specified for the current
* group (hasKey() returns false). Keys with null data are considered
* nonexistent.
*
* @param pKey The key to search for.
* @return If @ref true, the key is available.
*/
virtual bool hasKey( const QString& pKey ) const = 0;
/**
* Return a map (tree) of entries for all entries in a particular
* group. Only the actual entry string is returned, none of the
* other internal data should be included.
*
* @param pGroup A group to get keys from.
* @return A map of entries in the group specified, indexed by key.
* The returned map may be empty if the group is not found.
* @see QMap
*/
virtual QMap<QString, QString> entryMap(const QString &pGroup) const = 0;
/**
* Reparses all configuration files. This is useful for programs
* which use standalone graphical configuration tools. The base
* method implemented here only clears the group list and then
* appends the default group.
*
* Derivative classes should clear any internal data structures and
* then simply call @ref parseConfigFiles() when implementing this
* method.
*
* @see parseConfigFiles()
*/
virtual void reparseConfiguration() = 0;
/**
* Possible return values for @ref getConfigState().
*
* @see getConfigState()
*/
enum ConfigState { NoAccess, ReadOnly, ReadWrite };
/**
* Retrieve the state of the app-config object.
*
* Possible return values
* are NoAccess (the application-specific config file could not be
* opened neither read-write nor read-only), ReadOnly (the
* application-specific config file is opened read-only, but not
* read-write) and ReadWrite (the application-specific config
* file is opened read-write).
*
* @see ConfigState()
*/
ConfigState getConfigState() const;
protected:
/**
* Read the locale and put in the configuration data struct.
* Note: This should be done in the constructor, but this is not
* possible due to some mutual dependencies in KApplication::init()
*/
void setLocale();
/**
* Sets the global dirty flag of the config object
*
* @param _bDirty how to mark the object's dirty status
*/
void setDirty(bool _bDirty = true) { bDirty = _bDirty; }
/**
* Parse all configuration files for a configuration object.
*
* The actual parsing is done by the associated KConfigBackEnd.
*/
void parseConfigFiles();
/**
* Returns an map (tree) of the entries in the specified group.
* This may or may not return all entries that belong to the
* config object. The only guarantee that you are given is that
* any entries that are dirty (i.e. modified and not yet written back
* to the disk) will be contained in the map. Some derivative
* classes may choose to return everything.
*
* Do not use this function, the implementation / return type are
* subject to change.
*
* @param pGroup the group to provide a KEntryMap for.
* @return The map of the entries in the group.
* @internal
*/
virtual KEntryMap internalEntryMap( const QString& pGroup ) const = 0;
/**
* Returns an map (tree) of the entries in the tree.
*
* Do not use this function, the implementation / return type are
* subject to change.
*
* @return a map of the entries in the tree.
* @internal
*/
virtual KEntryMap internalEntryMap() const = 0;
/**
* Insert a key,value pair into the internal storage mechanism of
* the configuration object. Classes that derive from KConfigBase
* will need to implement this method in a storage-specific manner.
*
* Do not use this function, the implementation / return type are
* subject to change.
*
* @param _key The key to insert. It contains information both on
* the group of the key and the key itself. If the key already
* exists, the old value will be replaced.
* @param _data the KEntry that is to be stored.
* @internal
*/
virtual void putData(const KEntryKey &_key, const KEntry &_data) = 0;
/**
* Look up an entry in the config object's internal structure.
* Classes that derive from KConfigBase will need to implement this
* method in a storage-specific manner.
*
* Do not use this function, the implementation / return type are
* subject to change.
*
* @param _key The key to look up It contains information both on
* the group of the key and the entry's key itself.
* @return the KEntry value (data) found for the key. KEntry.aValue
* will be the null string if nothing was located.
* @internal
*/
virtual KEntry lookupData(const KEntryKey &_key) const = 0;
/**
* A back end for loading/saving to disk in a particular format.
*/
KConfigBackEnd *backEnd;
private:
/**
* The currently selected group. */
QString aGroup;
/**
* the locale to retrieve keys under if possible, i.e en_US or fr. */
QString aLocaleString;
/**
* Indicates whether there are any dirty entries in the config object
* that need to be written back to disk. */
bool bDirty;
bool bLocaleInitialized;
bool bReadOnly; // currently only used by KSimpleConfig
bool bExpand; // whether dollar expansion is used
KConfigBasePrivate *d;
};
// we put this here instead of in the declaration above to
// avoid warnings about the unused parameter.
inline void KConfigBase::rollback( bool /*bDeep = true*/ )
{
bDirty = false;
}
kdelibs'KConfigBase::KConfigBase() (./kdelibs/kdecore/kconfigbase.cpp:33)
KConfigBase::KConfigBase()
: backEnd(0L), bDirty(false), bLocaleInitialized(false),
bReadOnly(false), bExpand(true)
{
aGroup = "<default>";
}
kdelibs'KConfigBase::~KConfigBase() (./kdelibs/kdecore/kconfigbase.cpp:40)
KConfigBase::~KConfigBase()
{
}
kdelibs'KConfigBase::setLocale() (./kdelibs/kdecore/kconfigbase.cpp:44)
void KConfigBase::setLocale()
{
bLocaleInitialized = true;
if (KGlobal::locale())
aLocaleString = KGlobal::locale()->language();
else
aLocaleString = "C";
}
kdelibs'KConfigBase::setGroup() (./kdelibs/kdecore/kconfigbase.cpp:54)
void KConfigBase::setGroup( const QString& pGroup )
{
if ( pGroup.isNull() )
aGroup = "<default>";
else if (pGroup.find(QString::fromLatin1("Desktop Entry")) != -1) {
debug("warning, setting Desktop Entry group through KConfig::setGroup() is deprecated.");
debug("please use KConfig::setDesktopGroup() instead.");
abort();
setDesktopGroup();
} else
aGroup = pGroup;
}
kdelibs'KConfigBase::setDesktopGroup() (./kdelibs/kdecore/kconfigbase.cpp:67)
void KConfigBase::setDesktopGroup()
{
// we maintain the first for backwards compatibility with
// old .kdelnk files
if (hasGroup(QString::fromLatin1("KDE Desktop Entry")))
aGroup = "KDE Desktop Entry";
else
aGroup = "Desktop Entry";
}
kdelibs'KConfigBase::readEntry() (./kdelibs/kdecore/kconfigbase.cpp:77)
QString KConfigBase::readEntry( const QString& aKey,
const QString& aDefault ) const
{
// we need to access _locale instead of the method locale()
// because calling locale() will create a locale object if it
// doesn't exist, which requires KConfig, which will create a infinite
// loop, and nobody likes those.
if (!bLocaleInitialized && KGlobal::_locale) {
// get around const'ness.
KConfigBase *that = const_cast<KConfigBase *>(this);
that->setLocale();
}
QString aValue = QString::null;
// construct a localized version of the key
QString aLocalizedKey = QString( aKey );
aLocalizedKey += '[';
aLocalizedKey += aLocaleString;
aLocalizedKey += ']';
// find the value for the key in the current group
// try the localized key first
KEntry aEntryData;
KEntryKey entryKey(aGroup, aLocalizedKey);
aEntryData = lookupData(entryKey);
if (!aEntryData.aValue.isNull()) {
aValue = aEntryData.aValue;
} else {
entryKey.key = aKey;
aEntryData = lookupData(entryKey);
if (!aEntryData.aValue.isNull()) {
aValue = aEntryData.aValue;
} else {
aValue = aDefault;
}
}
// only do dollar expansion if so desired
if( bExpand )
{
// check for environment variables and make necessary translations
int nDollarPos = aValue.find( '$' );
while( nDollarPos != -1 && nDollarPos+1 < static_cast<int>(aValue.length())) {
// there is at least one $
if( (aValue)[nDollarPos+1] != '$' ) {
uint nEndPos = nDollarPos;
// the next character is no $
do {
nEndPos++;
} while ( aValue[nEndPos].isNumber()
|| aValue[nEndPos].isLetter() || nEndPos > aValue.length() );
QString aVarName = aValue.mid( nDollarPos+1, nEndPos-nDollarPos-1 );
const char* pEnv = 0;
if (!aVarName.isEmpty())
pEnv = getenv( aVarName.ascii() );
if( pEnv )
aValue.replace( nDollarPos, nEndPos-nDollarPos, QString::fromLatin1(pEnv) );
else
aValue.remove( nDollarPos, nEndPos-nDollarPos );
} else {
// remove one of the dollar signs
aValue.remove( nDollarPos, 1 );
nDollarPos++;
}
nDollarPos = aValue.find( '$', nDollarPos );
}
}
return aValue;
}
kdelibs'KConfigBase::readPropertyEntry() (./kdelibs/kdecore/kconfigbase.cpp:150)
QVariant KConfigBase::readPropertyEntry( const QString& aKey,
QVariant::Type type ) const
{
QValueList<QVariant> list;
QStringList strList;
QStringList::ConstIterator it;
QStringList::ConstIterator end;
QVariant tmp;
switch( type )
{
case QVariant::Invalid:
return QVariant();
case QVariant::String:
return QVariant( readEntry( aKey ) );
case QVariant::StringList:
return QVariant( readListEntry( aKey ) );
case QVariant::List:
strList = readListEntry( aKey );
it = strList.begin();
end = strList.end();
for (; it != end; ++it ) {
tmp = *it;
list.append( tmp );
}
return QVariant( list );
case QVariant::Font:
return QVariant( readFontEntry( aKey ) );
case QVariant::Pixmap:
ASSERT( 0 );
return QVariant();
case QVariant::Image:
ASSERT( 0 );
return QVariant();
case QVariant::Brush:
ASSERT( 0 );
return QVariant();
case QVariant::Point:
return QVariant( readPointEntry( aKey ) );
case QVariant::Rect:
return QVariant( readRectEntry( aKey ) );
case QVariant::Size:
return QVariant( readSizeEntry( aKey ) );
case QVariant::Color:
return QVariant( readColorEntry( aKey ) );
case QVariant::Palette:
ASSERT( 0 );
return QVariant();
case QVariant::ColorGroup:
ASSERT( 0 );
return QVariant();
case QVariant::Int:
return QVariant( readNumEntry( aKey ) );
case QVariant::Bool:
return QVariant( readBoolEntry( aKey ) );
case QVariant::Double:
return QVariant( readDoubleNumEntry( aKey ) );
default:
ASSERT( 0 );
}
// Never reached
return QVariant();
}
kdelibs'KConfigBase::readListEntry() (./kdelibs/kdecore/kconfigbase.cpp:218)
int KConfigBase::readListEntry( const QString& pKey,
QStrList &list, char sep ) const
{
if( !hasKey( pKey ) )
return 0;
QString str_list, value;
str_list = readEntry( pKey );
if (str_list.isEmpty())
return 0;
list.clear();
int i;
value = "";
int len = str_list.length();
for (i = 0; i < len; i++) {
if (str_list[i] != sep && str_list[i] != '\\') {
value += str_list[i];
continue;
}
if (str_list[i] == '\\') {
i++;
value += str_list[i];
continue;
}
// if we fell through to here, we are at a separator. Append
// contents of value to the list
list.append( value.ascii() );
value.truncate(0);
}
if ( str_list[len-1].latin1() != sep )
list.append( value.ascii() );
return list.count();
}
kdelibs'KConfigBase::readListEntry() (./kdelibs/kdecore/kconfigbase.cpp:255)
QStringList KConfigBase::readListEntry( const QString& pKey, char sep ) const
{
QStringList list;
if( !hasKey( pKey ) )
return list;
QString str_list, value;
str_list = readEntry( pKey );
if( str_list.isEmpty() )
return list;
int i;
value = "";
int len = str_list.length();
for( i = 0; i < len; i++ )
{
if( str_list[i] != sep && str_list[i] != '\\' )
{
value += str_list[i];
continue;
}
if( str_list[i] == '\\' )
{
i++;
value += str_list[i];
continue;
}
list.append( value );
value.truncate(0);
}
if ( str_list[len-1] != sep )
list.append( value );
return list;
}
kdelibs'KConfigBase::readIntListEntry() (./kdelibs/kdecore/kconfigbase.cpp:288)
QValueList<int> KConfigBase::readIntListEntry( const QString& pKey ) const
{
QStringList strlist = readListEntry(pKey);
QValueList<int> list;
for (QStringList::ConstIterator it = strlist.begin(); it != strlist.end(); it++)
// I do not check if the toInt failed because I consider the number of items
// more important than their value
list << (*it).toInt();
return list;
}
kdelibs'KConfigBase::readNumEntry() (./kdelibs/kdecore/kconfigbase.cpp:300)
int KConfigBase::readNumEntry( const QString& pKey, int nDefault) const
{
bool ok;
int rc;
QString aValue = readEntry( pKey );
if( aValue.isNull() )
return nDefault;
else if( aValue == QString::fromLatin1("true") )
return 1;
else if( aValue == QString::fromLatin1("on") )
return 1;
else if( aValue == QString::fromLatin1("yes") )
return 1;
else
{
rc = aValue.toInt( &ok );
return( ok ? rc : 0 );
}
}
kdelibs'KConfigBase::readUnsignedNumEntry() (./kdelibs/kdecore/kconfigbase.cpp:322)
unsigned int KConfigBase::readUnsignedNumEntry( const QString& pKey, unsigned int nDefault) const
{
bool ok;
unsigned int rc;
QString aValue = readEntry( pKey );
if( aValue.isNull() )
return nDefault;
else
{
rc = aValue.toUInt( &ok );
return( ok ? rc : 0 );
}
}
kdelibs'KConfigBase::readLongNumEntry() (./kdelibs/kdecore/kconfigbase.cpp:338)
long KConfigBase::readLongNumEntry( const QString& pKey, long nDefault) const
{
bool ok;
long rc;
QString aValue = readEntry( pKey );
if( aValue.isNull() )
return nDefault;
else
{
rc = aValue.toLong( &ok );
return( ok ? rc : 0 );
}
}
kdelibs'KConfigBase::readUnsignedLongNumEntry() (./kdelibs/kdecore/kconfigbase.cpp:354)
unsigned long KConfigBase::readUnsignedLongNumEntry( const QString& pKey, unsigned long nDefault) const
{
bool ok;
unsigned long rc;
QString aValue = readEntry( pKey );
if( aValue.isNull() )
return nDefault;
else
{
rc = aValue.toULong( &ok );
return( ok ? rc : 0 );
}
}
kdelibs'KConfigBase::readDoubleNumEntry() (./kdelibs/kdecore/kconfigbase.cpp:370)
double KConfigBase::readDoubleNumEntry( const QString& pKey, double nDefault) const
{
bool ok;
double rc;
QString aValue = readEntry( pKey );
if( aValue.isNull() )
return nDefault;
else
{
rc = aValue.toDouble( &ok );
return( ok ? rc : 0 );
}
}
kdelibs'KConfigBase::readBoolEntry() (./kdelibs/kdecore/kconfigbase.cpp:386)
bool KConfigBase::readBoolEntry( const QString& pKey, const bool bDefault ) const
{
QString aValue = readEntry( pKey );
if( aValue.isNull() )
return bDefault;
else
{
if( aValue == QString::fromLatin1("true") || aValue == QString::fromLatin1("on") || aValue == QString::fromLatin1("1"))
return true;
else
{
bool bOK;
int val = aValue.toInt( &bOK );
if( bOK && val != 0 )
return true;
else
return false;
}
}
}
kdelibs'KConfigBase::readFontEntry() (./kdelibs/kdecore/kconfigbase.cpp:411)
QFont KConfigBase::readFontEntry( const QString& pKey,
const QFont* pDefault ) const
{
QFont aRetFont;
QString aValue = readEntry( pKey );
if( !aValue.isNull() )
{
// find first part (font family)
int nIndex = aValue.find( ',' );
if( nIndex == -1 ){
if( pDefault )
aRetFont = *pDefault;
return aRetFont;
}
aRetFont.setFamily( aValue.left( nIndex ) );
// find second part (point size)
int nOldIndex = nIndex;
nIndex = aValue.find( ',', nOldIndex+1 );
if( nIndex == -1 ){
if( pDefault )
aRetFont = *pDefault;
return aRetFont;
}
aRetFont.setPointSize( aValue.mid( nOldIndex+1,
nIndex-nOldIndex-1 ).toInt() );
// find third part (style hint)
nOldIndex = nIndex;
nIndex = aValue.find( ',', nOldIndex+1 );
if( nIndex == -1 ){
if( pDefault )
aRetFont = *pDefault;
return aRetFont;
}
aRetFont.setStyleHint( (QFont::StyleHint)aValue.mid( nOldIndex+1, nIndex-nOldIndex-1 ).toUInt() );
// find fourth part (char set)
nOldIndex = nIndex;
nIndex = aValue.find( ',', nOldIndex+1 );
if( nIndex == -1 ){
if( pDefault )
aRetFont = *pDefault;
return aRetFont;
}
QString chStr=aValue.mid( nOldIndex+1,
nIndex-nOldIndex-1 );
bool chOldEntry;
QFont::CharSet chId=(QFont::CharSet)aValue.mid( nOldIndex+1,
nIndex-nOldIndex-1 ).toUInt(&chOldEntry);
if (chOldEntry)
aRetFont.setCharSet( chId );
else if (kapp) {
if (chStr == QString::fromLatin1("default"))
if (KGlobal::locale())
chStr = KGlobal::locale()->charset();
else chStr = "iso-8859-1";
KGlobal::charsets()->setQFont(aRetFont,chStr);
}
// find fifth part (weight)
nOldIndex = nIndex;
nIndex = aValue.find( ',', nOldIndex+1 );
if( nIndex == -1 ){
if( pDefault )
aRetFont = *pDefault;
return aRetFont;
}
aRetFont.setWeight( aValue.mid( nOldIndex+1,
nIndex-nOldIndex-1 ).toUInt() );
// find sixth part (font bits)
uint nFontBits = aValue.right( aValue.length()-nIndex-1 ).toUInt();
if( nFontBits & 0x01 )
aRetFont.setItalic( true );
else
aRetFont.setItalic( false );
if( nFontBits & 0x02 )
aRetFont.setUnderline( true );
else
aRetFont.setUnderline( false );
if( nFontBits & 0x04 )
aRetFont.setStrikeOut( true );
else
aRetFont.setStrikeOut( false );
if( nFontBits & 0x08 )
aRetFont.setFixedPitch( true );
else
aRetFont.setFixedPitch( false );
if( nFontBits & 0x20 )
aRetFont.setRawMode( true );
else
aRetFont.setRawMode( false );
}
else
{
if( pDefault )
aRetFont = *pDefault;
}
return aRetFont;
}
kdelibs'KConfigBase::readRectEntry() (./kdelibs/kdecore/kconfigbase.cpp:527)
QRect KConfigBase::readRectEntry( const QString& pKey, const QRect* pDefault ) const
{
QStrList list;
if( !hasKey( pKey ) )
{
if( pDefault )
return *pDefault;
else
return QRect();
}
int count = readListEntry( pKey, list, ',' );
if( count != 4 )
return QRect();
else
return QRect( QString::fromLatin1( list.at( 0 ) ).toInt(),
QString::fromLatin1( list.at( 1 ) ).toInt(),
QString::fromLatin1( list.at( 2 ) ).toInt(),
QString::fromLatin1( list.at( 3 ) ).toInt() );
}
kdelibs'KConfigBase::readPointEntry() (./kdelibs/kdecore/kconfigbase.cpp:550)
QPoint KConfigBase::readPointEntry( const QString& pKey,
const QPoint* pDefault ) const
{
QStrList list;
if( !hasKey( pKey ) )
{
if( pDefault )
return *pDefault;
else
return QPoint();
}
int count = readListEntry( pKey, list, ',' );
if( count != 2 )
return QPoint();
else
return QPoint( QString::fromLatin1( list.at( 0 ) ).toInt(),
QString::fromLatin1( list.at( 1 ) ).toInt() );
}
kdelibs'KConfigBase::readSizeEntry() (./kdelibs/kdecore/kconfigbase.cpp:572)
QSize KConfigBase::readSizeEntry( const QString& pKey,
const QSize* pDefault ) const
{
QStrList list;
if( !hasKey( pKey ) )
{
if( pDefault )
return *pDefault;
else
return QSize();
}
int count = readListEntry( pKey, list, ',' );
if( count != 2 )
return QSize();
else
return QSize( QString::fromLatin1( list.at( 0 ) ).toInt(),
QString::fromLatin1( list.at( 1 ) ).toInt() );
}
kdelibs'KConfigBase::readColorEntry() (./kdelibs/kdecore/kconfigbase.cpp:594)
QColor KConfigBase::readColorEntry( const QString& pKey,
const QColor* pDefault ) const
{
QColor aRetColor;
int nRed = 0, nGreen = 0, nBlue = 0;
QString aValue = readEntry( pKey );
if( !aValue.isEmpty() )
{
if ( aValue.at(0) == '#' )
{
aRetColor.setNamedColor(aValue);
}
else
{
bool bOK;
// find first part (red)
int nIndex = aValue.find( ',' );
if( nIndex == -1 ){
// return a sensible default -- Bernd
if( pDefault )
aRetColor = *pDefault;
return aRetColor;
}
nRed = aValue.left( nIndex ).toInt( &bOK );
// find second part (green)
int nOldIndex = nIndex;
nIndex = aValue.find( ',', nOldIndex+1 );
if( nIndex == -1 ){
// return a sensible default -- Bernd
if( pDefault )
aRetColor = *pDefault;
return aRetColor;
}
nGreen = aValue.mid( nOldIndex+1,
nIndex-nOldIndex-1 ).toInt( &bOK );
// find third part (blue)
nBlue = aValue.right( aValue.length()-nIndex-1 ).toInt( &bOK );
aRetColor.setRgb( nRed, nGreen, nBlue );
}
}
else {
if( pDefault )
aRetColor = *pDefault;
}
return aRetColor;
}
kdelibs'KConfigBase::readDateTimeEntry() (./kdelibs/kdecore/kconfigbase.cpp:653)
QDateTime KConfigBase::readDateTimeEntry( const QString& pKey,
const QDateTime* pDefault ) const
{
QStrList list;
QDateTime aRetDateTime = QDateTime::currentDateTime();
if( !hasKey( pKey ) )
{
if( pDefault )
return *pDefault;
else
return aRetDateTime;
}
int count = readListEntry( pKey, list, ',' );
if( count == 6 ) {
QTime time;
QDate date;
date.setYMD( QString::fromLatin1( list.at( 0 ) ).toInt(),
QString::fromLatin1( list.at( 1 ) ).toInt(),
QString::fromLatin1( list.at( 2 ) ).toInt() );
time.setHMS( QString::fromLatin1( list.at( 3 ) ).toInt(),
QString::fromLatin1( list.at( 4 ) ).toInt(),
QString::fromLatin1( list.at( 5 ) ).toInt() );
aRetDateTime.setTime( time );
aRetDateTime.setDate( date );
}
return aRetDateTime;
}
kdelibs'KConfigBase::writeEntry() (./kdelibs/kdecore/kconfigbase.cpp:687)
QString KConfigBase::writeEntry( const QString& pKey, const QString& value,
bool bPersistent,
bool bGlobal,
bool bNLS )
{
// the KConfig object is dirty now
// set this before any IO takes place so that if any derivative
// classes do caching, they won't try and flush the cache out
// from under us before we read. A race condition is still
// possible but minimized.
if( bPersistent )
bDirty = true;
if (!bLocaleInitialized && KGlobal::locale())
setLocale();
// if this is localized entry, add the locale
QString aLocalizedKey = pKey;
if( bNLS )
aLocalizedKey = aLocalizedKey + '[' + aLocaleString + ']';
KEntryKey entryKey(aGroup, aLocalizedKey);
KEntry aEntryData;
QString aValue;
// try to retrieve the current entry for this key
aEntryData = lookupData(entryKey);
if (!aEntryData.aValue.isNull()) {
// there already is such a key
aValue = aEntryData.aValue; // save old key as return value
}
aEntryData.aValue = value; // set new value
aEntryData.bGlobal = bGlobal;
aEntryData.bNLS = bNLS;
if (bPersistent)
aEntryData.bDirty = true;
// rewrite the new value
putData(entryKey, aEntryData);
return aValue;
}
kdelibs'KConfigBase::writeEntry() (./kdelibs/kdecore/kconfigbase.cpp:731)
void KConfigBase::writeEntry ( const QString& pKey, const QVariant &prop,
bool bPersistent,
bool bGlobal, bool bNLS )
{
QValueList<QVariant> list;
QValueList<QVariant>::ConstIterator it;
QValueList<QVariant>::ConstIterator end;
QStringList strList;
switch( prop.type() )
{
case QVariant::Invalid:
writeEntry( pKey, "", bPersistent, bGlobal, bNLS );
break;
case QVariant::String:
writeEntry( pKey, prop.toString(), bPersistent, bGlobal, bNLS );
break;
case QVariant::StringList:
writeEntry( pKey, prop.toStringList(), ',', bPersistent, bGlobal, bNLS );
break;
case QVariant::List:
list = prop.toList();
it = list.begin();
end = list.end();
for (; it != end; ++it )
strList.append( (*it).toString() );
writeEntry( pKey, strList, ',', bPersistent, bGlobal, bNLS );
break;
case QVariant::Font:
writeEntry( pKey, prop.toFont(), bPersistent, bGlobal, bNLS );
break;
// case QVariant::Movie:
// return "QMovie";
case QVariant::Pixmap:
ASSERT( 0 );
break;
case QVariant::Image:
ASSERT( 0 );
break;
case QVariant::Brush:
ASSERT( 0 );
break;
case QVariant::Point:
writeEntry( pKey, prop.toPoint(), bPersistent, bGlobal, bNLS );
break;
case QVariant::Rect:
writeEntry( pKey, prop.toRect(), bPersistent, bGlobal, bNLS );
break;
case QVariant::Size:
writeEntry( pKey, prop.toSize(), bPersistent, bGlobal, bNLS );
break;
case QVariant::Color:
writeEntry( pKey, prop.toColor(), bPersistent, bGlobal, bNLS );
break;
case QVariant::Palette:
ASSERT( 0 );
break;
case QVariant::ColorGroup:
ASSERT( 0 );
break;
case QVariant::Int:
writeEntry( pKey, prop.toInt(), bPersistent, bGlobal, bNLS );
break;
case QVariant::Bool:
writeEntry( pKey, prop.toBool(), bPersistent, bGlobal, bNLS );
break;
case QVariant::Double:
writeEntry( pKey, prop.toDouble(), bPersistent, bGlobal, 'g', 6, bNLS );
break;
default:
ASSERT( 0 );
}
}
kdelibs'KConfigBase::writeEntry() (./kdelibs/kdecore/kconfigbase.cpp:810)
void KConfigBase::writeEntry ( const QString& pKey, const QStrList &list,
char sep , bool bPersistent,
bool bGlobal, bool bNLS )
{
if( list.isEmpty() )
{
writeEntry( pKey, QString::fromLatin1(""), bPersistent );
return;
}
QString str_list;
QStrListIterator it( list );
for( ; it.current(); ++it )
{
uint i;
QString value = QString::fromLatin1(it.current());
for( i = 0; i < value.length(); i++ )
{
if( value[i] == sep || value[i] == '\\' )
str_list += '\\';
str_list += value[i];
}
str_list += sep;
}
if( str_list.at(str_list.length() - 1) == sep )
str_list.truncate( str_list.length() -1 );
writeEntry( pKey, str_list, bPersistent, bGlobal, bNLS );
}
kdelibs'KConfigBase::writeEntry() (./kdelibs/kdecore/kconfigbase.cpp:838)
void KConfigBase::writeEntry ( const QString& pKey, const QStringList &list,
char sep , bool bPersistent,
bool bGlobal, bool bNLS )
{
if( list.isEmpty() )
{
writeEntry( pKey, QString::fromLatin1(""), bPersistent );
return;
}
QString str_list;
QStringList::ConstIterator it = list.begin();
for( ; it != list.end(); ++it )
{
QString value = *it;
uint i;
for( i = 0; i < value.length(); i++ )
{
if( value[i] == sep || value[i] == '\\' )
str_list += '\\';
str_list += value[i];
}
str_list += sep;
}
if( str_list.at(str_list.length() - 1) == sep )
str_list.truncate( str_list.length() -1 );
writeEntry( pKey, str_list, bPersistent, bGlobal, bNLS );
}
kdelibs'KConfigBase::writeEntry() (./kdelibs/kdecore/kconfigbase.cpp:866)
void KConfigBase::writeEntry ( const QString& pKey, const QValueList<int> &list,
bool bPersistent, bool bGlobal, bool bNLS )
{
QStringList strlist;
QValueList<int>::ConstIterator end = list.end();
for (QValueList<int>::ConstIterator it = list.begin(); it != end; it++)
strlist << QString::number(*it);
writeEntry(pKey, strlist, ',', bPersistent, bGlobal, bNLS );
}
kdelibs'KConfigBase::writeEntry() (./kdelibs/kdecore/kconfigbase.cpp:876)
QString KConfigBase::writeEntry( const QString& pKey, int nValue,
bool bPersistent, bool bGlobal,
bool bNLS )
{
return writeEntry( pKey, QString::number(nValue), bPersistent, bGlobal, bNLS );
}
kdelibs'KConfigBase::writeEntry() (./kdelibs/kdecore/kconfigbase.cpp:884)
QString KConfigBase::writeEntry( const QString& pKey, unsigned int nValue,
bool bPersistent, bool bGlobal,
bool bNLS )
{
return writeEntry( pKey, QString::number(nValue), bPersistent, bGlobal, bNLS );
}
kdelibs'KConfigBase::writeEntry() (./kdelibs/kdecore/kconfigbase.cpp:892)
QString KConfigBase::writeEntry( const QString& pKey, long nValue,
bool bPersistent, bool bGlobal,
bool bNLS )
{
return writeEntry( pKey, QString::number(nValue), bPersistent, bGlobal, bNLS );
}
kdelibs'KConfigBase::writeEntry() (./kdelibs/kdecore/kconfigbase.cpp:900)
QString KConfigBase::writeEntry( const QString& pKey, unsigned long nValue,
bool bPersistent, bool bGlobal,
bool bNLS )
{
return writeEntry( pKey, QString::number(nValue), bPersistent, bGlobal, bNLS );
}
kdelibs'KConfigBase::writeEntry() (./kdelibs/kdecore/kconfigbase.cpp:908)
QString KConfigBase::writeEntry( const QString& pKey, double nValue,
bool bPersistent, bool bGlobal,
char format, int precision,
bool bNLS )
{
return writeEntry( pKey, QString::number(nValue, format, precision),
bPersistent, bGlobal, bNLS );
}
kdelibs'KConfigBase::writeEntry() (./kdelibs/kdecore/kconfigbase.cpp:918)
QString KConfigBase::writeEntry( const QString& pKey, bool bValue,
bool bPersistent,
bool bGlobal,
bool bNLS )
{
QString aValue;
if( bValue )
aValue = "true";
else
aValue = "false";
return writeEntry( pKey, aValue, bPersistent, bGlobal, bNLS );
}
kdelibs'KConfigBase::writeEntry() (./kdelibs/kdecore/kconfigbase.cpp:934)
QString KConfigBase::writeEntry( const QString& pKey, const QFont& rFont,
bool bPersistent, bool bGlobal,
bool bNLS )
{
QString aValue;
UINT8 nFontBits = 0;
// this mimics get_font_bits() from qfont.cpp
if( rFont.italic() )
nFontBits = nFontBits | 0x01;
if( rFont.underline() )
nFontBits = nFontBits | 0x02;
if( rFont.strikeOut() )
nFontBits = nFontBits | 0x04;
if( rFont.fixedPitch() )
nFontBits = nFontBits | 0x08;
if( rFont.rawMode() )
nFontBits = nFontBits | 0x20;
QString aCharset = QString::fromLatin1("default");
if( rFont.charSet() != QFont::AnyCharSet )
aCharset.setNum( static_cast<int>(rFont.charSet()) );
QTextOStream ts( &aValue );
ts << rFont.family() << "," << rFont.pointSize() << ","
<< static_cast<int>(rFont.styleHint()) << ","
<< aCharset << "," << rFont.weight() << ","
<< static_cast<int>(nFontBits);
return writeEntry( pKey, aValue, bPersistent, bGlobal, bNLS );
}
kdelibs'KConfigBase::writeEntry() (./kdelibs/kdecore/kconfigbase.cpp:966)
void KConfigBase::writeEntry( const QString& pKey, const QRect& rRect,
bool bPersistent, bool bGlobal,
bool bNLS )
{
QStrList list;
QCString tempstr;
list.insert( 0, tempstr.setNum( rRect.left() ) );
list.insert( 1, tempstr.setNum( rRect.top() ) );
list.insert( 2, tempstr.setNum( rRect.width() ) );
list.insert( 3, tempstr.setNum( rRect.height() ) );
writeEntry( pKey, list, ',', bPersistent, bGlobal, bNLS );
}
kdelibs'KConfigBase::writeEntry() (./kdelibs/kdecore/kconfigbase.cpp:981)
void KConfigBase::writeEntry( const QString& pKey, const QPoint& rPoint,
bool bPersistent, bool bGlobal,
bool bNLS )
{
QStrList list;
QCString tempstr;
list.insert( 0, tempstr.setNum( rPoint.x() ) );
list.insert( 1, tempstr.setNum( rPoint.y() ) );
writeEntry( pKey, list, ',', bPersistent, bGlobal, bNLS );
}
kdelibs'KConfigBase::writeEntry() (./kdelibs/kdecore/kconfigbase.cpp:994)
void KConfigBase::writeEntry( const QString& pKey, const QSize& rSize,
bool bPersistent, bool bGlobal,
bool bNLS )
{
QStrList list;
QCString tempstr;
list.insert( 0, tempstr.setNum( rSize.width() ) );
list.insert( 1, tempstr.setNum( rSize.height() ) );
writeEntry( pKey, list, ',', bPersistent, bGlobal, bNLS );
}
kdelibs'KConfigBase::writeEntry() (./kdelibs/kdecore/kconfigbase.cpp:1007)
void KConfigBase::writeEntry( const QString& pKey, const QColor& rColor,
bool bPersistent,
bool bGlobal,
bool bNLS )
{
QString aValue;
aValue.sprintf( "%d,%d,%d", rColor.red(), rColor.green(), rColor.blue() );
writeEntry( pKey, aValue, bPersistent, bGlobal, bNLS );
}
kdelibs'KConfigBase::writeEntry() (./kdelibs/kdecore/kconfigbase.cpp:1018)
void KConfigBase::writeEntry( const QString& pKey, const QDateTime& rDateTime,
bool bPersistent, bool bGlobal,
bool bNLS )
{
QStrList list;
QCString tempstr;
QTime time = rDateTime.time();
QDate date = rDateTime.date();
list.insert( 0, tempstr.setNum( date.year() ) );
list.insert( 1, tempstr.setNum( date.month() ) );
list.insert( 2, tempstr.setNum( date.day() ) );
list.insert( 3, tempstr.setNum( time.hour() ) );
list.insert( 4, tempstr.setNum( time.minute() ) );
list.insert( 5, tempstr.setNum( time.second() ) );
writeEntry( pKey, list, ',', bPersistent, bGlobal, bNLS );
}
kdelibs'KConfigBase::parseConfigFiles() (./kdelibs/kdecore/kconfigbase.cpp:1039)
void KConfigBase::parseConfigFiles()
{
backEnd->parseConfigFiles();
}
kdelibs'KConfigBase::sync() (./kdelibs/kdecore/kconfigbase.cpp:1044)
void KConfigBase::sync()
{
if (isReadOnly())
return;
backEnd->sync();
if (bDirty)
rollback();
}
KConfigBase::ConfigState KConfigBase::getConfigState() const {
return backEnd->getConfigState();
}
kdelibs'KConfigBase::rollback() (./kdelibs/kdecore/kconfigbase.h:967)
inline void KConfigBase::rollback( bool /*bDeep = true*/ )
{
bDirty = false;
}