Default values of KConfigXT items
Ingo Klöcker
kloecker at kde.org
Sun Feb 13 13:07:50 GMT 2005
Hi,
I ran into the problem that there's no easy way to get the default value
of a KConfigXT item. But this is needed in all configuration dialogs
which have a "Defaults" button. AFAICS the only way to set a config
widget back to the default value without actually reverting the setting
in the KConfigXT object is something like the following:
// save the current value of the KConfigXT item
Type currentSetting = Settings::foo();
// reset KConfigXT item to its default value
Settings::self()->fooItem()->setDefault();
// set the widget to the default value of the KConfigXT item
fooWidget->setValue( Settings::foo() );
// restore the current value of the KConfigXT item
Settings::setFoo( currentSetting );
Another possibility is:
// swap current value and default value of the KConfigXT item
Settings::self()->fooItem()->swapDefault();
// set the widget to the default value of the KConfigXT item
fooWidget->setValue( Settings::foo() );
// swap default value and current value of the KConfigXT item
Settings::self()->fooItem()->swapDefault();
Obviously, both methods suck. Is there a reason there's no easy way to
get the default value of a KConfigSkeletonItem? If not then I propose
to generate a static Settings::fooDefault() for all KConfigXT item so
that the above can be achieved with a simple
// set the widget to the default value of the KConfigXT item
fooWidget->setValue( Settings::fooDefault() );
Regards,
Ingo
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20050213/f15b4fc3/attachment.sig>
More information about the kde-core-devel
mailing list