Commit Graph

67573 Commits (3c9bb0daaf0cbff9135f88e55bae8243aa937faa)

Author SHA1 Message Date
Thiago Macieira 3c9bb0daaf tst_qfloat16: don't cause UB in converting from float to ints
The test data is provided as float, so we must obey [conv.fpint]/1 when
converting from float to integer types. There are values in the rows
that are outside of the range of short and shorter integers, so just
check the range.

Fixes: QTBUG-125889
Pick-to: 6.7
Change-Id: If3345151ddf84c43a4f1fffd17d405ee0cd00d44
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2024-05-30 17:23:35 -03:00
Volker Hilsheimer 626831db34 Android: enable QIcon test case
The test passes locally, and if individual functions should fail, then
skip those.

Change-Id: Ib9123bacaff2a83c2bc378b37201fd1d75dfdb45
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2024-05-30 22:23:35 +02:00
Marc Mutz 5677c111cb QFormData(Part)Builder: simplify filename formatting
We don't need the bodyName member, because it's the same as
originalBodyName, just encoded, and we can delay the encoding to
build() time.

This is not worse than the old code, since we anyway toString() the
QAnyStringView unconditionally.

So we don't need to visit the QASV and implement RFC2232 encoding for
all three view types, we can just use the QString version, after
toString().

This not only has the advantage of less code and not storing duplicate
data, but we now also encode u8"ä.txt" the same as "ä.txt"_L1 and
u"ä.txt", ie. using latin1, as required by Postel's Law, and not as
UTF-8, as the old code did.

Change-Id: If82a33a1cd09b859b3a4450a60083b1d3aedf7bc
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2024-05-30 20:52:42 +02:00
Mate Barany 32610561e3 Add convenience classes to generate QHttpMultipart messages
Constructing and composing a QHttpMultipart contains some aspects that
are possible candidates for automating, such as setting the headers
manually for each included part. As a reference, when issuing a default
multipart with CURL, one does not need to manually set the headers.

Add the class QFormDataPartBuilder to simplify the construction of
QHttpPart objects.

Add the class QFormDataBuilder to simplify the construction of
QHttpMultiPart objects.

[ChangeLog][QtNetwork][QFormDataBuilder] New class to help constructing
multipart/form-data QHttpMultiParts.

Fixes: QTBUG-114647
Change-Id: Ie035dabc01a9818d65a67c239807b50001fd984a
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2024-05-30 18:52:42 +00:00
Eirik Aavitsland a5953d20e2 Add QPaintDevice metric query to get precise fractional DPR value
For compatibility reasons, QPaintDevice needs to query subclasses for
device metrics as int values. To report fractional DPR values, they
have been multiplied with a large constant and divided back
afterwards. However, the loss of accuracy introduced by this, though
tiny, could still lead to rounding errors and painting artefacts when
the values where multiplied up for large coordinates.

Avoid this issue by adding a metric query that transports the full
floating point value encoded as two ints.

[ChangeLog][QtGui] Added new QPaintDevice metrics for querying
fractional device pixel ratios with high precision. Custom paintdevice
classes that support fractional DPRs are recommended to implement
support for these queries in metric(). Others can ignore them.

Fixes: QTBUG-124342
Change-Id: Ia6fa46e68e9fe981bdcbafb41daf080b4d1fb6d7
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2024-05-30 20:51:46 +02:00
Rym Bouabid 890c270b9b QPointer: Use new comparison helper macros
Provide the new comparesEqual() helper function as an implementation of
(in)equality operators.
Use QT_DECLARE_EQUALITY_OPERATORS_HELPER macro instead of
Q_DECLARE_EQUALITY_COMPARABLE for the comparison between QPointer<T>
and QPointer<X> to avoid creating the reversed version of the
operators in C++17 mode.

Use new \compares command in the documentation to describe the
comparison operators provided by QPointer.

Task-number: QTBUG-120306
Change-Id: Iff24d3ef5c790de7f06ab825f853e06186fa1471
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2024-05-30 20:51:46 +02:00
Edward Welbourne 99475db542 Revise Windows time-zone mapping to use proper IANA IDs
The CLDR's "IANA" IDs may (for the sake of stability) date back to
before IANA's own naming has been updated. As a result, the "IANA" IDs
we were using were in some cases out of date. CLDR does provide a
mapping from its stable IDs to all aliases and the current IANA name
for each (which I shall soon be needing in other work), so use that to
map the CLDR IDs to contemporary IANA ones.

Revise the documentation of CldrAccess.readWindowsTimeZones() to take
this into account, pass it the alias mapping from the table, use that
to map IDs internally and, in passing, rename a variable.  Update
cldr2qtimezone.py to match the new CldrAccess methods and regenerate
the data.

Change-Id: I23d8a7d048d76392099d125376b544a41faf7eb3
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Mate Barany <mate.barany@qt.io>
2024-05-30 20:28:55 +02:00
Edward Welbourne e2e5ab0932 Add QTimeZone::aliasMatches()
This makes it possible for the stdCompatibility() test to cope with
the backend (based on the Windows Registry, which disagrees with MS's
ICU-based std::chrono::tzdb) successfully constructing a zone, by
finding a known alias, instead of failing because it doesn't know the
name. It may also be useful to client code when dealing with legacy
names.

Amended some existing tests to only expect what they now should and
added some tests specific to aliasMatches(). Also added some
explanative comments where it isn't needed.

Task-number: QTBUG-115158
Change-Id: I095bdbead78df339e29b29518d5010ef905fa8b2
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2024-05-30 20:28:55 +02:00
Edward Welbourne c464f67db4 tst_QTimeZone::stdCompatibility(): fix handling of unknown IDs
Follow-up to commit 69555b364d, using
QTimeZone::isTimeZoneIdAvailable() instead of trying to construct an
ad-hoc test for known unknonwn zone IDs.

Reopens: QTBUG-102187
Fixes: QTBUG-102187
Change-Id: I36ff4f1dfbc4035d73df5b8fd68376c1bc9641e1
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2024-05-30 20:28:55 +02:00
Tatiana Borisova bf9f6791cd Put conditioned header under appropriate feature configuration
- Add #if QT_CONFIG(xmlstream) for qxmlstream.h usage
in removed_api.cpp

Amends cd5dd8b95b

Change-Id: Ibb5962ff1ee9d26a2f115c6cf0a8b9b88109fab7
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2024-05-30 19:33:20 +02:00
Alexei Cazacov ce26eaf1b9 Docs: Update the obsolete requirements for Q_OBJECT and Q_GADGET
Since 6.5, you can declare the Q_OBJECT macro in any class section, not
only in private. The docs are updated accordingly. The Q_OBJECT macro
specifies a private section on its own, thus making private all the
members declared after the macro. This is an important behavior change,
so the note about it was rewritten for clarity & moved a little bit up.

Fixes: QTBUG-125776
Pick-to: 6.5 6.6 6.7
Change-Id: Ifba063af7cf7fe7258b6183da5a4599784171052
Reviewed-by: Nicholas Bennett <nicholas.bennett@qt.io>
2024-05-30 19:05:04 +03:00
Marc Mutz 2b6a77cd15 QMessageAuthenticationCode: add hashInto() overloads
Same change as previously done for QCryptographicHash; same rationale
applies.

[ChangeLog][QtCore][QMessageAuthenticationCode] Added hashInto()
methods, see QCryptographicHash for more information.

Fixes: QTBUG-125431
Change-Id: I88a15479b020b39ff0669a9615793886289c83f7
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2024-05-30 06:23:45 +00:00
Ahmad Samir 1c6f594c38 QDirListing: split a unitttest for easier debugging
Also rename the subdirs in the hiddenDirs_hiddenFiles test dir,
normalDirectory/normalDirectory/ is a bit confusing.

Make the test more deterministic by comparing lists of files/dirs
instead of just counts.

Change-Id: I12fdb5428bbef8382d4ee591792d167abcd216cf
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2024-05-30 03:41:57 +03:00
Volker Hilsheimer 87896c03c1 QIcon: enable icon engine plugins to implement themes
So far, the keys of icon engine plugins were only interpreted as the
suffix of icon files, loaded via QIcon(filename). However, an icon
engine could provide a lot more flexibility if it could implement an
entire theme.

Match the list of keys a plugin can register itself with also against
the current theme name. If a matching plugin is found, use that plugin
to create the icon engine. Store the factory from the plugin to avoid
costly lookups for each icon.

Extend the QIcon test case by adding a custom plugin that supports two
themes. Since the plugin and icon engine creation infrastructure
doesn't communicate which theme the plugin was created for, use
QIcon::themeName to record the current theme when the engine gets
created.

[ChangeLog][QtGui][QIconEnginePlugin] The keys registered by an
QIconEnginePlugin implementation are now also matched against the
current theme (system or user theme), allowing engine providers
to implement entire themes through a plugin.

Change-Id: I8a5e30ff8b5bb7c78b5204e82760e4328671e4c1
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2024-05-30 02:36:04 +02:00
Marc Mutz 5831c31235 totally_ordered_wrapper: add swap and qHash overloads; std::hash specialization
Pointers have these.

We also have qt_ptr_hash for raw pointers, so add an ADL overload for
that, too.

Don't provide a member-swap, since raw pointers don't have that.

Change-Id: I1517588d2ff1aa5caf06ad5861ff09d5e7652183
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2024-05-30 00:40:38 +02:00
Marc Mutz d397ae4c06 totally_ordered_wrapper: make default-constructible
Pointers are.

The default-constructor is = default'ed, meaning it has the same
semantics as the raw pointer it replaces:

   totally_ordered_wrapper<int*> p; // partially-formed (uninit'ed)
   totally_ordered_wrapper<int*> p{}; // well-formed (nullptr)

   totally_ordered_wrapper<int*> a[1024]; // doesn't write 8KiB of NULs

Change-Id: I0d2e906bc5ec45d95b03a3af451167fec84439fd
Reviewed-by: Rym Bouabid <rym.bouabid@qt.io>
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2024-05-30 00:40:38 +02:00
Marc Mutz 9dbe681218 totally_ordered_wrapper: make ctor noexcept
Copying pointers is noexept.

Adding unconditional noexcept doesn't limit us to switch to
conditional noexcept going forward, because any P for which
copy-construction isn't noexcept is currently excluded by the
static_assert(is_pointer).

Change-Id: I475e6294515a4c76bb31974cd6fd458fb0c0d42e
Reviewed-by: Rym Bouabid <rym.bouabid@qt.io>
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2024-05-30 00:40:38 +02:00
Marc Mutz ccb8efbfe5 qminmax.h: move QTypeTraits part to qttypetraits.h
Makes sense to collect the stuff in a similarly-named header.

Change-Id: Ic4190932a32fa06f1219473583327424dd2a8c11
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2024-05-30 00:40:38 +02:00
Alexandru Croitor 358effb7a3 CMake: Add a _qt_internal_forward_function_args function
It's a helper to pass along option arguments that are set by
cmake_parse_arguments, from the current scope to another function
call.

It avoids a lot

 if(arg_FOO) set(options FOO ${arg_FOO})

boilerplate.

It is somewhat the opposite of _qt_internal_remove_args.

The options that the function takes are prefixed with FORWARD_
to avoid possible naming conflicts with the actual options that should
be forwarded.

Change-Id: I54fd22b884d8af8379f2f735eb911a3bc66d3416
Reviewed-by:  Alexey Edelev <alexey.edelev@qt.io>
2024-05-29 23:01:47 +02:00
Alexandru Croitor 58eefbd0b6 CMake: Record package provided targets in Dependencies.cmake files
Each qt_find_package can specify a PROVIDED_TARGETS option, to inform
which targets will be created by that package.
The call then saves the package name, version, etc on each of the
provided targets.

Currently the provided targets info is not persisted anywhere after
configuration ends.

We will need this for SBOM creation, so that we can collect
information about such dependencies when configuring leaf
repos, where find_dependency calls are implicit, and don't contain
the PROVIDED_TARGETS option, and we need to go from package name to
target name (and any recorded info it the target has).

This is especially relevant for static library builds, where private
dependencies become public dependencies.

Collect the provided targets information at post process time and
persist it for each 'package name + components requested' combination
into the Dependencies.cmake file.

This information will be used in a later change for SBOM generation.

Change-Id: I1693f81b1ad3beaf9b02e44b09a5e977923f0d85
Reviewed-by:  Alexey Edelev <alexey.edelev@qt.io>
2024-05-29 23:01:47 +02:00
Alexandru Croitor 28c8f8e92a CMake: Pass along the version in FindWrap cmake scripts
The QtFindWrapHelper include used in FindWrap scripts can choose to
call find_package() on one of two packages. The packages might set a
VERSION variable. We should set the same version for the FindWrap
package as well.

There are two sources where the version will be queried from. First
from the underlying ${package_name}_VERSION variable.

And if that is empty, from a property that is set by qt_find_package()

The former might be empty because find_package might be called from
a function instead of a macro, which is the case for any find_package
call in configure.cmake files that get loaded by the
qt_feature_evaluate_features function.
Thus we need the indirection via the property that qt_find_package
will set.

Change-Id: I57fd818cb9dedf5e27a6d805e3d817d8d18be36d
Reviewed-by:  Alexey Edelev <alexey.edelev@qt.io>
2024-05-29 23:01:47 +02:00
Alexandru Croitor 8fe9cabe16 CMake: Add functions to safely append to cmake properties
Encapsulate the boilerplate logic of querying a property and setting
it to an empty string instead of NOTFOUND, before appending a value,
removing duplicates and assigning the values back to the property.

Change-Id: I7aefd11e9bdd77090324ec50c682d62181d22076
Reviewed-by:  Alexey Edelev <alexey.edelev@qt.io>
2024-05-29 23:01:47 +02:00
Alexandru Croitor 0e984f41e8 CMake: Move some functions into QtPublicCMakeHelpers
Move the implementations into QtPublicCMakeHelpers and just forward
to those public implementations in the old code.

The new public api will be used in the public sbom cmake files.

Change-Id: I979319935611e3f553ebd414f8304f1a3163c4ee
Reviewed-by:  Alexey Edelev <alexey.edelev@qt.io>
2024-05-29 23:01:47 +02:00
Alexandru Croitor 84a9f934b2 CMake: Fix calling some functions in CMake 3.16
Calling qt_internal_get_framework_info failed when the target was
an INTERFACE_LIBRARY, because it tried to access properties that
aren't allowed on such a target. Interface libraries can't be
frameworks, so just add an early return guard.

Do the same for qt_internal_apply_apple_privacy_manifest.

Change-Id: I85b73449a0d56b92cd01b032d4ce5db905643c9f
Reviewed-by:  Alexey Edelev <alexey.edelev@qt.io>
2024-05-29 23:01:47 +02:00
Alexandru Croitor a1445670f5 CMake: Fix configs passed to qt_get_install_target_default_args
Because the configs passed to the ALL_CMAKE_CONFIGS option were quoted
cmake_parse_arguments(PARSE_ARGV) would escape the semicolon in
the set value, effectively doing
 set(arg_ALL_CMAKE_CONFIGS "Release\;Debug")

Then the
 list(GET arg_ALL_CMAKE_CONFIGS 0 first_config)
call would essentially do
 set(first_config "Release;Debug")
and the
 if(all_configs_count GREATER 1
    AND NOT arg_CMAKE_CONFIG STREQUAL first_config)
condition would never trigger because a single config string can never
equal a double config string.

Remove the quotes to ensure correct behavior.

This won't really trigger any behavior change, because we exclude
installation of Debug executables in -debug-and-release builds,
but it will make --trace-expand logs less confusing.

Amends f240d94f14

Pick-to: 6.7
Change-Id: I53179511c7698c90b33cb3ff2762cef680a99815
Reviewed-by:  Alexey Edelev <alexey.edelev@qt.io>
2024-05-29 23:01:47 +02:00
Tatiana Borisova d5493d616f Put conditioned header under appropriate feature configuration
- Add #if QT_CONFIG(mimetype) for qmimetype.h usage
in removed_api.cpp

Amends 5dbd6a44d8

Change-Id: I0ef3c07bba7c3df56cfd1551d8962ab2efc15651
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Reviewed-by: Tasuku Suzuki <tasuku.suzuki@signal-slot.co.jp>
2024-05-29 20:40:10 +02:00
Robert Löhning 257bbd84e8 tst_qmatrixnxn: Mark variable as unused to avoid compiler warning
Change-Id: Ieae8716683530769a22473dfac616776cc96a359
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2024-05-29 20:27:18 +02:00
Wladimir Leuschner b457376c03 QWindows11Style: Increase min size of QAbstractSpinbox Widgets
With WinUI3 a new layout of the lineedit and buttons was introduced. The
buttons are now aligned horizontally instead of vertically. Trying to
mimic that layout in widgets results in too few space for the text in
the lineedit. This patch increases the minimum width when using the
QWindows11Style for QAbstractSpinBox elements and saves the original
width in a property in case the style is changed at runtime to restore
the original geometry.

Fixes: QTBUG-124235
Fixes: QTBUG-124150
Pick-to: 6.7
Change-Id: I8067b338fa4a2c1efd0a1b0644fb8a563601385b
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2024-05-29 20:12:45 +02:00
Tor Arne Vestbø 1dd916fec3 coin: Ignore CTest exit code for Tart configs, unless module overrides
By selectively setting the COIN_CTEST_IGNORE_EXIT_CODE we can allow
modules to gradually become significant, without touching qt5.git

Change-Id: Ie5b6e683cd755b1cf46886bb30803a56885a11a6
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2024-05-29 20:12:44 +02:00
Tor Arne Vestbø ca95a10987 coin: Decide whether to ignore CTest exit code based on environment var
This deduplicates some of the coin instruction files, and opens up the
possibility for other instructions to determine whether a test run
is significant or not.

The only module still using the coin_module_test_template_v2 template
is the QtMQTT module, so the behavior of ignore the test run has been
kept.

The static library opt out was a remnant from the cmake porting, and
can be removed.

Change-Id: I0f9fcbbd3a5a18bd9c8e0f545b0f0656e03bf388
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2024-05-29 20:12:44 +02:00
Marc Mutz 5c1ea2c57f Export QLatin1::convertFromUnicode()
We need it in QtNetwork.

Change-Id: I6d26592ee79bffc7390ea742892f134e69ad77b1
Reviewed-by: Juha Vuolle <juha.vuolle@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2024-05-29 12:27:54 +00:00
Marc Mutz 4bb36a6e78 tst_QStringApiSymmetry: add tests for unary arg() calls
This exercise found an inconsistency involving char16_t. Filed
QTBUG-125588 to keep track of this and decide how to deal with it.

Task-number: QTBUG-125588
Pick-to: 6.7 6.5
Change-Id: I259fecef34539e8841149570d7411d959b48d876
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2024-05-29 14:24:30 +02:00
Marc Mutz 88b1c96239 QAnyStringView: fix char-ish ctors to not allocate memory
Extending the fromCharacter() tests to check for the construction to
be noexcept and implicit turned up a few bugs:

The constructor from char32_t was simply not marked as noexcept, even
though all its operations were. So just mark it noexcept.

The constructor from QChar, otoh, was never called, (certainly not for
rvalues), because QString happens to be constructible from QChar (and
QLatin1Char and QChar::SpecialCharactor), so due to perfect
forwarding, the if_convertible_to<QString> ctor won, allocating a
QString.

This is a regression of Qt 6.5 compared to Qt 6.4.

To fix this, exclude arguments that convert to QChar from matching the
if_convertible_to<QString/QByteArray> ctors, taking care to not match
those arguments that are already compatible_char<>s.

This, in turn, creates a problem for implicit QASV construction from
QLatin1Char and QChar::SpecialCharacter, because now that we've
excluded them from the if_convertible_to<QString> ctor, calling the
existing QChar or QString non-template constructors for these types
would require two user-defined conversions (from said type to
QChar/QString and from QChar/QString to QAnyStringView). That works
for explicit construction, but we need implicit convertability.

So bring out the big guns once more and add a perfectly-forwarding
ctor for anything convertible to QChar. QChar itself is actually
already handled by compatible_char<>, so the old QChar non-template
ctor can go. The extra copy of the QChar argument will be optimized
away by the compiler.

[ChangeLog][QtCore][QAnyStringView] Fixed a regression where
constructing a QAnyStringView from a char-like type (QChar,
QLatin1Char, ...) would first construct a QString and only then
convert that to QAnyStringView.

Amends 812a0d3125.

This change is forward and backward BC and SC, but not
behavior-compatible: certain operations detectably change
noexcept'ness, and some arguments may now cause the resulting
QAnyStringView to have a different encoding (though I really tried
hard to avoid that).

Since it's a regression, I proposed to pick this to the affected
branches, 6.7 and 6.5 (6.6 is already closed at this point).

Pick-to: 6.7 6.5
Fixes: QTBUG-125735
Change-Id: I86f37df5d80bee36db27e529c017cb73995a6831
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2024-05-29 14:24:30 +02:00
Marc Mutz d8131960d8 QUuid: port createUuidV{3,5}() to QByteArrayView
Requires to mark the existing QString overload as Q_WEAK_OVERLOAD.¹
And since this non-polymorphic class is exported wholesale, we need to
involve REMOVED_SINCE here, too.

¹ While QString and QByteArray don't overload well, the new overload
  set makes calls with QByteArray arguments ambiguous, unless the
  QString overload is demoted to a weak one.

As a drive-by, change the QUuid argument passing from cref to
by-value, fixing a Clazy warning.

[ChangeLog][QtCore][QUuid] Ported createUuidV3() and createUuidV5()
from QByteArray to QByteArrayView, made them noexcept, and fixed
various ambiguities in the overload set.

Change-Id: I9f71209f2ddb58ace4e15fb68418b1a21d2b3602
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2024-05-29 14:24:30 +02:00
Marc Mutz fa8256bb5a QCryptographicHash: extend hashInto to more than one piece of data
This allows use of the noexcept static function in cases where more
than one piece of data needs to be hashed, and concatenation of said
data would have to allocate memory.

Port QUuid to use the new function, allowing to mark the V3 and V5
create functions noexcept.

As a drive-by, take QUuid by value in the internal helper function,
fixing a Clazy warning.

Task-number: QTBUG-125431
Change-Id: I17938f0be44c91085e2aaa5574953f8dceacc990
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2024-05-29 14:24:30 +02:00
Marc Mutz c70c81b371 Long live QCryptographicHash::hashInto()!
Until now, QCryptographicHash had a big drawback over the underlying
C APIs: at least one extra memory allocation: Either you created a
QCryptographicHash object (allocates a Private), and enjoy noexcept
addData() and resultView(), or you used the static hash() function
(which creates a Private on the stack, so doesn't need to allocate
one), but then we needed to return in an owning container.

Enter QSpan and hashInto(), which allow the user to provide a buffer
into which to write, and therefore can be completely noexcept and
(apart from a missing optimization which, however, doesn't affect the
API) deliver near C-API efficiency.

We don't have QMutableByteArrayView, which would deal with the
different types of equivalent char types for us, so we overload for
QSpan<std::bytes>, QSpan<char> and QSpan<uchar>, which makes the
overload set accept roughly what QByteArrayView would accept, too.

Return by QByteArrayView because that has a richer API than QSpan,
which lacks (on purpose) string-ish API.

[ChangeLog][QtCore][QCryptographicHash] Added hashInto().

Task-number: QTBUG-125431
Change-Id: I80ecc7151d3418a36c4d5db6d22d0b82c869b19f
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2024-05-29 14:24:29 +02:00
Marc Mutz 39189190fe tst_QAnyStringView: add fromX for various char-like types
These were not covered by the existing tests.

Pick-to: 6.7 6.5 6.2
Change-Id: I909ea3aa5b676904dc72ecf8ce32b73cca1b6af7
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
2024-05-29 14:24:29 +02:00
Ari Parkkila 41b0277924 tests: Fix tst_qtemporaryfile to use temporary file
Create a temporary file instead of trying to use a file from source
directory because that's not available when test was installed via
packaging.

Task-number: QTBUG-118680
Change-Id: Ic152d68c79ac467c0d149cab04ab224c3b64099f
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2024-05-29 15:24:25 +03:00
Edward Welbourne e9b79c0c74 tst_QTZ::localeSpecificDisplayName(): expect failure when data lacking
QTZ::displayName() returns an empty string if it doesn't know how to
localize a zone name. In this case, we can't expect it to match the
expected name, which depends on having relevant locale data available.

Task-number: QTBUG-115158
Change-Id: I1cd8c1469399502764c354bf24423298f106f23e
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2024-05-29 14:24:25 +02:00
Giuseppe D'Angelo 0dca6c40e1 PDF: use a map, not a hash, to write the dest roots name tree
A PDF name tree is sorted, so just use a sorted data structure for that.
This simplifies the code.

This work has been kindly sponsored by the QGIS project
(https://qgis.org/).

Change-Id: Ib08b14aaf79c9180319efe7fefa9e797a4364d54
Reviewed-by: Albert Astals Cid <aacid@kde.org>
2024-05-29 09:43:18 +02:00
Christian Ehrlicher 2f9c72028d QTreeView: optimize Private::intersectedRect()
The implementation for QTreeViewPrivate::intersectedRect() calculated
the view rect for every single index which is not needed:
 - when the row is spanned, the first item spans the complete viewport
 - the x-position of an index in the same column but different row is
   the same so no need to re-calculate the boundaries again (similar to
   the implementation in QTableView)

This reduces the visualRect() call count from n*m to n+m

Task-number: QTBUG-124173
Change-Id: I651b2ff9b6d4e68a82f32b3f5c3c0e746f88ce5e
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2024-05-29 06:17:25 +02:00
Giuseppe D'Angelo 64b6a2aa70 PDF: code tidies
Take by QByteArrayView instead of const QByteArray &.

This work has been kindly sponsored by the QGIS project
(https://qgis.org/).

Change-Id: I2a5b96ba81fc16487e25be3e957c50ea1b11be76
Reviewed-by: Albert Astals Cid <aacid@kde.org>
Reviewed-by: Tobias Koenig <tobias.koenig@kdab.com>
2024-05-29 04:23:16 +02:00
Giuseppe D'Angelo a3a91c947c PDF: write a TrimBox
This is necessary for PDF/X-4 conformance (§ 6.12), but does not
hurt specify it always, matching the MediaBox.

This work has been kindly sponsored by the QGIS project
(https://qgis.org/).

Change-Id: Ifc698f271eb1217da15413e4bf25321dea2e955f
Reviewed-by: Tobias Koenig <tobias.koenig@kdab.com>
Reviewed-by: Albert Astals Cid <aacid@kde.org>
2024-05-29 04:23:16 +02:00
Giuseppe D'Angelo 67dffd871f QPdf: do not write a /Filter key if we are not compressing
Streams may or may not be compressed depending on zlib availability,
so fix this dictionary.

This work has been kindly sponsored by the QGIS project
(https://qgis.org/).

Change-Id: I852569f053a1338d4bc54be5e8fb1e9c7741a5a1
Reviewed-by: Tobias Koenig <tobias.koenig@kdab.com>
Reviewed-by: Albert Astals Cid <aacid@kde.org>
2024-05-29 04:23:16 +02:00
Tor Arne Vestbø fd97a820df macOS: Add support for safe area margins
We reflect both the NSView's own safeAreaInsets as well as the screen's
safeAreaInsets mapped to the view. This covers both in-window views that
obscure the view, e.g. toolbars or the titlebar, as well as areas outside
of the window that affect the window if it has geometry that overlaps
these areas (such as the notch on MacBook Pro laptops).

Fixes: QTBUG-125372
Change-Id: I17af7f456ade83eef910ef5b0eaeab7cd8075263
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2024-05-29 03:27:18 +02:00
Tor Arne Vestbø bee9de0452 iOS: Enable the Qt Print Support module
The print support module was disabled for the initial port of Qt
for iOS due to the lack of a native print backend and native
print dialogs, as we have on macOS.

However, even lacking these we should be able to offer the print
to PDF feature, with widget based print dialogs. We can do so
by opting in to the generic Unix print dialogs and backends,
as these do not have a hard dependency on CUPS.

Longer term we should adopt UIPrintInteractionController,
UIPrinterPickerController, and UIPrinter, but that's a bigger
task.

[ChangeLog[iOS] The Qt Print Support module is now enabled,
allowing printing to PDF. Printing to system provided printers
are not yet supported.

Fixes: QTBUG-125581
Change-Id: I5bc143e47c7277b3cea52760672ac4d0c8a7a898
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2024-05-29 03:27:18 +02:00
Lorn Potter d67d49f45e wasm: fix uri-list handling urls
We were only handling the case where uri-list was a file.
This fixes a regression.

Also - add dragging url into the clipboard manual test

Pick-to: 6.7 6.7.1
Change-Id: Ifbd087ffd157463b6b903199e3ff22c2de1c4942
Reviewed-by: Piotr Wierciński <piotr.wiercinski@qt.io>
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2024-05-29 08:18:06 +10:00
Alexey Edelev 3073b9c4de Ensure that libzstd targets are promoted to global if they were found
Promote all internal zstd targets if they were found by WrapZSTD to
global using PROVIDED_TARGETS mechanism.

Amends 7d9d1220f3

Task-numer: QTBUG-119469
Change-Id: I15ec484304f7bf2b3ee2a533d2badb3bb7797863
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2024-05-29 00:18:06 +02:00
Giuseppe D'Angelo 0effdc98dc PDF: fix the encoding for the file name of attachments
A file specification in PDF is a string (§3.10.1 of the PDF 1.6 spec).
As such, it needs to be properly encoded. Right now the code was
doing a naive conversion to latin1 (which was lossy), and was not
considering things like round parenthesis which need to be properly
escaped. Just use printString instead.

This work has been kindly sponsored by the QGIS project
(https://qgis.org/).

Change-Id: Icdcf8b553955d31fe2bc430dea54bb6e68221fc7
Pick-to: 6.7 6.5
Reviewed-by: Albert Astals Cid <aacid@kde.org>
2024-05-28 21:17:46 +02:00
Giuseppe D'Angelo e95812df85 QDateTime::fromStdTimePoint: fix the constraint
The constraint requires the input time_point's duration to be
convertible to milliseconds. That's inaccurate: we need to check the
duration of the time_point we get from the clock_cast, not the input.
In general, clock_cast is allowed to return arbitrary durations, so
it may not match the input. (It indeed doesn't match for some
standard clocks, like gps_clock.)

Pick-to: 6.7
Task-number: QTBUG-125587
Change-Id: I5a93317c8cdc0a3cef4acab17c656e2e5dac5d8d
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2024-05-28 21:11:23 +02:00