summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorEdward Welbourne <edward.welbourne@qt.io>2023-06-08 18:33:50 +0200
committerEdward Welbourne <edward.welbourne@qt.io>2023-07-13 17:07:27 +0200
commitf339262217fefbdf8ba29d5f44691a3cc6ca5d0e (patch)
treedf1ccc0186844c65b6105bae318f4de3e38fd239 /examples
parentfde0d8a0176b8d9a36feea08d5aeffcf4aaf0cb8 (diff)
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)
Diffstat (limited to 'examples')
-rw-r--r--examples/corelib/serialization/streambookmarks/xbelreader.cpp36
1 files changed, 18 insertions, 18 deletions
diff --git a/examples/corelib/serialization/streambookmarks/xbelreader.cpp b/examples/corelib/serialization/streambookmarks/xbelreader.cpp
index 0c50cd6bba..88ed256cb7 100644
--- a/examples/corelib/serialization/streambookmarks/xbelreader.cpp
+++ b/examples/corelib/serialization/streambookmarks/xbelreader.cpp
@@ -68,6 +68,24 @@ void XbelReader::readXBEL()
}
//! [3]
+void XbelReader::readBookmark(QTreeWidgetItem *item)
+{
+ Q_ASSERT(xml.isStartElement() && xml.name() == "bookmark"_L1);
+
+ QTreeWidgetItem *bookmark = createChildItem(item);
+ bookmark->setFlags(bookmark->flags() | Qt::ItemIsEditable);
+ bookmark->setIcon(0, bookmarkIcon);
+ bookmark->setText(0, QObject::tr("Unknown title"));
+ bookmark->setText(1, xml.attributes().value("href"_L1).toString());
+
+ while (xml.readNextStartElement()) {
+ if (xml.name() == "title"_L1)
+ readTitle(bookmark);
+ else
+ xml.skipCurrentElement();
+ }
+}
+
//! [4]
void XbelReader::readTitle(QTreeWidgetItem *item)
{
@@ -112,24 +130,6 @@ void XbelReader::readFolder(QTreeWidgetItem *item)
}
}
-void XbelReader::readBookmark(QTreeWidgetItem *item)
-{
- Q_ASSERT(xml.isStartElement() && xml.name() == "bookmark"_L1);
-
- QTreeWidgetItem *bookmark = createChildItem(item);
- bookmark->setFlags(bookmark->flags() | Qt::ItemIsEditable);
- bookmark->setIcon(0, bookmarkIcon);
- bookmark->setText(0, QObject::tr("Unknown title"));
- bookmark->setText(1, xml.attributes().value("href"_L1).toString());
-
- while (xml.readNextStartElement()) {
- if (xml.name() == "title"_L1)
- readTitle(bookmark);
- else
- xml.skipCurrentElement();
- }
-}
-
QTreeWidgetItem *XbelReader::createChildItem(QTreeWidgetItem *item)
{
QTreeWidgetItem *childItem = item ? new QTreeWidgetItem(item) : new QTreeWidgetItem(treeWidget);