+void MainWindow::make_substitution()
+{
+ QItemSelectionModel *select = ui->player_view->selectionModel();
+
+ // FIXME: we should backdate t to start of point (last goal, or 0) if:
+ // - no players we're removing have had actions yet
+ // - there have been no other in/out events
+ //
+ // ...but if so, we might need to modify in/out events that are already there
+ // (perhaps just overwrite them all?)
+ uint64_t t = player->position();
+
+ set<int> old_team = events->get_team_at(t);
+ set<int> new_team;
+
+ for (QModelIndex row : select->selectedRows()) {
+ new_team.insert(players->get_player_id(row.row()));
+ }
+
+ for (int player_id : old_team) {
+ if (!new_team.count(player_id)) {
+ events->insert_event(t, player_id, "out");
+ }
+ }
+ for (int player_id : new_team) {
+ if (!old_team.count(player_id)) {
+ events->insert_event(t, player_id, "in");
+ }
+ }
+}
+