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

Massimo massimo.endrighi at geopartner.it
Thu Oct 4 01:38:39 PDT 2012


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.


More information about the Qgis-developer mailing list