From b610c7aa89dd6224fbf58983ad8c2a391b2a559e Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Thu, 8 Jun 2023 18:33:50 +0200 Subject: [PATCH] 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 --- .../streambookmarks/xbelreader.cpp | 36 +++++++++---------- 1 file 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);