summaryrefslogtreecommitdiffhomepage
path: root/migration
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2018-01-03 14:00:44 +0100
committerStanislaw Halik <sthalik@misaki.pl>2018-01-03 14:35:56 +0100
commitabf0bf769a8f1fb7bc3022aa69d519e261e1d595 (patch)
tree5487392e621f6446fab2c45c90de857069d57d2e /migration
parentcbaafb9a828f13abb55b99f8f2c4caa2337ef9e9 (diff)
gui/process-detector: change separator characters
Prevent common characters from breaking the saved list. Use unprintable characters. Add migration.
Diffstat (limited to 'migration')
-rw-r--r--migration/20180102_00-process-detector-separator.cpp48
1 files changed, 48 insertions, 0 deletions
diff --git a/migration/20180102_00-process-detector-separator.cpp b/migration/20180102_00-process-detector-separator.cpp
new file mode 100644
index 00000000..c1864adf
--- /dev/null
+++ b/migration/20180102_00-process-detector-separator.cpp
@@ -0,0 +1,48 @@
+#include "migration.hpp"
+#include "options/options.hpp"
+
+using namespace options;
+using namespace migrations;
+
+static constexpr auto OLD_RECORD_SEPARATOR = QChar('|');
+static constexpr auto OLD_UNIT_SEPARATOR = QChar(':');
+
+static constexpr auto NEW_RECORD_SEPARATOR = QChar(0x1e);
+static constexpr auto NEW_UNIT_SEPARATOR = QChar(0x1f);
+
+static constexpr QLatin1String KEY_NAME = "executable-list"_qstr;
+
+struct process_detector_record_separator : migration
+{
+ QString unique_date() const override
+ {
+ return "20180102_00";
+ }
+
+ QString name() const override
+ {
+ return "process detector record separator";
+ }
+
+ bool should_run() const override
+ {
+ return group::with_global_settings_object([](const QSettings& s)
+ {
+ const QString old_value = s.value(KEY_NAME).toString();
+ return old_value.contains(OLD_RECORD_SEPARATOR);
+ });
+ }
+
+ void run() override
+ {
+ return group::with_global_settings_object([](QSettings& s)
+ {
+ QString value = s.value(KEY_NAME).toString();
+ value.replace(OLD_UNIT_SEPARATOR, NEW_UNIT_SEPARATOR);
+ value.replace(OLD_RECORD_SEPARATOR, NEW_RECORD_SEPARATOR);
+ s.setValue(KEY_NAME, value);
+ });
+ }
+};
+
+OPENTRACK_MIGRATION(process_detector_record_separator);