aboutsummaryrefslogtreecommitdiff
path: root/confui/ui_tab_node_overview.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'confui/ui_tab_node_overview.cpp')
-rw-r--r--confui/ui_tab_node_overview.cpp17
1 files changed, 12 insertions, 5 deletions
diff --git a/confui/ui_tab_node_overview.cpp b/confui/ui_tab_node_overview.cpp
index 44ef788..b3a79ee 100644
--- a/confui/ui_tab_node_overview.cpp
+++ b/confui/ui_tab_node_overview.cpp
@@ -11,15 +11,22 @@ CDNodeOverviewTabWidget::CDNodeOverviewTabWidget(CDMainWindow* main_window) : QW
this->mainwindow = main_window;
main_layout = new CDScrollContainerLayout(this);
- vector<cd_s_node*> nodes = this->mainwindow->mesh_connector->get_nodes();
- CDNodeWidget* nd_w = new CDNodeWidget(nodes[0], this);
-
- main_layout->addWidget(nd_w);
-
update();
setLayout(main_layout);
}
void CDNodeOverviewTabWidget::update() {
+ vector<cd_s_node*> nodes = this->mainwindow->mesh_connector->get_nodes();
+ map<uint8_t(*)[6], CDNodeWidget*> node_widgets;
+ for (cd_s_node* node : nodes) {
+ // c++ cast from uint8_t[6] to uint8_t* with length 6
+ uint8_t (*addr)[6] = (uint8_t (*)[6]) node->address;
+ if (node_widgets.count(addr)) { // node is already in list
+ node_widgets[addr]->update();
+ } else {
+ node_widgets[addr] = new CDNodeWidget(node, this);
+ }
+ main_layout->addWidget(node_widgets[addr]);
+ }
}