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
+}
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 {
private:
void seek(int64_t delta_ms);
+ void set_current_event_type(const std::string &type);
Ui::MainWindow *ui;
EventsModel *model;
<property name="text">
<string>Pull (&p)</string>
</property>
+ <property name="shortcut">
+ <string>P, Return</string>
+ </property>
</widget>
</item>
<item row="0" column="0">
<property name="text">
<string>Catch/take (&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 (&+)</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 (&-)</string>
</property>
+ <property name="shortcut">
+ <string>+</string>
+ </property>
</widget>
</item>
<item row="1" column="0">
<property name="text">
<string>Drop (&x)</string>
</property>
+ <property name="shortcut">
+ <string>X</string>
+ </property>
</widget>
</item>
<item row="1" column="1">
<property name="text">
<string>Goal (&g)</string>
</property>
+ <property name="shortcut">
+ <string>G</string>
+ </property>
</widget>
</item>
</layout>
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)
}
}
+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;