Hi all<br><br>I managed to reconstruct my legend in my QTreeWidget by using a dictionary to store the item I have already added in the tree while looping through groupLayerRelationship !<br><br>Cheers<br>Kimaidou<br><br><div class="gmail_quote">
2011/6/20 kimaidou <span dir="ltr"><<a href="mailto:kimaidou@gmail.com">kimaidou@gmail.com</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">Hi devs,<br>
<br>I am a bit stuck here....<br>I would like to recreate the complete legend tree inside a python plugin. I have chosen to use a QtreeWidget to do so.<br><br>Imagine I have:<br>*****************<br>group 0 (empty)<br>
<br>group 1<br>|-- group 11<br>
|-- layer 11a<br> |-- layer 11b<br>|-- layer 1a<br><br>layer a<br><br>group 2<br>|-- group 21<br>|-- layer 2a<br>***********************<br><br>I have seen the <br>
<p style="margin:0px;text-indent:0px">iface.legendInterface().groupLayerRelationship()</p><p style="margin:0px;text-indent:0px">returns usefull information, but in a flat "C-style" way like :</p><p style="margin:0px;text-indent:0px">
<br></p>[<br> ['group 0', [] ], <br> ['group 1', ['group 11', 'layer_1a_10020100526085601790'] ], <br> ['', ['layer_a_20110617181245226'] ], <br> ['group 2', ['groupe21', 'layer_2a_20110616121558434'] ], <br>
['group 11', ['layer_11a_20100526085601799', 'layer_11b_gen20100526100356932'] ], <br> ['groupe21', []]<br>]<br><br><br>I would like to loop though this result and create my own hierarchical representation such as :<br>
[<br> 'name' : 'group 0' , 'type' : 'group', 'children' : [],<br> 'name' : 'group 1' , 'type' : 'group', 'children' : [<br> 'name' : 'group 11' , 'type' : 'group', 'children' : [<br>
'name' : 'layer 11a' , 'type' : 'layer', 'children' : [],<br> 'name' : 'layer 11b' , 'type' : 'layer', 'children' : []<br>
],<br> 'name' : 'layer 1a' , 'type' : 'layer', 'children' : []<br> ],<br> 'name' : 'layer a' , 'type' : 'layer', 'children' : [],<br>
'name' : 'group 2' , 'type' : 'group', 'children' : [<br> 'name' : 'group 21' , 'type' : 'group', 'children' : [],<br> 'name' : 'layer 2a' , 'type' : 'layer', 'children' : []<br>
]<br>]<br><br>I have tried hard since yesterday, but have not succeeded... Has anyone already encoutered this need ? <br><br>Thanks in advance, <br><font color="#888888">kimaidou<br>
</font></blockquote></div><br>