summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIvan Solovev <ivan.solovev@qt.io>2022-04-05 15:19:17 +0200
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2022-04-10 19:30:07 +0000
commit4cb27786be86694e56150291170c338ab2450c13 (patch)
tree0b549aac9ff1534a5314ebe4aa5fdf5d294bae08
parentdeb8be93e1e09ab1926fe2c4cea5f77e1c02c713 (diff)
Android: minor refactor in QTimeZonePrivate backend
getDisplayName() now returns QString instead of QJniObject. It's more clear and allows to save some QJniObject::toString() calls in other parts of code. Change-Id: I0f2061cf1dff21c09c2272bf1e9126ff1ea0ed3e Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io> (cherry picked from commit c366d57594bfb84c215fda2b101bcd7f37b93dcd) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r--src/corelib/time/qtimezoneprivate_android.cpp11
1 files changed, 5 insertions, 6 deletions
diff --git a/src/corelib/time/qtimezoneprivate_android.cpp b/src/corelib/time/qtimezoneprivate_android.cpp
index 4d98597dc7..9ba6f58072 100644
--- a/src/corelib/time/qtimezoneprivate_android.cpp
+++ b/src/corelib/time/qtimezoneprivate_android.cpp
@@ -85,7 +85,7 @@ QAndroidTimeZonePrivate::~QAndroidTimeZonePrivate()
{
}
-static QJniObject getDisplayName(QJniObject zone, jint style, jboolean dst,
+static QString getDisplayName(QJniObject zone, jint style, jboolean dst,
const QLocale &locale)
{
QJniObject jlanguage
@@ -102,7 +102,7 @@ static QJniObject getDisplayName(QJniObject zone, jint style, jboolean dst,
return zone.callObjectMethod("getDisplayName",
"(ZILjava/util/Locale;)Ljava/lang/String;",
- dst, style, jlocale.object());
+ dst, style, jlocale.object()).toString();
}
void QAndroidTimeZonePrivate::init(const QByteArray &ianaId)
@@ -113,8 +113,7 @@ void QAndroidTimeZonePrivate::init(const QByteArray &ianaId)
QJniObject::fromString(iana).object<jstring>());
// The ID or display name of the zone we've got, if it looks like what we asked for:
- const auto match = [iana](const QJniObject &jname) -> QByteArray {
- const QString name = jname.toString();
+ const auto match = [iana](const QString &name) -> QByteArray {
if (iana.compare(name, Qt::CaseInsensitive) == 0)
return name.toUtf8();
@@ -125,7 +124,7 @@ void QAndroidTimeZonePrivate::init(const QByteArray &ianaId)
// recognize the name; so check for whether ianaId is a recognized name of
// the zone object we got and ignore the zone if not.
// Try checking ianaId against getID(), getDisplayName():
- m_id = match(androidTimeZone.callObjectMethod("getID", "()Ljava/lang/String;"));
+ m_id = match(androidTimeZone.callObjectMethod("getID", "()Ljava/lang/String;").toString());
for (int style = 1; m_id.isEmpty() && style >= 0; --style) {
for (int dst = 1; m_id.isEmpty() && dst >= 0; --dst) {
for (int pick = 2; m_id.isEmpty() && pick >= 0; --pick) {
@@ -154,7 +153,7 @@ QString QAndroidTimeZonePrivate::displayName(QTimeZone::TimeType timeType, QTime
// treat all NameTypes as java TimeZone style LONG (value 1), except of course QTimeZone::ShortName which is style SHORT (value 0);
jint style = (nameType == QTimeZone::ShortName ? 0 : 1);
- name = getDisplayName(androidTimeZone, style, daylightTime, locale).toString();
+ name = getDisplayName(androidTimeZone, style, daylightTime, locale);
}
return name;