From 8cc4463a1af4bbce2dd5ea61d6ab8a5b107fb3b7 Mon Sep 17 00:00:00 2001 From: Joakim Bygdell Date: Sat, 13 Feb 2016 18:34:30 +0100 Subject: Add helper function to parse gasmix strings Signed-off-by: Joakim Bygdell Signed-off-by: Dirk Hohndel --- subsurface-core/qthelper.cpp | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) (limited to 'subsurface-core/qthelper.cpp') diff --git a/subsurface-core/qthelper.cpp b/subsurface-core/qthelper.cpp index 07ec19486..fa7e894bb 100644 --- a/subsurface-core/qthelper.cpp +++ b/subsurface-core/qthelper.cpp @@ -885,6 +885,47 @@ int parsePressureToMbar(const QString &text) return mbar; } +int parseGasMixO2(const QString &text) +{ + QString gasString = text; + int o2, number; + if (gasString.contains(QObject::tr("AIR"), Qt::CaseInsensitive)) { + o2 = O2_IN_AIR; + } + else if (gasString.contains(QObject::tr("EAN"), Qt::CaseInsensitive)) { + gasString.remove(QRegExp("[^0-9]")); + number = gasString.toInt(); + o2 = number * 10; + } + else if (gasString.contains("/")) { + QStringList gasSplit = gasString.split("/"); + number = gasSplit[0].toInt(); + o2 = number * 10; + } + else { + number = gasString.toInt(); + o2 = number * 10; + } + + return o2; +} + +int parseGasMixHE(const QString &text) +{ + QString gasString = text; + int he, number; + if (gasString.contains("/")) { + QStringList gasSplit = gasString.split("/"); + number = gasSplit[1].toInt(); + he = number * 10; + } + else { + he = 0; + } + + return he; +} + QString get_dive_duration_string(timestamp_t when, QString hourText, QString minutesText) { int hrs, mins; -- cgit v1.2.3-70-g09d2