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

kimaidou kimaidou at gmail.com
Fri Oct 5 05:41:48 PDT 2012


Hi all,

+ 1 for the proposal of Massimo using the DOM implementation. I will be
straightforward to use.

Michael

2012/10/5 Massimo <massimo.endrighi at geopartner.it>

> 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.
>
> 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>
>
> 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
> Qgis-developer at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/qgis-developer
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20121005/10d264e9/attachment.html>


More information about the Qgis-developer mailing list