[Qgis-developer] QgsLegendInterface

Marco Bernasocchi marco at bernawebdesign.ch
Thu Mar 3 10:27:34 EST 2011


QgsLegendInterface::groupLayerRelationship() returns this:
[group0, group1, subGroupOfGroup0]
BUT
QgsLegendInterface::groups() returns:
[group0, subGroupOfGroup0, group1]

notice the difference in the order, is this done on purpose? or a bug? I
spent couple of ours digging for the problem in my code today and it
turned out to be because I was using the indexes from groups().

as well, if you want to have all the groups name, now you have to
iterate on groupLayerRelationship() like this:

groups = []
for group in self.legend.groupLayerRelationship():
                    groups.append(group[0])

and then groups is an array with all the group names (like groups()) but
in the same order as the groupLayerRelationship().

I think that it would be sensible to have a method like groups() that
returns the same as my iteration above. what do you think? I would of
course do it if it is needed.

ciao

-- 
Marco Bernasocchi
www.bernawebdesign.ch
skype: mbernasocchi


More information about the Qgis-developer mailing list