{"action":"created","comment":{"url":"https://api.github.com/repos/dimitar-asenov/Envision/pulls/comments/34461184","id":34461184,"diff_hunk":"@@ -274,4 +278,87 @@ void ViewItem::ensureColumnExists(int column)\n \t\tnodes_.resize(column + 1);\n }\n \n+//JSON storing/loading\n+QJsonDocument ViewItem::toJson() const\n+{\n+\t//Store all the nodes\n+\tQJsonArray nodes;\n+\tfor (int col = 0; col < nodes_.size(); col++)\n+\t\tfor (int row = 0; row < nodes_[col].size(); row++)\n+\t\t\tif (auto node = DCast<ViewItemNode>(nodes_[col][row]))\n+\t\t\t\tnodes.append(node->toJson(this));\n+\t//Store all the arrows\n+\tQJsonArray arrows;\n+\tfor (auto key : arrows_.keys())\n+\t\tfor (auto pair : arrows_[key])\n+\t\t\tarrows.append(arrowToJson(pair, key));\n+\tQJsonObject main;\n+\tmain.insert(\"nodes\", nodes);\n+\tmain.insert(\"arrows\", arrows);\n+\tmain.insert(\"name\", name());\n+\tQJsonDocument result;\n+\tresult.setObject(main);\n+\treturn result;\n+}\n+\n+void ViewItem::fromJson(QJsonDocument json)\n+{\n+\tnodes_.clear();\n+\tarrows_.clear();\n+\tQJsonObject obj = json.object();\n+\tsetName(obj[\"name\"].toString());\n+\tQStringList steps{\"NODE\", \"SPACING\", \"INFO\"};\n+\tint step = 0;\n+\tauto objArray = obj[\"nodes\"].toArray();\n+\t//Load the nodes: First normal nodes, then spacing nodes, and lastly info nodes\n+\tfor (step = 0; step < steps.size(); step++)\n+\t\tfor (int i = 0; i < objArray.size(); i++)\n+\t\t{\n+\t\t\tauto current = objArray[i].toObject();\n+\t\t\tif (current[\"type\"] == steps[step])\n+\t\t\t\tinsertViewItemNode(ViewItemNode::withJson(current, this),\n+\t\t\t\t\t\t\t\t   current[\"col\"].toInt(), current[\"row\"].toInt());\n+\t\t}\n+\t//Load the arrows\n+\tauto arrowArray = obj[\"arrows\"].toArray();\n+\tfor (auto arrow : arrowArray)\n+\t\tarrowFromJson(arrow.toObject());\n+}\n+\n+QJsonObject ViewItem::arrowToJson(QPair<Item*, Item*> arrow, QString layer) const\n+{\n+\tQJsonObject json;\n+\tjson.insert(\"layer\", layer);\n+\t//The first/second nodes might be a ViewItemNode -> in that case handled by the parent\n+\tif (arrow.first->node()->manager())\n+\t\tjson.insert(\"node1\", arrow.first->node()->manager()->\n+\t\t\t\t\t\t\t\t nodeIdMap().id(arrow.first->node()).toString());\n+\tif (arrow.second->node()->manager())\n+\t\tjson.insert(\"node2\", arrow.second->node()->manager()->\n+\t\t\t\t\t\t\t\t nodeIdMap().id(arrow.second->node()).toString());\n+\tauto parent1 = arrow.first->findAncestorOfType<VViewItemNode>();\n+\tjson.insert(\"parent1col\", positionOfItem(parent1).x());","path":"VisualizationBase/src/items/ViewItem.cpp","position":63,"original_position":74,"commit_id":"5c5cbacf147e5532e2eb52a187da969759eddb04","original_commit_id":"faeb3310844cbba6a64c6bb2021654b7c407ef27","user":{"login":"cyril-steimer","id":11210821,"avatar_url":"https://avatars.githubusercontent.com/u/11210821?v=3","gravatar_id":"","url":"https://api.github.com/users/cyril-steimer","html_url":"https://github.com/cyril-steimer","followers_url":"https://api.github.com/users/cyril-steimer/followers","following_url":"https://api.github.com/users/cyril-steimer/following{/other_user}","gists_url":"https://api.github.com/users/cyril-steimer/gists{/gist_id}","starred_url":"https://api.github.com/users/cyril-steimer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cyril-steimer/subscriptions","organizations_url":"https://api.github.com/users/cyril-steimer/orgs","repos_url":"https://api.github.com/users/cyril-steimer/repos","events_url":"https://api.github.com/users/cyril-steimer/events{/privacy}","received_events_url":"https://api.github.com/users/cyril-steimer/received_events","type":"User","site_admin":false},"body":"Kind of. For example, right now a method might be displayed multiple times, but the calling method does not have arrows to all of them (as not all of them were added in the context of showing it as a callee of the other method).\r\n\r\nI feel this approach is good, since we need almost no case distinction, and it will always restore the arrows exactly as they were.","created_at":"2015-07-13T13:18:44Z","updated_at":"2015-07-13T13:18:44Z","html_url":"https://github.com/dimitar-asenov/Envision/pull/105#discussion_r34461184","pull_request_url":"https://api.github.com/repos/dimitar-asenov/Envision/pulls/105","_links":{"self":{"href":"https://api.github.com/repos/dimitar-asenov/Envision/pulls/comments/34461184"},"html":{"href":"https://github.com/dimitar-asenov/Envision/pull/105#discussion_r34461184"},"pull_request":{"href":"https://api.github.com/repos/dimitar-asenov/Envision/pulls/105"}}},"pull_request":{"url":"https://api.github.com/repos/dimitar-asenov/Envision/pulls/105","id":39675307,"html_url":"https://github.com/dimitar-asenov/Envision/pull/105","diff_url":"https://github.com/dimitar-asenov/Envision/pull/105.diff","patch_url":"https://github.com/dimitar-asenov/Envision/pull/105.patch","issue_url":"https://api.github.com/repos/dimitar-asenov/Envision/issues/105","number":105,"state":"open","locked":false,"title":"Task views - Json","user":{"login":"cyril-steimer","id":11210821,"avatar_url":"https://avatars.githubusercontent.com/u/11210821?v=3","gravatar_id":"","url":"https://api.github.com/users/cyril-steimer","html_url":"https://github.com/cyril-steimer","followers_url":"https://api.github.com/users/cyril-steimer/followers","following_url":"https://api.github.com/users/cyril-steimer/following{/other_user}","gists_url":"https://api.github.com/users/cyril-steimer/gists{/gist_id}","starred_url":"https://api.github.com/users/cyril-steimer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cyril-steimer/subscriptions","organizations_url":"https://api.github.com/users/cyril-steimer/orgs","repos_url":"https://api.github.com/users/cyril-steimer/repos","events_url":"https://api.github.com/users/cyril-steimer/events{/privacy}","received_events_url":"https://api.github.com/users/cyril-steimer/received_events","type":"User","site_admin":false},"body":"Adding some Json support. Do you think it would be useful to have a toJson/fromJson function as a pure virtual function in UINode? Then e.g. the InfoNode stuff wouldn't need to be hardcoded and there could be extensions with other UINodes where necessary.\r\n\r\nIt doesn't store the Json anywhere yet, but at least directly restoring the view from Json works right now. ","created_at":"2015-07-10T11:25:59Z","updated_at":"2015-07-13T13:18:44Z","closed_at":null,"merged_at":null,"merge_commit_sha":"d54ca1dc475ab5d758e6a2b976572971b93a2f6e","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/dimitar-asenov/Envision/pulls/105/commits","review_comments_url":"https://api.github.com/repos/dimitar-asenov/Envision/pulls/105/comments","review_comment_url":"https://api.github.com/repos/dimitar-asenov/Envision/pulls/comments{/number}","comments_url":"https://api.github.com/repos/dimitar-asenov/Envision/issues/105/comments","statuses_url":"https://api.github.com/repos/dimitar-asenov/Envision/statuses/5c5cbacf147e5532e2eb52a187da969759eddb04","head":{"label":"cyril-steimer:task-views","ref":"task-views","sha":"5c5cbacf147e5532e2eb52a187da969759eddb04","user":{"login":"cyril-steimer","id":11210821,"avatar_url":"https://avatars.githubusercontent.com/u/11210821?v=3","gravatar_id":"","url":"https://api.github.com/users/cyril-steimer","html_url":"https://github.com/cyril-steimer","followers_url":"https://api.github.com/users/cyril-steimer/followers","following_url":"https://api.github.com/users/cyril-steimer/following{/other_user}","gists_url":"https://api.github.com/users/cyril-steimer/gists{/gist_id}","starred_url":"https://api.github.com/users/cyril-steimer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cyril-steimer/subscriptions","organizations_url":"https://api.github.com/users/cyril-steimer/orgs","repos_url":"https://api.github.com/users/cyril-steimer/repos","events_url":"https://api.github.com/users/cyril-steimer/events{/privacy}","received_events_url":"https://api.github.com/users/cyril-steimer/received_events","type":"User","site_admin":false},"repo":{"id":31468586,"name":"Envision","full_name":"cyril-steimer/Envision","owner":{"login":"cyril-steimer","id":11210821,"avatar_url":"https://avatars.githubusercontent.com/u/11210821?v=3","gravatar_id":"","url":"https://api.github.com/users/cyril-steimer","html_url":"https://github.com/cyril-steimer","followers_url":"https://api.github.com/users/cyril-steimer/followers","following_url":"https://api.github.com/users/cyril-steimer/following{/other_user}","gists_url":"https://api.github.com/users/cyril-steimer/gists{/gist_id}","starred_url":"https://api.github.com/users/cyril-steimer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cyril-steimer/subscriptions","organizations_url":"https://api.github.com/users/cyril-steimer/orgs","repos_url":"https://api.github.com/users/cyril-steimer/repos","events_url":"https://api.github.com/users/cyril-steimer/events{/privacy}","received_events_url":"https://api.github.com/users/cyril-steimer/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/cyril-steimer/Envision","description":"A next generation IDE with a visual programming interface","fork":true,"url":"https://api.github.com/repos/cyril-steimer/Envision","forks_url":"https://api.github.com/repos/cyril-steimer/Envision/forks","keys_url":"https://api.github.com/repos/cyril-steimer/Envision/keys{/key_id}","collaborators_url":"https://api.github.com/repos/cyril-steimer/Envision/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/cyril-steimer/Envision/teams","hooks_url":"https://api.github.com/repos/cyril-steimer/Envision/hooks","issue_events_url":"https://api.github.com/repos/cyril-steimer/Envision/issues/events{/number}","events_url":"https://api.github.com/repos/cyril-steimer/Envision/events","assignees_url":"https://api.github.com/repos/cyril-steimer/Envision/assignees{/user}","branches_url":"https://api.github.com/repos/cyril-steimer/Envision/branches{/branch}","tags_url":"https://api.github.com/repos/cyril-steimer/Envision/tags","blobs_url":"https://api.github.com/repos/cyril-steimer/Envision/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/cyril-steimer/Envision/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/cyril-steimer/Envision/git/refs{/sha}","trees_url":"https://api.github.com/repos/cyril-steimer/Envision/git/trees{/sha}","statuses_url":"https://api.github.com/repos/cyril-steimer/Envision/statuses/{sha}","languages_url":"https://api.github.com/repos/cyril-steimer/Envision/languages","stargazers_url":"https://api.github.com/repos/cyril-steimer/Envision/stargazers","contributors_url":"https://api.github.com/repos/cyril-steimer/Envision/contributors","subscribers_url":"https://api.github.com/repos/cyril-steimer/Envision/subscribers","subscription_url":"https://api.github.com/repos/cyril-steimer/Envision/subscription","commits_url":"https://api.github.com/repos/cyril-steimer/Envision/commits{/sha}","git_commits_url":"https://api.github.com/repos/cyril-steimer/Envision/git/commits{/sha}","comments_url":"https://api.github.com/repos/cyril-steimer/Envision/comments{/number}","issue_comment_url":"https://api.github.com/repos/cyril-steimer/Envision/issues/comments{/number}","contents_url":"https://api.github.com/repos/cyril-steimer/Envision/contents/{+path}","compare_url":"https://api.github.com/repos/cyril-steimer/Envision/compare/{base}...{head}","merges_url":"https://api.github.com/repos/cyril-steimer/Envision/merges","archive_url":"https://api.github.com/repos/cyril-steimer/Envision/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/cyril-steimer/Envision/downloads","issues_url":"https://api.github.com/repos/cyril-steimer/Envision/issues{/number}","pulls_url":"https://api.github.com/repos/cyril-steimer/Envision/pulls{/number}","milestones_url":"https://api.github.com/repos/cyril-steimer/Envision/milestones{/number}","notifications_url":"https://api.github.com/repos/cyril-steimer/Envision/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/cyril-steimer/Envision/labels{/name}","releases_url":"https://api.github.com/repos/cyril-steimer/Envision/releases{/id}","created_at":"2015-02-28T16:40:30Z","updated_at":"2015-03-05T13:45:04Z","pushed_at":"2015-07-13T13:08:00Z","git_url":"git://github.com/cyril-steimer/Envision.git","ssh_url":"git@github.com:cyril-steimer/Envision.git","clone_url":"https://github.com/cyril-steimer/Envision.git","svn_url":"https://github.com/cyril-steimer/Envision","homepage":"http://dimitar-asenov.github.com/Envision/","size":42242,"stargazers_count":0,"watchers_count":0,"language":"C++","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"development"}},"base":{"label":"dimitar-asenov:development","ref":"development","sha":"602af9d726cfb87c73bd54035fbb39dca8612b95","user":{"login":"dimitar-asenov","id":1152976,"avatar_url":"https://avatars.githubusercontent.com/u/1152976?v=3","gravatar_id":"","url":"https://api.github.com/users/dimitar-asenov","html_url":"https://github.com/dimitar-asenov","followers_url":"https://api.github.com/users/dimitar-asenov/followers","following_url":"https://api.github.com/users/dimitar-asenov/following{/other_user}","gists_url":"https://api.github.com/users/dimitar-asenov/gists{/gist_id}","starred_url":"https://api.github.com/users/dimitar-asenov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dimitar-asenov/subscriptions","organizations_url":"https://api.github.com/users/dimitar-asenov/orgs","repos_url":"https://api.github.com/users/dimitar-asenov/repos","events_url":"https://api.github.com/users/dimitar-asenov/events{/privacy}","received_events_url":"https://api.github.com/users/dimitar-asenov/received_events","type":"User","site_admin":false},"repo":{"id":2650576,"name":"Envision","full_name":"dimitar-asenov/Envision","owner":{"login":"dimitar-asenov","id":1152976,"avatar_url":"https://avatars.githubusercontent.com/u/1152976?v=3","gravatar_id":"","url":"https://api.github.com/users/dimitar-asenov","html_url":"https://github.com/dimitar-asenov","followers_url":"https://api.github.com/users/dimitar-asenov/followers","following_url":"https://api.github.com/users/dimitar-asenov/following{/other_user}","gists_url":"https://api.github.com/users/dimitar-asenov/gists{/gist_id}","starred_url":"https://api.github.com/users/dimitar-asenov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dimitar-asenov/subscriptions","organizations_url":"https://api.github.com/users/dimitar-asenov/orgs","repos_url":"https://api.github.com/users/dimitar-asenov/repos","events_url":"https://api.github.com/users/dimitar-asenov/events{/privacy}","received_events_url":"https://api.github.com/users/dimitar-asenov/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/dimitar-asenov/Envision","description":"A next generation IDE with a visual programming interface","fork":false,"url":"https://api.github.com/repos/dimitar-asenov/Envision","forks_url":"https://api.github.com/repos/dimitar-asenov/Envision/forks","keys_url":"https://api.github.com/repos/dimitar-asenov/Envision/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dimitar-asenov/Envision/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dimitar-asenov/Envision/teams","hooks_url":"https://api.github.com/repos/dimitar-asenov/Envision/hooks","issue_events_url":"https://api.github.com/repos/dimitar-asenov/Envision/issues/events{/number}","events_url":"https://api.github.com/repos/dimitar-asenov/Envision/events","assignees_url":"https://api.github.com/repos/dimitar-asenov/Envision/assignees{/user}","branches_url":"https://api.github.com/repos/dimitar-asenov/Envision/branches{/branch}","tags_url":"https://api.github.com/repos/dimitar-asenov/Envision/tags","blobs_url":"https://api.github.com/repos/dimitar-asenov/Envision/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dimitar-asenov/Envision/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dimitar-asenov/Envision/git/refs{/sha}","trees_url":"https://api.github.com/repos/dimitar-asenov/Envision/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dimitar-asenov/Envision/statuses/{sha}","languages_url":"https://api.github.com/repos/dimitar-asenov/Envision/languages","stargazers_url":"https://api.github.com/repos/dimitar-asenov/Envision/stargazers","contributors_url":"https://api.github.com/repos/dimitar-asenov/Envision/contributors","subscribers_url":"https://api.github.com/repos/dimitar-asenov/Envision/subscribers","subscription_url":"https://api.github.com/repos/dimitar-asenov/Envision/subscription","commits_url":"https://api.github.com/repos/dimitar-asenov/Envision/commits{/sha}","git_commits_url":"https://api.github.com/repos/dimitar-asenov/Envision/git/commits{/sha}","comments_url":"https://api.github.com/repos/dimitar-asenov/Envision/comments{/number}","issue_comment_url":"https://api.github.com/repos/dimitar-asenov/Envision/issues/comments{/number}","contents_url":"https://api.github.com/repos/dimitar-asenov/Envision/contents/{+path}","compare_url":"https://api.github.com/repos/dimitar-asenov/Envision/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dimitar-asenov/Envision/merges","archive_url":"https://api.github.com/repos/dimitar-asenov/Envision/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dimitar-asenov/Envision/downloads","issues_url":"https://api.github.com/repos/dimitar-asenov/Envision/issues{/number}","pulls_url":"https://api.github.com/repos/dimitar-asenov/Envision/pulls{/number}","milestones_url":"https://api.github.com/repos/dimitar-asenov/Envision/milestones{/number}","notifications_url":"https://api.github.com/repos/dimitar-asenov/Envision/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dimitar-asenov/Envision/labels{/name}","releases_url":"https://api.github.com/repos/dimitar-asenov/Envision/releases{/id}","created_at":"2011-10-26T12:03:58Z","updated_at":"2015-07-10T16:22:24Z","pushed_at":"2015-07-13T13:08:00Z","git_url":"git://github.com/dimitar-asenov/Envision.git","ssh_url":"git@github.com:dimitar-asenov/Envision.git","clone_url":"https://github.com/dimitar-asenov/Envision.git","svn_url":"https://github.com/dimitar-asenov/Envision","homepage":"http://dimitar-asenov.github.com/Envision/","size":47323,"stargazers_count":18,"watchers_count":18,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":14,"mirror_url":null,"open_issues_count":30,"forks":14,"open_issues":30,"watchers":18,"default_branch":"development"}},"_links":{"self":{"href":"https://api.github.com/repos/dimitar-asenov/Envision/pulls/105"},"html":{"href":"https://github.com/dimitar-asenov/Envision/pull/105"},"issue":{"href":"https://api.github.com/repos/dimitar-asenov/Envision/issues/105"},"comments":{"href":"https://api.github.com/repos/dimitar-asenov/Envision/issues/105/comments"},"review_comments":{"href":"https://api.github.com/repos/dimitar-asenov/Envision/pulls/105/comments"},"review_comment":{"href":"https://api.github.com/repos/dimitar-asenov/Envision/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/dimitar-asenov/Envision/pulls/105/commits"},"statuses":{"href":"https://api.github.com/repos/dimitar-asenov/Envision/statuses/5c5cbacf147e5532e2eb52a187da969759eddb04"}}}}