aboutsummaryrefslogtreecommitdiff
path: root/confui/ui_automation.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'confui/ui_automation.cpp')
-rw-r--r--confui/ui_automation.cpp24
1 files changed, 23 insertions, 1 deletions
diff --git a/confui/ui_automation.cpp b/confui/ui_automation.cpp
index f427930..2a04edb 100644
--- a/confui/ui_automation.cpp
+++ b/confui/ui_automation.cpp
@@ -1,7 +1,10 @@
#include "ui_automation.h"
+#include "mesh_connector.h"
+
+using std::pair;
CDAutomationWidget::~CDAutomationWidget() { }
-CDAutomationWidget::CDAutomationWidget(cd_s_automation* automation, QWidget *parent) : QWidget(parent) {
+CDAutomationWidget::CDAutomationWidget(cd_s_automation* automation, QWidget* parent) : QWidget(parent) {
set_automation(automation);
main_layout = new QHBoxLayout;
@@ -28,8 +31,27 @@ void CDAutomationWidget::set_automation(cd_s_automation* automation) {
void CDAutomationWidget::update() {
button_remove->setText("Delete");
+ map<cd_mac_addr_cpp_t, cd_s_node*> nodes = g_cd_mesh_connector->get_nodes(false);
+
+ for (pair<cd_mac_addr_cpp_t, cd_s_node*> node : nodes) {
+ QString label = "";
+ label.append(QString::fromLocal8Bit(node.second->name, node.second->name_len));
+ label.append(" (");
+ label.append(QString::fromStdString(cd_mac_to_string(node.second->address)));
+ label.append(")");
+
+ QString userData = QString::fromLocal8Bit((char*) node.second->address, 6);
+ dropdown_button->addItem(label, userData);
+ dropdown_light->addItem(label, userData);
+ }
+
+ dropdown_button->setCurrentIndex(dropdown_button->findData(QString::fromLocal8Bit((char*) _automation->button->address, 6)));
+
dropdown_action->clear();
dropdown_action->addItem("Toggles", CD_AUTOMATION_TYPE_TOGGLE);
dropdown_action->addItem("Switches on", CD_AUTOMATION_TYPE_TURN_ON);
dropdown_action->addItem("Switches off", CD_AUTOMATION_TYPE_TURN_OFF);
+ dropdown_action->setCurrentIndex(dropdown_action->findData(_automation->type));
+
+ dropdown_light->setCurrentIndex(dropdown_light->findData(QString::fromLocal8Bit((char*) _automation->light->address, 6)));
}