Home · All Classes · Main Classes · Deprecated
Signals | Public Member Functions

MGConfItem Class Reference

MGConfItem is a simple C++ wrapper for GConf. More...

Inherits QObject.

List of all members.

Signals

void valueChanged ()

Public Member Functions

 MGConfItem (const QString &key, QObject *parent=0)
virtual ~MGConfItem ()
QString key () const
QVariant value () const
QVariant value (const QVariant &def) const
void set (const QVariant &val)
void unset ()
void sync ()
QList< QStringlistDirs () const
QList< QStringlistEntries () const

Detailed Description

MGConfItem is a simple C++ wrapper for GConf.

Creating a MGConfItem instance gives you access to a single GConf key. You can get and set its value, and connect to its valueChanged() signal to be notified about changes.

The value of a GConf key is returned to you as a QVariant, and you pass in a QVariant when setting the value. MGConfItem converts between a QVariant and GConf values as needed, and according to the following rules:

Warning:
MGConfItem is as thread-safe as GConf.

Constructor & Destructor Documentation

MGConfItem::MGConfItem ( const QString key,
QObject parent = 0 
) [explicit]

Initializes a MGConfItem to access the GConf key denoted by key. Key names should follow the normal GConf conventions like "/myapp/settings/first".

Parameters:
key The name of the key.
parent Parent object
MGConfItem::~MGConfItem (  )  [virtual]

Finalizes a MGConfItem.


Member Function Documentation

QString MGConfItem::key (  )  const

Returns the key of this item, as given to the constructor.

QList< QString > MGConfItem::listDirs (  )  const

Return a list of the directories below this item. The returned strings are absolute key names like "/myapp/settings".

A directory is a key that has children. The same key might also have a value, but that is confusing and best avoided.

QList< QString > MGConfItem::listEntries (  )  const

Return a list of entries below this item. The returned strings are absolute key names like "/myapp/settings/first".

A entry is a key that has a value. The same key might also have children, but that is confusing and is best avoided.

void MGConfItem::set ( const QVariant val  ) 

Set the value of this item to val. If val can not be represented in GConf or GConf refuses to accept it for other reasons, the current value is not changed and nothing happens.

When the new value is different from the old value, the changedValue() signal is emitted on this MGConfItem as part of calling set(), but other MGConfItem:s for the same key do only receive a notification once the main loop runs.

Parameters:
val The new value.
void MGConfItem::sync (  ) 

Suggest to GConf that it's an optimal time to sync to permanent storage.

void MGConfItem::unset (  ) 

Unset this item. This is equivalent to

        item.set(QVariant(QVariant::Invalid));
QVariant MGConfItem::value (  )  const

Returns the current value of this item, as a QVariant.

QVariant MGConfItem::value ( const QVariant def  )  const

Returns the current value of this item, as a QVariant. If there is no value for this item, return def instead.

void MGConfItem::valueChanged (  )  [signal]

Emitted when the value of this item has changed.


Copyright © 2010 Nokia Corporation
MeeGo Touch