]> git.sesse.net Git - pkanalytics/commitdiff
Add some offense events, now working-ish.
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Mon, 1 May 2023 12:50:09 +0000 (14:50 +0200)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Mon, 1 May 2023 12:50:53 +0000 (14:50 +0200)
events.cpp
events.h
mainwindow.h
mainwindow.ui
stats.cpp

index a08f1c78458a7292e16d41c496aa35fe9205225d..414c1572d1ac08cf958f04dad74c28e861810437 100644 (file)
@@ -138,3 +138,11 @@ int EventsModel::insert_event(uint64_t t, int player_id)
 
        return pos;
 }
+
+void EventsModel::set_event_type(unsigned pos, const string &type)
+{
+       events[pos].type = type;
+       emit dataChanged(createIndex(pos, 0), createIndex(pos, 2));
+
+       // FIXME sqlite
+}
index 66398d1d567eb1d941f1db83c4a1c98ad298a188..e86d02bf0b1273bc11d05ebd252d5f6b641ef862 100644 (file)
--- a/events.h
+++ b/events.h
@@ -26,6 +26,7 @@ public:
        QVariant data(const QModelIndex &index, int role) const override;
 
        int insert_event(uint64_t t, int player_id);
+       void set_event_type(unsigned row, const std::string &type);
 
 private:
        struct Player {
index 430b88d5c37a0037d9e7551172536e94729b73df..4e7095f11dacf8503f10ad72899b657b624ca1be 100644 (file)
@@ -17,6 +17,7 @@ public:
 
 private:
        void seek(int64_t delta_ms);
+       void set_current_event_type(const std::string &type);
 
        Ui::MainWindow *ui;
        EventsModel *model;
index b54428638dc9c4096f02a9724040112fbd493719..91ef5e5e0d02a53bea10491dd428afafebf26055 100644 (file)
             <property name="text">
              <string>Pull (&amp;p)</string>
             </property>
+            <property name="shortcut">
+             <string>P, Return</string>
+            </property>
            </widget>
           </item>
           <item row="0" column="0">
             <property name="text">
              <string>Catch/take (&amp;c)</string>
             </property>
+            <property name="shortcut">
+             <string>C</string>
+            </property>
            </widget>
           </item>
           <item row="4" column="1">
            </widget>
           </item>
           <item row="2" column="0">
-           <widget class="QPushButton" name="offense_soft_plus">
+           <widget class="QPushButton" name="offensive_soft_plus">
             <property name="text">
              <string>Soft plus (&amp;+)</string>
             </property>
+            <property name="shortcut">
+             <string>-</string>
+            </property>
            </widget>
           </item>
           <item row="2" column="1">
-           <widget class="QPushButton" name="offense_soft_minus">
+           <widget class="QPushButton" name="offensive_soft_minus">
             <property name="text">
              <string>Soft minus (&amp;-)</string>
             </property>
+            <property name="shortcut">
+             <string>+</string>
+            </property>
            </widget>
           </item>
           <item row="1" column="0">
             <property name="text">
              <string>Drop (&amp;x)</string>
             </property>
+            <property name="shortcut">
+             <string>X</string>
+            </property>
            </widget>
           </item>
           <item row="1" column="1">
             <property name="text">
              <string>Goal (&amp;g)</string>
             </property>
+            <property name="shortcut">
+             <string>G</string>
+            </property>
            </widget>
           </item>
          </layout>
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;