-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathTreeNode.h
More file actions
38 lines (30 loc) · 939 Bytes
/
Copy pathTreeNode.h
File metadata and controls
38 lines (30 loc) · 939 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#pragma once
#include <QString>
#include <QVector>
#include <memory>
class TreeNode: public std::enable_shared_from_this<TreeNode>
{
public:
using ChildPtr = std::shared_ptr<TreeNode>;
using ConstChildPtr = std::shared_ptr<const TreeNode>;
using ParentPtr = std::weak_ptr<TreeNode>;
using ConstParentPtr = std::weak_ptr<const TreeNode>;
using LockedParentPtr = ChildPtr;
using ConstLockedParentPtr = ConstChildPtr;
public:
const QString name;
public:
explicit TreeNode(const QString &name);
ParentPtr parent() const;
int row() const;
int childrenCount() const;
void insertChild(const ChildPtr &child, int position = -1);
void removeChild(const ChildPtr &child);
ChildPtr child(int row) const;
private:
void setParent(const ParentPtr &parent);
void moveChild(const ChildPtr &child, int newPosition);
private:
ParentPtr parent_;
QVector<ChildPtr> children_;
};