X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=main.cpp;h=ade653a72b4e1f1cdd31aac389ece506a1a12953;hb=655991d5951123173cb88509c18eddb9abcd0ef4;hp=6ca5ecdce930bd484ecba1486fd582e3d398d3c8;hpb=971d4957bed4eba223b0ace948cfb5f991e0847f;p=pkanalytics diff --git a/main.cpp b/main.cpp index 6ca5ecd..ade653a 100644 --- a/main.cpp +++ b/main.cpp @@ -33,7 +33,7 @@ sqlite3 *open_db(const char *filename) )", nullptr, nullptr, nullptr); // Ignore errors. sqlite3_exec(db, R"( - CREATE TABLE IF NOT EXISTS match (match INTEGER PRIMARY KEY, description VARCHAR, video_filename VARCHAR); + CREATE TABLE IF NOT EXISTS match (match INTEGER PRIMARY KEY, description VARCHAR, video_filename VARCHAR, gender_rule_a BOOLEAN DEFAULT false, gender_pull_rule BOOLEAN DEFAULT false); )", nullptr, nullptr, nullptr); // Ignore errors. sqlite3_exec(db, R"( @@ -96,7 +96,9 @@ int get_match_id(sqlite3 *db, QWidget *parent, int requested_match) dialog.setWindowTitle("Open game"); dialog.setLabelText("Choose game to analyze:"); dialog.setComboBoxItems(items); - dialog.setTextValue(items[items.size() - 2]); + if (items.size() >= 2) { + dialog.setTextValue(items[items.size() - 2]); + } dialog.setOption(QInputDialog::UseListViewForComboBoxItems, true); if (!dialog.exec()) { return -1; @@ -118,7 +120,7 @@ int get_match_id(sqlite3 *db, QWidget *parent, int requested_match) } // Insert the new row into the database. - ret = sqlite3_prepare_v2(db, "INSERT INTO match (description) VALUES (?)", -1, &stmt, 0); + ret = sqlite3_prepare_v2(db, "INSERT INTO match (description, gender_rule_a, gender_pull_rule) VALUES (?, COALESCE((SELECT gender_rule_a FROM match ORDER BY match DESC LIMIT 1),false), COALESCE((SELECT gender_pull_rule FROM match ORDER BY match DESC LIMIT 1),false))", -1, &stmt, 0); if (ret != SQLITE_OK) { fprintf(stderr, "INSERT prepare: %s\n", sqlite3_errmsg(db)); abort(); @@ -165,8 +167,5 @@ int main(int argc, char *argv[]) int ret = app.exec(); - // TODO: do this on-demand instead, from a menu - export_to_json(db, "ultimate.json"); - return ret; }