summaryrefslogtreecommitdiffstats
path: root/examples/corelib
diff options
context:
space:
mode:
authorEdward Welbourne <edward.welbourne@qt.io>2023-06-08 18:33:50 +0200
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2023-06-12 15:46:14 +0200
commitb610c7aa89dd6224fbf58983ad8c2a391b2a559e (patch)
tree9fea175126099e911bbb471886a86f7de1669468 /examples/corelib
parentde9e978532ef5a3c212426f0e46de9059377968d (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. Pick-to: 6.6 6.5 Task-number: QTBUG-111228 Change-Id: I91d3d6bf8adc3f3001c90274bb62a9da6bf05362 Reviewed-by: Ievgenii Meshcheriakov <ievgenii.meshcheriakov@qt.io>
Diffstat (limited to 'examples/corelib')
-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 3f3231e561..0e7f5f7ef1 100644
--- a/examples/corelib/serialization/streambookmarks/xbelreader.cpp
+++ b/examples/corelib/serialization/streambookmarks/xbelreader.cpp
@@ -67,6 +67,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)
{
@@ -109,24 +127,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);