Hi all,<br><br>+ 1 for the proposal of Massimo using the DOM implementation. I will be straightforward to use.<br><br>Michael<br><br><div class="gmail_quote">2012/10/5 Massimo <span dir="ltr"><<a href="mailto:massimo.endrighi@geopartner.it" target="_blank">massimo.endrighi@geopartner.it</a>></span><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Etienne Tourigny-3 wrote<br>
> .....<br>
<div class="im">> While it woulf be good to expose legend api to python, it mught be a<br>
> lot of work.<br>
<br>
</div>Yes it could be a lot of work and I'm not sure about how to do it.<br>
<br>
<br>
Etienne Tourigny-3 wrote<br>
<div class="im">> would it be sufficient to have the following?<br>
><br>
> 1) groups relations like this:<br>
> QList< QPair< int, QList < int > > ><br>
><br>
> 2) layers within a group like this:<br>
> QList< QPair< int, QList< QString > > ><br>
> or<br>
> QList< QPair< int, QList< QgsMapLayer* > > ><br>
><br>
> this way, you have access to group hierarchies by id, and layers for each<br>
> group.<br>
><br>
> You would use existing methods like setGroupExpanded() to work on<br>
> groups in a relatively simple manner.<br>
<br>
</div>Using the index instead of group name is a good idea. Anyway, the groups<br>
relations could be recursive in order to avoid a "complex" algorithm to<br>
reconstruct the hierarchy.<br>
Furthermore splitting the information over two lists cuts off the exact<br>
sequence of layers/groups and any post processing logic will fail to<br>
reconstruct  the hierarchy.<br>
<br>
Thus I propose another solution based on QDomDocument similar to the one<br>
adopted into the QgsLegend::writeProject method.<br>
The returned document will contain only groups and layers names and indexes,<br>
like the following example:<br>
<!DOCTYPE Group Layer Hierarchy><br>
<Legend><br>
 <Group Name="G0" Index="0"><br>
  <Layer GroupIndex="0" Id="L020120904162647883" Name="L0" Index="0"/><br>
  <Group Name="G1" Index="1"><br>
   <Group Name="G2" Index="2"><br>
    <Layer GroupIndex="2" Id="L120120904162647883" Name="L1" Index="1"/><br>
    <Layer GroupIndex="2" Id="L220120904162647382" Name="L2" Index="2"/><br>
    <Layer GroupIndex="2" Id="L320120904162644097" Name="L3" Index="3"/><br>
   </Group><br>
   <Group Name="G3" Index="3"><br>
    <Layer GroupIndex="3" Id="L40120904162648624" Name="L4" Index="4"/><br>
   </Group><br>
   <Group Name="G4" Index="4"><br>
    <Layer GroupIndex="4" Id="L520120904162649445" Name="L5" Index="5"/><br>
   </Group><br>
  </Group><br>
 </Group><br>
</Legend><br>
<br>
Massimo<br>
<br>
<br>
<br>
<br>
<br>
--<br>
View this message in context: <a href="http://osgeo-org.1560.n6.nabble.com/index-in-self-legend-groupLayerRelationship-different-behavior-between-QGIS-1-8-and-master-tp5004337p5006614.html" target="_blank">http://osgeo-org.1560.n6.nabble.com/index-in-self-legend-groupLayerRelationship-different-behavior-between-QGIS-1-8-and-master-tp5004337p5006614.html</a><br>

<div class="HOEnZb"><div class="h5">Sent from the Quantum GIS - Developer mailing list archive at Nabble.com.<br>
_______________________________________________<br>
Qgis-developer mailing list<br>
<a href="mailto:Qgis-developer@lists.osgeo.org">Qgis-developer@lists.osgeo.org</a><br>
<a href="http://lists.osgeo.org/mailman/listinfo/qgis-developer" target="_blank">http://lists.osgeo.org/mailman/listinfo/qgis-developer</a><br>
</div></div></blockquote></div><br>