qt6windows7/examples/xml/dombookmarks/xbeltree.h

43 lines
988 B
C
Raw Normal View History

2023-10-30 06:33:08 +08:00
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef XBELTREE_H
#define XBELTREE_H
#include <QDomDocument>
#include <QIcon>
#include <QTreeWidget>
2023-11-02 01:02:52 +08:00
//! [0]
2023-10-30 06:33:08 +08:00
class XbelTree : public QTreeWidget
{
Q_OBJECT
public:
2023-11-02 01:02:52 +08:00
explicit XbelTree(QWidget *parent = nullptr);
2023-10-30 06:33:08 +08:00
bool read(QIODevice *device);
bool write(QIODevice *device) const;
protected:
2023-11-02 01:02:52 +08:00
#if QT_CONFIG(clipboard) && QT_CONFIG(contextmenu)
2023-10-30 06:33:08 +08:00
void contextMenuEvent(QContextMenuEvent *event) override;
#endif
private slots:
void updateDomElement(const QTreeWidgetItem *item, int column);
private:
void parseFolderElement(const QDomElement &element,
QTreeWidgetItem *parentItem = nullptr);
QTreeWidgetItem *createItem(const QDomElement &element,
QTreeWidgetItem *parentItem = nullptr);
QDomDocument domDocument;
QIcon folderIcon;
QIcon bookmarkIcon;
};
2023-11-02 01:02:52 +08:00
//! [0]
2023-10-30 06:33:08 +08:00
#endif