| # kdecore Library API Documentation
Overview | Class Hierarchy | Classes | Classes (annotated) | Members | Namespaces | Source Files

# KConfigDialogManager Class Reference

Provides a means of automatically retrieving, saving and resetting KConfigSkeleton based settings in a dialog. More...

`#include <kconfigdialogmanager.h>`

Inheritance diagram for KConfigDialogManager:

[legend]
Collaboration diagram for KConfigDialogManager:

[legend]
List of all members.

## Public Slots
void | updateSettings ()
void | updateWidgets ()
void | updateWidgetsDefault ()
## Signals
void | settingsChanged ()
void | settingsChanged (QWidget *widget)
void | widgetModified ()
## Public Member Functions
| KConfigDialogManager (QWidget *parent, KConfigSkeleton *conf, const char *name=0)
| ~KConfigDialogManager ()
void | addWidget (QWidget *widget)
bool | hasChanged ()
bool | isDefault ()
## Protected Member Functions
void | init (bool trackChanges)
bool | parseChildren (const QWidget *widget, bool trackChanges)
void | setProperty (QWidget *w, const QVariant &v)
QVariant | property (QWidget *w)
void | setupWidget (QWidget *widget, KConfigSkeletonItem *item)
## Protected Attributes
KConfigSkeleton * | m_conf
QWidget * | m_dialog
QSqlPropertyMap * | propertyMap
QMap< QString, QCString > | changedMap

## Detailed Description

Provides a means of automatically retrieving, saving and resetting KConfigSkeleton based settings in a dialog.

The KConfigDialogManager class provides a means of automatically retrieving, saving and resetting basic settings. It also can emit signals when settings have been changed (settings were saved) or modified (the user changes a checkbox from on to off).

The names of the widgets to be managed have to correspond to the names of the configuration entries in the KConfigSkeleton object plus an additional "kcfg_" prefix. For example a widget named "kcfg_MyOption" would be associated to the configuration entry "MyOption".

KConfigDialogManager uses the QSqlPropertyMap class to determine if it can do anything to a widget. Note that KConfigDialogManager doesn't require a database, it simply uses the functionality that is built into the QSqlPropertyMap class. New widgets can be added to the map using QSqlPropertyMap::installDefaultMap(). Note that you can't just add any class. The class must have a matching Q_PROPERTY(...) macro defined.

For example (note that KColorButton is already added and it doesn't need to manually added):

kcolorbutton.h defines the following property:

     Q_PROPERTY( QColor color READ color WRITE setColor )

To add KColorButton the following code would be inserted in the main.

     kapp->installKDEPropertyMap();
     QSqlPropertyMap *map = QSqlPropertyMap::defaultMap();
     map->insert("KColorButton", "color");

If you add a new widget to the QSqlPropertyMap and wish to be notified when it is modified you should add its signal using addWidgetChangedSignal().

Since:
  3.2

Author:
  Benjamin C Meyer <ben+kdelibs at meyerhome dot net>

  Waldo Bastian <bastian@kde.org>

Definition at line 78 of file kconfigdialogmanager.h.

## Constructor & Destructor Documentation

KConfigDialogManager::KConfigDialogManager | ( | QWidget * | parent,
|  | KConfigSkeleton * | conf,
|  | const char * | name = `0`
| ) |

  | Constructor. Parameters:
  | parent | Dialog widget to manage
  | conf | Object that contains settings
  | name | - Object name.
Definition at line 51 of file kconfigdialogmanager.cpp. References QSqlPropertyMap::defaultMap(), init(), m_conf, m_dialog, and propertyMap.

KConfigDialogManager::~KConfigDialogManager | ( |  | ) |

| Destructor. Definition at line 62 of file kconfigdialogmanager.cpp.

## Member Function Documentation

void KConfigDialogManager::settingsChanged | ( |  | ) | `[signal]`

| One or more of the settings have been saved (such as when the user clicks on the Apply button). This is only emitted by updateSettings() whenever one or more setting were changed and consequently saved. Referenced by updateSettings().

void KConfigDialogManager::settingsChanged | ( | QWidget * | widget | ) | `[signal]`

  | TODO: Verify One or more of the settings have been changed. Parameters:
  | widget | - The widget group (pass in via addWidget()) that contains the one or more modified setting.
See also: settingsChanged()

void KConfigDialogManager::widgetModified | ( |  | ) | `[signal]`

| If retrieveSettings() was told to track changes then if any known setting was changed this signal will be emitted. Note that a settings can be modified several times and might go back to the original saved state. hasChanged() will tell you if anything has actually changed from the saved values. Referenced by parseChildren(), and updateWidgets().

void KConfigDialogManager::addWidget | ( | QWidget * | widget | ) |

  | Add additional widgets to manage. Parameters:
  | widget | Additional widget to manage, inlcuding all its children
Definition at line 124 of file kconfigdialogmanager.cpp. References parseChildren().

bool KConfigDialogManager::hasChanged | ( |  | ) |

| Returns whether the current state of the known widgets are different from the state in the config object. Definition at line 366 of file kconfigdialogmanager.cpp. References endl(), KConfigSkeleton::findItem(), m_conf, KConfigSkeletonItem::property(), and property(). Referenced by isDefault().

bool KConfigDialogManager::isDefault | ( |  | ) |

| Returns whether the current state of the known widgets are the same as the default state in the config object. Definition at line 390 of file kconfigdialogmanager.cpp. References hasChanged(), m_conf, and KConfigSkeleton::useDefaults().

void KConfigDialogManager::updateSettings | ( |  | ) | `[slot]`

| Traverse the specified widgets, saving the settings of all known widgets in the settings object. Example use: User clicks Ok or Apply button in a configure dialog. Definition at line 305 of file kconfigdialogmanager.cpp. References endl(), KConfigSkeleton::findItem(), m_conf, KConfigSkeletonItem::property(), property(), KConfigSkeletonItem::setProperty(), settingsChanged(), and KConfigSkeleton::writeConfig().

void KConfigDialogManager::updateWidgets | ( |  | ) | `[slot]`

| Traverse the specified widgets, sets the state of all known widgets according to the state in the settings object. Example use: Initialisation of dialog. Example use: User clicks Reset button in a configure dialog. Definition at line 260 of file kconfigdialogmanager.cpp. References QObject::blockSignals(), endl(), QWidget::find(), KConfigSkeleton::findItem(), KConfigSkeletonItem::isImmutable(), m_conf, property(), KConfigSkeletonItem::property(), QWidget::setEnabled(), setProperty(), QObject::signalsBlocked(), QTimer::singleShot(), and widgetModified(). Referenced by updateWidgetsDefault().

void KConfigDialogManager::updateWidgetsDefault | ( |  | ) | `[slot]`

| Traverse the specified widgets, sets the state of all known widgets according to the default state in the settings object. Example use: User clicks Defaults button in a configure dialog. Definition at line 298 of file kconfigdialogmanager.cpp. References m_conf, updateWidgets(), and KConfigSkeleton::useDefaults().

void KConfigDialogManager::init | ( | bool | trackChanges | ) | `[protected]`

  | Parameters:
  | trackChanges | - If any changes by the widgets should be tracked set true. This causes the emitting the modified() signal when something changes. TODO:
Returns: bool - True if any setting was changed from the default. Definition at line 67 of file kconfigdialogmanager.cpp. References changedMap, QMap::insert(), m_dialog, and parseChildren(). Referenced by KConfigDialogManager().

bool KConfigDialogManager::parseChildren | ( | const QWidget * | widget,
|  | bool | trackChanges
| ) | `[protected]`

  | Recursive function that finds all known children. Goes through the children of widget and if any are known and not being ignored, stores them in currentGroup. Also checks if the widget should be disabled because it is set immutable. Parameters:
  | widget | - Parent of the children to look at.
  | trackChanges | - If true then tracks any changes to the children of widget that are known.
Returns: bool - If a widget was set to something other then its default. Definition at line 153 of file kconfigdialogmanager.cpp. References changedMap, QObject::connect(), QPtrListIterator::current(), QComboBox::editable(), QMap::end(), endl(), QMap::find(), KConfigSkeleton::findItem(), QObject::isWidgetType(), m_conf, setupWidget(), and widgetModified(). Referenced by addWidget(), and init().

void KConfigDialogManager::setProperty | ( | QWidget * | w,
|  | const QVariant & | v
| ) | `[protected]`

| Set a property. Definition at line 334 of file kconfigdialogmanager.cpp. References QComboBox::editable(), propertyMap, QButtonGroup::setButton(), QComboBox::setCurrentText(), and QSqlPropertyMap::setProperty(). Referenced by updateWidgets().

QVariant KConfigDialogManager::property | ( | QWidget * | w | ) | `[protected]`

| Retrieve a property. Definition at line 353 of file kconfigdialogmanager.cpp. References QComboBox::currentText(), QComboBox::editable(), QSqlPropertyMap::property(), propertyMap, and QButtonGroup::selectedId(). Referenced by hasChanged(), updateSettings(), and updateWidgets().

void KConfigDialogManager::setupWidget | ( | QWidget * | widget,
|  | KConfigSkeletonItem * | item
| ) | `[protected]`

| Setup secondary widget properties. Definition at line 129 of file kconfigdialogmanager.cpp. References QWhatsThis::add(), QString::isEmpty(), and QVariant::isValid(). Referenced by parseChildren().

## Member Data Documentation

KConfigSkeleton* KConfigDialogManager::m_conf`[protected]`

| KConfigSkeleton object used to store settings. Definition at line 209 of file kconfigdialogmanager.h. Referenced by hasChanged(), isDefault(), KConfigDialogManager(), parseChildren(), updateSettings(), updateWidgets(), and updateWidgetsDefault().

QWidget* KConfigDialogManager::m_dialog`[protected]`

| Dialog being managed. Definition at line 214 of file kconfigdialogmanager.h. Referenced by init(), and KConfigDialogManager().

QSqlPropertyMap* KConfigDialogManager::propertyMap`[protected]`

| Pointer to the property map for easy access. Definition at line 219 of file kconfigdialogmanager.h. Referenced by KConfigDialogManager(), property(), and setProperty().

QMap<QString, QCString> KConfigDialogManager::changedMap`[protected]`

| Map of the classes and the signals that they emit when changed. Definition at line 224 of file kconfigdialogmanager.h. Referenced by init(), and parseChildren().

The documentation for this class was generated from the following files:

- kconfigdialogmanager.h
- kconfigdialogmanager.cpp

This file is part of the documentation for kdecore Library Version 3.4.1.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Sat Jun 11 20:18:29 2005 by doxygen 1.4.1 written by Dimitri van Heesch, © 1997-2003