Feature request #3263

QgsLegendInterface.addGroup() nests all groups

Added by Anita Graser almost 10 years ago. Updated over 9 years ago.

Status:Closed
Priority:Low
Assignee:Marco Hugentobler
Category:Map Legend
Pull Request or Patch supplied: Resolution:fixed
Easy fix?:No Copied to github as #:13323

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

bug3263fix.diff Magnifier - 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 (5.41 KB) Marco Bernasocchi, 2011-03-22 03:09 AM

bug3263fix.patch Magnifier - trying to delete a wrong file (1 Byte) Marco Bernasocchi, 2011-03-22 03:11 AM

bug3263docFix.diff Magnifier - Fixing documentation string (538 Bytes) Marco Bernasocchi, 2011-03-24 05:17 PM

bug3263_addGroupNesting.diff Magnifier - patch to add nesting on gui (2.47 KB) Marco Bernasocchi, 2011-04-19 06:31 AM

addGroupNestingPython.diff Magnifier - This patch creates the python binding to addGroup. For the moment it allows only one level of nesting like removeGroup (4.16 KB) Marco Bernasocchi, 2011-04-20 04:53 AM

History

#1 Updated by Marco Bernasocchi over 9 years ago

I m dealing with the same problem in my multiview plugin (https://issues.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.

#2 Updated by Marco Hugentobler over 9 years ago

Applied in 855601c3 (SVN r15562). Thanks!

#3 Updated by Borys Jurgiel over 9 years ago

  • Resolution set to fixed
  • Status changed from Open to Closed

I believe it can be closed now.

#4 Updated by Marco Bernasocchi over 9 years ago

  • Status changed from Closed to Feedback
  • Resolution deleted (fixed)

#5 Updated by Borys Jurgiel over 9 years ago

applied in bf9e9d54 (SVN r15595)

#6 Updated by Borys Jurgiel over 9 years ago

  • Resolution set to fixed
  • Status changed from Feedback to Closed

#7 Updated by Marco Bernasocchi over 9 years ago

  • Status changed from Closed to Feedback
  • Resolution deleted (fixed)

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

ciao

#8 Updated by Marco Hugentobler over 9 years ago

  • Resolution set to fixed
  • Status changed from Feedback to Closed

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

#9 Updated by Marco Bernasocchi over 9 years ago

ups... :|

#10 Updated by Marco Bernasocchi over 9 years ago

  • Status changed from Closed to Feedback
  • Resolution deleted (fixed)

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

#11 Updated by Marco Hugentobler over 9 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)

#12 Updated by Marco Bernasocchi over 9 years ago

Replying to [comment:13 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?

#13 Updated by Marco Hugentobler over 9 years ago

  • Status changed from Feedback to Closed
  • Resolution set to fixed

Yes, applied in b8853323 (SVN r15788)

Also available in: Atom PDF