1 | // Copyright (C) 2016 The Qt Company Ltd. |
---|---|
2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 |
3 | |
4 | #ifndef BOOKMARKITEM_H |
5 | #define BOOKMARKITEM_H |
6 | |
7 | #include <QtCore/QVariant> |
8 | #include <QtCore/QList> |
9 | |
10 | QT_BEGIN_NAMESPACE |
11 | |
12 | enum { |
13 | UserRoleUrl = Qt::UserRole + 50, |
14 | UserRoleFolder = Qt::UserRole + 100, |
15 | UserRoleExpanded = Qt::UserRole + 150 |
16 | }; |
17 | |
18 | typedef QList<QVariant> DataVector; |
19 | |
20 | class BookmarkItem |
21 | { |
22 | public: |
23 | explicit BookmarkItem(const DataVector &data, BookmarkItem *parent = nullptr); |
24 | ~BookmarkItem(); |
25 | |
26 | BookmarkItem *parent() const; |
27 | void setParent(BookmarkItem *parent); |
28 | |
29 | void addChild(BookmarkItem *child); |
30 | BookmarkItem *child(int number) const; |
31 | |
32 | int childCount() const; |
33 | int childNumber() const; |
34 | |
35 | QVariant data(int column) const; |
36 | void setData(const DataVector &data); |
37 | bool setData(int column, const QVariant &value); |
38 | |
39 | bool insertChildren(bool isFolder, int position, int count); |
40 | bool removeChildren(int position, int count); |
41 | |
42 | void dumpTree(int indent) const; |
43 | |
44 | private: |
45 | DataVector m_data; |
46 | |
47 | BookmarkItem *m_parent; |
48 | QList<BookmarkItem*> m_children; |
49 | }; |
50 | |
51 | QT_END_NAMESPACE |
52 | |
53 | #endif // BOOKMARKITEM_H |
54 |