[RFC] KConfig API stuff

David Faure faure at kde.org
Mon Oct 22 13:08:59 BST 2007


On Monday 22 October 2007, Oswald Buddenhagen wrote:
> On Mon, Oct 22, 2007 at 11:17:58AM +0200, David Faure wrote:
> > On Sunday 21 October 2007, Oswald Buddenhagen wrote:
> > > make kconfig inherit kconfiggroup.
> > 
> > I object to KConfig inheriting KConfigGroup:
> > 
> > 1) the entries in the root group aren't that important, using them is
> > kind of bad practice for actual KDE config files, except special cases
> > (kioslaverc).
> >
> that doesn't mean that the api needs to be intentionally ugly. ugly apis
> don't prevent people from doing ugly things, they just make the code
> look ugly, including the one that uses the api legitimately.

I'm sorry but there is nothing ugly with KConfigGroup(config, QString()).

> > 3) let's not be confusing about how to use KConfig. There should be
> > one way, and it should work.  And that way is: KConfigGroup.
> > 
> that's no contradiction by definition. ;)

There is. I mean KConfigGroup, explicitely, in the code.
I already see all the newbie-written kde4 apps using KConfig only and 
thus writing everything into the root group.... ugly.

> > 2) the porting from kde3 will be horrible. Every single kde3 app out
> > there, whose code does config.setGroup("foo");
> > config.writeEntry("bar","42"), will end up writing into the root group
> > without the author wanting that at all.
> > 
> after the hierarchy change setGroup() wouldn't make any sense and
> therefore must be removed anyway, so this is a non-issue.

I thought you said "too much porting effort, it will remain, but deprecated"?
Therefore it will compile, but will NOT work as expected.
*That* is ugly API.

> really, it's all about viewing a config as a tree and not as a list.
> when you internalize this, the inconsistency in the current api becomes
> disgusting.

KConfigGroup(config, QString()) is the parent group of KConfigGroup(config,"..."),
or you could even have a KConfig::rootGroup() for the toplevel of the tree.
Viewing config as a tree is a good reason for having a root group indeed, but it
is not a reason for KConfig being the root group itself.

-- 
David Faure, faure at kde.org, sponsored by Trolltech to work on KDE,
Konqueror (http://www.konqueror.org), and KOffice (http://www.koffice.org).




More information about the kde-core-devel mailing list