summaryrefslogtreecommitdiffstats
path: root/src/corelib/text/qlocale.h
Commit message (Collapse)AuthorAgeFilesLines
* Update QLocale and calendar data to CLDR v44.1Edward Welbourne2024-02-021-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (This turns out to be identical to v44, for our purposes.) The CLDR license has been revised at v44 to "UNICODE LICENSE V3", which is now included (as LICENSES/UNICODE-3.0.txt) in addition to the old license (still in use, presumably, by UCD - at least until its next update). Some new QLocale::Language entries are needed. There is no change to the time-zone data. Some tests needed changes: * Various Arabic locales now use U+0623 (Arabic letter aleph with hamza above) in exponent separator, replacing plain U+0627 (Arabic letter aleph); it is still followed by U+0633 (Arabic letter seen). * Where likely sub-tags used to fill in world, 001, as territory for a language, they now (e.g. for Prussian and Yiddish) give specific countries. * Tamil locales now have something of a mix of inherited and localized forms for AM/PM, which looks a lot like a mistake in CLDR. * New likely sub-tag rules fix ctor(und_US) and ctor(und_GB), which previously failed. [ChangeLog][Third-Party Code] Updated QLocale's data extracted from the Unicode Common Locale Data Repository (CLDR) to v44.1. The license changed to Unicode License V3. Pick-to: 6.7 6.6 6.5 Fixes: QTBUG-121485 Task-number: QTBUG-121325 Change-Id: Ide1a68016129526d7a5aa3fc67f1a674858696bc Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Make public QLocale's constant for the two-digit-year baseIvan Solovev2024-01-221-10/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The private QLocale::FirstTwoDigitYear constant, which is used as a default value for the parameters in some methods, causes troubles for Qt for Python Team, because they need to use the default values in the binding code. It also potentially create some inconveniences for the users who want to write functions wrapping these methods. The name is also confusing, because, when read out of context, it implies that there might be SecondTwoDigitYear, etc... Rename QLocale::FirstTwoDigitYear to QLocale::DefaultTwoDigitBaseYear and make it public. Now when the constant is public, we can use it in QDate, instead of introducing another constant, so do that. The qdatetime.h header already includes qlocale.h via qcalendar.h, but, rather than relying on this transitive include, add it explicitly. As pointed out by Thiago [1], the static constexpr members of exported classes need out-of-line definitions, so add such definition to qlocale.cpp. Amends 41f84f3ddb780ec751e3fc706dd242fc4a99de7a Found in 6.7 API review. [1]: https://lists.qt-project.org/pipermail/development/2024-January/044888.html Pick-to: 6.7 Change-Id: Ib3c6f1d5b181968bf311fd0435173e025a369865 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* Give the caller control over the century used for two-digit datesEdward Welbourne2023-12-081-4/+27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The twentieth century is now some way behind us, so using its years when parsing a date-time format that only provides the last two digits is increasingly likely to produce unwelcome results. Most such formats are saved by the "redundant" presence of a day-of-week field but, for those that are not (notably including ASN.1 date fields), there is a need to provide some way to over-ride the twentieth century default. Allow the caller to pass a base year to the fromString() methods, of QDate and QDateTime, and to QLocale's toDate() and toDateTime(), that indicates the first of 100 consecutive years, among which the two digits given can select a year. Add some test-cases to exercise the new API. [ChangeLog][QtCore][QDate] When fromString() has only a two-digit year to go on, it is now possible to set the start-year of the century within which this selects. [ChangeLog][QtCore][QDateTime] When fromString() has only a two-digit year to go on, it is now possible to set the start-year of the century within which this selects. [ChangeLog][QtCore][QLocale] When toDate() or toDateTime() has only a two-digit year to go on, it is now possible to set the start-year of the century within which this selects. Fixes: QTBUG-46843 Change-Id: Ieb312ee9e0b80557a15edcb0e6d75a57b10d7a62 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* QLocale: Add Q_ENUM registration for some enumsOlivier De Cannière2023-08-301-0/+3
| | | | | | | | Fixes: QTBUG-116527 Pick-to: 6.5 6.6 Change-Id: If04bd5f504b3a8a39a35b9ba7024cdc9eb2d154a Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Give QLocale's name() and bcp47Name() separator parametersEdward Welbourne2023-08-181-1/+6
| | | | | | | | | | | | | Previously name() has always used underscore and bcp47Name() dash; let the user chose which one best fits their needs. [ChangeLog][QtCore][QLocale] QLocale's name() and bcp47Name() now let the caller chose what separator to use between the tags making up the name, where there is more than one. Change-Id: Ia689e6a3fb581b42905e7fb1ae7a7b688244d267 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Give QLocale::uiLanguages() a separator parameterEdward Welbourne2023-08-161-0/+5
| | | | | | | | | | | | | | | | | | | It has always returned dash-joined forms of the locale names, and callers who need an underscore-joined form have been obliged to replace('-', '_') before using them. Given that everything it adds to the list comes from QLocaleId methods that accept a separator, it's trivial to let it offer the same choice to its callers and save them this hassle. Amended code in QTranslater and QMimeType to save them that hassle. [ChangeLog][CoreLib][QLocale] QLocale::uiLanguages() now lets the caller choose what separator to use between the tags that make up each locale-identifier in the list returned. Change-Id: I91fcd0b988d9a64e0e9ad9e851f6cb8c1be8ae50 Reviewed-by: Marc Mutz <marc.mutz@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Update QLocale to CLDR v43Edward Welbourne2023-08-021-2/+7
| | | | | | | | | | | | Ran the scripts, added the new enum members to docs. Updated tests: * Two of the new languages are right-to-left, * Canada has replaced a silly date format with a sensible one. Fixes: QTBUG-111550 Change-Id: Ie6f1e6e94477167c9e2b5c67e6518ca0f6a7e7fb Reviewed-by: Mate Barany <mate.barany@qt.io> Reviewed-by: Ievgenii Meshcheriakov <ievgenii.meshcheriakov@qt.io>
* Move month names from QGregorianCalendar to QRomanCalendarEdward Welbourne2023-07-211-1/+1
| | | | | | | | | The other Roman-based calendars share the same month names as Gregorian, so it makes sense for them to use the same system fallbacks as it when available. Change-Id: Idf2f2901032c7a02d641f00a3993cc95b6bb8067 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Update CLDR to v42Mate Barany2023-02-071-1/+8
| | | | | | | | | | | | | | | | | | | | New languages (and one local for each) added with v42 - Haryanvi - Moksha - Northern Frisian - Obolo - Pijin - Rajasthani - Toki Pona It also appears that Canada has changed its date format. Modify the relevant test case to reflect this change. Task-number: QTBUG-110333 Pick-to: 6.5 Change-Id: Ia8975c2866cd54c9e565543d05bacd52f4987909 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Apply Q_FLAG to flag type instead of enum typeFabian Kosmale2022-10-191-2/+2
| | | | | Change-Id: I05cebef521a532654ae8fa306eed9c8db5a0db69 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* qlocale: Fix some flags not being exposed to the metatype systemMaximilian Goldstein2022-08-111-0/+2
| | | | | | | | | This caused it to be unavailable in metatypes and thus to not work in qml. Change-Id: I22b6fa3b43fe609bdc1167dc081290eb93845491 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* QLocale: Expose FormatTime enum via Q_ENUMMaximilian Goldstein2022-08-021-0/+1
| | | | | | | | | Previously it wasn't exposed to the metatypes system. Change-Id: I096fb505c957ff30a5dc43b30f02530513e5f85a Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* QVariant: make many more QtCore types nothrow-copyableThiago Macieira2022-07-301-2/+2
| | | | | | | | | | | | | | | All of those are implicitly-shared Qt data types whose copy constructors can't throw and have wide contracts (there aren't even any assertions for validity in any of them). These are all types with a QVariant implicit constructor, except for QCborValue, which is updated on this list so QJsonValue (which has a QVariant constructor) is also legitimately noexcept. To ensure we haven't made a mistake, the Private constructor checks again. Change-Id: I3859764fed084846bcb0fffd17044d8319a45e1f Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QtBase: eradicate QT_STRINGVIEW_LEVEL usesMarc Mutz2022-07-201-6/+0
| | | | | | | | | | | | It's not used and not useful. The macro itself has to stay, for now, because Qt5Compat uses it, too. Task-number: QTBUG-100861 Pick-to: 6.4 6.3 6.2 Change-Id: I5d0557a6c959d6facf6e47f26786a9d365339e95 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Long live QT_INLINE_SINCE!Marc Mutz2022-06-221-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We have now had several requests for inlining previously-exported member functions, but no standard mechanism to effect it. As QT_REMOVED_SINCE has shown, there is great value in having such a standard mechanism, so here is one. With this change, to inline a previously exported (member) function, simply - mark the declaration with QT_<MODULE>_INLINE_SINCE - move the definition into the header file (outside the class), - wrap it in QT_<MODULE>_INLINE_IMPL_SINCE - #include the header into the module's removed_api.cpp Just including the header into removed_api.cpp is enough, so you may want to add a comment: #include "header.h" // uses QT_<MODULE>_INLINE_SINCE The effect is as follows: - A TU in a _different_ library will see an inline declaration, followed by the definition, and so it will see a normal inline function. - A TU in the same library will, however, see a non-inline declaration, to avoid the ODR violation that at least GCC/ld are able to detect. - When QT_<MODULE>_BUILD_REMOVED_API is in effect, the TU will also see the definition, which is the same setup as before the change, except in a different TU, and therefore export the member. - When, OTOH, QT_<MODULE>_BUILD_REMOVED_API is _not_ in effect, the TU will see no declaration, assuming (correctly), that the definition will be supplied by a different TU. This is, of course, an ODR violation, but not worse than what we do elsewhere, as the definitions differ only between library and user. The function is inline only for the users of the library, not the library itself, which will still see the function as non-inline. If inlining is critical within the library, too, the existing function should call a new inline function, and calls in the same library should be changed to call the new inline function instead. Use the new mechanism to inline the QLocale ctor we intended to inline for 6.3, but couldn't, because we hadn't found the magic incantation, yet. Thiago found it a few weeks later, and this is what this patch is based on. Fixes: QTBUG-100452 Pick-to: 6.4 Change-Id: Ia0030cddc64b6b92edfed860170d5204aa74b953 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Use SPDX license identifiersLucie Gérard2022-05-161-38/+2
| | | | | | | | | | | | | Replace the current license disclaimer in files by a SPDX-License-Identifier. Files that have to be modified by hand are modified. License files are organized under LICENSES directory. Task-number: QTBUG-67283 Change-Id: Id880c92784c40f3bbde861c0d93f58151c18b9f1 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
* QLocale: Un-inline QString& constructorMårten Nordheim2022-02-041-1/+1
| | | | | | | | | | | Because it's BiC. From the API review. Pick-to: 6.3 Change-Id: I69f1fe58428241a876ae9058e8a0108a8e496c22 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Marc Mutz <marc.mutz@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QLocale: Use Q_CORE_REMOVED_SINCE instead of explicit version checksIevgenii Meshcheriakov2022-02-031-5/+2
| | | | | | | | | | | Use Q_CORE_REMOVED_SINCE macro for languageToCode()/codeToLanguage() API changes. Pick-to: 6.3 Change-Id: I8cc5279b1272165541c345241af49523c0f25737 Reviewed-by: Marc Mutz <marc.mutz@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* QtCore: replace qSwap with std::swap/member-swap where possibleMarc Mutz2022-01-201-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | qSwap() is a monster that looks for ADL overloads of swap() and also detects the noexcept of the wrapped swap() function, so it should only be used when the argument type is unknown. In the vast majority of cases, the type is known to be efficiently std::swap()able or to have a member-swap. Call either of these. For the common case of pointer types, circumvent the expensive trait checks on std::swap() by providing a hand-rolled qt_ptr_swap() template, the advantage being that it can be unconditionally noexcept, removing all type traits instantiations. Don't document it, otherwise we'd be unable to pick it to 6.2. Effects on Clang -ftime-trace of a PCH'ed libQt6Gui.so build: before: **** Template sets that took longest to instantiate: [...] 27766 ms: qSwap<$> (9073 times, avg 3 ms) [...] 2806 ms: std::swap<$> (1229 times, avg 2 ms) (30572ms) after: **** Template sets that took longest to instantiate: [...] 5047 ms: qSwap<$> (641 times, avg 7 ms) [...] 3371 ms: std::swap<$> (1376 times, avg 2 ms) [qt_ptr_swap<$> does not appear in the top 400, so < 905ms] (< 9323ms) As a drive-by, remove superfluous inline keywords and template ornaments. Task-number: QTBUG-97601 Pick-to: 6.3 6.2 Change-Id: I88f9b4e3cbece268c4a1238b6d50e5712a1bab5a Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* QLocale: Extend support for language codesIevgenii Meshcheriakov2021-12-091-0/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | | This commit extends functionality for QLocale::codeToLanguage() and QLocale::languageToCode() by adding an additional argument that allows selection of the ISO 639 code-set to consider for those operations. The following ISO 639 codes are supported: * Part 1 * Part 2 bibliographic * Part 2 terminological * Part 3 As a result of this change the codeToLanguage() overload without the additional argument now returns a Language value if it matches any know code. Previously a valid language was returned only if the function argument matched the first code defined for that language from the above list. [ChangeLog][QtCore][QLocale] Added overloads for codeToLanguage() and languageToCode() that support specifying which ISO 639 codes to consider. Fixes: QTBUG-98129 Change-Id: I4da8a89e2e68a673cf63a621359cded609873fa2 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* QLocale: Add support for Kaingang and Nheengatu languagesIevgenii Meshcheriakov2021-11-101-1/+3
| | | | | | | | | | Update the locale generation script to support Kaingang and Nheengatu languages. These are new in CLDR v40. Regenerate the locale data. Task-number: QTBUG-94358 Change-Id: I5195d5161d8c4d9f17129bbcfde39dfd3fcf1cd5 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Add a QLocale(QStringView) constructorEdward Welbourne2021-09-011-1/+4
| | | | | | | | | | | Only a few more internals just needed to change to take QStringView, to connect up the constructor with internals already long since converted. [ChangeLog][QtCore][QLocale] Added QLocale(QStringView) constructor. Change-Id: Iec31391e6168f333b4b6fc633c3d7d01872f83b3 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Consolidate documentation of floating-point formatting codeEdward Welbourne2021-08-031-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Move the documentation of the format and precision parameters to QLocale::toString(double, char, int), reference it from various QString methods (instead of repeating there and referencing one of those from QLocale). Add brief first lines for various documentation comments. Mention the special handling of negative precision in the moved documentation. Mention QLocale::FloatingPointShortest, add its type to \sa lines of methods it affects. Change a comment on some code implementing its special treatment to make clear that it does apply to 'e' and 'f' formats, not only to 'g', even though it has no overt special handling in that code; and update docs to report the undocumented behavior the comment previously described. Document how infinity and NaN are represented. Be somewhat more consistent about single-quoting the format names where referred to and applying \c to character constants. Make clear what things are different between different methods using these parameters. Reference QString::number() from QByteArray's relevant methods, since they share its quirks. In the process, rename the format and precision parameters of relevant functions so they're consistently named, replacing a mixture of abbreviated forms. Pick-to: 6.2 Change-Id: I077521b30346000e4b4f6968a8e750e934f72937 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Revise deprecation of countriesForLanguage()Edward Welbourne2021-04-161-3/+3
| | | | | | | | | | | | | | | | | It was originally marked \obsolete without any comment on what was to be used to replace it, or deprecation markings in the declaration, so it got missed at 6.0. More recently it's been deprecated in favor of a territory-based name; but actually it was obsoleted by (iterating the territory() of each return from) matchingLocales() in Qt 4.8. So back out of adding territoriesForLanguage to replace it and, instead, mark it as deprecated in the declaration, in favor of matchingLocales(). Also rewrite the implementation to be exactly that replacement. Rewrote the one example using it. Fixes: QTBUG-92484 Change-Id: Iedaf30378446dd9adac5128b7ee5fee48aab1636 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Make script and territory optional in QLocale constructorsEdward Welbourne2021-04-151-3/+3
| | | | | | | | | | | | | Previously the (language, territory) constructor had optional territory; however, the (language, script, territory) one required all three. Making the latter's script and territory optional, while requiring the former to pass territory, makes it possible to construct with (language), with (language, territory), with (language, script) or with (language, script, territory), without (overt) use of AnyScrit or AnyTerritory. Change-Id: Iaf6e46c473042d886eee7068515f9e41a704c2e7 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Add the "Territory" enumerated type for QLocaleJiDe Zhang2021-04-151-8/+38
| | | | | | | | | | | | | | | | | | | The use of "Country" is misleading as some entries in the enumeration are not countries (eg, HongKong), for all that most are. The Unicode Consortium's Common Locale Data Repository (CLDR, from which QLocale's data is taken) calls these territories, so introduce territory-based names and prepare to deprecate the country-based ones in due course. [ChangeLog][QtCore][QLocale] QLocale now has Territory as an alias for its Country enumeration, and associated territory-based names to match its country-named methods, to better match the usage in relevant standards. The country-based names shall in due course be deprecated in favor of the territory-based names. Fixes: QTBUG-91686 Change-Id: Ia1ae1ad7323867016186fb775c9600cd5113aa42 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QLocale: Allow direct conversion from language, country, and script codesKai Köhne2021-01-251-0/+3
| | | | | | | | | | | | | | | This complements patch a148c7b5d71d244, where languageToCode(), countryToCode() scriptToCode() methods were introduced, with matching codeToLanguage(), codeToCountry(), and codeToScript() methods. This allows us to remove the use of private Qt Core API in Qt Linguist. [ChangeLog][QtCore][QLocale] Added static codeToLanguage(), codeToCountry(), codeToScript() methods that convert ISO code strings to the respective enum values. Change-Id: If5c0843a718c006ade086a6f74ceb86ac6e0fce4 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* QLocale: Allow direct conversion to language, country, and script codesKai Köhne2021-01-181-0/+4
| | | | | | | | | | | | | | | | | | | | Currently the codes are only exposed in aggregated form, i.e. through name(), bcp47Name(). There are use cases though where you are only interested in either language, country, or script codes. One example is in Qt Linguist. This patch therefore exposes the static languageToCode(), countryToCode(), scriptToCode() methods that were so far only available in the private API also in the public API. [ChangeLog][QtCore][QLocale] Added static languageToCode(), countryToCode() scriptToCode() methods that convert enum values to the respective ISO code strings. Fixes: QTBUG-39542 Fixes: QTBUG-64942 Change-Id: Ib1d5c3293e2f53245ba4c1fc8159275bcb290080 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Clean up docs of QCalendar-related QLocale::toString() variantsEdward Welbourne2020-11-231-3/+4
| | | | | | | | | | | | | Some of the new functions were added without documentation, or without updating the docs to mention the optional calendars. Shuffle the methods so that the one with calendar is what the primary documentation comment describes and the one without is documented as an overload. Pick-to: 5.15 Change-Id: Iee4cdb1d3b0ed21a50e205a5275a0695a2667550 Reviewed-by: Paul Wicking <paul.wicking@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Inline QLocale's QString overloads via QStringViewEdward Welbourne2020-11-171-17/+29
| | | | | | | | Make declarations use same parameter name as implementation and documentation, in the process. Fixed indent of some doc comments. Change-Id: Ibaa3a5f6316a16c5b65f6ea6e0034f4eb2864b98 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Reorder locale enums alphabeticallyEdward Welbourne2020-11-081-728/+728
| | | | | | | | | | | | | Binary-incompatible change: change the numeric values of QLocale's Language, Script and Country enums, as encouraged by a comment in the generator script enumdata.py and clarify documentation around that. In the process (since I was changing almost every line anyway), convert the dictionary values from (mutable) lists of length two to tuples, since they are (and should be) immutable data. Change-Id: I26222bce45b9f5074b1d81ed70015a75ac34adcd Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Use newer names for various languages, territories and scriptsEdward Welbourne2020-11-081-27/+53
| | | | | | | | | | Our enumdata.py namings of countries had fallen somewhat out of sync with CLDR's names. In the process, support including hyphenation in the unsquashed name, along with spacing. Distinguish, in comments, between older renamings and those first seen in Qt6. Change-Id: I91ec444bf35222ab6a9332e389ace19cca0e4fdf Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Turn QLocale's operator==() and operator!=() into hidden friendsEdward Welbourne2020-11-071-3/+4
| | | | | | | Update docs to match. Add note on the conditions for equality. Change-Id: I973b7a5dae3fae2e62f8a0d1db1f3115d24bee8b Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Purge deprecated language and country codes from QLocaleEdward Welbourne2020-10-291-102/+0
| | | | | | | | | | | | | | | | | | | | Requires subsequent re-numbering of the enum tables to eliminate gaps, before locale data can be regenerated. However, it will work with the present locale data, since it merely loses the means to use some names for which the available data was just the name and code. This implies a transient issue of recognising some codes for which there is no actual enum member; but relevant code will work as before, finding nothing but the code and its name. This shall be resolved by a coming BiC change to resort the language, country and script codes, changing the numbering (almost) completely. [ChangeLog][QtCore][QLocale] Various obsolete language and country codes have been removed. Some lacked locale data, others were obsolete aliases. All have been deprecated in 5.15. Task-number: QTBUG-84669 Change-Id: I45fc76a5f2f6c3b0ea3c1bb61e917da984183783 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Deprecate old aliases for two countries and several languagesEdward Welbourne2020-10-281-7/+13
| | | | | | | | | | [ChangeLog][QtCore][QLocale] Deprecated several Language and Country aliases, ready for removal in Qt 6.0, in favor of their newer names. Task-number: QTBUG-84669 Pick-to: 5.15 5.15.2 Change-Id: Iebaa0a5a77bfa12f7014de53fab4a25b5f1cc92c Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Deprecate QLocale::Language entries that no locale data relates toEdward Welbourne2020-10-281-43/+89
| | | | | | | | | | | | | | | | | These are languages for which CLDR does not even recognize the claimed language code (three-letter codes except for bh = Bihari, which might be an old name for bho = Bhojpuri, which CLDR does give, but provides no locale data using it). [ChangeLog][QtCore][QLocale::Language] Many obsolete language names are now deprecated in preparation for removal at Qt 6.0. No data has been available for any locale using these languages since CLDR v29 (at least; Qt now uses v37). Task-number: QTBUG-84669 Pick-to: 5.15 5.15.2 Change-Id: I2bf2d49211ade7cc511277f35fb1a247e7048b31 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Update CLDR to v37, adding Nigerian Pidgin as a new languageEdward Welbourne2020-10-261-1/+2
| | | | | | | | | | | | | | | | Routine update by running scripts, ignoring clang-format's extensive grumbles. Added notes to util/locale_database/'s README, on the need for that, and enumdata.py, on when to add entries. As usual, several new locales are also added, for existing languages, territories and scripts. [ChangeLog][QtCore][QLocale] Updated to new version of CLDR (the Unicode Consortium's Common Locale Data Repository) v37. Fixes: QTBUG-84669 Pick-to: 5.15 Change-Id: Ib76848bf4bd1219180faf46820077e8d8049a4e3 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* QLocale: do the inlining in the class body to save repetitionEdward Welbourne2020-10-191-36/+17
| | | | | | | | It also makes it easier to find the definition when looking at the declaration. Change-Id: Idae18d3881f3cf8ba6c6c7e48201ec925815013e Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Mark QLocale's Language, Country and Script enums as ushortEdward Welbourne2020-10-121-3/+3
| | | | | | | | | | The code pervasively presumes their values can be held in a ushort, so make sure the compiler knows we expect that to work (and doesn't complain about narrowing when we do convert them to ushort). Change-Id: Idde7be6cceee8a6dae333c5b1d5a0120fec32e4a Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Centralize the implementation of move assignment operatorsGiuseppe D'Angelo2020-10-031-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | At the moment we have two main strategies for dealing with move assignment in Qt: 1) move-and-swap, used by "containers" (in the broad sense): containers, but also smart pointers and similar classes that can hold user-defined types; 2) pure swap, used by containers that hold only memory (e.g. QString, QByteArray, ...) as well as most implicitly shared datatypes. Given the fact that a move assignment operator's code is just boilerplate (whether it's move-and-swap or pure swap), provide two _strictly internal_ macros to help write them, and apply the macros across corelib and gui, porting away from the hand-rolled implementations. The rule of thumb when porting to the new macros is: * Try to stick to the existing code behavior, unless broken * if changing, then follow this checklist: * if the class does not have a move constructor => pure swap (but consider ADDING a move constructor, if possible!) * if the class does have a move constructor, try to follow the criteria above, namely: * if the class holds only memory, pure swap; * if the class may hold anything else but memory (file handles, etc.), then move and swap. Noteworthy details: * some operators planned to be removed in Qt 6 were not ported; * as drive-by, some move constructors were simplified to be using qExchange(); others were outright broken and got fixed; * some contained some more interesting code and were not touched. Change-Id: Idaab3489247dcbabb6df3fa1e5286b69e1d372e9 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* Move QStringRef and remains to Qt5CompatKarsten Heimrich2020-08-201-1/+0
| | | | | | | | | Export some private functions from QUtf8 to resolve undefined symbols in Qt5Compat after moving QStringRef. Task-number: QTBUG-84437 Change-Id: I9046dcb14ed520d8868a511d79da6e721e26f72b Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Remove non-Qt6 compile time switches from QtCoreAllan Sandfeld Jensen2020-07-241-12/+0
| | | | | | | | We already manage to compile without this code, and none of it are full classes or separate functions suitable for qt5compat. Change-Id: I47facac7ec621cfc4b0b26214b7de37897443519 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* QLocale: purge deprecated APIEdward Welbourne2020-07-231-6/+0
| | | | | | | | Since 5.15 - toTime() with a calendar in the argument list The calendar was never used. Change-Id: I37897d47b42e69d1a8312e6389d6349febb889ae Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Remove more QStringRef overloads that aren't requiredLars Knoll2020-06-111-11/+0
| | | | | | | | The QStringView versions will do the job just fine :) Task-number: QTBUG-84319 Change-Id: I376b310deb27683fd98bbcc55e0f56014cacecc3 Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
* Port QLocale::quoteString from QStringRef to QStringViewLars Knoll2020-06-111-2/+3
| | | | | | | Task-number: QTBUG-84319 Change-Id: I29726ebfda7a5f51a0a6ee29e905b0b904256c8d Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Change qHash() to work with size_t instead of uintLars Knoll2020-04-091-2/+2
| | | | | | | | | | | This is required, so that QHash and QSet can hold more than 2^32 items on 64 bit platforms. The actual hashing functions for strings are still 32bit, this will be changed in a follow-up commit. Change-Id: I4372125252486075ff3a0b45ecfa818359fe103b Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Merge remote-tracking branch 'origin/5.15' into devQt Forward Merge Bot2020-04-081-1/+1
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: examples/opengl/doc/src/cube.qdoc src/corelib/global/qlibraryinfo.cpp src/corelib/text/qbytearray_p.h src/corelib/text/qlocale_data_p.h src/corelib/time/qhijricalendar_data_p.h src/corelib/time/qjalalicalendar_data_p.h src/corelib/time/qromancalendar_data_p.h src/network/ssl/qsslcertificate.h src/widgets/doc/src/graphicsview.qdoc src/widgets/widgets/qcombobox.cpp src/widgets/widgets/qcombobox.h tests/auto/corelib/tools/qscopeguard/tst_qscopeguard.cpp tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp tests/benchmarks/corelib/io/qdiriterator/qdiriterator.pro tests/manual/diaglib/debugproxystyle.cpp tests/manual/diaglib/qwidgetdump.cpp tests/manual/diaglib/qwindowdump.cpp tests/manual/diaglib/textdump.cpp util/locale_database/cldr2qlocalexml.py util/locale_database/qlocalexml.py util/locale_database/qlocalexml2cpp.py Resolution of util/locale_database/ are based on: https://codereview.qt-project.org/c/qt/qtbase/+/294250 and src/corelib/{text,time}/*_data_p.h were then regenerated by running those scripts. Updated CMakeLists.txt in each of tests/auto/corelib/serialization/qcborstreamreader/ tests/auto/corelib/serialization/qcborvalue/ tests/auto/gui/kernel/ and generated new ones in each of tests/auto/gui/kernel/qaddpostroutine/ tests/auto/gui/kernel/qhighdpiscaling/ tests/libfuzzer/corelib/text/qregularexpression/optimize/ tests/libfuzzer/gui/painting/qcolorspace/fromiccprofile/ tests/libfuzzer/gui/text/qtextdocument/sethtml/ tests/libfuzzer/gui/text/qtextdocument/setmarkdown/ tests/libfuzzer/gui/text/qtextlayout/beginlayout/ by running util/cmake/pro2cmake.py on their changed .pro files. Changed target name in tests/auto/gui/kernel/qaction/qaction.pro tests/auto/gui/kernel/qaction/qactiongroup.pro tests/auto/gui/kernel/qshortcut/qshortcut.pro to ensure unique target names for CMake Changed tst_QComboBox::currentIndex to not test the currentIndexChanged(QString), as that one does not exist in Qt 6 anymore. Change-Id: I9a85705484855ae1dc874a81f49d27a50b0dcff7
| * Rework qlocalexml2cpp.py to use writers based on TranscriberEdward Welbourne2020-04-021-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This saves repetition of temporary-file manipulation code. In the process, ensure that we tidy away temporary files on failure. Moved a comment in qlocale.h to *outside* the re-written portion, to save having to rewrite it every time. Added blank lines to separate script data from country data in the generated output. Changed 0s in one comment to zeros, to match another comment. Isolated use of sys to the __main__ block. Isolated use of enumdata to the new LocaleHeaderWriter class. Modernised all the string-formatting I touched. Task-number: QTBUG-81344 Change-Id: I5768e45d9a8ea23facc303b3dd8af8b3ccbf7ff2 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* | Make QLocale(QString) explicitLars Knoll2020-04-011-1/+1
| | | | | | | | | | | | | | | | We should not implicitly convert a QString to a QLocale object. It can easily create unwanted side effects. Change-Id: I7bd9b4a4e4512c0e60176ee4d241d172f00fdc32 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* | Pass QDate and QTime as value classesEdward Welbourne2020-02-271-8/+8
| | | | | | | | | | | | | | | | | | It's what they are, so const refs are needless burden. In the process, consolidate two of the affected methods (one of which just adds another argument to the other's signature) into one. Change-Id: I80de35ffe078a652d1999889dede0b10302abaa9 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>