]> git.sesse.net Git - pkanalytics/blobdiff - stats.cpp
Add some offense events, now working-ish.
[pkanalytics] / stats.cpp
index c8f0be5ab196c186a81fc3f1fe343cab9ef465b6..9d621249cdafdb873b627bb20bb8f3fcfea4f823 100644 (file)
--- a/stats.cpp
+++ b/stats.cpp
@@ -99,6 +99,16 @@ MainWindow::MainWindow()
        connect(ui->player_7, &QPushButton::clicked, [this]() {
                ui->event_view->selectRow(model->insert_event(player->position(), 7));
        });
+
+       // TODO: disable if nothing is selected
+       connect(ui->catch_, &QPushButton::clicked, [this]() { set_current_event_type("catch"); });
+       connect(ui->throwaway, &QPushButton::clicked, [this]() { set_current_event_type("throwaway"); });
+       connect(ui->drop, &QPushButton::clicked, [this]() { set_current_event_type("drop"); });
+       connect(ui->goal, &QPushButton::clicked, [this]() { set_current_event_type("goal"); });
+       connect(ui->offensive_soft_plus, &QPushButton::clicked, [this]() { set_current_event_type("offensive_soft_plus"); });
+       connect(ui->offensive_soft_minus, &QPushButton::clicked, [this]() { set_current_event_type("offensive_soft_minus"); });
+       connect(ui->pull, &QPushButton::clicked, [this]() { set_current_event_type("pull"); });
+       connect(ui->pull_landed, &QPushButton::clicked, [this]() { set_current_event_type("pull_landed"); });
 }
 
 void MainWindow::setModel(EventsModel *model)
@@ -118,6 +128,16 @@ void MainWindow::seek(int64_t delta_ms)
        }
 }
 
+void MainWindow::set_current_event_type(const string &type)
+{
+       QItemSelectionModel *select = ui->event_view->selectionModel();
+       if (!select->hasSelection()) {
+               return;
+       }
+       int row = select->selectedRows().front().row();  // Should only be one, due to our selection behavior.
+       model->set_event_type(row, type);
+}
+
 sqlite3 *open_db(const char *filename)
 {
        sqlite3 *db;