[Qgis-developer] index in self.legend.groupLayerRelationship - different behavior between QGIS 1.8 and master?

Andreas Neumann a.neumann at carto.net
Thu Oct 4 01:51:11 PDT 2012


Hi,

I know that there can be two or more layers of the same name, but I
think we can solve it in different ways:

1. the method providing access to layers by name could return a list /
array with layer references - if the plugin author knows/assumes that
the layer names in his project are distinct he can just pick up the
first reference in the list

* we could improve the method by allowing to specify a search path /
layer hierarchy, so the plugin author could filter the whole tree to a
subset - but the method would also return a list like in the other
solution above

The current way to access the legend tree is complicated and not
developer friendly - and currently it is buggy (returns the wrong index).

Andreas

Am 04.10.2012 10:38, schrieb Massimo:
> Andreas Neumann wrote
>> Alternatively it would be nice to have a method for direct access to
>> groups by name, without having to loop through all groups and see if the
>> name matches ...
> 
> some notes:
> 
> At the moment it is possible to have the same group name at the same or
> different level in the tree. 
> For example the following is a valid legend tree:
> -- GroupGisAnalisys1
>    |_ layer1
>    |_ Layer2
>    |_ Group1
>       |_Group2
>          |_Layer4
>       |_Group3
> -- GroupGisAnalisys2
>    |_ layer1
>    |_ Layer2
>    |_ Group1
>       |_Group2
>          |_Layer4
>       |_Group3
> 
> How can be possible to have direct access to a group by name?
> 
> For example:
> legend =  qgis.utils.iface.legendInterface()
> groupIndex = legend.groupIndex('group1')  [a shortcut for
> legend.groups().indexOf (.....)]
> 
> will always return the index of the first group in the tree.
> 
> Even the groupLayerRelationship does not help too much.
> 
> I think that the best way to solve this problem is to give full access to
> the legend tree in terms of QgsLegendItem(s) and avoid to put some logic
> into the legendInterface. Each plugin will implement his own business logic.
> 
> At the moment QgsLegendItem is not exposed to python API and I'm not so
> skilled to do it.
> 
> I tried to add the following function to qgslegendinterface and implement
> it:
> virtual QgsLegendItem * firstItem() = 0;
> but I'm in trouble with sip binding because QgsLegendItem is not exposed in
> sip.
> 
> Does anybody think that this make sense?
> If yes, Can I expect that anybody will implement such behavior or will help
> me to do that in the short term?
> 
> Any comment will be appreciated.
> 
> Massimo
> 
> 
> 
> 
> 
> 
> 
> --
> View this message in context: http://osgeo-org.1560.n6.nabble.com/index-in-self-legend-groupLayerRelationship-different-behavior-between-QGIS-1-8-and-master-tp5004337p5006317.html
> Sent from the Quantum GIS - Developer mailing list archive at Nabble.com.
> _______________________________________________
> 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