[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-core-devel
Subject:    Default values of KConfigXT items
From:       Ingo =?iso-8859-15?q?Kl=F6cker?= <kloecker () kde ! org>
Date:       2005-02-13 13:07:50
Message-ID: 200502131407.54824 () erwin ! ingo-kloecker ! de
[Download RAW message or body]


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

[Attachment #3 (application/pgp-signature)]

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic