Commit e5daf7ef authored by Volker Krause's avatar Volker Krause
Browse files

Trim string fields for display

parent a35bfef3
Pipeline #67701 passed with stage
in 2 minutes and 18 seconds
...@@ -33,10 +33,16 @@ private Q_SLOTS: ...@@ -33,10 +33,16 @@ private Q_SLOTS:
auto obj = auto obj =
QJsonDocument::fromJson(R"({"key":"valid-date","label":"Datum","dateStyle":"PKDateStyleShort","value":"2021-06-27T14:30:00+02:00"})").object(); QJsonDocument::fromJson(R"({"key":"valid-date","label":"Datum","dateStyle":"PKDateStyleShort","value":"2021-06-27T14:30:00+02:00"})").object();
KPkPass::Field f(obj, pass.get()); KPkPass::Field f(obj, pass.get());
QCOMPARE(f.value().type(), QVariant::DateTime); QCOMPARE(f.value().type(), QVariant::DateTime);
QCOMPARE(f.value(), QDateTime({2021, 6, 27}, {14, 30})); QCOMPARE(f.value(), QDateTime({2021, 6, 27}, {14, 30}));
QCOMPARE(f.valueDisplayString(), QLatin1String("27/06/2021 14:30")); QCOMPARE(f.valueDisplayString(), QLatin1String("27/06/2021 14:30"));
obj = QJsonDocument::fromJson(R"({"key":"valid-locations","label":"Ort","value":"Freibad Killesberg\n"})").object();
f = KPkPass::Field(obj, pass.get());
QCOMPARE(f.value().type(), QVariant::String);
QCOMPARE(f.value(), QLatin1String("Freibad Killesberg\n"));
QCOMPARE(f.valueDisplayString(), QLatin1String("Freibad Killesberg"));
} }
}; };
} }
......
...@@ -85,7 +85,7 @@ QString Field::valueDisplayString() const ...@@ -85,7 +85,7 @@ QString Field::valueDisplayString() const
} }
// TODO respect number formatting options // TODO respect number formatting options
return value().toString(); return value().toString().trimmed();
} }
QString Field::changeMessage() const QString Field::changeMessage() const
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment