diff options
author | Gabriel de Dietrich <gabriel.dedietrich@qt.io> | 2017-07-13 16:34:32 -0700 |
---|---|---|
committer | Gabriel de Dietrich <gabriel.dedietrich@qt.io> | 2017-07-13 16:36:10 -0700 |
commit | d38fe875c7850ca2c6ca28f91e94ae276735fac8 (patch) | |
tree | e5c92cef74e0853490d77cf0139b23f00d548a6e /src/corelib/tools | |
parent | ac4e848c9802377b7c4ff673180f28b9ca76b746 (diff) | |
parent | 627f0a7f7d775ecd263b95dd07fca44bfcb0c5cf (diff) |
Merge remote-tracking branch 'origin/5.9' into dev
Conflicts:
src/widgets/widgets/qmainwindowlayout.cpp
Change-Id: I306b4f5ad11bceb336c9091241b468d455fe6bb6
Diffstat (limited to 'src/corelib/tools')
-rw-r--r-- | src/corelib/tools/qbytearray.cpp | 24 | ||||
-rw-r--r-- | src/corelib/tools/qdatetime.cpp | 53 | ||||
-rw-r--r-- | src/corelib/tools/qlocale.cpp | 17 |
3 files changed, 57 insertions, 37 deletions
diff --git a/src/corelib/tools/qbytearray.cpp b/src/corelib/tools/qbytearray.cpp index bbac058f2f..3ecb2ac662 100644 --- a/src/corelib/tools/qbytearray.cpp +++ b/src/corelib/tools/qbytearray.cpp @@ -1583,13 +1583,13 @@ void QByteArray::chop(int n) \snippet code/src_corelib_tools_qbytearray.cpp 12 Note: QByteArray is an \l{implicitly shared} class. Consequently, - if \e this is an empty QByteArray, then \e this will just share - the data held in \a ba. In this case, no copying of data is done, + if you append to an empty byte array, then the byte array will just + share the data held in \a ba. In this case, no copying of data is done, taking \l{constant time}. If a shared instance is modified, it will be copied (copy-on-write), taking \l{linear time}. - If \e this is not an empty QByteArray, a deep copy of the data is - performed, taking \l{linear time}. + If the byte array being appended to is not empty, a deep copy of the + data is performed, taking \l{linear time}. This operation typically does not suffer from allocation overhead, because QByteArray preallocates extra space at the end of the data @@ -1848,13 +1848,13 @@ QByteArray QByteArray::nulTerminated() const This is the same as insert(0, \a ba). Note: QByteArray is an \l{implicitly shared} class. Consequently, - if \e this is an empty QByteArray, then \e this will just share - the data held in \a ba. In this case, no copying of data is done, + if you prepend to an empty byte array, then the byte array will just + share the data held in \a ba. In this case, no copying of data is done, taking \l{constant time}. If a shared instance is modified, it will be copied (copy-on-write), taking \l{linear time}. - If \e this is not an empty QByteArray, a deep copy of the data is - performed, taking \l{linear time}. + If the byte array being prepended to is not empty, a deep copy of the + data is performed, taking \l{linear time}. \sa append(), insert() */ @@ -1936,13 +1936,13 @@ QByteArray &QByteArray::prepend(char ch) This is the same as insert(size(), \a ba). Note: QByteArray is an \l{implicitly shared} class. Consequently, - if \e this is an empty QByteArray, then \e this will just share - the data held in \a ba. In this case, no copying of data is done, + if you append to an empty byte array, then the byte array will just + share the data held in \a ba. In this case, no copying of data is done, taking \l{constant time}. If a shared instance is modified, it will be copied (copy-on-write), taking \l{linear time}. - If \e this is not an empty QByteArray, a deep copy of the data is - performed, taking \l{linear time}. + If the byte array being appended to is not empty, a deep copy of the + data is performed, taking \l{linear time}. This operation typically does not suffer from allocation overhead, because QByteArray preallocates extra space at the end of the data diff --git a/src/corelib/tools/qdatetime.cpp b/src/corelib/tools/qdatetime.cpp index 5b15ffad9d..88270643d9 100644 --- a/src/corelib/tools/qdatetime.cpp +++ b/src/corelib/tools/qdatetime.cpp @@ -1647,10 +1647,14 @@ QString QTime::toString(Qt::DateFormat format) const \li the hour with a leading zero (00 to 23, even with AM/PM display) \row \li m \li the minute without a leading zero (0 to 59) \row \li mm \li the minute with a leading zero (00 to 59) - \row \li s \li the second without a leading zero (0 to 59) - \row \li ss \li the second with a leading zero (00 to 59) - \row \li z \li the milliseconds without leading zeroes (0 to 999) - \row \li zzz \li the milliseconds with leading zeroes (000 to 999) + \row \li s \li the whole second, without any leading zero (0 to 59) + \row \li ss \li the whole second, with a leading zero where applicable (00 to 59) + \row \li z \li the fractional part of the second, to go after a decimal + point, without trailing zeroes (0 to 999). Thus "\c{s.z}" + reports the seconds to full available (millisecond) precision + without trailing zeroes. + \row \li zzz \li the fractional part of the second, to millisecond + precision, including trailing zeroes where applicable (000 to 999). \row \li AP or A \li use AM/PM display. \e A/AP will be replaced by either QLocale::amText() or QLocale::pmText(). @@ -2005,10 +2009,14 @@ QTime QTime::fromString(const QString& string, Qt::DateFormat format) \li the hour with a leading zero (00 to 23 or 01 to 12 if AM/PM display) \row \li m \li the minute without a leading zero (0 to 59) \row \li mm \li the minute with a leading zero (00 to 59) - \row \li s \li the second without a leading zero (0 to 59) - \row \li ss \li the second with a leading zero (00 to 59) - \row \li z \li the milliseconds without leading zeroes (0 to 999) - \row \li zzz \li the milliseconds with leading zeroes (000 to 999) + \row \li s \li the whole second, without any leading zero (0 to 59) + \row \li ss \li the whole second, with a leading zero where applicable (00 to 59) + \row \li z \li the fractional part of the second, to go after a decimal + point, without trailing zeroes (0 to 999). Thus "\c{s.z}" + reports the seconds to full available (millisecond) precision + without trailing zeroes. + \row \li zzz \li the fractional part of the second, to millisecond + precision, including trailing zeroes where applicable (000 to 999). \row \li AP \li interpret as an AM/PM time. \e AP must be either "AM" or "PM". \row \li ap @@ -3932,10 +3940,14 @@ QString QDateTime::toString(Qt::DateFormat format) const \li the hour with a leading zero (00 to 23, even with AM/PM display) \row \li m \li the minute without a leading zero (0 to 59) \row \li mm \li the minute with a leading zero (00 to 59) - \row \li s \li the second without a leading zero (0 to 59) - \row \li ss \li the second with a leading zero (00 to 59) - \row \li z \li the milliseconds without leading zeroes (0 to 999) - \row \li zzz \li the milliseconds with leading zeroes (000 to 999) + \row \li s \li the whole second without a leading zero (0 to 59) + \row \li ss \li the whole second with a leading zero where applicable (00 to 59) + \row \li z \li the fractional part of the second, to go after a decimal + point, without trailing zeroes (0 to 999). Thus "\c{s.z}" + reports the seconds to full available (millisecond) precision + without trailing zeroes. + \row \li zzz \li the fractional part of the second, to millisecond + precision, including trailing zeroes where applicable (000 to 999). \row \li AP or A \li use AM/PM display. \e A/AP will be replaced by either "AM" or "PM". \row \li ap or a @@ -3949,13 +3961,14 @@ QString QDateTime::toString(Qt::DateFormat format) const in the output. Formats without separators (e.g. "HHmm") are currently not supported. Example format strings (assumed that the QDateTime is 21 May 2001 - 14:13:09): + 14:13:09.120): \table \header \li Format \li Result \row \li dd.MM.yyyy \li 21.05.2001 \row \li ddd MMMM d yy \li Tue May 21 01 - \row \li hh:mm:ss.zzz \li 14:13:09.042 + \row \li hh:mm:ss.zzz \li 14:13:09.120 + \row \li hh:mm:ss.z \li 14:13:09.12 \row \li h:m:s ap \li 2:13:9 pm \endtable @@ -4963,10 +4976,14 @@ QDateTime QDateTime::fromString(const QString& string, Qt::DateFormat format) \li the hour with a leading zero (00 to 23, even with AM/PM display) \row \li m \li the minute without a leading zero (0 to 59) \row \li mm \li the minute with a leading zero (00 to 59) - \row \li s \li the second without a leading zero (0 to 59) - \row \li ss \li the second with a leading zero (00 to 59) - \row \li z \li the milliseconds without leading zeroes (0 to 999) - \row \li zzz \li the milliseconds with leading zeroes (000 to 999) + \row \li s \li the whole second without a leading zero (0 to 59) + \row \li ss \li the whole second with a leading zero where applicable (00 to 59) + \row \li z \li the fractional part of the second, to go after a decimal + point, without trailing zeroes (0 to 999). Thus "\c{s.z}" + reports the seconds to full available (millisecond) precision + without trailing zeroes. + \row \li zzz \li the fractional part of the second, to millisecond + precision, including trailing zeroes where applicable (000 to 999). \row \li AP or A \li interpret as an AM/PM time. \e AP must be either "AM" or "PM". \row \li ap or a diff --git a/src/corelib/tools/qlocale.cpp b/src/corelib/tools/qlocale.cpp index 43d83db835..789a15dded 100644 --- a/src/corelib/tools/qlocale.cpp +++ b/src/corelib/tools/qlocale.cpp @@ -2964,14 +2964,17 @@ QString QLocalePrivate::dateTimeToString(QStringView format, const QDateTime &da } else { repeat = 1; } - switch (repeat) { - case 1: - result.append(m_data->longLongToString(time.msec())); - break; - case 3: - result.append(m_data->longLongToString(time.msec(), -1, 10, 3, QLocaleData::ZeroPadded)); - break; + + // note: the millisecond component is treated like the decimal part of the seconds + // so ms == 2 is always printed as "002", but ms == 200 can be either "2" or "200" + result.append(m_data->longLongToString(time.msec(), -1, 10, 3, QLocaleData::ZeroPadded)); + if (repeat == 1) { + if (result.endsWith(zero())) + result.chop(1); + if (result.endsWith(zero())) + result.chop(1); } + break; case 't': |