[Qgis-developer] Create groups in python plugins
Martin Dobias
wonder.sk at gmail.com
Mon Nov 30 07:03:44 EST 2009
On Mon, Nov 30, 2009 at 12:39 PM, Andres Manz <manz.andres at gmail.com> wrote:
> Hi List,
>
> Well, I created a QgsLegendInterface with the functions
> - addGroup( QString name );
> - moveLayer( QgsMapLayer * layer, QString group )
> - removeGroup( QString name );
>
> There's (at least) one thing I don't like about this:
> What if the user has more than one group with the same name?
> All groups with the same name would be removed (removeGroup) or a
> layer would be moved to the first group with the given name
> (moveLayer). So the scripter / user does not have much control on the
> group selection.
Hi Andres
what about using indices for groups? You could create a groups()
method that would return a list of groups, the groups could be
addressed by the index instead of name, so:
int addGroup( QString name ) ... returns index of newly added group
QStringList groups()
moveLayer( ... ) ... should be enough flexible to allow ordering also
within groups, moving out of groups, maybe even moving of groups?
removeGroup ( int groupIndex ) ... one thing to consider is whether
all layers within the group should be removed too or not...
I think there's also place for additional functions for querying /
setting legend items: order of layers, layer/group visibility etc. But
I'm not sure how much time would you like to invest into that :-) Just
try to design the API to be easily extensible.
One last note - we're going to enter feature freeze very soon, so if
you want the changes to appear in 1.4 release, you should be quick :-)
Regards
Martin
More information about the Qgis-developer
mailing list