131 Commits

Author SHA1 Message Date
Edward Welbourne
f435aeb904 Make \brief of Saving a Game to File actually brief
Specifically, prune it to fit on a single line.
Much of what it was saying was implicit in its context already.
It also neglected to mention CBOR's part in the story.

Pick-to: 6.5
Task-number: QTBUG-111228
Change-Id: I161a345cbbea8b706490fcbbadecd01b8946af31
Reviewed-by: Konrad Kujawa <konrad.kujawa@qt.io>
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
(cherry picked from commit e67f030600886a5630e22fa912e22087a7d63c56)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2023-10-06 06:50:00 +00:00
Edward Welbourne
8f43b0ee5b Deduplicate code in setup of serialization converters
The setup of the input and output converters is fairly complex but was
made harder to read by nearly-duplicating its logic for input and for
output. Break out into a separate function to make clear what parts
differ between the two and what parts don't. In the process, allow the
search for a named converter to continue past a match that doesn't
support the needed direction, on the off chance of a name collision.
Make an error message more articulate in the process.

Pick-to: 6.5
Task-number: QTBUG-111228
Change-Id: I2a9de8b406c538098076f388fc8a1980b91fe16b
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
(cherry picked from commit 6a7b7272cd6ce6b8264796c25b686bf5376b8aea)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2023-09-29 10:38:31 +00:00
Edward Welbourne
b4e09800bb Check input and output converters do support the relevant directions
It was previously possible to select an input-only converter for
output or an output-only converter for input. Also add a comment to
explain why failure to probe for the auto output converter isn't an
error, where failure to probe for the auto input converter is.

Pick-to: 6.5
Task-number: QTBUG-111228
Change-Id: I17dfbbee7d8b5a9629e66d0e1a6a4014b01a7262
Reviewed-by: Ievgenii Meshcheriakov <ievgenii.meshcheriakov@qt.io>
(cherry picked from commit ccd59b2d4f8f1c4fde3f1498d28c0dc91ba75efd)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2023-09-29 10:38:31 +00:00
Edward Welbourne
7bd8ab4917 Replace the image to illustrate the Serialization Converter
The old image wasted a log of space, was poorly legible and showed
little more than the cbordump example's illustration shows. Make
explicit that we get an initial CBOR file from savegame, show how it
can be converted to and from XML (idempotently) and still find space
to show the same thing as before. All more legibly and in a smaller
file.

Pick-to: 6.5
Task-number: QTBUG-111228
Change-Id: Ifc599d0dd646f136ccd2860ca927186d478b0fb9
Reviewed-by: Tatiana Borisova <tatiana.borisova@qt.io>
(cherry picked from commit b9787a3985e503a51115da6a7282eb27f1958c64)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2023-09-29 10:38:31 +00:00
Edward Welbourne
f8466e5b2c Turn Directions enum into an enum class in serialization converter
Task-number: QTBUG-111228
Change-Id: Ie1f8ea5e2575427528c19875db7a8e4e27200aec
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
(cherry picked from commit e53d0220da4906f88494933ff3b0076335ad065f)
2023-09-12 20:12:37 +02:00
Edward Welbourne
9fcee2287a Turn Converter::Direction into a QFlags enum
This lets us testFlag() instead of using raw bit-field operations.

Task-number: QTBUG-111228
Change-Id: I2c26e9a24728e81baa42cf14c75271a015460913
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
(cherry picked from commit ad63118071e3068ef3f45e75fad82a04952ba0fb)
2023-09-12 20:12:37 +02:00
Edward Welbourne
50b51d2b50 Serialization converter example: const-ify the Converter type
Its methods act on their parameters without changing the converter, so
can all be const. Its instances thus have no non-const members to
exercise, so can always be const.

Task-number: QTBUG-111228
Change-Id: Ifcdb2f2159c2cfcd7998dd118aa327a32d299ccf
Reviewed-by: Dennis Oberst <dennis.oberst@qt.io>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
(cherry picked from commit 77fdd21cbf1a053efe6eec51356c665ed982d47c)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2023-09-12 20:12:37 +02:00
Edward Welbourne
2d9935cc6d Separate streaming dumper and converter in the convert example
The two were in the same files but mostly unrelated to one another -
aside from the converter defaulting to the dumper for output.
Furthermore, the dumper actually uses QDebug and QTextStream, not
QDataStream; rename it to reflect this reality.

Task-number: QTBUG-111228
Change-Id: Id65c120c319b555039f7fd186ed262f35ff5260a
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
(cherry picked from commit eaebb5c4d2e2a87b23d63c5406bf54458b4c4a24)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2023-09-12 18:12:36 +00:00
Edward Welbourne
ca9a3ba6c8 corelib/serialization examples: clang-tidy and coding style clean-up
I overrode clang-tidy where it uglified or obfuscated and did some
clean-up provoked or made possible by its changes. Konrad pointed out,
in review, a constructor that could be = default; it could, in fact,
vanish entirely as a result.

Task-number: QTBUG-111228
Change-Id: I9b7744a3abaa29e6f9e0689d0f6985bfd88cd0fd
Reviewed-by: Konrad Kujawa <konrad.kujawa@qt.io>
(cherry picked from commit d8517fb1ab83e7051b1d2c2152014e7ff1760426)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2023-09-12 18:12:36 +00:00
Edward Welbourne
d066497527 corelib/serialization examples: use string literals more
A couple more compilation units could use Qt::StringLiterals. Prefer
QL1SV for the code constants, to keep code small. Convert fpToString()
to take QL1SV instead of const char *, with suffix empty by default.
Also rearranged some spacing, some if it suggested by clang-tidy.

Task-number: QTBUG-111228
Change-Id: I03d810d52afcd4a760d18f2553914b75af716b74
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
(cherry picked from commit 319b2e0e86f0afa6aa48625702010b5a6db4fe38)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2023-09-12 18:12:36 +00:00
Edward Welbourne
4b39596512 Minor tidies in example's XML converter
Make a local variable more local, set a variable only once its new
value is known to be valid.

Task-number: QTBUG-111228
Change-Id: Ib6aa16e8c834f89c6ccc0715f20b0e5f0a7f3b6d
Reviewed-by: Konrad Kujawa <konrad.kujawa@qt.io>
(cherry picked from commit 40b07ee887d9717088e3189b15c86a5c87759b1d)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2023-09-05 20:42:00 +00:00
Edward Welbourne
9478aa74ee Exploit C++17 init-statements in if to simplify a loop
The serialization converter example's text converter's loadFile() can
be made tidier by making the conditions within its loop into a chain.

Task-number: QTBUG-111228
Change-Id: Ic82355eab7380a0c671b3805ca140958bb1c5af5
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Øystein Heskestad <oystein.heskestad@qt.io>
(cherry picked from commit d631f888042e3f3f5d4d0284c6bad8eb91e2c9a3)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2023-09-05 20:41:53 +00:00
Edward Welbourne
7cd3b65980 Update datastream converter to use Qt_6_0 instead of Qt_5_0
It was added in 5.12 and we've had a few upates since then.

Task-number: QTBUG-111228
Change-Id: Iacb5368d4baa7d25f981bb0b8bd8d68b5461e17d
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
(cherry picked from commit 833ed75b650bb870a158fa8f6e50f06e64fb90a6)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2023-09-05 17:39:55 +00:00
Edward Welbourne
4091fe8516 Core serialization examples: spacing-only clang-format changes
Marc disagreed with clang-format on some, which are thus excluded.

Task-number: QTBUG-111228
Change-Id: I1402274635dba866a8160a68211874cb11dcfa61
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
(cherry picked from commit 670f66eed3fd81f4b7c3e6f43d06e5bb79176527)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2023-09-05 17:39:49 +00:00
Elias Hautala
e76a01d690 Exclude some examples from Android build
Excludes  dnslookup, waitconditions, semaphores, cbordump, savegame,
convert, pingpong and complexpingpong examples from Android build
because of missing Qui and Quick dependenies.

Task-number: QTBUG-111933
Change-Id: Ied01f62ee61a9220dcb44c13fda46f6a5e158293
Reviewed-by: Rami Potinkara <rami.potinkara@qt.io>
Reviewed-by: Ville Voutilainen <ville.voutilainen@qt.io>
(cherry picked from commit 39a5ed4bdd348d3cd18a08d322b48d85e8d116e8)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2023-08-31 14:39:34 +00:00
Edward Welbourne
6fedc36483 XBEL stream reader: rework documentation
Document previously-undocumented methods. Document in terms of what
each thing achieves, not how it does it. The U+00B7 is not the period,
it is the centred dot. Fix various anachronisms; the existing docs
were out of date with the actual code.

Task-number: QTBUG-111228
Change-Id: I17da880e0afd7260aa6f3b7bdddb430c437f4562
Reviewed-by: Jaishree Vyas <jaishree.vyas@qt.io>
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
(cherry picked from commit fd7fbaf887f951c34389aa58925ddc680ee544df)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2023-08-04 10:30:05 +00:00
Edward Welbourne
95ed706e82 XBEL stream example: use constructor initialization
The treeWidget member of MainWindow could be initialized before the
body of the constructor, enabling it to be a *const variable.

Task-number: QTBUG-111228
Change-Id: If4a3b04729bc7fa5859ca88183eec376f6992455
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
(cherry picked from commit 5651be517a9f25798a051f7dd7548d40381148df)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2023-07-18 07:33:14 +00:00
Edward Welbourne
f329934052 XBEL streaming example: renumber xbelreader.cpp's snippet fragments
I'll be adding docs for parts currently lacking them; fix up the
numbering first, to disentangle from "real" changes to docs.

Task-number: QTBUG-111228
Change-Id: Ia10f212626bf5ca9fab2b6ba6cf02dbd560a2f02
Reviewed-by: Ievgenii Meshcheriakov <ievgenii.meshcheriakov@qt.io>
(cherry picked from commit e8a68b556cfa7f4e72faecb400db625608bf6460)
2023-07-14 14:12:21 +02:00
Edward Welbourne
5b2e3475ba Do XBEL example's last !QT_NO_... -> QT_CONFIG()
Amends commit 723e331f0a811294e43207db162698c3ff8fde51

Task-number: QTBUG-111228
Change-Id: Ib9a094ab432a80b8b2dbbbecb497dca13d23a553
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
(cherry picked from commit 4b6986db32eef511718e9010636c5485b6512ac9)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2023-07-14 10:01:29 +00:00
Edward Welbourne
84ec6b1dc6 Core examples: consistent #include order
Task-number: QTBUG-111228
Change-Id: I014a895a8abeccc9d17b68fb67c00cea22957fed
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
(cherry picked from commit 59d28697655cbd41baa40804cdc43c96983261d5)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2023-07-14 10:00:50 +00:00
Edward Welbourne
1beb9335b4 XBEL streaming: shuffle mainwindow parts into more pedagogic order
Renumber the code fragments to match their order, while adding a
number for the previously undocumented custom method. Add a brief
description of it. Move the createMenus() part up to after it, combine
the createActions() with its (as createActions() is long gone, fused
into it and sharing its snippet number).

Task-number: QTBUG-111228
Change-Id: If0fbcadfa058fc12cbd74ba1897646113bd016b0
Reviewed-by: Ievgenii Meshcheriakov <ievgenii.meshcheriakov@qt.io>
(cherry picked from commit 98765cab974d02ccd364355a44dfeb8e8ef969d5)
2023-07-13 17:07:28 +02:00
Edward Welbourne
9dcff27fcf XBEL stream example: move createMenus() earlier
This will make the description of the type flow more naturally.

Task-number: QTBUG-111228
Change-Id: I751bdaf420be7afc9cb4925af4f2a94367840605
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Mate Barany <mate.barany@qt.io>
Reviewed-by: Konrad Kujawa <konrad.kujawa@qt.io>
(cherry picked from commit bb69def7d14795b64580ed68cc49ae31bff90340)
Reviewed-by: Ievgenii Meshcheriakov <ievgenii.meshcheriakov@qt.io>
2023-07-13 17:07:28 +02:00
Edward Welbourne
1671172375 Examples: "About &Qt" should show info about Qt, not quit
A few examples seem to have copied and pasted a help action "About
&Qt" that triggered QCoreApplication::quit. This does not look like
best practice. Use QApplication::aboutQt instead.

Task-number: QTBUG-111228
Change-Id: I1887a3c999d752a24c7c4d3cabc4a5d63b29b966
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
(cherry picked from commit 3ccf2f8308ba33cab575c22ad2e246b987a3dc0c)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2023-07-13 17:07:27 +02:00
Edward Welbourne
e57bf5b99d Move RSS listing example to networking
It's really showing how to request a resource and act on its becoming
available. The use of XML to do so is incidental; the use of
networking is central.

Task-number: QTBUG-111228
Change-Id: Ibcf438c7ef3b2464ddfa8b96a79fb15523e4a468
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
(cherry picked from commit e54a7c56677280d9a9eb976dd455085dcce10c40)
2023-07-13 17:07:27 +02:00
Edward Welbourne
f339262217 XBEL stream reader: shuffle order of functions
Put readBookmark() first of the constituent parts, as it's the most
intelligible (albeit currently undocumented) and gives some clue to
the purpose of readTitle(), which is next.

Task-number: QTBUG-111228
Change-Id: I91d3d6bf8adc3f3001c90274bb62a9da6bf05362
Reviewed-by: Ievgenii Meshcheriakov <ievgenii.meshcheriakov@qt.io>
(cherry picked from commit b610c7aa89dd6224fbf58983ad8c2a391b2a559e)
2023-07-13 17:07:27 +02:00
Edward Welbourne
8bad89cf53 XBEL examples: construct the text of the separators cleanly
Create the fixed string once and reuse it. Also give a name to the
escape code that's its repeated character.

Task-number: QTBUG-111228
Change-Id: I3d6416070f1d5490ec137e251daff0e1637fb788
Reviewed-by: Konrad Kujawa <konrad.kujawa@qt.io>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
(cherry picked from commit 97f68cd3068587103c8b0a0ccdcd6e61431efc1e)
2023-07-11 14:50:39 +02:00
Edward Welbourne
fd29e6ddb9 XBEL streaming: replace images with up-to-date version
The old screenshot showed an old XBEL file's content, with trolltech
URLs. Update to match the new XBEL file's content.

Task-number: QTBUG-111228
Change-Id: Idacc31b7786b1e6ed1425857470b1d37227096cd
Reviewed-by: Kimmo Leppälä <kimmo.leppala@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
(cherry picked from commit a028e53fa49c995a7dc06ffaac2be1ebe0923f9c)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2023-07-10 10:58:58 +00:00
Edward Welbourne
0114514c0a Update XBEL examples' sample data file
Most links are now https, several have relocated, one entirely
rebranded. Same example in both QXmlStream and DOM forms.

Task-number: QTBUG-111228
Change-Id: Ifbc58dadc834cf51113adb1c82de971a8768ee58
Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
(cherry picked from commit 4731cdc09d21050dacaaa66ddd79e50682a476f4)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2023-07-10 10:58:57 +00:00
Edward Welbourne
8c75df013a Update Qt Documentation link title in XBEL examples
doc.qt.io was described as Qt 5 documentation; no need to version-limit it.

Task-number: QTBUG-111228
Change-Id: I1c5abe3d805c2b845a74b9fe454c494fa1eff4c7
Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
(cherry picked from commit 54f65187ec2efb0c28582fbb0320d847556cb3f0)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2023-07-10 10:58:56 +00:00
Kai Köhne
be9797b6b6 Doc: Update example category names
Change-Id: If4a50c403ed0fb299ac0d9a66f1f606151c55930
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
(cherry picked from commit 60f706063aebee22f7fc1bb80f0003afb50fe73e)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2023-07-10 10:58:56 +00:00
Tor Arne Vestbø
bb08b96b29 Add missing QApplication include in streambookmarks example
Amends 3ccf2f8308ba33cab575c22ad2e246b987a3dc0c.

Change-Id: Ib51777ef9af44aff7fbb813b58eb0fbb74761373
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
(cherry picked from commit 14f31bf16e9eb5c31a944711225af90f23123a5c)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2023-06-17 15:41:49 +00:00
Edward Welbourne
8b693cd135 There is no frank.xbel so don't tell qmake to find it
Both the DOM and XML stream versions of the XBEL bookmarks example had
a frank.xbel in their EXAMPLE_FILES, but there is no such file. So
asking qmake to include it is spurious.

Task-number: QTBUG-111228
Change-Id: Iec08042d181fc09c2c428685ce841a13161ab273
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
(cherry picked from commit 8e1b60b33126a48acb0af14d938ceeb3b79f8891)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2023-06-16 22:59:05 +02:00
Edward Welbourne
f2995dc15a XBEL example - modernize strings: use "..."_L1 for literals
The XML stream reader and writer accept QAnyStringView arguments these
days, so passing a QLatin1StringView is entirely sufficient. This
makes static functions to provide access to unique QString instances
redundant. Linkers are allowed to uniquify the literals the "..."_L1
reference.

Task-number: QTBUG-111228
Change-Id: I7f37e97631e11683b9ddd3842fc6233547bed5ff
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
(cherry picked from commit 202b1dca5d96f225d9e576d5f9e83696c3e02b5a)
2023-06-16 22:59:05 +02:00
Edward Welbourne
33d7e170e6 XBEL example: minor simplifications
Pass one function's return as a parameter to another directly.
Use a ternary expression rather than conditional initialization.

Use initializer-list construction instead of appending to an empty
QStringList; and inline the result where it's used.

Task-number: QTBUG-111228
Change-Id: I781aedba8dcc4251193b55d82fe684c9b5da241a
Reviewed-by: Juha Vuolle <juha.vuolle@qt.io>
(cherry picked from commit 5fd4a65d95ac1f23af9583da752b1a0fb2646afe)
2023-06-16 22:59:05 +02:00
Edward Welbourne
cd1ef4db4f XBEL example: Fix null dereference bug
As readXBEL() does call readSeparator(nullptr), the latter should cope
with being passed nullptr as item.

Task-number: QTBUG-111228
Change-Id: I786e4438b566438448b5d54ff6442c27f1255aa8
Reviewed-by: Ievgenii Meshcheriakov <ievgenii.meshcheriakov@qt.io>
(cherry picked from commit 705e4e63c6ce26507d930428b8cf0d0f137bf3e5)
2023-06-16 22:59:05 +02:00
Topi Reinio
2e55a34c1c Doc: Fix documentation issues
The Qt Widgets Application example was moved to manual tests,
and no longer contains the snippet identifiers. Fix \snippet
and \quotefile commands to quote similar code snippets from
other examples or snippet files.

Fix also the following documentation warnings:

* No such parameter 'parsingMode' in QUrl::fromEncoded()
* Missing image: rsslisting.cpp

Change-Id: Ibc989e83abc49837db08628facaf8e5f72b2f123
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
(cherry picked from commit 17ddf2a6a52bab5d406bea560591961a7527929b)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2023-06-16 07:14:49 +00:00
Friedemann Kleint
7c6883d5db XBEL stream reader: Brush up
- Use mime types in the file dialog handling
- Use per class includes
- Use the configure system instead of QT_NO... defines

Task-number: QTBUG-111228
Change-Id: Iea915604e89d3005270f0eb83eca882855589a44
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
(cherry picked from commit 723e331f0a811294e43207db162698c3ff8fde51)
Reviewed-by: Kai Köhne <kai.koehne@qt.io>
2023-06-13 21:02:55 +02:00
Eike Ziller
47db21965d Examples: Do not add the same category twice
Amends 1371cd107a2dab2a29e3e10e9bb823a9ff04a3a9

Task-number: QTCREATORBUG-29197
Change-Id: I0dd4a08a597c237fd09f788cafb79af755953d0d
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Jani Heikkinen <jani.heikkinen@qt.io>
2023-05-26 17:44:54 +02:00
Edward Welbourne
f2ab85429d Document the RSS Listing example
Add an image and a QDoc file, remove the (in some cases misleading)
doc comments from the CPP sources, group the slots all together in the
source so as to document them together, group the two private methods
together. Dust the header lightly with comments to classify the class
members and enclose relevant parts in QDoc snippet markers.

Task-number: QTBUG-111228
Pick-to: 6.5
Change-Id: I0090fb45ce8d5a8f168fde9b3247d541b709c1b2
Reviewed-by: Andreas Eliasson <andreas.eliasson@qt.io>
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2023-05-25 17:40:38 +02:00
Edward Welbourne
2e09d03cd1 rsslisting example: use initializer list to construct string list
It's cleaner than declaring, using << to populate, then using once.
Just construct it and use it where it's needed.

Task-number: QTBUG-111228
Pick-to: 6.5
Change-Id: Id10483b26937a97899d656c4b26f27b37b8d39b6
Reviewed-by: Juha Vuolle <juha.vuolle@qt.io>
2023-05-25 17:40:37 +02:00
Edward Welbourne
3c78f1e96e rsslisting example: rename a slot to reflect what it does
Many slots can be connected to one signal so, unlike a virtual method
that must be named for the situation in which it is called, a slot can
(so should) be named for what it does, rather than naming it to match
the signal it's connected to.

Task-number: QTBUG-111228
Pick-to: 6.5
Change-Id: If2fa40cac0e51a243054526d7d2997fdd54aea3e
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Ievgenii Meshcheriakov <ievgenii.meshcheriakov@qt.io>
2023-05-25 17:40:36 +02:00
Edward Welbourne
fe2af0f8a3 RSSListing: remove metaDataChanged slot to handle redirects
QNetworkAccessManager takes care of doing that by default anyway,
these days.

Task-number: QTBUG-111228
Pick-to: 6.5
Change-Id: I890d258599e22efb6fc6ce0140304a97edcbb3f8
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Øystein Heskestad <oystein.heskestad@qt.io>
2023-05-25 17:40:35 +02:00
Edward Welbourne
e7b1bc6590 Turn itemActivated() slot of RSS listing example into a lambda
It needs nothing but the parameter it is passed and has no material
interaction with the rest of the RSSListing class, so there's no point
devoting a slot to it, much less a public one.

Task-number: QTBUG-111228
Pick-to: 6.5
Change-Id: I46d572982197550801c6fa4425453fc670c6f2f1
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-05-25 17:40:35 +02:00
Volker Hilsheimer
db2f4d5e46 Doc: fix links to examples
Remove the xml prefix, only reference the example by title. The
streambookmarks example is gone, so remove that link.

Change-Id: Ie3a77be24f60fca9e8f9ef0323f0ea5ffc904075
Reviewed-by: Safiyyah Moosa <safiyyah.moosa@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2023-05-24 07:04:31 +02:00
Edward Welbourne
d75e772e22 RSS listing example: prefer setDevice() over addData(readAll())
The network reply is a QIODevice, so the QXmlStreamReader can be set
to read from it directly, which it might potentially do incrementally,
rather than by reading all the data in one go.

In the process, change the set-up of the reply to first check that it
got a valid URL, then check it got a reply, before doing things with
that reply.

Pick-to: 6.5
Task-number: QTBUG-111228
Change-Id: I3642e24e0d10721e4a0325b35a94dcb5dfbcd4e6
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-05-16 20:09:38 +02:00
Edward Welbourne
30b9c3a135 Shrink the CBOR dumper example's image
Apply optipng -o7 -zm9 -strip all to the image to make it more compact.

Change-Id: Iebfc1f767759b5beac47bd7efa61d1c655163f03
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-05-15 15:51:01 +02:00
Edward Welbourne
637e1542cf rsslisting example: fix bug in construction of title string
The correct time to clear titleString and linkString is at the start
of the item element, to avoid not only the left-overs from a previous
item but also any stray titles and links that don't belong to any
item. The channel element, that contains the items, may also have
title and link elements. This, indeed, lead to the first entry in the
displayed table having a "Qt Blog" prefix on its blog-post's title.

Fortunately the link was already being set, usually to empty, due to
the lack of rss:about attributes on item elements.

Pick-to: 6.5
Task-number: QTBUG-111228
Change-Id: I16647e2498b58caaafa6e88ef73f0d934a1f8396
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2023-05-15 14:02:46 +02:00
Edward Welbourne
fb2d4074c1 rsslisting example: shuffle parts of constructor for clarity
Group related things together, improve the logical flow of the code.

Pick-to: 6.5
Task-number: QTBUG-111228
Change-Id: If3eb577b74128b305ca5fb3074168280ec2d4db8
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2023-05-15 14:02:46 +02:00
Edward Welbourne
233ca06500 rsslisting example: move default URL to main()
It felt more natural that the RSSListing class would be agnostic about
the default URL, so let it be a constructor parameter. In the process,
update the URL to what the old one now redirects to (thanks to Ivan
Solovev for spotting that) and make the constructor explcit (thaks to
Ievgenii Meshcheriakov for suggesting this).

Task-number: QTBUG-111228
Pick-to: 6.5
Change-Id: I9f4c0d126e0872bb4ec6e6bb41add7e9d2a9537f
Reviewed-by: Ievgenii Meshcheriakov <ievgenii.meshcheriakov@qt.io>
2023-05-15 14:02:45 +02:00
Edward Welbourne
3cdc65c2ec rsslisting example: Tidy up #include usage
Replace one #include with a forward-declaration - in rsslisting.h QUrl
is only passed by reference to a function. Shuffle order of existing
forward declarations to be alphabetic, in the process.

Shuffle #include order in sources so that this example's own headers
appear before the Qt ones.

Pick-to: 6.5
Task-number: QTBUG-111228
Change-Id: I69a9e091c77f9d3190c0217c8bd9262e056f66fc
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
2023-05-15 14:02:45 +02:00