Bug report #13575

"Add a Legend" adds ALL the layers in the project instead of just the visible or locked ones

Added by Harrissou Santanna over 8 years ago. Updated almost 5 years ago.

Category:Map Composer/Printing
Affected QGIS version:master Regression?:No
Operating System: Easy fix?:No
Pull Request or Patch supplied:No Resolution:end of life
Crashes QGIS or corrupts data:No Copied to github as #:21617


Most of the times, when you add legend to a map, it's about features that are shown in it. You only care about layers that are displayed or the ones that should be displayed. But in QGIS last releases, "Add a legend" tool adds ALL the layers in the project, without considering if they are visible or not, if they cover the map item extent or not.
Adding a legend in a big project means therefore that you have to spend a lot of time removing the unwanted layers and groups. This is really time consuming and imho an umproductive behaviour.
"Filtering legend by the map content" is neither a quick solution considering bug report #12969 or #11293.

There has been a fix for a kind of bug (see #7177), reason why I set this as a regression ( even if it was against 2.4). The best behaviour imho is that when a legend is added, it should :
- list all the visible layers in the map canvas when "lock layers for map item" is unchecked
- list only the locked layers in the map item when "lock layers for map item" is checked
- add group/subgroup structure only for the layers above (#12969)

The Auto-update option, when active, will keep updated these layer's styles or the list of locked layers if changed (using a preset for example).

Related issues

Related to QGIS Application - Feature request #12969: Autohide empty groups and sub-groups in "Filtered" Map Co... Closed 2015-06-15
Related to QGIS Application - Bug report #11293: Auto update Shows All Layers Closed 2014-09-29


#1 Updated by Nyall Dawson over 8 years ago

  • Priority changed from Severe/Regression to Normal

Not a regression or broken new feature, so not a blocker

#2 Updated by Harrissou Santanna over 8 years ago

You may be right Nyall, but i'm not sure this should be set as normal. Combined to the "filtering by map content" issues and the preset issue discussed in #13418, this leads designing (and keeping up to date) a complete composition, despite its nice features, painful imho. it should be set as high.

#3 Updated by Nyall Dawson over 8 years ago

High is used for issues which cause data loss or crashes, so normal is the right priority. I agree though that the described behavior would be a big improvement.

#4 Updated by Martin Dobias about 8 years ago

I think in order to fix this issue and the related issues, we will need to improve the layer tree model class to support flexible filtering of its items. Currently it only allows filtering of legend items within layers, which is not enough to allow hiding of layer items or group items. Unfortunately this is not feasible to add just before the LTR as the implementation will take a bit of time and there is a high risk of introducing some new bugs.

Anyway, with the advanced filtering, it should be quite straightforward to add nice features like 'quick find' box where the layer tree would get filtered as you type...

#5 Updated by Giovanni Manghi almost 7 years ago

  • Regression? set to No
  • Easy fix? set to No

#6 Updated by Giovanni Manghi almost 5 years ago

  • Resolution set to end of life
  • Status changed from Open to Closed

Also available in: Atom PDF