[Qgis-developer] Python: groups in QgsLegendInterface()

Marco Bernasocchi marco at bernawebdesign.ch
Tue Jun 14 15:55:48 EDT 2011


Hi Chris,
On 06/14/2011 09:14 PM, Chris Crook wrote:
> Hi Marco
>
> I realise I've been very slow to reply.  Thanks for the pointer to this .. I see that you are using the same approach, basically the group id is the index of the group name in the groupLayerRelationship() list.
>
> This seems to work, but from an API point of view it does seem very indirect.  I haven't looked at the underlying code but I'd have thought it better for groups to have a unique id in the same way as layers, and to be able to use this to assign layers (and other groups?) to groups.  Not something I have time to consider at the moment :-(
I know, when I added the support for adding nested groups, I asked Marco 
Hugentobler and he said that the whole legend could use a bit more of 
"love", but at the moment I was (and still am) very short on time as 
well. thus the "temporary" solution
> Thanks
> Chris
ciao Marco
>> -----Original Message-----
>> From: Marco Bernasocchi [mailto:marco at bernawebdesign.ch]
>> Sent: Friday, 10 June 2011 7:51 p.m.
>> To: Chris Crook
>> Cc: qgis-developer-request at lists.osgeo.org
>> Subject: Re: [Qgis-developer] Python: groups in QgsLegendInterface()
>>
>> Hi
>> On 06/10/2011 04:05 AM, Chris Crook wrote:
>>> Hi All
>>>
>>> How can I determine the group index of a group containing a layer?
>>>
>> have  a look at [0] it is th data loader for my temporal data
>> plugin, It generates new groups and adds layers
>> programmatically. Please note that it is not possible [yet]
>> to nest groups deeper than a level due to the legend model.
>>> Basically I'm creating a new layer, and wanting to add it
>> to the same group as a new layer. It looks like the only way
>> to add a layer to a group is via the group index.  But I
>> can't see any way to determine the group index of an existing layer.
>>> The nearest I've got is
>>>
>>>     [i for i,x in enumerate(legend.groupLayerRelationship()) if
>>> layer.id() in x[1]]
>>>
>>> But this doesn't work with nested groups.
>>>
>>> Any other suggestions?
>>>
>>> Thanks
>>> Chris
>>>
>> ______________________________________________________________________
>>> ________________________________
>>>
>>> This message contains information, which is confidential
>> and may be subject to legal privilege.
>>> If you are not the intended recipient, you must not peruse,
>> use, disseminate, distribute or copy this message.
>>> If you have received this message in error, please notify
>> us immediately (Phone 0800 665 463 or info at linz.govt.nz) and
>> destroy the original message.
>>> LINZ accepts no responsibility for changes to this email,
>> or for any attachments, after its transmission from LINZ.
>>> Thank you.
>>>
>> ______________________________________________________________________
>>> ________________________________
>>> _______________________________________________
>>> Qgis-developer mailing list
>>> Qgis-developer at lists.osgeo.org
>>> http://lists.osgeo.org/mailman/listinfo/qgis-developer
>> Ciao
>> Marco
>> [0]
>> http://hub.qgis.org/projects/multiview/repository/revisions/ma
>> ster/entry/temporalrasterloaderdialog.py
>>
>>
> ______________________________________________________________________________________________________
>
> This message contains information, which is confidential and may be subject to legal privilege.
> If you are not the intended recipient, you must not peruse, use, disseminate, distribute or copy this message.
> If you have received this message in error, please notify us immediately (Phone 0800 665 463 or info at linz.govt.nz) and destroy the original message.
> LINZ accepts no responsibility for changes to this email, or for any attachments, after its transmission from LINZ.
>
> Thank you.
> ______________________________________________________________________________________________________



More information about the Qgis-developer mailing list