From 87ec7098ffcdbec50af68c2bd7ae756b78d609dd Mon Sep 17 00:00:00 2001 From: Josef Rokos Date: Sun, 7 May 2017 23:40:17 +0200 Subject: [PATCH] Fixed saving of enums to json settings. Added global enum for rounding. --- core/enums.h | 9 +++++++++ core/settingsservice.h | 14 +++++++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/core/enums.h b/core/enums.h index 65adf26..14dec69 100644 --- a/core/enums.h +++ b/core/enums.h @@ -9,6 +9,7 @@ class CORESHARED_EXPORT Enums : public QObject Q_OBJECT Q_ENUMS(VatType) + Q_ENUMS(Rounding) public: enum VatType @@ -19,6 +20,14 @@ public: SECOND_LOWER }; + enum Rounding + { + R_NONE, + R_UP, + R_DOWN, + R_MATH + }; + Enums() { } diff --git a/core/settingsservice.h b/core/settingsservice.h index 15aa258..45dcb4b 100644 --- a/core/settingsservice.h +++ b/core/settingsservice.h @@ -8,6 +8,7 @@ #include #include +#include #include "data/system.h" #include "service.h" @@ -50,8 +51,19 @@ public: { QDecDouble dec(TO_DEC(varVal.toInt())); varVal = QVariant::fromValue(dec); + objSettings->setProperty(propName, varVal); + continue; + } + + // all other numbers are int + if (varVal.toInt() > 0) + { + objSettings->setProperty(propName, varVal.toInt()); + } + else + { + objSettings->setProperty(propName, varVal); } - objSettings->setProperty(propName, varVal); } return settingsObj;