refs #289, negative time values supported, required for time offset

This commit is contained in:
Klaus Basan
2014-07-09 19:58:18 +02:00
parent 76cbb5348c
commit af17c2c4e6
5 changed files with 115 additions and 11 deletions

View File

@@ -95,9 +95,14 @@ namespace BlackMisc
*/
QVariant CPqString::parseToVariant(const QString &value, SeparatorMode mode)
{
static QRegExp rx("([0-9]+)\\s*(\\D*)$");
static QRegExp rx("([-+]?[0-9]*[\\.,]?[0-9]+)\\s*(\\D*)$");
QVariant v;
if (value.isEmpty()) return v;
// fine tuning of the string
QString vs = value.trimmed().simplified();
// check
if (vs.isEmpty()) return v;
if (rx.indexIn(value) < 0) return v; // not a valid number
QString unit = rx.cap(2).trimmed();