diff options
author | Andrei Karas <akaras@inbox.ru> | 2018-11-27 21:12:28 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2018-11-27 21:12:28 +0300 |
commit | 2734f4a788dad6faf960d53de00da74ebff69bd5 (patch) | |
tree | 340b0f641708b4060be755ea1d5d581dbcbe8e63 /src/utils/itemxmlutils.cpp | |
parent | 0c20db8d108c4123fcc3ecb343759e68567a4d4e (diff) | |
download | plus-2734f4a788dad6faf960d53de00da74ebff69bd5.tar.gz plus-2734f4a788dad6faf960d53de00da74ebff69bd5.tar.bz2 plus-2734f4a788dad6faf960d53de00da74ebff69bd5.tar.xz plus-2734f4a788dad6faf960d53de00da74ebff69bd5.zip |
Fix dispaly '+' on stats with negative values.
Diffstat (limited to 'src/utils/itemxmlutils.cpp')
-rw-r--r-- | src/utils/itemxmlutils.cpp | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/src/utils/itemxmlutils.cpp b/src/utils/itemxmlutils.cpp index ac8e48e2b..7362441b9 100644 --- a/src/utils/itemxmlutils.cpp +++ b/src/utils/itemxmlutils.cpp @@ -29,6 +29,15 @@ #include "debug.h" +static void convertSignedValue(std::string &outStr, + const std::string &srcStr) +{ + if (!srcStr.empty() && srcStr[0] != '-') + outStr = std::string("+").append(srcStr); + else + outStr = srcStr; +} + static bool readField(ItemFieldInfos::const_iterator it, XmlNodeConstPtr node, std::string &combined) @@ -52,8 +61,8 @@ static bool readField(ItemFieldInfos::const_iterator it, std::string value2; if (field->sign) { - value1 = std::string("+").append(tokens[0]); - value2 = std::string("+").append(tokens[1]); + convertSignedValue(value1, tokens[0]); + convertSignedValue(value2, tokens[1]); } else { @@ -67,7 +76,7 @@ static bool readField(ItemFieldInfos::const_iterator it, else { if (field->sign) - value = std::string("+").append(value); + convertSignedValue(value, value); } const std::string format = translator->getStr(field->description); combined = strprintf(format.c_str(), |