TreeWidget.h
Go to the documentation of this file.
1#pragma once
2
3#include <map>
4
5#include <QTreeWidget>
6
9
10namespace armarx::armem::gui
11{
12
13 class TreeWidget : public QTreeWidget
14 {
15 Q_OBJECT
16 using This = TreeWidget;
17
18 public:
19 TreeWidget();
20
21 void update(const armem::wm::Memory& memory);
22 void update(const std::map<std::string, const armem::wm::Memory*>& memories);
23
24 std::optional<MemoryID> selectedID() const;
25
26
27 signals:
28
29 /// Tree contents have changed.
30 void updated();
31
32 /// The selected item or its contents have changed.
34
35 void itemSelected(const MemoryID& id);
36
37 void memorySelected(const MemoryID& id);
40 void entitySelected(const MemoryID& id);
41 void snapshotSelected(const MemoryID& id);
42 void instanceSelected(const MemoryID& id);
43
44 void actionsMenuRequested(const MemoryID& memoryID,
45 QWidget* parent,
46 const QPoint& pos,
47 QMenu* menu);
48
49
50 private slots:
51
52 void handleSelection();
53
54
55 private:
56 void initWidget();
57 void initBuilders();
58
59 void updateChildren(const armem::wm::Memory& memory, QTreeWidget* tree);
60 void updateChildren(const std::map<std::string, const armem::wm::Memory*>& memories,
61 QTreeWidget* tree);
62
63 void updateChildren(const armem::wm::Memory& memory, QTreeWidgetItem* memoryItem);
64 void updateChildren(const armem::wm::CoreSegment& coreSeg, QTreeWidgetItem* coreSegItem);
65 void updateChildren(const armem::wm::ProviderSegment& provSeg,
66 QTreeWidgetItem* provSegItem);
67 void updateChildren(const armem::wm::Entity& entity, QTreeWidgetItem* entityItem);
68 void updateChildren(const armem::wm::EntitySnapshot& snapshot,
69 QTreeWidgetItem* snapshotItem);
70 void updateChildren(const armem::wm::EntityInstance& data, QTreeWidgetItem* parent);
71
72 void prepareTreeContextMenu(const QPoint& pos);
73
74 template <class MemoryItemT>
75 QTreeWidgetItem* makeItem(const std::string& key, const MemoryItemT& memoryItem);
76 QTreeWidgetItem*
77 makeItem(const std::string& key, const std::string& levelName, const MemoryID& id);
78
79 void updateItemItem(const armem::base::detail::MemoryItem& level, QTreeWidgetItem* item);
80 template <class ContainerT>
81 void updateContainerItem(const ContainerT& container, QTreeWidgetItem* item);
82
83
84 private:
86 TreeWidgetBuilder<wm::CoreSegment> coreSegmentBuilder;
91
92 std::optional<MemoryID> _selectedID;
93 /// While this is false, do not handle selection updates.
94 bool handleSelections = true;
95
96 enum class Columns
97 {
98 KEY = 0,
99 SIZE = 1,
100 TYPE = 2,
101 LEVEL = 3,
102 ID = 4,
103 NUM = 5
104 };
105 };
106
107} // namespace armarx::armem::gui
108
109namespace armarx::armem::gui
110{
112}
Base class of memory classes on different levels.
Definition MemoryItem.h:14
void entitySelected(const MemoryID &id)
void selectedItemChanged(const MemoryID &id)
The selected item or its contents have changed.
void actionsMenuRequested(const MemoryID &memoryID, QWidget *parent, const QPoint &pos, QMenu *menu)
void updated()
Tree contents have changed.
void update(const armem::wm::Memory &memory)
void snapshotSelected(const MemoryID &id)
void instanceSelected(const MemoryID &id)
void itemSelected(const MemoryID &id)
void coreSegmentSelected(const MemoryID &id)
std::optional< MemoryID > selectedID() const
void memorySelected(const MemoryID &id)
void providerSegmentSelected(const MemoryID &id)
Client-side working memory core segment.
Client-side working entity instance.
Client-side working memory entity snapshot.
Client-side working memory entity.
Client-side working memory.
Client-side working memory provider segment.
Brief description of class memory.
Definition memory.h:39
TreeWidget MemoryTreeWidget
Definition TreeWidget.h:111
A class to efficiently build and maintain sorted items of QTreeWidget or QTreeWidgetItem based on a m...
A class to efficiently build and maintain sorted items of QTreeWidget or QTreeWidgetItem based on a s...