Opened 13 years ago

Closed 13 years ago

#3263 closed patch (fixed)

QgsLegendInterface.addGroup() nests all groups

Reported by: anitagraser Owned by: mhugent
Priority: major: does not work as expected Milestone: Version 1.7.0
Component: Map Legend Version: Trunk
Keywords: Cc:
Must Fix for Release: No Platform: All
Platform Version: Awaiting user input: no

Description

The following code adds four groups to the legend. Unfortunately they're all nested while the goal would be to put them into legend root:

i = qgis.utils.iface
l = i.legendInterface()
groupAnnotation = l.addGroup("Annotation",False)
groupDimensioning = l.addGroup("Dimensioning", True)
groupLocation = l.addGroup("Location", True)
groupTopo = l.addGroup("Topo", True)

Compare: http://forum.qgis.org/viewtopic.php?f=5&t=7583

Attachments (5)

bug3263fix.diff (5.4 KB ) - added by mbernasocchi 13 years ago.
Better fix, instead of forcing the element to be at the end, addGroup can receive a parent object. The new method addGroupToCurrentItem adds a new goup to the currentItem
bug3263fix.patch (1 byte ) - added by mbernasocchi 13 years ago.
trying to delete a wrong file
bug3263docFix.diff (538 bytes ) - added by mbernasocchi 13 years ago.
Fixing documentation string
bug3263_addGroupNesting.diff (2.5 KB ) - added by mbernasocchi 13 years ago.
patch to add nesting on gui
addGroupNestingPython.diff (4.2 KB ) - added by mbernasocchi 13 years ago.
This patch creates the python binding to addGroup. For the moment it allows only one level of nesting like removeGroup

Download all attachments as: .zip

Change History (20)

comment:1 by mbernasocchi, 13 years ago

Priority: minor: annoyancemajor: does not work as expected

I m dealing with the same problem in my multiview plugin (http://hub.qgis.org/projects/multiview/repository/revisions/master/entry/temporalrasterloaderdialog.py) and i noticed that if i create a group and then load a layer the groups get created at the end of the list (look for the hack in the link). So maybe it is a more complex issue/bug.

comment:2 by mhugent, 13 years ago

Type: bugpatch

comment:3 by mhugent, 13 years ago

Owner: changed from nobody to mhugent

by mbernasocchi, 13 years ago

Attachment: bug3263fix.diff added

Better fix, instead of forcing the element to be at the end, addGroup can receive a parent object. The new method addGroupToCurrentItem adds a new goup to the currentItem

by mbernasocchi, 13 years ago

Attachment: bug3263fix.patch added

trying to delete a wrong file

comment:4 by mhugent, 13 years ago

Applied in r15561. Thanks!

comment:5 by borysiasty, 13 years ago

Resolution: fixed
Status: newclosed

I believe it can be closed now.

by mbernasocchi, 13 years ago

Attachment: bug3263docFix.diff added

Fixing documentation string

comment:6 by mbernasocchi, 13 years ago

Resolution: fixed
Status: closedreopened

comment:7 by borysiasty, 13 years ago

applied in r15594

comment:8 by borysiasty, 13 years ago

Resolution: fixed
Status: reopenedclosed

by mbernasocchi, 13 years ago

patch to add nesting on gui

comment:9 by mbernasocchi, 13 years ago

Resolution: fixed
Status: closedreopened

the patch applied was an incomplete one... missunderstanding between Marcos :) here the patch to the patch

ciao

comment:10 by mhugent, 13 years ago

Resolution: fixed
Status: reopenedclosed

Applied in r15766 with two small modifications: -added missing return statement in addGroupToCurrentItem() -removed debug msg

comment:11 by mbernasocchi, 13 years ago

ups... :|

by mbernasocchi, 13 years ago

Attachment: addGroupNestingPython.diff added

This patch creates the python binding to addGroup. For the moment it allows only one level of nesting like removeGroup

comment:12 by mbernasocchi, 13 years ago

Resolution: fixed
Status: closedreopened

added python bindings. it supports only nesting into a top level element like removeGroup. we should think of a more flexible solution.

comment:13 by mhugent, 13 years ago

Yes, all these group functions with int indices come frome the pre-multiple nesting time. It would probably be better to do a bit of interface redesign for both QgsLegend and QgsLegendInterface after 1.7 (maybe working with QTreeWidgetItems)

in reply to:  13 comment:14 by mbernasocchi, 13 years ago

Replying to mhugent:

Yes, all these group functions with int indices come frome the pre-multiple nesting time. It would probably be better to do a bit of interface redesign for both QgsLegend and QgsLegendInterface after 1.7 (maybe working with QTreeWidgetItems)

True, once done with my master we can have a look at it. will you still apply the patch?

comment:15 by mhugent, 13 years ago

Resolution: fixed
Status: reopenedclosed

Yes, applied in r15787

Note: See TracTickets for help on using tickets.