From 26598f7dbeab8117834850888bbe236d25c2223c Mon Sep 17 00:00:00 2001 From: "Steinar H. Gunderson" Date: Mon, 1 May 2023 23:02:49 +0200 Subject: [PATCH] Split update_status(). --- main.cpp | 18 +++++++++++++----- mainwindow.h | 5 ++++- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/main.cpp b/main.cpp index 95ecdb9..3c44f94 100644 --- 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, diff --git a/mainwindow.h b/mainwindow.h index 112c161..d3f834c 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -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; -- 2.39.2