]> git.sesse.net Git - pkanalytics/blobdiff - events.h
Small typo.
[pkanalytics] / events.h
index 3dd69594908e8d0f5c2671421aa97f67c9fdcf3e..6dc2faf2f069e3d0d8c8c35e0cdf54a8c7113e90 100644 (file)
--- 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
        {
@@ -25,7 +25,7 @@ public:
        QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
        QVariant data(const QModelIndex &index, int role) const override;
 
-       unsigned insert_event(uint64_t t, std::optional<int> player_id, const std::string &type = "unknown");  // Returns the row.
+       unsigned insert_event(uint64_t t, std::optional<int> player_id, std::optional<int> formation_id, const std::string &type = "unknown");  // Returns the row.
        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; }
@@ -48,6 +48,12 @@ public:
        std::set<int> get_team_at(uint64_t t);
        void set_team_at(uint64_t, const std::set<int> &new_team);
        std::vector<int> sort_team(const std::set<int> &team) const;  // Ordered first by gender, then by number.
+       void set_formation_at(uint64_t t, bool offense, unsigned formation);
+
+       // Used to notify when we've inserted a new one into the database.
+       void inserted_new_formation(int formation_id, const std::string &name) {
+               formations[formation_id] = Formation{ formation_id, name };
+       }
 
 private:
        struct Player {
@@ -58,15 +64,23 @@ private:
        std::map<int, Player> players;
        std::map<int, int> player_ordering;  // From id to position.
 
+       struct Formation {
+               int formation_id;
+               std::string name;
+       };
+       std::map<int, Formation> formations;
+
        struct Event {
                int event_id;
                uint64_t t;
                std::optional<int> player_id;
+               std::optional<int> formation_id;
                std::string type;
        };
        std::vector<Event> events;
 
        sqlite3 *db;
+       int match_id;
 
        void load_data();
 };