On Fri, Oct 5, 2012 at 6:28 AM, Massimo <[email protected]> wrote: > Etienne Tourigny-3 wrote >> ..... >> While it woulf be good to expose legend api to python, it mught be a >> lot of work. > > Yes it could be a lot of work and I'm not sure about how to do it. > > > Etienne Tourigny-3 wrote >> would it be sufficient to have the following? >> >> 1) groups relations like this: >> QList< QPair< int, QList < int > > > >> >> 2) layers within a group like this: >> QList< QPair< int, QList< QString > > > >> or >> QList< QPair< int, QList< QgsMapLayer* > > > >> >> this way, you have access to group hierarchies by id, and layers for each >> group. >> >> You would use existing methods like setGroupExpanded() to work on >> groups in a relatively simple manner. > > Using the index instead of group name is a good idea. Anyway, the groups > relations could be recursive in order to avoid a "complex" algorithm to > reconstruct the hierarchy. > Furthermore splitting the information over two lists cuts off the exact > sequence of layers/groups and any post processing logic will fail to > reconstruct the hierarchy.
OK, i see how this could fail. > > Thus I propose another solution based on QDomDocument similar to the one > adopted into the QgsLegend::writeProject method. > The returned document will contain only groups and layers names and indexes, > like the following example: > <!DOCTYPE Group Layer Hierarchy> > <Legend> > <Group Name="G0" Index="0"> > <Layer GroupIndex="0" Id="L020120904162647883" Name="L0" Index="0"/> > <Group Name="G1" Index="1"> > <Group Name="G2" Index="2"> > <Layer GroupIndex="2" Id="L120120904162647883" Name="L1" Index="1"/> > <Layer GroupIndex="2" Id="L220120904162647382" Name="L2" Index="2"/> > <Layer GroupIndex="2" Id="L320120904162644097" Name="L3" Index="3"/> > </Group> > <Group Name="G3" Index="3"> > <Layer GroupIndex="3" Id="L40120904162648624" Name="L4" Index="4"/> > </Group> > <Group Name="G4" Index="4"> > <Layer GroupIndex="4" Id="L520120904162649445" Name="L5" Index="5"/> > </Group> > </Group> > </Group> > </Legend> xml stuff is good for export/import but not very handy for modifications, so this isn't a viable solution I'll give a -1 on your implementation as it's another stop-gap solution. I'd support either Martin's solution or exposing the QgsLegend and related classes to python. But even there, GroupLayerInfo and QgsLegend::groupLayerRelationship() have to be modified, or dropped. cheers Etienne > > 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-tp5004337p5006614.html > Sent from the Quantum GIS - Developer mailing list archive at Nabble.com. > _______________________________________________ > Qgis-developer mailing list > [email protected] > http://lists.osgeo.org/mailman/listinfo/qgis-developer _______________________________________________ Qgis-developer mailing list [email protected] http://lists.osgeo.org/mailman/listinfo/qgis-developer
