summaryrefslogtreecommitdiffhomepage
path: root/migration/20160906_01-axis-signs.cpp
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2016-09-09 20:28:21 +0200
committerStanislaw Halik <sthalik@misaki.pl>2016-09-09 20:41:54 +0200
commit6e752439a11328b6afea20771715c19e80c9ac34 (patch)
treea1d5945a2b515611b4265b7f3eda351bb7f81246 /migration/20160906_01-axis-signs.cpp
parent1db97bdf3cd8de3130a9685189aff9f415ddc6c0 (diff)
migrations: rename for 2-digit serial
Diffstat (limited to 'migration/20160906_01-axis-signs.cpp')
-rw-r--r--migration/20160906_01-axis-signs.cpp73
1 files changed, 73 insertions, 0 deletions
diff --git a/migration/20160906_01-axis-signs.cpp b/migration/20160906_01-axis-signs.cpp
new file mode 100644
index 00000000..7cf0c719
--- /dev/null
+++ b/migration/20160906_01-axis-signs.cpp
@@ -0,0 +1,73 @@
+// TODO XXX write migration for axis sign going to mappings bundle
+
+#include "migration.hpp"
+#include "options/options.hpp"
+#include "logic/main-settings.hpp"
+
+#include <QString>
+#include <QVariant>
+
+using namespace options;
+using namespace migrations;
+
+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";
+ }
+
+ QString name() const override
+ {
+ return "asymmetric axis sign to another .ini section";
+ }
+
+ bool should_run() const override
+ {
+ 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;
+ }
+
+ void run() override
+ {
+ 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();
+ }
+};
+
+const char* axis_signs_split_rc11::axis_names[] =
+{
+ "yaw", "pitch", "roll",
+ "x", "y", "z",
+};
+
+const QString axis_signs_split_rc11::fmt = QStringLiteral("%1-alt-axis-sign");
+
+OPENTRACK_MIGRATION(axis_signs_split_rc11);