{"action":"created","comment":{"url":"https://api.github.com/repos/Acly/hdrv/pulls/comments/63275628","id":63275628,"diff_hunk":"@@ -16,25 +18,104 @@ std::shared_ptr<Image> createDefaultImage()\n \n QUrl defaultUrl() { return QUrl(\"file:////HDRV\"); }\n \n-ImageDocument::ImageDocument(std::shared_ptr<Image> image, QUrl const& url, QObject * parent)\n+ImageDocument::ImageDocument(QUrl const& url, QObject * parent)\n   : QObject(parent)\n   , name_(QFileInfo(url.fileName()).baseName())\n   , url_(url)\n+  , activeTasks_(0)\n   , scale_(1.0f)\n   , brightness_(0.0f)\n   , gamma_(2.2f)\n-  , image_(std::move(image))\n-{}\n+  , image_(createDefaultImage())\n+  , errorText_({ \"\", \"\", \"\" })\n+  , watcher_(nullptr)\n+  , comparisonWatcher_(nullptr)\n+{\n+  watcher_ = new QFutureWatcher<LoadResult>(this);\n+  connect(watcher_, SIGNAL(started()), this, SIGNAL(busyChanged()));\n+  connect(watcher_, SIGNAL(finished()), this, SIGNAL(busyChanged()));\n+\n+  auto* fsWatcher = new QFileSystemWatcher(QStringList(url_.toLocalFile()), this);\n+  auto* delay = new QTimer(this);\n+  delay->setSingleShot(true);\n \n-ImageDocument::ImageDocument(std::shared_ptr<Image> base, std::shared_ptr<Image> comparison,\n-  QUrl const& url, QObject * parent)\n-  : ImageDocument(std::move(base), url, parent)\n+  connect(\n+    watcher_, &QFutureWatcher<LoadResult>::finished,\n+    std::bind(&ImageDocument::loadFinished, this, watcher_, url_, false));\n+  connect(\n+    fsWatcher, &QFileSystemWatcher::fileChanged,\n+    [delay]() { delay->start(500); });\n+  connect(\n+    delay, &QTimer::timeout,\n+    std::bind(&ImageDocument::load, this, url_.toLocalFile(), watcher_));\n+\n+  load(url_.toLocalFile(), watcher_);\n+}\n+\n+ImageDocument::ImageDocument(QUrl const& base, QUrl const& comparison, QObject * parent)","path":"src/model/ImageDocument.cpp","position":53,"original_position":53,"commit_id":"dc011dabd20128895a67776b59347f0b3dd9110f","original_commit_id":"dc011dabd20128895a67776b59347f0b3dd9110f","user":{"login":"Acly","id":6485914,"avatar_url":"https://avatars.githubusercontent.com/u/6485914?v=3","gravatar_id":"","url":"https://api.github.com/users/Acly","html_url":"https://github.com/Acly","followers_url":"https://api.github.com/users/Acly/followers","following_url":"https://api.github.com/users/Acly/following{/other_user}","gists_url":"https://api.github.com/users/Acly/gists{/gist_id}","starred_url":"https://api.github.com/users/Acly/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Acly/subscriptions","organizations_url":"https://api.github.com/users/Acly/orgs","repos_url":"https://api.github.com/users/Acly/repos","events_url":"https://api.github.com/users/Acly/events{/privacy}","received_events_url":"https://api.github.com/users/Acly/received_events","type":"User","site_admin":false},"body":"This seems like a lot of copy paste, can we\r\n. forward to a common constructor (or write the default values into the header)\r\n. do something like `setupWatcher(watcher_, url_)` and `setupWatcher(comparisonWatcher_, comparisonUrl_)`\r\n","created_at":"2016-05-14T12:38:50Z","updated_at":"2016-05-14T12:38:50Z","html_url":"https://github.com/Acly/hdrv/pull/3#discussion_r63275628","pull_request_url":"https://api.github.com/repos/Acly/hdrv/pulls/3","_links":{"self":{"href":"https://api.github.com/repos/Acly/hdrv/pulls/comments/63275628"},"html":{"href":"https://github.com/Acly/hdrv/pull/3#discussion_r63275628"},"pull_request":{"href":"https://api.github.com/repos/Acly/hdrv/pulls/3"}}},"pull_request":{"url":"https://api.github.com/repos/Acly/hdrv/pulls/3","id":70086100,"html_url":"https://github.com/Acly/hdrv/pull/3","diff_url":"https://github.com/Acly/hdrv/pull/3.diff","patch_url":"https://github.com/Acly/hdrv/pull/3.patch","issue_url":"https://api.github.com/repos/Acly/hdrv/issues/3","number":3,"state":"open","locked":false,"title":"Improved load and formatting","user":{"login":"proog128","id":2821679,"avatar_url":"https://avatars.githubusercontent.com/u/2821679?v=3","gravatar_id":"","url":"https://api.github.com/users/proog128","html_url":"https://github.com/proog128","followers_url":"https://api.github.com/users/proog128/followers","following_url":"https://api.github.com/users/proog128/following{/other_user}","gists_url":"https://api.github.com/users/proog128/gists{/gist_id}","starred_url":"https://api.github.com/users/proog128/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/proog128/subscriptions","organizations_url":"https://api.github.com/users/proog128/orgs","repos_url":"https://api.github.com/users/proog128/repos","events_url":"https://api.github.com/users/proog128/events{/privacy}","received_events_url":"https://api.github.com/users/proog128/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-05-14T08:28:50Z","updated_at":"2016-05-14T12:38:50Z","closed_at":null,"merged_at":null,"merge_commit_sha":"d448aecb306e4d6c102ddb785b4bf8d13beef1f5","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/Acly/hdrv/pulls/3/commits","review_comments_url":"https://api.github.com/repos/Acly/hdrv/pulls/3/comments","review_comment_url":"https://api.github.com/repos/Acly/hdrv/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Acly/hdrv/issues/3/comments","statuses_url":"https://api.github.com/repos/Acly/hdrv/statuses/dc011dabd20128895a67776b59347f0b3dd9110f","head":{"label":"proog128:improved-load-and-formatting","ref":"improved-load-and-formatting","sha":"dc011dabd20128895a67776b59347f0b3dd9110f","user":{"login":"proog128","id":2821679,"avatar_url":"https://avatars.githubusercontent.com/u/2821679?v=3","gravatar_id":"","url":"https://api.github.com/users/proog128","html_url":"https://github.com/proog128","followers_url":"https://api.github.com/users/proog128/followers","following_url":"https://api.github.com/users/proog128/following{/other_user}","gists_url":"https://api.github.com/users/proog128/gists{/gist_id}","starred_url":"https://api.github.com/users/proog128/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/proog128/subscriptions","organizations_url":"https://api.github.com/users/proog128/orgs","repos_url":"https://api.github.com/users/proog128/repos","events_url":"https://api.github.com/users/proog128/events{/privacy}","received_events_url":"https://api.github.com/users/proog128/received_events","type":"User","site_admin":false},"repo":{"id":56537290,"name":"hdrv","full_name":"proog128/hdrv","owner":{"login":"proog128","id":2821679,"avatar_url":"https://avatars.githubusercontent.com/u/2821679?v=3","gravatar_id":"","url":"https://api.github.com/users/proog128","html_url":"https://github.com/proog128","followers_url":"https://api.github.com/users/proog128/followers","following_url":"https://api.github.com/users/proog128/following{/other_user}","gists_url":"https://api.github.com/users/proog128/gists{/gist_id}","starred_url":"https://api.github.com/users/proog128/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/proog128/subscriptions","organizations_url":"https://api.github.com/users/proog128/orgs","repos_url":"https://api.github.com/users/proog128/repos","events_url":"https://api.github.com/users/proog128/events{/privacy}","received_events_url":"https://api.github.com/users/proog128/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/proog128/hdrv","description":"HDR Viewer","fork":true,"url":"https://api.github.com/repos/proog128/hdrv","forks_url":"https://api.github.com/repos/proog128/hdrv/forks","keys_url":"https://api.github.com/repos/proog128/hdrv/keys{/key_id}","collaborators_url":"https://api.github.com/repos/proog128/hdrv/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/proog128/hdrv/teams","hooks_url":"https://api.github.com/repos/proog128/hdrv/hooks","issue_events_url":"https://api.github.com/repos/proog128/hdrv/issues/events{/number}","events_url":"https://api.github.com/repos/proog128/hdrv/events","assignees_url":"https://api.github.com/repos/proog128/hdrv/assignees{/user}","branches_url":"https://api.github.com/repos/proog128/hdrv/branches{/branch}","tags_url":"https://api.github.com/repos/proog128/hdrv/tags","blobs_url":"https://api.github.com/repos/proog128/hdrv/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/proog128/hdrv/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/proog128/hdrv/git/refs{/sha}","trees_url":"https://api.github.com/repos/proog128/hdrv/git/trees{/sha}","statuses_url":"https://api.github.com/repos/proog128/hdrv/statuses/{sha}","languages_url":"https://api.github.com/repos/proog128/hdrv/languages","stargazers_url":"https://api.github.com/repos/proog128/hdrv/stargazers","contributors_url":"https://api.github.com/repos/proog128/hdrv/contributors","subscribers_url":"https://api.github.com/repos/proog128/hdrv/subscribers","subscription_url":"https://api.github.com/repos/proog128/hdrv/subscription","commits_url":"https://api.github.com/repos/proog128/hdrv/commits{/sha}","git_commits_url":"https://api.github.com/repos/proog128/hdrv/git/commits{/sha}","comments_url":"https://api.github.com/repos/proog128/hdrv/comments{/number}","issue_comment_url":"https://api.github.com/repos/proog128/hdrv/issues/comments{/number}","contents_url":"https://api.github.com/repos/proog128/hdrv/contents/{+path}","compare_url":"https://api.github.com/repos/proog128/hdrv/compare/{base}...{head}","merges_url":"https://api.github.com/repos/proog128/hdrv/merges","archive_url":"https://api.github.com/repos/proog128/hdrv/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/proog128/hdrv/downloads","issues_url":"https://api.github.com/repos/proog128/hdrv/issues{/number}","pulls_url":"https://api.github.com/repos/proog128/hdrv/pulls{/number}","milestones_url":"https://api.github.com/repos/proog128/hdrv/milestones{/number}","notifications_url":"https://api.github.com/repos/proog128/hdrv/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/proog128/hdrv/labels{/name}","releases_url":"https://api.github.com/repos/proog128/hdrv/releases{/id}","deployments_url":"https://api.github.com/repos/proog128/hdrv/deployments","created_at":"2016-04-18T19:50:27Z","updated_at":"2016-04-18T19:50:28Z","pushed_at":"2016-05-14T08:27:41Z","git_url":"git://github.com/proog128/hdrv.git","ssh_url":"git@github.com:proog128/hdrv.git","clone_url":"https://github.com/proog128/hdrv.git","svn_url":"https://github.com/proog128/hdrv","homepage":null,"size":12845,"stargazers_count":0,"watchers_count":0,"language":"C++","has_issues":false,"has_downloads":true,"has_wiki":true,"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":"Acly:master","ref":"master","sha":"9b09b856080073ef16e1373f618851eef7a57917","user":{"login":"Acly","id":6485914,"avatar_url":"https://avatars.githubusercontent.com/u/6485914?v=3","gravatar_id":"","url":"https://api.github.com/users/Acly","html_url":"https://github.com/Acly","followers_url":"https://api.github.com/users/Acly/followers","following_url":"https://api.github.com/users/Acly/following{/other_user}","gists_url":"https://api.github.com/users/Acly/gists{/gist_id}","starred_url":"https://api.github.com/users/Acly/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Acly/subscriptions","organizations_url":"https://api.github.com/users/Acly/orgs","repos_url":"https://api.github.com/users/Acly/repos","events_url":"https://api.github.com/users/Acly/events{/privacy}","received_events_url":"https://api.github.com/users/Acly/received_events","type":"User","site_admin":false},"repo":{"id":49750644,"name":"hdrv","full_name":"Acly/hdrv","owner":{"login":"Acly","id":6485914,"avatar_url":"https://avatars.githubusercontent.com/u/6485914?v=3","gravatar_id":"","url":"https://api.github.com/users/Acly","html_url":"https://github.com/Acly","followers_url":"https://api.github.com/users/Acly/followers","following_url":"https://api.github.com/users/Acly/following{/other_user}","gists_url":"https://api.github.com/users/Acly/gists{/gist_id}","starred_url":"https://api.github.com/users/Acly/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Acly/subscriptions","organizations_url":"https://api.github.com/users/Acly/orgs","repos_url":"https://api.github.com/users/Acly/repos","events_url":"https://api.github.com/users/Acly/events{/privacy}","received_events_url":"https://api.github.com/users/Acly/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/Acly/hdrv","description":"HDR Viewer","fork":false,"url":"https://api.github.com/repos/Acly/hdrv","forks_url":"https://api.github.com/repos/Acly/hdrv/forks","keys_url":"https://api.github.com/repos/Acly/hdrv/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Acly/hdrv/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Acly/hdrv/teams","hooks_url":"https://api.github.com/repos/Acly/hdrv/hooks","issue_events_url":"https://api.github.com/repos/Acly/hdrv/issues/events{/number}","events_url":"https://api.github.com/repos/Acly/hdrv/events","assignees_url":"https://api.github.com/repos/Acly/hdrv/assignees{/user}","branches_url":"https://api.github.com/repos/Acly/hdrv/branches{/branch}","tags_url":"https://api.github.com/repos/Acly/hdrv/tags","blobs_url":"https://api.github.com/repos/Acly/hdrv/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Acly/hdrv/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Acly/hdrv/git/refs{/sha}","trees_url":"https://api.github.com/repos/Acly/hdrv/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Acly/hdrv/statuses/{sha}","languages_url":"https://api.github.com/repos/Acly/hdrv/languages","stargazers_url":"https://api.github.com/repos/Acly/hdrv/stargazers","contributors_url":"https://api.github.com/repos/Acly/hdrv/contributors","subscribers_url":"https://api.github.com/repos/Acly/hdrv/subscribers","subscription_url":"https://api.github.com/repos/Acly/hdrv/subscription","commits_url":"https://api.github.com/repos/Acly/hdrv/commits{/sha}","git_commits_url":"https://api.github.com/repos/Acly/hdrv/git/commits{/sha}","comments_url":"https://api.github.com/repos/Acly/hdrv/comments{/number}","issue_comment_url":"https://api.github.com/repos/Acly/hdrv/issues/comments{/number}","contents_url":"https://api.github.com/repos/Acly/hdrv/contents/{+path}","compare_url":"https://api.github.com/repos/Acly/hdrv/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Acly/hdrv/merges","archive_url":"https://api.github.com/repos/Acly/hdrv/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Acly/hdrv/downloads","issues_url":"https://api.github.com/repos/Acly/hdrv/issues{/number}","pulls_url":"https://api.github.com/repos/Acly/hdrv/pulls{/number}","milestones_url":"https://api.github.com/repos/Acly/hdrv/milestones{/number}","notifications_url":"https://api.github.com/repos/Acly/hdrv/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Acly/hdrv/labels{/name}","releases_url":"https://api.github.com/repos/Acly/hdrv/releases{/id}","deployments_url":"https://api.github.com/repos/Acly/hdrv/deployments","created_at":"2016-01-15T23:28:09Z","updated_at":"2016-01-18T11:51:02Z","pushed_at":"2016-05-14T08:28:51Z","git_url":"git://github.com/Acly/hdrv.git","ssh_url":"git@github.com:Acly/hdrv.git","clone_url":"https://github.com/Acly/hdrv.git","svn_url":"https://github.com/Acly/hdrv","homepage":null,"size":12845,"stargazers_count":2,"watchers_count":2,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":1,"forks":1,"open_issues":1,"watchers":2,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Acly/hdrv/pulls/3"},"html":{"href":"https://github.com/Acly/hdrv/pull/3"},"issue":{"href":"https://api.github.com/repos/Acly/hdrv/issues/3"},"comments":{"href":"https://api.github.com/repos/Acly/hdrv/issues/3/comments"},"review_comments":{"href":"https://api.github.com/repos/Acly/hdrv/pulls/3/comments"},"review_comment":{"href":"https://api.github.com/repos/Acly/hdrv/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Acly/hdrv/pulls/3/commits"},"statuses":{"href":"https://api.github.com/repos/Acly/hdrv/statuses/dc011dabd20128895a67776b59347f0b3dd9110f"}}}}