-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtree_item.hpp
41 lines (32 loc) · 1.01 KB
/
tree_item.hpp
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
39
40
41
#ifndef TREE_ITEM_HPP
#define TREE_ITEM_HPP
#include "item_data.hpp"
#include <QVariant>
#include <QHash>
#include <memory>
#include <vector>
class TreeItem {
public:
using ItemUptr = std::unique_ptr<TreeItem>;
explicit TreeItem (int columns = 0, TreeItem* parent = nullptr);
TreeItem* parent ();
TreeItem* child (int index);
int childCount () const;
int columns () const;
int row () const;
void insertChild (int index, ItemUptr item);
void appendChild (ItemUptr item);
void removeChildren (int first, int count);
void insertColumns (int start, int count);
void removeColumns (int start, int count);
QVariant data (int column, int role = Qt::DisplayRole) const;
void setData (int column, int role, const QVariant& value);
private:
// methods
void setParent (TreeItem* parent);
// data
TreeItem* parent_;
std::vector<ItemUptr> children_;
std::vector<ItemData> data_;
};
#endif // TREE_ITEM_HPP