diff options
| author | in1tiate <32779090+in1tiate@users.noreply.github.com> | 2025-01-23 03:16:42 -0600 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-01-23 03:16:42 -0600 |
| commit | fa94955d4f76735aac621d74b7f28a905a898998 (patch) | |
| tree | 1b63d0e142ee7c04a559ca47fdd110a0f84b912e /src | |
| parent | 764b2f8944ef4d40a3829c1e55112b0cb4ff32fe (diff) | |
Fix legacy position population (#1069)
* Reworked legacy position population
- Changed data structure to a static list of pairs to avoid unnecessary deep copies
- Fixed oversight which caused iteration over the value and not the key of the previous QMap
* clang-format pass :rolling_eyes:
* disambiguate pair order further
Diffstat (limited to 'src')
| -rw-r--r-- | src/courtroom.cpp | 24 |
1 files changed, 8 insertions, 16 deletions
diff --git a/src/courtroom.cpp b/src/courtroom.cpp index cf321c35..372432ac 100644 --- a/src/courtroom.cpp +++ b/src/courtroom.cpp @@ -1394,26 +1394,18 @@ void Courtroom::set_background(QString p_background, bool display) ui_vp_testimony->stopPlayback(); current_background = p_background; - // welcome to hardcode central may I take your order of regularly scheduled - // CBT - QMap<QString, QString> default_pos; - default_pos["defenseempty"] = "def"; - default_pos["helperstand"] = "hld"; - default_pos["prosecutorempty"] = "pro"; - default_pos["prohelperstand"] = "hlp"; - default_pos["witnessempty"] = "wit"; - default_pos["judgestand"] = "jud"; - default_pos["jurystand"] = "jur"; - default_pos["seancestand"] = "sea"; + // Modern positions paired to their legacy counterparts for use in dropdown population + // {"new", "old"} + static QList<QPair<QString, QString>> legacy_positions = {{"def", "defenseempty"}, {"hld", "helperstand"}, {"pro", "prosecutorempty"}, {"hlp", "prohelperstand"}, {"wit", "witnessempty"}, {"jud", "judgestand"}, {"jur", "jurystand"}, {"sea", "seancestand"}}; // Populate the dropdown list with all pos that exist on this bg QStringList pos_list = {}; - for (const QString &key : std::as_const(default_pos)) + for (const QPair<QString, QString> &pos_pair : std::as_const(legacy_positions)) { - if (file_exists(ao_app->get_image_suffix(ao_app->get_background_path(default_pos[key]))) || // if we have 2.8-style positions, e.g. def.png, wit.webp, hld.apng - file_exists(ao_app->get_image_suffix(ao_app->get_background_path(key)))) - { // if we have pre-2.8-style positions, e.g. defenseempty.png - pos_list.append(default_pos[key]); + if (file_exists(ao_app->get_image_suffix(ao_app->get_background_path(pos_pair.first))) || // if we have 2.8-style positions, e.g. def.png, wit.webp, hld.apng + file_exists(ao_app->get_image_suffix(ao_app->get_background_path(pos_pair.second)))) // if we have pre-2.8-style positions, e.g. defenseempty.png + { + pos_list.append(pos_pair.first); // the dropdown always uses the new style } } if (file_exists(ao_app->get_image_suffix(ao_app->get_background_path("court")))) |
