[Qgis-developer] Legend refactoring branch merged

Martin Dobias wonder.sk at gmail.com
Tue Jun 3 11:01:17 PDT 2014


On Tue, Jun 3, 2014 at 7:42 PM, Hugo Mercier <hugo.mercier at oslandia.com> wrote:
> Le 02/06/2014 17:36, Martin Dobias a écrit :
>> Hi Hugo
>>
>> On Mon, Jun 2, 2014 at 10:13 PM, Hugo Mercier <hugo.mercier at oslandia.com> wrote:
>>> Hi Martin,
>>>
>>> Le 21/05/2014 19:11, Martin Dobias a écrit :
>>>> Hi everyone
>>>>
>>>> I have just merged the first part of the legend refactoring work to
>>>> master [1]. It does not really bring any new features for the end
>>>> user, the changes are mainly under the hood. Things should ideally
>>>> work as before, if not then probably it is a bug.
>>>>
>>>
>>> Thanks for all the great work.
>>>
>>> When adding a new layer, the behaviour used to be that the new layer was
>>> placed on top of the active layer. It is not the case anymore if I am
>>> correct.
>>
>> Works for me exactly as expected - new layer is placed on top of the
>> active layer.
>>
>
> After some more tests, it seems to happen when a layer is first removed.
> To reproduce :
> * start from a blank project,
> * add a new layer,
> * add another layer,
> * remove the newly added,
> * add another layer => it will be placed at the bottom, and if you do it
> again, on top, and then at the bottom, etc.

Thanks for the test case. Should be fixed now, please check again with
latest master.


>>> When passing a list of layers in a certain order to
>>> QgsMapCanvas::setLayerSet(), the obtained order seems random (from
>>> Python). Is it wanted ? (not sure if it was already the case before your
>>> changes)
>>
>> I am not sure if I understand what you mean.... order obtained from
>> where? from map canvas?
>
> Say, from a Python plugin, if you want to reorder layers rendered on the
> map canvas. But what I observed might be linked to the previous issue.

You can reorder layers in map canvas by simply reordering the entries
in the layer tree - the same way as done with drag'n'drop: 1. add a
new node(s), 2. remove old node(s). Simply get the layer tree from
project (QgsProject.instance().layerTreeRoot()) and then just call the
root group's methods to add/remove nodes.

Alternatively one could use the map canvas bridge class and set a
customized layer order in case the layer order in canvas should not be
the same as in the tree. The bridge class is currently not exposed
from QgisApp, though no problem to add it.

Regards
Martin


More information about the Qgis-developer mailing list