From 17bf553b76ebd688e58e4de4271407e2058d89ef Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Mon, 15 Mar 2021 12:27:00 +0100 Subject: [PATCH 1/2] Include minus sign in ImhFormattedNumbersOnly's available keys MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit UIKeyboardTypeDecimalPad only provides digits and decimal point, no minus sign, but ImhFormattedNumbersOnly is documented to provide a minus sign as well. UIKeyboardTypeNumbersAndPunctuation includes punctuation, which should cover signs as well as decimal separator, so use that - same as for ImhPreferNumbers. A little more permissive than we want here, but that's better than more restrictive ! Fixes: QTBUG-91455 Pick-to: 6.1 6.0 5.15 Change-Id: I0418946014e0a66d503e61704154fd7798a0b785 Reviewed-by: Tor Arne Vestbø --- src/plugins/platforms/ios/qiostextresponder.mm | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/plugins/platforms/ios/qiostextresponder.mm b/src/plugins/platforms/ios/qiostextresponder.mm index e030ec200c..c9ecaecb6d 100644 --- a/src/plugins/platforms/ios/qiostextresponder.mm +++ b/src/plugins/platforms/ios/qiostextresponder.mm @@ -227,13 +227,11 @@ self.keyboardType = UIKeyboardTypeEmailAddress; else if (hints & Qt::ImhDigitsOnly) self.keyboardType = UIKeyboardTypeNumberPad; - else if (hints & Qt::ImhFormattedNumbersOnly) - self.keyboardType = UIKeyboardTypeDecimalPad; else if (hints & Qt::ImhDialableCharactersOnly) self.keyboardType = UIKeyboardTypePhonePad; else if (hints & Qt::ImhLatinOnly) self.keyboardType = UIKeyboardTypeASCIICapable; - else if (hints & Qt::ImhPreferNumbers) + else if (hints & (Qt::ImhPreferNumbers | Qt::ImhFormattedNumbersOnly)) self.keyboardType = UIKeyboardTypeNumbersAndPunctuation; else self.keyboardType = UIKeyboardTypeDefault; From eefaf54d9e4d77c2e67a3926c7e5080b376f7067 Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Tue, 2 Mar 2021 12:30:54 +0100 Subject: [PATCH 2/2] Use QFile directly instead of via QTextStream MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Follows up on a TODO comment that says QTextStream is less efficient. In any case, QFile has readLine() returning QByteArray, without conversion to QString, and the parsing is uncomplicated. Change-Id: I06e563df417692d3b6514a52a313a0ff55b0b52e Reviewed-by: Øystein Heskestad Reviewed-by: Thiago Macieira --- src/corelib/time/qtimezoneprivate_tz.cpp | 36 +++++++++++++++--------- 1 file changed, 23 insertions(+), 13 deletions(-) diff --git a/src/corelib/time/qtimezoneprivate_tz.cpp b/src/corelib/time/qtimezoneprivate_tz.cpp index ace966e15b..e758f1c12f 100644 --- a/src/corelib/time/qtimezoneprivate_tz.cpp +++ b/src/corelib/time/qtimezoneprivate_tz.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2020 The Qt Company Ltd. +** Copyright (C) 2021 The Qt Company Ltd. ** Copyright (C) 2019 Crimson AS ** Copyright (C) 2013 John Layt ** Contact: https://www.qt.io/licensing/ @@ -88,19 +88,29 @@ static QTzTimeZoneHash loadTzTimeZones() return QTzTimeZoneHash(); QTzTimeZoneHash zonesHash; - // TODO QTextStream inefficient, replace later - QTextStream ts(&tzif); - while (!ts.atEnd()) { - const QString line = ts.readLine(); - // Comment lines are prefixed with a # - if (!line.isEmpty() && line.at(0) != u'#') { - // Data rows are tab-separated columns Region, Coordinates, ID, Optional Comments - const auto parts = QStringView{line}.split(QLatin1Char('\t')); + while (!tzif.atEnd()) { + const QByteArray line = tzif.readLine().trimmed(); + if (line.isEmpty() || line.at(0) == '#') // Ignore empty or comment + continue; + // Data rows are tab-separated columns Region, Coordinates, ID, Optional Comments + QByteArrayView text(line); + int cut = text.indexOf('\t'); + if (Q_LIKELY(cut > 0)) { QTzTimeZone zone; - zone.country = QLocalePrivate::codeToCountry(parts.at(0)); - if (parts.size() > 3) - zone.comment = parts.at(3).toUtf8(); - zonesHash.insert(parts.at(2).toUtf8(), zone); + // TODO: QLocale & friends could do this look-up without UTF8-conversion: + zone.country = QLocalePrivate::codeToCountry(QString::fromUtf8(text.first(cut))); + text = text.sliced(cut + 1); + cut = text.indexOf('\t'); + if (Q_LIKELY(cut >= 0)) { // Skip over Coordinates, read ID and comment + text = text.sliced(cut + 1); + cut = text.indexOf('\t'); // < 0 if line has no comment + if (Q_LIKELY(cut)) { + const QByteArray id = (cut > 0 ? text.first(cut) : text).toByteArray(); + if (cut > 0) + zone.comment = text.sliced(cut + 1).toByteArray(); + zonesHash.insert(id, zone); + } + } } } return zonesHash;