X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=events.h;h=caf832ac26ca0180364d8e899dba453beb909c00;hb=415442b56355392b207551b2cc84e663d8d7f914;hp=00c5f1d97f52556ae186cd38fd54d46a61687ef5;hpb=fd47dc764ce17096c227d03af4e8965056fc0bfb;p=pkanalytics diff --git a/events.h b/events.h index 00c5f1d..caf832a 100644 --- a/events.h +++ b/events.h @@ -12,7 +12,7 @@ class EventsModel : public QAbstractTableModel { public: - EventsModel(sqlite3 *db); + EventsModel(sqlite3 *db, int match_id); int rowCount(const QModelIndex &parent) const override { @@ -29,13 +29,17 @@ public: void delete_event(unsigned row); void set_event_type(unsigned row, const std::string &type); uint64_t get_time(unsigned row) { return events[row].t; } + unsigned get_last_event_pos(uint64_t t) const; // Last event that happened at or before t. + QModelIndex get_last_event_qt(uint64_t t) const { + return createIndex(get_last_event_pos(t), 0); + } std::optional get_player_id(unsigned row) { return events[row].player_id; } struct Status { unsigned our_score, their_score; enum { NOT_STARTED, OFFENSE, DEFENSE } attack_state; bool stoppage; - bool should_pull; + enum { NOT_PULLING, SHOULD_PULL, PULL_IN_AIR } pull_state; unsigned num_passes; unsigned possession_sec; unsigned stoppage_sec; @@ -43,6 +47,7 @@ public: Status get_status_at(uint64_t t); std::set get_team_at(uint64_t t); void set_team_at(uint64_t, const std::set &new_team); + std::vector sort_team(const std::set &team) const; // Ordered first by gender, then by number. private: struct Player { @@ -51,6 +56,7 @@ private: std::string name; }; std::map players; + std::map player_ordering; // From id to position. struct Event { int event_id; @@ -61,6 +67,7 @@ private: std::vector events; sqlite3 *db; + int match_id; void load_data(); };