]> git.sesse.net Git - pkanalytics/commitdiff
Split update_status().
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Mon, 1 May 2023 21:02:49 +0000 (23:02 +0200)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Mon, 1 May 2023 21:02:49 +0000 (23:02 +0200)
main.cpp
mainwindow.h

index 95ecdb95ee83f11f53380dde71215c776ac2b62a..3c44f94adbbe8cb034b259747ceaaed215a032cc 100644 (file)
--- a/main.cpp
+++ b/main.cpp
@@ -127,7 +127,7 @@ void MainWindow::position_changed(uint64_t pos)
        if (!playing) {
                video->pause();  // We only played to get a picture.
        }
-       update_status();
+       update_ui_from_time(pos);
 }
 
 void MainWindow::seek(int64_t delta_ms)
@@ -179,7 +179,7 @@ void MainWindow::set_current_event_type(const string &type)
        }
        int row = select->selectedRows().front().row();  // Should only be one, due to our selection behavior.
        events->set_event_type(row, type);
-       update_status();
+       update_ui_from_time(video->position());
 }
 
 void MainWindow::delete_current_event()
@@ -192,7 +192,7 @@ void MainWindow::delete_current_event()
        ui->event_view->selectionModel()->blockSignals(true);
        events->delete_event(row);
        ui->event_view->selectionModel()->blockSignals(false);
-       update_status();
+       update_ui_from_time(video->position());
 }
 
 void MainWindow::make_substitution()
@@ -226,15 +226,23 @@ void MainWindow::make_substitution()
        }
 }
 
-void MainWindow::update_status()
+void MainWindow::update_ui_from_time(uint64_t t)
+{
+       update_status(t);
+       update_player_buttons(t);
+}
+
+void MainWindow::update_status(uint64_t t)
 {
-       uint64_t t = video->position();
        EventsModel::Status s = events->get_status_at(t);
        char buf[256];
        snprintf(buf, sizeof(buf), "%d–%d | %s | %d passes, %d sec possession",
                s.our_score, s.their_score, s.offense ? "offense" : "defense", s.num_passes, s.possession_sec);
        ui->status->setText(buf);
+}
 
+void MainWindow::update_player_buttons(uint64_t t)
+{
        // FIXME: sort by number, instead of by internal ID
        QPushButton *buttons[] = {
                ui->player_1,
index 112c1612827119fb880db0ebd0b0ae6c7fdf2417..d3f834c85025ffd049401d0ad31ab7582783ee50 100644 (file)
@@ -23,7 +23,10 @@ private:
        void set_current_event_type(const std::string &type);
        void delete_current_event();
        void make_substitution();
-       void update_status();
+
+       void update_ui_from_time(uint64_t t);
+       void update_status(uint64_t t);
+       void update_player_buttons(uint64_t t);
 
        Ui::MainWindow *ui;
        EventsModel *events;