[Qgis-developer] Legend group API
Andreas Neumann
a.neumann at carto.net
Tue Dec 11 03:02:57 PST 2012
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
More information about the Qgis-developer
mailing list