[Qgis-developer] Legend group API

Nathan Woodrow madmanwoo at gmail.com
Tue Dec 11 03:04:15 PST 2012


I think Martin has some ideas about how we can improve the legend
based stuff.  Might be best to see what he has in mind.

Regards,
Nathan

On Tue, Dec 11, 2012 at 9:02 PM, Andreas Neumann <a.neumann at carto.net> wrote:
> Hi,
>
> I would like to see such an improved legend interface. Currently the group
> and layer index even behaves differently between version 1.8 and version
> 1.9. I have to check the version and decrease the index in case it is
> version 1.9.
>
> I use this horrible code to find a group and attach a new layer:
>
> --------------------
>                 #get the current group index of Schüler group
>                 groups = []
>                 for group in self.legend.groupLayerRelationship():
>                         groups.append(group[0])
>                 groupIndex = groups.index(groupName)
>                 #move new layer to existing group
>                 if QGis.QGIS_VERSION[0:3] >= "1.9":
>                         groupIndex -= 1
>                 self.legend.moveLayer(schoolDistrictLayer, groupIndex)
> -------------------
>
> Really horrible - this really should be a one-liner ... and not a different
> behavior between QGIS versions for no good reason.
>
> Andreas
>
>
> On Tue, 11 Dec 2012 11:11:33 +0100, Sandro Santilli wrote:
>>
>> On Tue, Dec 11, 2012 at 08:56:16AM +0100, Sandro Santilli wrote:
>>
>>> One option would be to store an unique identifier in each LegendGroup
>>> object
>>> and use that identifier for all lookups. There would be a counter within
>>> each Legend incremented everytime a new group is added. Would this break
>>> any existing usage ? Are there tests for this in place ?
>>> The advantage of this is that the interface of addGroup and moveLayer
>>> would
>>> not change.
>>
>>
>> I've a patch ready implementing a model similar to the above
>> (only difference is that the counter is a static within the group class)
>>
>> https://github.com/qgis/Quantum-GIS/pull/351
>>
>> Feedback welcome
>>
>> --strk;
>>
>> _______________________________________________
>> Qgis-developer mailing list
>> Qgis-developer at lists.osgeo.org
>> http://lists.osgeo.org/mailman/listinfo/qgis-developer
>
>
> --
> --
> Andreas Neumann
> Böschacherstrasse 10A
> 8624 Grüt (Gossau ZH)
> Switzerland
>
> _______________________________________________
> Qgis-developer mailing list
> Qgis-developer at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/qgis-developer


More information about the Qgis-developer mailing list