[PATCH]KConfigGroup::groupList() kind of broken

Oswald Buddenhagen ossi at kde.org
Mon Nov 19 22:12:19 GMT 2007


On Mon, Nov 19, 2007 at 10:12:25PM +0100, Andreas Pakulat wrote:
> it seems that KConfigGroup::groupList() doesn't work really well with
> subgroups.
>
yes. i noticed that before. i'm somewhat reluctant to fix it now, though
- it could break code silently. otoh, it's just wrong and probably not
relied much upon.
more on that matter:
- kconfiggroup::name() returns the full path, too. while that can be
  useful, it should be a separate function.
- does kconfiggroup::keyList() behave as it should (i.e., not including
  keys from subgroups)?
- and does kconfiggroup::entryMap()?

> Of course this assumes that a groupname cannot contain a forward
> slash. If thats not true than either a parser for the groupname is
> needed or some change of how KConfigGroup keeps track of its
> subgroups.
> 
iirc, we discussed this on k-c-d at some point. dunno what came out of it.

>      foreach (const KEntryKey& key, entryMap.keys())
>          if (key.mKey.isNull() && key.mGroup.startsWith(group) && key.mGroup != group)
> +	{
> +            QString groupname = QString::fromUtf8(key.mGroup.mid(group.length()+1));

> +            groups << groupname.mid(0, groupname.indexOf("/"));
>
the function is called left(). ;)
the approach is somewhat naive, as it will duplicate groups that have
multiple subgroups. use a set and convert it to a list afterwards or
something.

> +	}
>  
>      return groups;
>  }

-- 
Hi! I'm a .signature virus! Copy me into your ~/.signature, please!
--
Chaos, panic, and disorder - my work here is done.




More information about the kde-core-devel mailing list