diff options
Diffstat (limited to 'migration/20160906_01-axis-signs.cpp')
| -rw-r--r-- | migration/20160906_01-axis-signs.cpp | 78 |
1 files changed, 39 insertions, 39 deletions
diff --git a/migration/20160906_01-axis-signs.cpp b/migration/20160906_01-axis-signs.cpp index 0934990d..eeb6963d 100644 --- a/migration/20160906_01-axis-signs.cpp +++ b/migration/20160906_01-axis-signs.cpp @@ -8,7 +8,6 @@ #include "migration.hpp" #include "options/options.hpp" -#include "logic/main-settings.hpp" #include <QString> #include <QVariant> @@ -16,13 +15,18 @@ using namespace options; using namespace migrations; +const char* const axis_names[] = +{ + "yaw", "pitch", "roll", + "x", "y", "z", +}; + +const QString alt_sign_fmt = QStringLiteral("%1-alt-axis-sign"); + struct axis_signs_split_rc11 : migration { axis_signs_split_rc11() = default; - static const char* axis_names[6]; - static const QString fmt; - QString unique_date() const override { return "20160909_01"; @@ -33,47 +37,43 @@ struct axis_signs_split_rc11 : migration return "asymmetric axis option to other section"; } - bool should_run() const override + bool should_run() const override; + void run() override; +}; + +OPENTRACK_MIGRATION(axis_signs_split_rc11) + +bool axis_signs_split_rc11::should_run() const +{ + bundle new_bundle = make_bundle("opentrack-mappings"); + bundle old_bundle = make_bundle("opentrack-ui"); + + for (const char* name : axis_names) { - bundle new_bundle = make_bundle("opentrack-mappings"); - bundle old_bundle = make_bundle("opentrack-ui"); - - for (const char* name : axis_names) - { - // new present, already applied - if (new_bundle->contains(fmt.arg(name))) - return false; - } - - for (const char* name : axis_names) - { - // old present - if (old_bundle->contains(fmt.arg(name))) - return true; - } - - // nothing to copy - return false; + // new present, already applied + if (new_bundle->contains(alt_sign_fmt.arg(name))) + return false; } - void run() override + for (const char* name : axis_names) { - bundle new_bundle = make_bundle("opentrack-mappings"); - bundle old_bundle = make_bundle("opentrack-ui"); - - for (const char* name : axis_names) - new_bundle->store_kv(fmt.arg(name), QVariant(old_bundle->get<bool>(fmt.arg(name)))); - - new_bundle->save(); + // old present + if (old_bundle->contains(alt_sign_fmt.arg(name))) + return true; } -}; -const char* axis_signs_split_rc11::axis_names[] = + // nothing to copy + return false; +} + +void axis_signs_split_rc11::run() { - "yaw", "pitch", "roll", - "x", "y", "z", -}; + bundle new_bundle = make_bundle("opentrack-mappings"); + bundle old_bundle = make_bundle("opentrack-ui"); -const QString axis_signs_split_rc11::fmt = QStringLiteral("%1-alt-axis-sign"); + for (const char* name : axis_names) + new_bundle->store_kv(alt_sign_fmt.arg(name), + old_bundle->get_variant(alt_sign_fmt.arg(name))); -OPENTRACK_MIGRATION(axis_signs_split_rc11); + new_bundle->save(); +} |
