qgis/Quantum-GIS — pull request #217 by endmax (2012-08-28 07:57:01+00:00)
Title: The QgslegendInterface manages only top level items

I need to create a groups/layers hierarchy starting from a third-party xml file. The QgslegendInterface is limited to manage only top level item. I've no chance to create sub groups other than inside a top level group or add a layer into a sub-group.
The groupIndex/parentIndex used by the members of QgslegendInterface is used as an item index to top level item in the legend. So far the following member are limited to work for top level item:
- addGroup(QString name, bool expand, int parentIndex)
- groupExists(int groupIndex)
- isGroupExpanded(int groupIndex)
- isGroupVisible(int groupIndex)
- moveLayer(QgsMapLayer *ml, int groupIndex)
- removeGroup(int groupIndex)
- setGroupExpanded(int groupIndex, bool expand)
- setGroupVisible(int groupIndex, bool visible)
I've modified the previous members in the way the groupIndex is a true index to all group hierarchy. Now the groupIndex values are in range 0 to len(QgslegendInterface.groups()).

Furthermore it would be usefull a moveLayer/moveGroup member to move a layer/group after or before another layer/group. In this way it would be possible to create a new project with a exact groups/layers hierarchy or integrate an existing project with a fragment o groups/layers hierarchy.