mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-31 21:15:33 +08:00
refs #289, negative time values supported, required for time offset
This commit is contained in:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user