[Qgis-developer] Legend group API

Sandro Santilli strk at keybit.net
Mon Dec 10 23:56:16 PST 2012


Hi all,
I've recently had troubles using the LegendGroup API from a python plugin
in that the addGroup method returns in integer which seems to be the input
for moveLayer, but it doesn't work as such.

More info I've added to this ticket http://hub.qgis.org/issues/6591

I've found that addGroup returns what QModelIndex.row() returns, but that
index doesn't seem to identify the group in any way..

Before 2.0 gets out it seems worth fixing that API, do you agree ?

One option would be to store an unique identifier in each LegendGroup object
and use that identifier for all lookups. There would be a counter within
each Legend incremented everytime a new group is added. Would this break
any existing usage ? Are there tests for this in place ?
The advantage of this is that the interface of addGroup and moveLayer would
not change.

Another option is the change addGroup to return and moveLayer to take
a full QModelIndex object, which would then need to be exposed to python
(if not already available) and could require upgrade of any plugin or core
code using those interfaces. Also I don't think a QModelIndex is persistent
so would not simplify identification of a group in any way.

--strk; 


More information about the Qgis-developer mailing list