[Qgis-developer] Legend refactoring branch merged

Tim Sutton lists at linfiniti.com
Wed Jun 4 09:06:30 PDT 2014


Hi


Another regression / change in behaviour between legend in 2.x and master
is that layers added in python are not focussed in the legend. This breaks
some of our InaSAFE stuff that expects this behaviour.

Good:

http://storage8.static.itmages.com/i/14/0604/h_1401898037_8549074_84a270face.png

Bad:

http://storage9.static.itmages.com/i/14/0604/h_1401898084_4943485_004d455ff0.png

Regards

Tim


On Wed, Jun 4, 2014 at 10d:52 PM, Martin Dobias <wonder.sk at gmail.com> wrote:

> Hi Hugo
>
> On Wed, Jun 4, 2014 at 10:00 PM, Hugo Mercier <hugo.mercier at oslandia.com>
> wrote:
> > Some issues :
> >
> > - passing 'false' to the 'addToLegend' parameter of
> > QgsMapLayerRegistry::addMapLayer (in Python) still adds the layer to the
> > legend, apparently
>
> Fixed.
>
> > - QgsLayerTreeGroup.insertLayer( 0, layer ) gives strange things in
> > Python (crash of qgis). Doing insertChildNode( 0, QgsLayerTreeLayer(
> > layer ) ), or storing the object returned by insertLayer solves the
> > problem. It seems to be related to the way Python garbage collects (?)
>
> Fixed.
>
> > Just a remark on the API : if layers must be added first to the
> > MapLayerRegistry before being added to the legend, then why removing a
>
> Layers do not need to be added to map layer registry first. A layer
> can exist in the layer tree even without being loaded.
>
> > layer from the legend makes it removed from the registry and only if it
> > is the only one remaining ?
>
> Otherwise the layer would be removed from the layer tree and it would
> never get deleted.
>
> If you create your own layer tree, you will not have this behaviour
> unless you use it with map layer registry bridge.
>
> For the future (QGIS 3), I'd like to see the following:
> - map layer registry will not be used explicitly by client code
> (calling addMapLayer/removeMapLayer methods)
> - all map layers will be automatically added to the map layer registry
> when constructed - and removed when deleted
> - if client code will want to add a map layer to layer tree, it would
> do it by itself
>
> Thanks for testing!
>
> Cheers
> Martin
> _______________________________________________
> Qgis-developer mailing list
> Qgis-developer at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/qgis-developer
>



-- 
Tim Sutton - QGIS Project Steering Committee Member
==============================================
Please do not email me off-list with technical
support questions. Using the lists will gain
more exposure for your issues and the knowledge
surrounding your issue will be shared with all.

Irc: timlinux on #qgis at freenode.net
==============================================
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20140604/d9330ab8/attachment.html>


More information about the Qgis-developer mailing list