KDE 4.2 PyKDE API Reference

- KDE's Python API

# KCoreConfigSkeleton Class Reference

`from PyKDE4.kdecore import *`

Inherits: QObject

## Detailed Description

## Signals

| configChanged ()

## Methods

| __init__ (self, QString configname=QString(), QObject parent=0)
| __init__ (self, KSharedConfig.Ptr config, QObject parent=0)
| addItem (self, KConfigSkeletonItem a0, QString name=QString())
KCoreConfigSkeleton.ItemBool | addItemBool (self, QString name, bool reference, bool defaultValue=0, QString key=QString())
KCoreConfigSkeleton.ItemDateTime | addItemDateTime (self, QString name, QDateTime reference, QDateTime defaultValue=QDateTime(), QString key=QString())
KCoreConfigSkeleton.ItemDouble | addItemDouble (self, QString name, float reference, float defaultValue=0.0, QString key=QString())
KCoreConfigSkeleton.ItemInt | addItemInt (self, QString name, int reference, int defaultValue=0, QString key=QString())
KCoreConfigSkeleton.ItemLongLong | addItemInt64 (self, QString name, long reference, long defaultValue=0, QString key=QString())
KCoreConfigSkeleton.ItemIntList | addItemIntList (self, QString name, [int] reference, [int] defaultValue=QList<int>(), QString key=QString())
KCoreConfigSkeleton.ItemLongLong | addItemLongLong (self, QString name, long reference, long defaultValue=0, QString key=QString())
KCoreConfigSkeleton.ItemPassword | addItemPassword (self, QString name, QString reference, QString defaultValue=QLatin1String(""), QString key=QString())
KCoreConfigSkeleton.ItemPath | addItemPath (self, QString name, QString reference, QString defaultValue=QLatin1String(""), QString key=QString())
KCoreConfigSkeleton.ItemPoint | addItemPoint (self, QString name, QPoint reference, QPoint defaultValue=QPoint(), QString key=QString())
KCoreConfigSkeleton.ItemProperty | addItemProperty (self, QString name, QVariant reference, QVariant defaultValue=QVariant(), QString key=QString())
KCoreConfigSkeleton.ItemRect | addItemRect (self, QString name, QRect reference, QRect defaultValue=QRect(), QString key=QString())
KCoreConfigSkeleton.ItemSize | addItemSize (self, QString name, QSize reference, QSize defaultValue=QSize(), QString key=QString())
KCoreConfigSkeleton.ItemString | addItemString (self, QString name, QString reference, QString defaultValue=QLatin1String(""), QString key=QString())
KCoreConfigSkeleton.ItemStringList | addItemStringList (self, QString name, QStringList reference, QStringList defaultValue=QStringList(), QString key=QString())
KCoreConfigSkeleton.ItemUInt | addItemUInt (self, QString name, long reference, long defaultValue=0, QString key=QString())
KCoreConfigSkeleton.ItemULongLong | addItemUInt64 (self, QString name, quint64 reference, quint64 defaultValue=0, QString key=QString())
KCoreConfigSkeleton.ItemULongLong | addItemULongLong (self, QString name, quint64 reference, quint64 defaultValue=0, QString key=QString())
KConfig | config (self)
KConfig | config (self)
| configChanged (self)
QString | currentGroup (self)
KConfigSkeletonItem | findItem (self, QString name)
bool | isImmutable (self, QString name)
KConfigSkeletonItem.List | items (self)
| readConfig (self)
| setCurrentGroup (self, QString group)
| setDefaults (self)
| setSharedConfig (self, KSharedConfig.Ptr pConfig)
bool | useDefaults (self, bool b)
| usrReadConfig (self)
| usrSetDefaults (self)
bool | usrUseDefaults (self, bool b)
| usrWriteConfig (self)
| writeConfig (self)

## Method Documentation

__init__ | ( | self, |
|  | QString | configname=QString(),
|  | QObject | parent=0
| ) |  |  |

Constructor.

Parameters:

  | configname | name of config file. If no name is given, the default config file as returned by KGlobal.config() is used
  | parent | the parent object (see QObject documentation)

__init__ | ( | self, |
|  | KSharedConfig.Ptr | config,
|  | QObject | parent=0
| ) |  |  |

Constructor.

Parameters:

  | config | configuration object to use
  | parent | the parent object (see QObject documentation)

addItem | ( | self, |
|  | KConfigSkeletonItem | a0,
|  | QString | name=QString()
| ) |  |  |

Register a custom KConfigSkeletonItem with a given name.

If the name parameter is null, take the name from KConfigSkeletonItem.key(). Note that all names must be unique but that multiple entries can have the same key if they reside in different groups.

KCoreConfigSkeleton takes ownership of the KConfigSkeletonItem.

KCoreConfigSkeleton.ItemBool addItemBool | ( | self, |
|  | QString | name,
|  | bool | reference,
|  | bool | defaultValue=0,
|  | QString | key=QString()
| ) |  |  |

Register an item of type bool.

Parameters:

  | name | Name used to identify this setting. Names must be unique.
  | reference | Pointer to the variable, which is set by readConfig() calls and read by writeConfig() calls.
  | defaultValue | Default value, which is used when the config file does not yet contain the key of this item.
  | key | Key used in config file. If key is null, name is used as key.

Returns:
  The created item

KCoreConfigSkeleton.ItemDateTime addItemDateTime | ( | self, |
|  | QString | name,
|  | QDateTime | reference,
|  | QDateTime | defaultValue=QDateTime(),
|  | QString | key=QString()
| ) |  |  |

Register an item of type QDateTime.

Parameters:

  | name | Name used to identify this setting. Names must be unique.
  | reference | Pointer to the variable, which is set by readConfig() calls and read by writeConfig() calls.
  | defaultValue | Default value, which is used when the config file does not yet contain the key of this item.
  | key | Key used in config file. If key is null, name is used as key.

Returns:
  The created item

KCoreConfigSkeleton.ItemDouble addItemDouble | ( | self, |
|  | QString | name,
|  | float | reference,
|  | float | defaultValue=0.0,
|  | QString | key=QString()
| ) |  |  |

Register an item of type double.

Parameters:

  | name | Name used to identify this setting. Names must be unique.
  | reference | Pointer to the variable, which is set by readConfig() calls and read by writeConfig() calls.
  | defaultValue | Default value, which is used when the config file does not yet contain the key of this item.
  | key | Key used in config file. If key is null, name is used as key.

Returns:
  The created item

KCoreConfigSkeleton.ItemInt addItemInt | ( | self, |
|  | QString | name,
|  | int | reference,
|  | int | defaultValue=0,
|  | QString | key=QString()
| ) |  |  |

Register an item of type qint32.

Parameters:

  | name | Name used to identify this setting. Names must be unique.
  | reference | Pointer to the variable, which is set by readConfig() calls and read by writeConfig() calls.
  | defaultValue | Default value, which is used when the config file does not yet contain the key of this item.
  | key | Key used in config file. If key is null, name is used as key.

Returns:
  The created item

KCoreConfigSkeleton.ItemLongLong addItemInt64 | ( | self, |
|  | QString | name,
|  | long | reference,
|  | long | defaultValue=0,
|  | QString | key=QString()
| ) |  |  |

Deprecated:
  Use addItemLongLong().

KCoreConfigSkeleton.ItemIntList addItemIntList | ( | self, |
|  | QString | name,
|  | [int] | reference,
|  | [int] | defaultValue=QList<int>(),
|  | QString | key=QString()
| ) |  |  |

Register an item of type QList<int>.

Parameters:

  | name | Name used to identify this setting. Names must be unique.
  | reference | Pointer to the variable, which is set by readConfig() calls and read by writeConfig() calls.
  | defaultValue | Default value, which is used when the config file does not yet contain the key of this item.
  | key | Key used in config file. If key is null, name is used as key.

Returns:
  The created item

KCoreConfigSkeleton.ItemLongLong addItemLongLong | ( | self, |
|  | QString | name,
|  | long | reference,
|  | long | defaultValue=0,
|  | QString | key=QString()
| ) |  |  |

Register an item of type qint64.

Parameters:

  | name | Name used to identify this setting. Names must be unique.
  | reference | Pointer to the variable, which is set by readConfig() calls and read by writeConfig() calls.
  | defaultValue | Default value, which is used when the config file does not yet contain the key of this item.
  | key | Key used in config file. If key is null, name is used as key.

Returns:
  The created item

KCoreConfigSkeleton.ItemPassword addItemPassword | ( | self, |
|  | QString | name,
|  | QString | reference,
|  | QString | defaultValue=QLatin1String(""),
|  | QString | key=QString()
| ) |  |  |

Register a password item of type QString. The string value is written encrypted to the config file. Note that the current encryption scheme is very weak.

Parameters:

  | name | Name used to identify this setting. Names must be unique.
  | reference | Pointer to the variable, which is set by readConfig() calls and read by writeConfig() calls.
  | defaultValue | Default value, which is used when the config file does not yet contain the key of this item.
  | key | Key used in config file. If key is null, name is used as key.

Returns:
  The created item

KCoreConfigSkeleton.ItemPath addItemPath | ( | self, |
|  | QString | name,
|  | QString | reference,
|  | QString | defaultValue=QLatin1String(""),
|  | QString | key=QString()
| ) |  |  |

Register a path item of type QString. The string value is interpreted as a path. This means, dollar expension is activated for this value, so that e.g. $HOME gets expanded.

Parameters:

  | name | Name used to identify this setting. Names must be unique.
  | reference | Pointer to the variable, which is set by readConfig() calls and read by writeConfig() calls.
  | defaultValue | Default value, which is used when the config file does not yet contain the key of this item.
  | key | Key used in config file. If key is null, name is used as key.

Returns:
  The created item

KCoreConfigSkeleton.ItemPoint addItemPoint | ( | self, |
|  | QString | name,
|  | QPoint | reference,
|  | QPoint | defaultValue=QPoint(),
|  | QString | key=QString()
| ) |  |  |

Register an item of type QPoint.

Parameters:

  | name | Name used to identify this setting. Names must be unique.
  | reference | Pointer to the variable, which is set by readConfig() calls and read by writeConfig() calls.
  | defaultValue | Default value, which is used when the config file does not yet contain the key of this item.
  | key | Key used in config file. If key is null, name is used as key.

Returns:
  The created item

KCoreConfigSkeleton.ItemProperty addItemProperty | ( | self, |
|  | QString | name,
|  | QVariant | reference,
|  | QVariant | defaultValue=QVariant(),
|  | QString | key=QString()
| ) |  |  |

Register a property item of type QVariant. Note that only the following QVariant types are allowed: String, StringList, Font, Point, Rect, Size, Color, Int, UInt, Bool, Double, DateTime and Date.

Parameters:

  | name | Name used to identify this setting. Names must be unique.
  | reference | Pointer to the variable, which is set by readConfig() calls and read by writeConfig() calls.
  | defaultValue | Default value, which is used when the config file does not yet contain the key of this item.
  | key | Key used in config file. If key is null, name is used as key.

Returns:
  The created item

KCoreConfigSkeleton.ItemRect addItemRect | ( | self, |
|  | QString | name,
|  | QRect | reference,
|  | QRect | defaultValue=QRect(),
|  | QString | key=QString()
| ) |  |  |

Register an item of type QRect.

Parameters:

  | name | Name used to identify this setting. Names must be unique.
  | reference | Pointer to the variable, which is set by readConfig() calls and read by writeConfig() calls.
  | defaultValue | Default value, which is used when the config file does not yet contain the key of this item.
  | key | Key used in config file. If key is null, name is used as key.

Returns:
  The created item

KCoreConfigSkeleton.ItemSize addItemSize | ( | self, |
|  | QString | name,
|  | QSize | reference,
|  | QSize | defaultValue=QSize(),
|  | QString | key=QString()
| ) |  |  |

Register an item of type QSize.

Parameters:

  | name | Name used to identify this setting. Names must be unique.
  | reference | Pointer to the variable, which is set by readConfig() calls and read by writeConfig() calls.
  | defaultValue | Default value, which is used when the config file does not yet contain the key of this item.
  | key | Key used in config file. If key is null, name is used as key.

Returns:
  The created item

KCoreConfigSkeleton.ItemString addItemString | ( | self, |
|  | QString | name,
|  | QString | reference,
|  | QString | defaultValue=QLatin1String(""),
|  | QString | key=QString()
| ) |  |  |

Register an item of type QString.

Parameters:

  | name | Name used to identify this setting. Names must be unique.
  | reference | Pointer to the variable, which is set by readConfig() calls and read by writeConfig() calls.
  | defaultValue | Default value, which is used when the config file does not yet contain the key of this item.
  | key | Key used in config file. If key is null, name is used as key.

Returns:
  The created item

KCoreConfigSkeleton.ItemStringList addItemStringList | ( | self, |
|  | QString | name,
|  | QStringList | reference,
|  | QStringList | defaultValue=QStringList(),
|  | QString | key=QString()
| ) |  |  |

Register an item of type QStringList.

Parameters:

  | name | Name used to identify this setting. Names must be unique.
  | reference | Pointer to the variable, which is set by readConfig() calls and read by writeConfig() calls.
  | defaultValue | Default value, which is used when the config file does not yet contain the key of this item.
  | key | Key used in config file. If key is null, name is used as key.

Returns:
  The created item

KCoreConfigSkeleton.ItemUInt addItemUInt | ( | self, |
|  | QString | name,
|  | long | reference,
|  | long | defaultValue=0,
|  | QString | key=QString()
| ) |  |  |

Register an item of type quint32.

Parameters:

  | name | Name used to identify this setting. Names must be unique.
  | reference | Pointer to the variable, which is set by readConfig() calls and read by writeConfig() calls.
  | defaultValue | Default value, which is used when the config file does not yet contain the key of this item.
  | key | Key used in config file. If key is null, name is used as key.

Returns:
  The created item

KCoreConfigSkeleton.ItemULongLong addItemUInt64 | ( | self, |
|  | QString | name,
|  | quint64 | reference,
|  | quint64 | defaultValue=0,
|  | QString | key=QString()
| ) |  |  |

Deprecated:
  Use addItemULongLong().

KCoreConfigSkeleton.ItemULongLong addItemULongLong | ( | self, |
|  | QString | name,
|  | quint64 | reference,
|  | quint64 | defaultValue=0,
|  | QString | key=QString()
| ) |  |  |

Register an item of type quint64

Parameters:

  | name | Name used to identify this setting. Names must be unique.
  | reference | Pointer to the variable, which is set by readConfig() calls and read by writeConfig() calls.
  | defaultValue | Default value, which is used when the config file does not yet contain the key of this item.
  | key | Key used in config file. If key is null, name is used as key.

Returns:
  The created item

KConfig config | ( |  | self ) |

Return the KConfig object used for reading and writing the settings.

KConfig config | ( |  | self ) |

Return the KConfig object used for reading and writing the settings.

configChanged | ( |  | self ) |

This signal is emitted when the configuration change.

Signal syntax:
  `QObject.connect(source, SIGNAL("configChanged()"), target_slot)`

QString currentGroup | ( |  | self ) |

Returns the current group used for addItem() calls.

KConfigSkeletonItem findItem | ( | self, |
|  | QString | name
| ) |  |  |

Lookup item by name

bool isImmutable | ( | self, |
|  | QString | name
| ) |  |  |

Return whether a certain item is immutable

KConfigSkeletonItem.List items | ( |  | self ) |

Return list of items managed by this KCoreConfigSkeleton object.

readConfig | ( |  | self ) |

Read preferences from config file. All registered items are set to the values read from disk. This method calls usrReadConfig() after reading the settings of the registered items from the KConfig. You can overridde usrReadConfig() in derived classes if you have special requirements. If you need more fine-grained control of storing the settings from the registered items you can override readConfig() in a derived class.

setCurrentGroup | ( | self, |
|  | QString | group
| ) |  |  |

Set the config file group for subsequent addItem() calls. It is valid until setCurrentGroup() is called with a new argument. Call this before you add any items. The default value is "No Group".

setDefaults | ( |  | self ) |

Set all registered items to their default values. This method calls usrSetDefaults() after setting the defaults for the registered items. You can overridde usrSetDefaults() in derived classes if you have special requirements. If you need more fine-grained control of setting the default values of the registered items you can override setDefaults() in a derived class.

setSharedConfig | ( | self, |
|  | KSharedConfig.Ptr | pConfig
| ) |  |  |

Set the KSharedConfig object used for reading and writing the settings.

bool useDefaults | ( | self, |
|  | bool | b
| ) |  |  |

Specify whether this object should reflect the actual values or the default values. This method is implemented by usrUseDefaults(), which can be overridden in derived classes if you have special requirements and can call usrUseDefaults() directly. If you don't have control whether useDefaults() or usrUseDefaults() is called override useDefaults() directly.

Parameters:

  | b | true to make this object reflect the default values, false to make it reflect the actual values.

Returns:
  The state prior to this call

usrReadConfig | ( |  | self ) |

Perform the actual reading of the configuration file. Override in derived classes to read special config values. Called from readConfig()

usrSetDefaults | ( |  | self ) |

Perform the actual setting of default values. Override in derived classes to set special default values. Called from setDefaults()

bool usrUseDefaults | ( | self, |
|  | bool | b
| ) |  |  |

Implemented by subclasses that use special defaults. It replaces the default values with the actual values and vice versa. Called from useDefaults()

Parameters:

  | b | true to make this object reflect the default values, false to make it reflect the actual values.

Returns:
  The state prior to this call

usrWriteConfig | ( |  | self ) |

Perform the actual writing of the configuration file. Override in derived classes to write special config values. Called from writeConfig()

writeConfig | ( |  | self ) |

Write preferences to config file. The values of all registered items are written to disk. This method calls usrWriteConfig() after writing the settings from the registered items to the KConfig. You can overridde usrWriteConfig() in derived classes if you have special requirements. If you need more fine-grained control of storing the settings from the registered items you can override writeConfig() in a derived class.