{"action":"created","comment":{"url":"https://api.github.com/repos/qgis/QGIS/pulls/comments/37021106","id":37021106,"diff_hunk":"@@ -1299,10 +1303,41 @@ QList<QgsLayerTreeModelLegendNode*> QgsLayerTreeModel::layerLegendNodes( QgsLaye\n \n void QgsLayerTreeModel::legendInvalidateMapBasedData()\n {\n+  // we have varying icon sizes, and we want icon to be centered and\n+  // text to be left aligned, so we have to compute the max width of icons\n+  //\n+  // we do that for nodes who share a common parent\n+  //\n+  // we do that here because for symbols with size defined in map units\n+  // the symbol sizes changes depends on the zoom level\n+\n+  QList<QgsSymbolV2LegendNode*> symbolNodes;\n+  QMap<QString, int> widthMax;\n   foreach ( const LayerLegendData& data, mLegend )\n   {\n     foreach ( QgsLayerTreeModelLegendNode* legendNode, data.originalNodes )\n+    {\n       legendNode->invalidateMapBasedData();\n+      QgsSymbolV2LegendNode* n = dynamic_cast<QgsSymbolV2LegendNode*>( legendNode );\n+      if ( n )\n+      {\n+        n->setParent( this ); // map scale are in the model, so the parent needs to be set\n+        const QSize sz( n->minimumIconSize() );\n+        const QString parentKey( n->data( QgsLayerTreeModelLegendNode::ParentRuleKeyRole ).toString() );\n+        widthMax[parentKey] = qMax( sz.width(), widthMax.contains( parentKey ) ? widthMax[parentKey] : 0 );\n+        n->setIconSize( sz );\n+        symbolNodes.append( n );\n+      }\n+    }\n+  }\n+\n+  foreach ( QgsSymbolV2LegendNode* n, symbolNodes )\n+  {\n+    const QString parentKey( n->data( QgsLayerTreeModelLegendNode::ParentRuleKeyRole ).toString() );\n+    Q_ASSERT( widthMax[parentKey] > 0 );\n+    const int twiceMarginWidth = 2; // a one pixel margin avoids hugly rendering of icon\n+    n->setIconSize( QSize( widthMax[parentKey] + twiceMarginWidth, n->iconSize().rheight() + twiceMarginWidth ) );\n+    n->invalidateMapBasedData();","path":"src/core/layertree/qgslayertreemodel.cpp","position":49,"original_position":49,"commit_id":"8776449a148e8b5422a73de45e5a364d1a7e5d5d","original_commit_id":"8776449a148e8b5422a73de45e5a364d1a7e5d5d","user":{"login":"vmora","id":4415710,"avatar_url":"https://avatars.githubusercontent.com/u/4415710?v=3","gravatar_id":"","url":"https://api.github.com/users/vmora","html_url":"https://github.com/vmora","followers_url":"https://api.github.com/users/vmora/followers","following_url":"https://api.github.com/users/vmora/following{/other_user}","gists_url":"https://api.github.com/users/vmora/gists{/gist_id}","starred_url":"https://api.github.com/users/vmora/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vmora/subscriptions","organizations_url":"https://api.github.com/users/vmora/orgs","repos_url":"https://api.github.com/users/vmora/repos","events_url":"https://api.github.com/users/vmora/events{/privacy}","received_events_url":"https://api.github.com/users/vmora/received_events","type":"User","site_admin":false},"body":"It is apparently, at least it seems necessary to call that last (after set iconSize).","created_at":"2015-08-13T20:26:19Z","updated_at":"2015-08-13T20:26:19Z","html_url":"https://github.com/qgis/QGIS/pull/2245#discussion_r37021106","pull_request_url":"https://api.github.com/repos/qgis/QGIS/pulls/2245","_links":{"self":{"href":"https://api.github.com/repos/qgis/QGIS/pulls/comments/37021106"},"html":{"href":"https://github.com/qgis/QGIS/pull/2245#discussion_r37021106"},"pull_request":{"href":"https://api.github.com/repos/qgis/QGIS/pulls/2245"}}},"pull_request":{"url":"https://api.github.com/repos/qgis/QGIS/pulls/2245","id":42386498,"html_url":"https://github.com/qgis/QGIS/pull/2245","diff_url":"https://github.com/qgis/QGIS/pull/2245.diff","patch_url":"https://github.com/qgis/QGIS/pull/2245.patch","issue_url":"https://api.github.com/repos/qgis/QGIS/issues/2245","number":2245,"state":"open","locked":false,"title":"Fix legend symbol size when using map units (fix #13078)","user":{"login":"vmora","id":4415710,"avatar_url":"https://avatars.githubusercontent.com/u/4415710?v=3","gravatar_id":"","url":"https://api.github.com/users/vmora","html_url":"https://github.com/vmora","followers_url":"https://api.github.com/users/vmora/followers","following_url":"https://api.github.com/users/vmora/following{/other_user}","gists_url":"https://api.github.com/users/vmora/gists{/gist_id}","starred_url":"https://api.github.com/users/vmora/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vmora/subscriptions","organizations_url":"https://api.github.com/users/vmora/orgs","repos_url":"https://api.github.com/users/vmora/repos","events_url":"https://api.github.com/users/vmora/events{/privacy}","received_events_url":"https://api.github.com/users/vmora/received_events","type":"User","site_admin":false},"body":"The computation of icon sizes for legend symbols has been moved to QgsLayerTreeModel::legendInvalidateMapBasedData() susch that icon size is recomputed when zooming.\r\n\r\n@wonder-sk thanks a lot for the pointers, does that look good to you ?","created_at":"2015-08-13T19:03:53Z","updated_at":"2015-08-13T20:26:19Z","closed_at":null,"merged_at":null,"merge_commit_sha":"e25ca1c9abea4b6841cc50e5ed23e15de8bcac89","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/qgis/QGIS/pulls/2245/commits","review_comments_url":"https://api.github.com/repos/qgis/QGIS/pulls/2245/comments","review_comment_url":"https://api.github.com/repos/qgis/QGIS/pulls/comments{/number}","comments_url":"https://api.github.com/repos/qgis/QGIS/issues/2245/comments","statuses_url":"https://api.github.com/repos/qgis/QGIS/statuses/8776449a148e8b5422a73de45e5a364d1a7e5d5d","head":{"label":"vmora:issue13078","ref":"issue13078","sha":"8776449a148e8b5422a73de45e5a364d1a7e5d5d","user":{"login":"vmora","id":4415710,"avatar_url":"https://avatars.githubusercontent.com/u/4415710?v=3","gravatar_id":"","url":"https://api.github.com/users/vmora","html_url":"https://github.com/vmora","followers_url":"https://api.github.com/users/vmora/followers","following_url":"https://api.github.com/users/vmora/following{/other_user}","gists_url":"https://api.github.com/users/vmora/gists{/gist_id}","starred_url":"https://api.github.com/users/vmora/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vmora/subscriptions","organizations_url":"https://api.github.com/users/vmora/orgs","repos_url":"https://api.github.com/users/vmora/repos","events_url":"https://api.github.com/users/vmora/events{/privacy}","received_events_url":"https://api.github.com/users/vmora/received_events","type":"User","site_admin":false},"repo":{"id":23867058,"name":"QGIS","full_name":"vmora/QGIS","owner":{"login":"vmora","id":4415710,"avatar_url":"https://avatars.githubusercontent.com/u/4415710?v=3","gravatar_id":"","url":"https://api.github.com/users/vmora","html_url":"https://github.com/vmora","followers_url":"https://api.github.com/users/vmora/followers","following_url":"https://api.github.com/users/vmora/following{/other_user}","gists_url":"https://api.github.com/users/vmora/gists{/gist_id}","starred_url":"https://api.github.com/users/vmora/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vmora/subscriptions","organizations_url":"https://api.github.com/users/vmora/orgs","repos_url":"https://api.github.com/users/vmora/repos","events_url":"https://api.github.com/users/vmora/events{/privacy}","received_events_url":"https://api.github.com/users/vmora/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/vmora/QGIS","description":"QGIS is a free, open source, cross platform (lin/win/mac) geographical information system (GIS)","fork":true,"url":"https://api.github.com/repos/vmora/QGIS","forks_url":"https://api.github.com/repos/vmora/QGIS/forks","keys_url":"https://api.github.com/repos/vmora/QGIS/keys{/key_id}","collaborators_url":"https://api.github.com/repos/vmora/QGIS/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/vmora/QGIS/teams","hooks_url":"https://api.github.com/repos/vmora/QGIS/hooks","issue_events_url":"https://api.github.com/repos/vmora/QGIS/issues/events{/number}","events_url":"https://api.github.com/repos/vmora/QGIS/events","assignees_url":"https://api.github.com/repos/vmora/QGIS/assignees{/user}","branches_url":"https://api.github.com/repos/vmora/QGIS/branches{/branch}","tags_url":"https://api.github.com/repos/vmora/QGIS/tags","blobs_url":"https://api.github.com/repos/vmora/QGIS/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/vmora/QGIS/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/vmora/QGIS/git/refs{/sha}","trees_url":"https://api.github.com/repos/vmora/QGIS/git/trees{/sha}","statuses_url":"https://api.github.com/repos/vmora/QGIS/statuses/{sha}","languages_url":"https://api.github.com/repos/vmora/QGIS/languages","stargazers_url":"https://api.github.com/repos/vmora/QGIS/stargazers","contributors_url":"https://api.github.com/repos/vmora/QGIS/contributors","subscribers_url":"https://api.github.com/repos/vmora/QGIS/subscribers","subscription_url":"https://api.github.com/repos/vmora/QGIS/subscription","commits_url":"https://api.github.com/repos/vmora/QGIS/commits{/sha}","git_commits_url":"https://api.github.com/repos/vmora/QGIS/git/commits{/sha}","comments_url":"https://api.github.com/repos/vmora/QGIS/comments{/number}","issue_comment_url":"https://api.github.com/repos/vmora/QGIS/issues/comments{/number}","contents_url":"https://api.github.com/repos/vmora/QGIS/contents/{+path}","compare_url":"https://api.github.com/repos/vmora/QGIS/compare/{base}...{head}","merges_url":"https://api.github.com/repos/vmora/QGIS/merges","archive_url":"https://api.github.com/repos/vmora/QGIS/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/vmora/QGIS/downloads","issues_url":"https://api.github.com/repos/vmora/QGIS/issues{/number}","pulls_url":"https://api.github.com/repos/vmora/QGIS/pulls{/number}","milestones_url":"https://api.github.com/repos/vmora/QGIS/milestones{/number}","notifications_url":"https://api.github.com/repos/vmora/QGIS/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/vmora/QGIS/labels{/name}","releases_url":"https://api.github.com/repos/vmora/QGIS/releases{/id}","created_at":"2014-09-10T08:38:57Z","updated_at":"2015-04-29T08:14:32Z","pushed_at":"2015-08-13T18:54:50Z","git_url":"git://github.com/vmora/QGIS.git","ssh_url":"git@github.com:vmora/QGIS.git","clone_url":"https://github.com/vmora/QGIS.git","svn_url":"https://github.com/vmora/QGIS","homepage":"http://qgis.org","size":1085851,"stargazers_count":0,"watchers_count":0,"language":"C++","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"qgis:master","ref":"master","sha":"4cf3fcc3c1527e1a9035a8712450295f8b7106af","user":{"login":"qgis","id":483444,"avatar_url":"https://avatars.githubusercontent.com/u/483444?v=3","gravatar_id":"","url":"https://api.github.com/users/qgis","html_url":"https://github.com/qgis","followers_url":"https://api.github.com/users/qgis/followers","following_url":"https://api.github.com/users/qgis/following{/other_user}","gists_url":"https://api.github.com/users/qgis/gists{/gist_id}","starred_url":"https://api.github.com/users/qgis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/qgis/subscriptions","organizations_url":"https://api.github.com/users/qgis/orgs","repos_url":"https://api.github.com/users/qgis/repos","events_url":"https://api.github.com/users/qgis/events{/privacy}","received_events_url":"https://api.github.com/users/qgis/received_events","type":"Organization","site_admin":false},"repo":{"id":1690480,"name":"QGIS","full_name":"qgis/QGIS","owner":{"login":"qgis","id":483444,"avatar_url":"https://avatars.githubusercontent.com/u/483444?v=3","gravatar_id":"","url":"https://api.github.com/users/qgis","html_url":"https://github.com/qgis","followers_url":"https://api.github.com/users/qgis/followers","following_url":"https://api.github.com/users/qgis/following{/other_user}","gists_url":"https://api.github.com/users/qgis/gists{/gist_id}","starred_url":"https://api.github.com/users/qgis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/qgis/subscriptions","organizations_url":"https://api.github.com/users/qgis/orgs","repos_url":"https://api.github.com/users/qgis/repos","events_url":"https://api.github.com/users/qgis/events{/privacy}","received_events_url":"https://api.github.com/users/qgis/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/qgis/QGIS","description":"QGIS is a free, open source, cross platform (lin/win/mac) geographical information system (GIS)","fork":false,"url":"https://api.github.com/repos/qgis/QGIS","forks_url":"https://api.github.com/repos/qgis/QGIS/forks","keys_url":"https://api.github.com/repos/qgis/QGIS/keys{/key_id}","collaborators_url":"https://api.github.com/repos/qgis/QGIS/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/qgis/QGIS/teams","hooks_url":"https://api.github.com/repos/qgis/QGIS/hooks","issue_events_url":"https://api.github.com/repos/qgis/QGIS/issues/events{/number}","events_url":"https://api.github.com/repos/qgis/QGIS/events","assignees_url":"https://api.github.com/repos/qgis/QGIS/assignees{/user}","branches_url":"https://api.github.com/repos/qgis/QGIS/branches{/branch}","tags_url":"https://api.github.com/repos/qgis/QGIS/tags","blobs_url":"https://api.github.com/repos/qgis/QGIS/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/qgis/QGIS/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/qgis/QGIS/git/refs{/sha}","trees_url":"https://api.github.com/repos/qgis/QGIS/git/trees{/sha}","statuses_url":"https://api.github.com/repos/qgis/QGIS/statuses/{sha}","languages_url":"https://api.github.com/repos/qgis/QGIS/languages","stargazers_url":"https://api.github.com/repos/qgis/QGIS/stargazers","contributors_url":"https://api.github.com/repos/qgis/QGIS/contributors","subscribers_url":"https://api.github.com/repos/qgis/QGIS/subscribers","subscription_url":"https://api.github.com/repos/qgis/QGIS/subscription","commits_url":"https://api.github.com/repos/qgis/QGIS/commits{/sha}","git_commits_url":"https://api.github.com/repos/qgis/QGIS/git/commits{/sha}","comments_url":"https://api.github.com/repos/qgis/QGIS/comments{/number}","issue_comment_url":"https://api.github.com/repos/qgis/QGIS/issues/comments{/number}","contents_url":"https://api.github.com/repos/qgis/QGIS/contents/{+path}","compare_url":"https://api.github.com/repos/qgis/QGIS/compare/{base}...{head}","merges_url":"https://api.github.com/repos/qgis/QGIS/merges","archive_url":"https://api.github.com/repos/qgis/QGIS/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/qgis/QGIS/downloads","issues_url":"https://api.github.com/repos/qgis/QGIS/issues{/number}","pulls_url":"https://api.github.com/repos/qgis/QGIS/pulls{/number}","milestones_url":"https://api.github.com/repos/qgis/QGIS/milestones{/number}","notifications_url":"https://api.github.com/repos/qgis/QGIS/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/qgis/QGIS/labels{/name}","releases_url":"https://api.github.com/repos/qgis/QGIS/releases{/id}","created_at":"2011-05-02T08:06:26Z","updated_at":"2015-08-12T15:53:39Z","pushed_at":"2015-08-13T19:03:54Z","git_url":"git://github.com/qgis/QGIS.git","ssh_url":"git@github.com:qgis/QGIS.git","clone_url":"https://github.com/qgis/QGIS.git","svn_url":"https://github.com/qgis/QGIS","homepage":"http://qgis.org","size":1201716,"stargazers_count":728,"watchers_count":728,"language":"C++","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":671,"mirror_url":null,"open_issues_count":49,"forks":671,"open_issues":49,"watchers":728,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/qgis/QGIS/pulls/2245"},"html":{"href":"https://github.com/qgis/QGIS/pull/2245"},"issue":{"href":"https://api.github.com/repos/qgis/QGIS/issues/2245"},"comments":{"href":"https://api.github.com/repos/qgis/QGIS/issues/2245/comments"},"review_comments":{"href":"https://api.github.com/repos/qgis/QGIS/pulls/2245/comments"},"review_comment":{"href":"https://api.github.com/repos/qgis/QGIS/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/qgis/QGIS/pulls/2245/commits"},"statuses":{"href":"https://api.github.com/repos/qgis/QGIS/statuses/8776449a148e8b5422a73de45e5a364d1a7e5d5d"}}}}