1// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
2//
3// SPDX-License-Identifier: GPL-3.0-or-later
4
5#ifndef TREEITEM_H
6#define TREEITEM_H
7
8#include "dap/protocol.h"
9
10#include <QList>
11#include <QVariant>
12#include <QVector>
13
14enum ColumnType {
15 kName,
16 KVaule,
17 KReference
18};
19
20class LocalTreeModel;
21class LocalTreeItem
22{
23public:
24 explicit LocalTreeItem(LocalTreeModel *model, LocalTreeItem *parentItem = nullptr);
25 ~LocalTreeItem();
26
27 void appendChild(LocalTreeItem *child);
28 void setVariable(dap::Variable &variable);
29
30 LocalTreeItem *child(int row);
31 int childCount() const;
32 int columnCount() const;
33 QVariant data(int column) const;
34 int row() const;
35 LocalTreeItem *getParentItem();
36 void removeChildren();
37 LocalTreeItem *parent() const;
38 int indexOf(const LocalTreeItem *item) const;
39
40 QModelIndex index() const;
41
42private:
43 using const_iterator = QVector<LocalTreeItem *>::const_iterator;
44 const_iterator begin() const { return children.begin(); }
45 const_iterator end() const { return children.end(); }
46
47 void clear();
48
49 QVector<LocalTreeItem*> children;
50 dap::Variable itemVariable;
51 LocalTreeItem *parentItem = nullptr;
52 LocalTreeModel *model = nullptr;
53};
54
55#endif // TREEITEM_H
56