{"action":"created","comment":{"url":"https://api.github.com/repos/BlueBrain/DisplayCluster/pulls/comments/49300148","id":49300148,"diff_hunk":"@@ -39,38 +39,81 @@\n \n #include \"Markers.h\"\n \n-Markers::Markers()\n+Markers::Markers( QObject* parent_ )\n+    : QAbstractListModel( parent_ )\n+{}\n+\n+QVariant Markers::data( const QModelIndex& index_, int role ) const\n+{\n+    if( index_.row() < 0 || index_.row() >= rowCount() || !index_.isValid( ))\n+        return QVariant();\n+\n+    if( role == XPOSITION_ROLE )\n+    {\n+        return QVariant( _markers[index_.row()].second.x( ));\n+    }\n+    else if( role == YPOSITION_ROLE )\n+    {\n+        return QVariant( _markers[index_.row()].second.y( ));\n+    }\n+    return QVariant();\n+}\n+\n+int Markers::rowCount( const QModelIndex& parent_ ) const\n {\n+    Q_UNUSED( parent_ );\n+    return _markers.size();\n }\n \n-const MarkersMap& Markers::getMarkers() const\n+QHash<int, QByteArray> Markers::roleNames() const\n {\n-    return _markers;\n+    QHash<int, QByteArray> roles;\n+    roles[ XPOSITION_ROLE ] = \"xposition\";\n+    roles[ YPOSITION_ROLE ] = \"yposition\";\n+    return roles;\n }\n \n void Markers::addMarker( const int id, const QPointF position )\n {\n-    if( _markers.count( id ))\n+    if( std::find_if( _markers.begin(), _markers.end(), [&id]( Marker& marker )\n+        { return marker.first == id; }) != _markers.end( ))\n+    {\n         return;\n+    }\n \n-    _markers[id] = position;\n+    int markerIndex = _markers.size();\n+    beginInsertRows( QModelIndex(), markerIndex, markerIndex );\n+    _markers.push_back( Marker( id, position ));\n+    endInsertRows();\n     emit( updated( shared_from_this( )));\n }\n \n void Markers::updateMarker( const int id, const QPointF position )\n {\n-    if( !_markers.count( id ))\n+    auto it = std::find_if( _markers.begin(), _markers.end(), [&id]( const Marker& marker )\n+              { return marker.first == id; });\n+\n+    if( it  == _markers.end())\n         return;\n \n-    _markers[id] = position;\n+    it->second = position;\n     emit( updated( shared_from_this( )));\n+\n+    int markerIndex = it - _markers.begin();\n+    emit dataChanged( createIndex( markerIndex, 0 ), createIndex( markerIndex, 0 ));\n }\n \n void Markers::removeMarker( const int id )\n {\n-    if( !_markers.count( id ))\n+    auto it = std::find_if( _markers.begin(), _markers.end(), [&id]( const Marker& marker )","path":"dc/core/Markers.cpp","position":78,"original_position":78,"commit_id":"9a3fb383f994ca6a4b3c21083b96ec7ee744d2d5","original_commit_id":"9a3fb383f994ca6a4b3c21083b96ec7ee744d2d5","user":{"login":"rdumusc","id":5166658,"avatar_url":"https://avatars.githubusercontent.com/u/5166658?v=3","gravatar_id":"","url":"https://api.github.com/users/rdumusc","html_url":"https://github.com/rdumusc","followers_url":"https://api.github.com/users/rdumusc/followers","following_url":"https://api.github.com/users/rdumusc/following{/other_user}","gists_url":"https://api.github.com/users/rdumusc/gists{/gist_id}","starred_url":"https://api.github.com/users/rdumusc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rdumusc/subscriptions","organizations_url":"https://api.github.com/users/rdumusc/orgs","repos_url":"https://api.github.com/users/rdumusc/repos","events_url":"https://api.github.com/users/rdumusc/events{/privacy}","received_events_url":"https://api.github.com/users/rdumusc/received_events","type":"User","site_admin":false},"body":"No, the find condition is always the same. Only one time you compare the result directly in the if(), which is less readable. It would be more readable with an:\r\nauto it = _findMarker( id ) everywhere","created_at":"2016-01-11T09:12:54Z","updated_at":"2016-01-11T09:12:54Z","html_url":"https://github.com/BlueBrain/DisplayCluster/pull/269#discussion_r49300148","pull_request_url":"https://api.github.com/repos/BlueBrain/DisplayCluster/pulls/269","_links":{"self":{"href":"https://api.github.com/repos/BlueBrain/DisplayCluster/pulls/comments/49300148"},"html":{"href":"https://github.com/BlueBrain/DisplayCluster/pull/269#discussion_r49300148"},"pull_request":{"href":"https://api.github.com/repos/BlueBrain/DisplayCluster/pulls/269"}}},"pull_request":{"url":"https://api.github.com/repos/BlueBrain/DisplayCluster/pulls/269","id":55456542,"html_url":"https://github.com/BlueBrain/DisplayCluster/pull/269","diff_url":"https://github.com/BlueBrain/DisplayCluster/pull/269.diff","patch_url":"https://github.com/BlueBrain/DisplayCluster/pull/269.patch","issue_url":"https://api.github.com/repos/BlueBrain/DisplayCluster/issues/269","number":269,"state":"open","locked":false,"title":"Touchpoint's markers are rendered with qml","user":{"login":"chevtche","id":10452408,"avatar_url":"https://avatars.githubusercontent.com/u/10452408?v=3","gravatar_id":"","url":"https://api.github.com/users/chevtche","html_url":"https://github.com/chevtche","followers_url":"https://api.github.com/users/chevtche/followers","following_url":"https://api.github.com/users/chevtche/following{/other_user}","gists_url":"https://api.github.com/users/chevtche/gists{/gist_id}","starred_url":"https://api.github.com/users/chevtche/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chevtche/subscriptions","organizations_url":"https://api.github.com/users/chevtche/orgs","repos_url":"https://api.github.com/users/chevtche/repos","events_url":"https://api.github.com/users/chevtche/events{/privacy}","received_events_url":"https://api.github.com/users/chevtche/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-01-08T12:29:14Z","updated_at":"2016-01-11T09:12:54Z","closed_at":null,"merged_at":null,"merge_commit_sha":"35b57ed9dcc9d601397e24556ec0ca561e4f8e97","assignee":{"login":"rdumusc","id":5166658,"avatar_url":"https://avatars.githubusercontent.com/u/5166658?v=3","gravatar_id":"","url":"https://api.github.com/users/rdumusc","html_url":"https://github.com/rdumusc","followers_url":"https://api.github.com/users/rdumusc/followers","following_url":"https://api.github.com/users/rdumusc/following{/other_user}","gists_url":"https://api.github.com/users/rdumusc/gists{/gist_id}","starred_url":"https://api.github.com/users/rdumusc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rdumusc/subscriptions","organizations_url":"https://api.github.com/users/rdumusc/orgs","repos_url":"https://api.github.com/users/rdumusc/repos","events_url":"https://api.github.com/users/rdumusc/events{/privacy}","received_events_url":"https://api.github.com/users/rdumusc/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/BlueBrain/DisplayCluster/pulls/269/commits","review_comments_url":"https://api.github.com/repos/BlueBrain/DisplayCluster/pulls/269/comments","review_comment_url":"https://api.github.com/repos/BlueBrain/DisplayCluster/pulls/comments{/number}","comments_url":"https://api.github.com/repos/BlueBrain/DisplayCluster/issues/269/comments","statuses_url":"https://api.github.com/repos/BlueBrain/DisplayCluster/statuses/9a3fb383f994ca6a4b3c21083b96ec7ee744d2d5","head":{"label":"chevtche:qml2","ref":"qml2","sha":"9a3fb383f994ca6a4b3c21083b96ec7ee744d2d5","user":{"login":"chevtche","id":10452408,"avatar_url":"https://avatars.githubusercontent.com/u/10452408?v=3","gravatar_id":"","url":"https://api.github.com/users/chevtche","html_url":"https://github.com/chevtche","followers_url":"https://api.github.com/users/chevtche/followers","following_url":"https://api.github.com/users/chevtche/following{/other_user}","gists_url":"https://api.github.com/users/chevtche/gists{/gist_id}","starred_url":"https://api.github.com/users/chevtche/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chevtche/subscriptions","organizations_url":"https://api.github.com/users/chevtche/orgs","repos_url":"https://api.github.com/users/chevtche/repos","events_url":"https://api.github.com/users/chevtche/events{/privacy}","received_events_url":"https://api.github.com/users/chevtche/received_events","type":"User","site_admin":false},"repo":{"id":35094368,"name":"DisplayCluster","full_name":"chevtche/DisplayCluster","owner":{"login":"chevtche","id":10452408,"avatar_url":"https://avatars.githubusercontent.com/u/10452408?v=3","gravatar_id":"","url":"https://api.github.com/users/chevtche","html_url":"https://github.com/chevtche","followers_url":"https://api.github.com/users/chevtche/followers","following_url":"https://api.github.com/users/chevtche/following{/other_user}","gists_url":"https://api.github.com/users/chevtche/gists{/gist_id}","starred_url":"https://api.github.com/users/chevtche/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chevtche/subscriptions","organizations_url":"https://api.github.com/users/chevtche/orgs","repos_url":"https://api.github.com/users/chevtche/repos","events_url":"https://api.github.com/users/chevtche/events{/privacy}","received_events_url":"https://api.github.com/users/chevtche/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/chevtche/DisplayCluster","description":"A collaborative software for driving large display walls","fork":true,"url":"https://api.github.com/repos/chevtche/DisplayCluster","forks_url":"https://api.github.com/repos/chevtche/DisplayCluster/forks","keys_url":"https://api.github.com/repos/chevtche/DisplayCluster/keys{/key_id}","collaborators_url":"https://api.github.com/repos/chevtche/DisplayCluster/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/chevtche/DisplayCluster/teams","hooks_url":"https://api.github.com/repos/chevtche/DisplayCluster/hooks","issue_events_url":"https://api.github.com/repos/chevtche/DisplayCluster/issues/events{/number}","events_url":"https://api.github.com/repos/chevtche/DisplayCluster/events","assignees_url":"https://api.github.com/repos/chevtche/DisplayCluster/assignees{/user}","branches_url":"https://api.github.com/repos/chevtche/DisplayCluster/branches{/branch}","tags_url":"https://api.github.com/repos/chevtche/DisplayCluster/tags","blobs_url":"https://api.github.com/repos/chevtche/DisplayCluster/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/chevtche/DisplayCluster/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/chevtche/DisplayCluster/git/refs{/sha}","trees_url":"https://api.github.com/repos/chevtche/DisplayCluster/git/trees{/sha}","statuses_url":"https://api.github.com/repos/chevtche/DisplayCluster/statuses/{sha}","languages_url":"https://api.github.com/repos/chevtche/DisplayCluster/languages","stargazers_url":"https://api.github.com/repos/chevtche/DisplayCluster/stargazers","contributors_url":"https://api.github.com/repos/chevtche/DisplayCluster/contributors","subscribers_url":"https://api.github.com/repos/chevtche/DisplayCluster/subscribers","subscription_url":"https://api.github.com/repos/chevtche/DisplayCluster/subscription","commits_url":"https://api.github.com/repos/chevtche/DisplayCluster/commits{/sha}","git_commits_url":"https://api.github.com/repos/chevtche/DisplayCluster/git/commits{/sha}","comments_url":"https://api.github.com/repos/chevtche/DisplayCluster/comments{/number}","issue_comment_url":"https://api.github.com/repos/chevtche/DisplayCluster/issues/comments{/number}","contents_url":"https://api.github.com/repos/chevtche/DisplayCluster/contents/{+path}","compare_url":"https://api.github.com/repos/chevtche/DisplayCluster/compare/{base}...{head}","merges_url":"https://api.github.com/repos/chevtche/DisplayCluster/merges","archive_url":"https://api.github.com/repos/chevtche/DisplayCluster/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/chevtche/DisplayCluster/downloads","issues_url":"https://api.github.com/repos/chevtche/DisplayCluster/issues{/number}","pulls_url":"https://api.github.com/repos/chevtche/DisplayCluster/pulls{/number}","milestones_url":"https://api.github.com/repos/chevtche/DisplayCluster/milestones{/number}","notifications_url":"https://api.github.com/repos/chevtche/DisplayCluster/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/chevtche/DisplayCluster/labels{/name}","releases_url":"https://api.github.com/repos/chevtche/DisplayCluster/releases{/id}","created_at":"2015-05-05T11:04:10Z","updated_at":"2015-05-05T11:08:09Z","pushed_at":"2016-01-08T12:27:58Z","git_url":"git://github.com/chevtche/DisplayCluster.git","ssh_url":"git@github.com:chevtche/DisplayCluster.git","clone_url":"https://github.com/chevtche/DisplayCluster.git","svn_url":"https://github.com/chevtche/DisplayCluster","homepage":"","size":15987,"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":"BlueBrain:qml2","ref":"qml2","sha":"ebae2627dbaa9e79b2048761e4655b8f341f0a6e","user":{"login":"BlueBrain","id":1479142,"avatar_url":"https://avatars.githubusercontent.com/u/1479142?v=3","gravatar_id":"","url":"https://api.github.com/users/BlueBrain","html_url":"https://github.com/BlueBrain","followers_url":"https://api.github.com/users/BlueBrain/followers","following_url":"https://api.github.com/users/BlueBrain/following{/other_user}","gists_url":"https://api.github.com/users/BlueBrain/gists{/gist_id}","starred_url":"https://api.github.com/users/BlueBrain/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/BlueBrain/subscriptions","organizations_url":"https://api.github.com/users/BlueBrain/orgs","repos_url":"https://api.github.com/users/BlueBrain/repos","events_url":"https://api.github.com/users/BlueBrain/events{/privacy}","received_events_url":"https://api.github.com/users/BlueBrain/received_events","type":"Organization","site_admin":false},"repo":{"id":10027845,"name":"DisplayCluster","full_name":"BlueBrain/DisplayCluster","owner":{"login":"BlueBrain","id":1479142,"avatar_url":"https://avatars.githubusercontent.com/u/1479142?v=3","gravatar_id":"","url":"https://api.github.com/users/BlueBrain","html_url":"https://github.com/BlueBrain","followers_url":"https://api.github.com/users/BlueBrain/followers","following_url":"https://api.github.com/users/BlueBrain/following{/other_user}","gists_url":"https://api.github.com/users/BlueBrain/gists{/gist_id}","starred_url":"https://api.github.com/users/BlueBrain/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/BlueBrain/subscriptions","organizations_url":"https://api.github.com/users/BlueBrain/orgs","repos_url":"https://api.github.com/users/BlueBrain/repos","events_url":"https://api.github.com/users/BlueBrain/events{/privacy}","received_events_url":"https://api.github.com/users/BlueBrain/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/BlueBrain/DisplayCluster","description":"A collaborative software for driving large display walls","fork":true,"url":"https://api.github.com/repos/BlueBrain/DisplayCluster","forks_url":"https://api.github.com/repos/BlueBrain/DisplayCluster/forks","keys_url":"https://api.github.com/repos/BlueBrain/DisplayCluster/keys{/key_id}","collaborators_url":"https://api.github.com/repos/BlueBrain/DisplayCluster/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/BlueBrain/DisplayCluster/teams","hooks_url":"https://api.github.com/repos/BlueBrain/DisplayCluster/hooks","issue_events_url":"https://api.github.com/repos/BlueBrain/DisplayCluster/issues/events{/number}","events_url":"https://api.github.com/repos/BlueBrain/DisplayCluster/events","assignees_url":"https://api.github.com/repos/BlueBrain/DisplayCluster/assignees{/user}","branches_url":"https://api.github.com/repos/BlueBrain/DisplayCluster/branches{/branch}","tags_url":"https://api.github.com/repos/BlueBrain/DisplayCluster/tags","blobs_url":"https://api.github.com/repos/BlueBrain/DisplayCluster/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/BlueBrain/DisplayCluster/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/BlueBrain/DisplayCluster/git/refs{/sha}","trees_url":"https://api.github.com/repos/BlueBrain/DisplayCluster/git/trees{/sha}","statuses_url":"https://api.github.com/repos/BlueBrain/DisplayCluster/statuses/{sha}","languages_url":"https://api.github.com/repos/BlueBrain/DisplayCluster/languages","stargazers_url":"https://api.github.com/repos/BlueBrain/DisplayCluster/stargazers","contributors_url":"https://api.github.com/repos/BlueBrain/DisplayCluster/contributors","subscribers_url":"https://api.github.com/repos/BlueBrain/DisplayCluster/subscribers","subscription_url":"https://api.github.com/repos/BlueBrain/DisplayCluster/subscription","commits_url":"https://api.github.com/repos/BlueBrain/DisplayCluster/commits{/sha}","git_commits_url":"https://api.github.com/repos/BlueBrain/DisplayCluster/git/commits{/sha}","comments_url":"https://api.github.com/repos/BlueBrain/DisplayCluster/comments{/number}","issue_comment_url":"https://api.github.com/repos/BlueBrain/DisplayCluster/issues/comments{/number}","contents_url":"https://api.github.com/repos/BlueBrain/DisplayCluster/contents/{+path}","compare_url":"https://api.github.com/repos/BlueBrain/DisplayCluster/compare/{base}...{head}","merges_url":"https://api.github.com/repos/BlueBrain/DisplayCluster/merges","archive_url":"https://api.github.com/repos/BlueBrain/DisplayCluster/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/BlueBrain/DisplayCluster/downloads","issues_url":"https://api.github.com/repos/BlueBrain/DisplayCluster/issues{/number}","pulls_url":"https://api.github.com/repos/BlueBrain/DisplayCluster/pulls{/number}","milestones_url":"https://api.github.com/repos/BlueBrain/DisplayCluster/milestones{/number}","notifications_url":"https://api.github.com/repos/BlueBrain/DisplayCluster/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/BlueBrain/DisplayCluster/labels{/name}","releases_url":"https://api.github.com/repos/BlueBrain/DisplayCluster/releases{/id}","created_at":"2013-05-13T08:48:40Z","updated_at":"2015-12-31T19:27:30Z","pushed_at":"2016-01-08T17:24:27Z","git_url":"git://github.com/BlueBrain/DisplayCluster.git","ssh_url":"git@github.com:BlueBrain/DisplayCluster.git","clone_url":"https://github.com/BlueBrain/DisplayCluster.git","svn_url":"https://github.com/BlueBrain/DisplayCluster","homepage":"https://bluebrain.github.io","size":16114,"stargazers_count":6,"watchers_count":6,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":12,"mirror_url":null,"open_issues_count":4,"forks":12,"open_issues":4,"watchers":6,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/BlueBrain/DisplayCluster/pulls/269"},"html":{"href":"https://github.com/BlueBrain/DisplayCluster/pull/269"},"issue":{"href":"https://api.github.com/repos/BlueBrain/DisplayCluster/issues/269"},"comments":{"href":"https://api.github.com/repos/BlueBrain/DisplayCluster/issues/269/comments"},"review_comments":{"href":"https://api.github.com/repos/BlueBrain/DisplayCluster/pulls/269/comments"},"review_comment":{"href":"https://api.github.com/repos/BlueBrain/DisplayCluster/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/BlueBrain/DisplayCluster/pulls/269/commits"},"statuses":{"href":"https://api.github.com/repos/BlueBrain/DisplayCluster/statuses/9a3fb383f994ca6a4b3c21083b96ec7ee744d2d5"}}}}