29317b426b
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>
51 lines
1.1 KiB
C++
51 lines
1.1 KiB
C++
// 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
|