summaryrefslogtreecommitdiffstats
path: root/examples/corelib/serialization/streambookmarks/xbelreader.h
diff options
context:
space:
mode:
authorØystein Heskestad <oystein.heskestad@qt.io>2023-03-09 17:01:59 +0100
committerØystein Heskestad <oystein.heskestad@qt.io>2023-03-31 13:26:42 +0200
commit29317b426b9ec84f4ba66e6c032f71c2a2bae091 (patch)
tree40164eb76d8fa5f7c7c128631582ca5c85cf5df7 /examples/corelib/serialization/streambookmarks/xbelreader.h
parenta815c40e736d0914b898a896f3dcee454804a7a2 (diff)
Move streambookmarks example into corelibe/serialization
The stream-based XML serialization API resides in corelib/serialization. Move the steambookmarks example there. The Qt XML documentation is updated to no longer refer to this example code directly and refer to the direct location in the example documentation instead. Task-number: QTBUG-110647 Pick-to: 6.5 Change-Id: Id36fb04a6acb7b8d1eb008f61568fe0abc221e3d Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Diffstat (limited to 'examples/corelib/serialization/streambookmarks/xbelreader.h')
-rw-r--r--examples/corelib/serialization/streambookmarks/xbelreader.h50
1 files changed, 50 insertions, 0 deletions
diff --git a/examples/corelib/serialization/streambookmarks/xbelreader.h b/examples/corelib/serialization/streambookmarks/xbelreader.h
new file mode 100644
index 0000000000..81a59b32b5
--- /dev/null
+++ b/examples/corelib/serialization/streambookmarks/xbelreader.h
@@ -0,0 +1,50 @@
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#ifndef XBELREADER_H
+#define XBELREADER_H
+
+#include <QIcon>
+#include <QXmlStreamReader>
+
+QT_BEGIN_NAMESPACE
+class QTreeWidget;
+class QTreeWidgetItem;
+QT_END_NAMESPACE
+
+//! [0]
+class XbelReader
+{
+public:
+//! [1]
+ XbelReader(QTreeWidget *treeWidget);
+//! [1]
+
+ bool read(QIODevice *device);
+
+ QString errorString() const;
+
+ static inline QString versionAttribute() { return QStringLiteral("version"); }
+ static inline QString hrefAttribute() { return QStringLiteral("href"); }
+ static inline QString foldedAttribute() { return QStringLiteral("folded"); }
+
+private:
+//! [2]
+ void readXBEL();
+ void readTitle(QTreeWidgetItem *item);
+ void readSeparator(QTreeWidgetItem *item);
+ void readFolder(QTreeWidgetItem *item);
+ void readBookmark(QTreeWidgetItem *item);
+
+ QTreeWidgetItem *createChildItem(QTreeWidgetItem *item);
+
+ QXmlStreamReader xml;
+ QTreeWidget *treeWidget;
+//! [2]
+
+ QIcon folderIcon;
+ QIcon bookmarkIcon;
+};
+//! [0]
+
+#endif