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

Marco Hugentobler marco.hugentobler at sourcepole.ch
Mon Oct 8 09:07:51 PDT 2012


Btw., the legend code is quite old and probably needs a complete 
redesign to make it easier maintainable. I think it would be good to do 
this before exposing all the things in the legend to plugins (but I 
don't know if there is any volunteer for it?).

Regards,
Marco

On 08.10.2012 17:58, Giuseppe Sucameli wrote:
> Hi,
>
> On Fri, Oct 5, 2012 at 11:28 AM, Massimo <massimo.endrighi at geopartner.it> wrote:
>> I propose another solution based on QDomDocument similar to the one
>> adopted into the QgsLegend::writeProject method.
> Massimo has made a pull request [1] to add a
> groupLayerHierarchy method that returns a QDomDocument.
>
> Here's my opinion (see the pull request comments):
>> A QDomDocument is good when you want to export/import
>> data (e.g between different QGis installations) and we already
>> have a such QDomDocument, i.e. the project file.
> I totally agree with Martin, we need to implement some
> classes to give plugin devs the opportunity to work on the
> legend using an API.
>
> Furthermore I don't understand why having a new xml
> document with it's own tags/elements.
> The QgsProject.write(...) calls the QgsLegend.writeXml(...)
> to write all the stuff needed to re-create the legend tree,
> so we could just expose the QgsLegend.writeXml().
>
> BTW, in the meantime the API is developed you could
> save a temporary project file and parse it.
> Note: you need to restore the project filename after done
> because the QgsProject.write(QFileInfo) changes it.
>
> Here's XML elements you need to know to get legend
> info from project file:
>
> *<legend>* is the legend root tag.
> It can contains both *legendlayer* and *legendgroup* elements.
>
> A legend layer can contains more sublayers,
> it has the following structure:
>
> <legendlayer name="mylayer1" checked="Qt::Checked">
>      <filegroup>
>          <legendlayerfile id="mylayer120121008125355262" />
>      </filegroup>
> </legendlayer>
>
> where the *filegroup* elem contains the sublayers with their id.
>
> Group info is stored into a *legendgroup* element,
> it can contains both *legendlayer* and *legendgroup* elements:
>
> <legendgroup name="mygroup1" checked="Qt::Checked">
>      <legendlayer name="mylayer1">...</legendlayer>
>      <legendgroup name="mygroup2" checked="Qt::Checked">
>          <legendlayer name="mylayer2">...</legendlayer>
>      </legendgroup>
> </legendgroup>
>
> Regards.
>
> [1] https://github.com/qgis/Quantum-GIS/pull/265
>



More information about the Qgis-developer mailing list