]> git.sesse.net Git - pkanalytics/blob - mainwindow.h
Make it possible to have separate videos per match, instead of hardcoding one specifi...
[pkanalytics] / mainwindow.h
1 #include <QMediaPlayer>
2 #include <QMainWindow>
3 #include <QApplication>
4 #include <stdint.h>
5 #include <sqlite3.h>
6 #include <optional>
7 #include "ui_mainwindow.h"
8
9 class EventsModel;
10 class PlayersModel;
11 class FormationsModel;
12
13 class MainWindow : public QMainWindow
14 {
15         Q_OBJECT
16
17 public:
18         MainWindow(EventsModel *events, PlayersModel *players,
19                    FormationsModel *offensive_formations, FormationsModel *defensive_formations,
20                    sqlite3 *db, int match_id);
21         ~MainWindow() {
22                 if (ui && ui->video) {
23                         ui->video->stop();
24                 }
25         }
26
27 private:
28         void position_changed(uint64_t pos);
29         void seek(int64_t delta_ms);
30         void insert_player_event(int button_id);
31         void insert_noplayer_event(const std::string &type);
32         void set_current_event_type(const std::string &type);
33         void insert_or_change_formation(bool offense);
34         void delete_current_event();
35         void make_substitution();
36         void formation_double_clicked(bool offense, unsigned row);
37
38         void update_ui_from_time(uint64_t t);
39         void update_status(uint64_t t);
40         void update_player_buttons(uint64_t t);
41         void update_action_buttons(uint64_t t);
42
43         Ui::MainWindow *ui;
44         EventsModel *events;
45         PlayersModel *players;
46         FormationsModel *offensive_formations;
47         FormationsModel *defensive_formations;
48         bool seeking = false;
49         std::atomic<bool> playing{true};
50         std::optional<uint64_t> buffered_seek;
51         sqlite3 *db;  // TODO: Check threading
52         int match_id;
53 };