{"action":"created","issue":{"url":"https://api.github.com/repos/qgis/QGIS/issues/1827","labels_url":"https://api.github.com/repos/qgis/QGIS/issues/1827/labels{/name}","comments_url":"https://api.github.com/repos/qgis/QGIS/issues/1827/comments","events_url":"https://api.github.com/repos/qgis/QGIS/issues/1827/events","html_url":"https://github.com/qgis/QGIS/pull/1827","id":54031577,"number":1827,"title":"Add function editor to expression widget","user":{"login":"NathanW2","id":381660,"avatar_url":"https://avatars.githubusercontent.com/u/381660?v=3","gravatar_id":"","url":"https://api.github.com/users/NathanW2","html_url":"https://github.com/NathanW2","followers_url":"https://api.github.com/users/NathanW2/followers","following_url":"https://api.github.com/users/NathanW2/following{/other_user}","gists_url":"https://api.github.com/users/NathanW2/gists{/gist_id}","starred_url":"https://api.github.com/users/NathanW2/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/NathanW2/subscriptions","organizations_url":"https://api.github.com/users/NathanW2/orgs","repos_url":"https://api.github.com/users/NathanW2/repos","events_url":"https://api.github.com/users/NathanW2/events{/privacy}","received_events_url":"https://api.github.com/users/NathanW2/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/qgis/QGIS/labels/Prototype","name":"Prototype","color":"d4c5f9"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":8,"created_at":"2015-01-12T08:59:55Z","updated_at":"2015-01-16T10:49:47Z","closed_at":"2015-01-16T10:49:36Z","pull_request":{"url":"https://api.github.com/repos/qgis/QGIS/pulls/1827","html_url":"https://github.com/qgis/QGIS/pull/1827","diff_url":"https://github.com/qgis/QGIS/pull/1827.diff","patch_url":"https://github.com/qgis/QGIS/pull/1827.patch"},"body":"**Note: For review and feedback. Not for merging yet**\r\n\r\nThis PR moves the custom function text area to a tab in the expression widget and allows for loading and saving of expression function files.  Expression function files are just normal Python files that live in `qgis2/functions` and are loaded at QGIS load time (not included in this PR yet).  Existing function files can be loaded from the combo box at the top of the widget.\r\n\r\n![screenshot from 2015-01-12 18 43 27](https://cloud.githubusercontent.com/assets/381660/5700536/635afc02-9a8b-11e4-8053-19a20036abf0.png)\r\n\r\nPressing the run button will run the Python code in the current session (no syntax or error handling yet) but also save the current file.  Changing the text in the combo box will create a new file if not found or save over the existing one.  Changing the combo box value will load that file into the editor if found.\r\n\r\nThe rational for this change is because after I added the custom function text edit area it became apparent that you could not access the Python code you had just written (doh!).  I toyed with the idea of being able to store the Python code with the function and allow loading function code from the function tree however that lead to many user issues after testing like:\r\n\r\n- Allows for more then one function per file. How do you load just the function you selected in the tree?\r\n- Any smart file naming or auto saving/restoring felt really hacky\r\n- Not a lot of room for more advanced logic \r\n\r\nTalking to Martin and Nyall this seemed like the smarter move.  It moves the focus more onto a code editor where you can define custom functions rather then a custom Python function (think ArcGIS) which the old UI implied \r\n\r\nThis new method seems more clear to me as it allows for function grouping into single files, sharing of function files, larger code editor, clearer intent.\r\n\r\nFeel free to try the code and leave any feedback. It's still not 100% yet but it does work."},"comment":{"url":"https://api.github.com/repos/qgis/QGIS/issues/comments/70237392","html_url":"https://github.com/qgis/QGIS/pull/1827#issuecomment-70237392","issue_url":"https://api.github.com/repos/qgis/QGIS/issues/1827","id":70237392,"user":{"login":"NathanW2","id":381660,"avatar_url":"https://avatars.githubusercontent.com/u/381660?v=3","gravatar_id":"","url":"https://api.github.com/users/NathanW2","html_url":"https://github.com/NathanW2","followers_url":"https://api.github.com/users/NathanW2/followers","following_url":"https://api.github.com/users/NathanW2/following{/other_user}","gists_url":"https://api.github.com/users/NathanW2/gists{/gist_id}","starred_url":"https://api.github.com/users/NathanW2/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/NathanW2/subscriptions","organizations_url":"https://api.github.com/users/NathanW2/orgs","repos_url":"https://api.github.com/users/NathanW2/repos","events_url":"https://api.github.com/users/NathanW2/events{/privacy}","received_events_url":"https://api.github.com/users/NathanW2/received_events","type":"User","site_admin":false},"created_at":"2015-01-16T10:49:47Z","updated_at":"2015-01-16T10:49:47Z","body":"Merged in 59162bc"}}