aboutsummaryrefslogtreecommitdiff
path: root/confui
diff options
context:
space:
mode:
Diffstat (limited to 'confui')
-rw-r--r--confui/mainwindow.cpp27
-rw-r--r--confui/mainwindow.h9
-rw-r--r--confui/makefile12
-rw-r--r--confui/mesh_connector.cpp121
-rw-r--r--confui/mesh_connector.h71
-rw-r--r--confui/ui_automation.cpp24
-rw-r--r--confui/ui_automation.h18
-rw-r--r--confui/ui_node.cpp15
-rw-r--r--confui/ui_node.h18
-rw-r--r--confui/ui_scroll_container.cpp15
-rw-r--r--confui/ui_scroll_container.h15
-rw-r--r--confui/ui_tab_automations.cpp34
-rw-r--r--confui/ui_tab_automations.h10
-rw-r--r--confui/ui_tab_node_overview.cpp16
-rw-r--r--confui/ui_tab_node_overview.h9
15 files changed, 200 insertions, 214 deletions
diff --git a/confui/mainwindow.cpp b/confui/mainwindow.cpp
index f5c29ed..cff5002 100644
--- a/confui/mainwindow.cpp
+++ b/confui/mainwindow.cpp
@@ -1,26 +1,24 @@
-#include <QMenuBar>
#include <QGridLayout>
+#include <QMenuBar>
#include <QTabWidget>
#include "mainwindow.h"
#include "ui_tab_automations.h"
#include "ui_tab_node_overview.h"
-CDMeshConnector* g_cd_mesh_connector = nullptr;
+CDMeshConnector *g_cd_mesh_connector = nullptr;
-CDMainWindow::~CDMainWindow() {
- delete this->mesh_connector;
-}
+CDMainWindow::~CDMainWindow() { delete this->mesh_connector; }
CDMainWindow::CDMainWindow(QWidget *parent) : QMainWindow(parent) {
- g_cd_mesh_connector = new CDMeshConnector();
+ g_cd_mesh_connector = new CDMeshConnector();
this->mesh_connector = g_cd_mesh_connector;
menu_bar = new QMenuBar(this);
- QTabWidget* tab_bar_widget = new QTabWidget(this);
+ QTabWidget *tab_bar_widget = new QTabWidget(this);
- automations_tab = new CDAutomationsTabWidget(this);
+ automations_tab = new CDAutomationsTabWidget(this);
node_overview_tab = new CDNodeOverviewTabWidget(this);
tab_bar_widget->addTab(this->node_overview_tab, "node overview");
@@ -39,26 +37,23 @@ void CDMainWindow::update() {
setWindowTitle("confui");
menu_bar->clear();
- QMenu* menu_options = menu_bar->addMenu("options");
+ QMenu *menu_options = menu_bar->addMenu("options");
- QAction* menu_options_refresh = menu_options->addAction("refresh node list");
+ QAction *menu_options_refresh = menu_options->addAction("refresh node list");
connect(menu_options_refresh, &QAction::triggered, this, &CDMainWindow::menu_refresh);
- QAction* menu_options_add_automation = menu_options->addAction("add automation");
+ QAction *menu_options_add_automation = menu_options->addAction("add automation");
connect(menu_options_add_automation, &QAction::triggered, this, &CDMainWindow::menu_add_automation);
- QMenu* menu_options_serialport = menu_options->addMenu("serial port (FIXME)");
+ QMenu *menu_options_serialport = menu_options->addMenu("serial port (FIXME)");
menu_options_serialport->addAction("FIXME A");
menu_options_serialport->addAction("FIXME B");
}
-void CDMainWindow::menu_refresh() {
- update();
-}
+void CDMainWindow::menu_refresh() { update(); }
void CDMainWindow::menu_add_automation() {
g_cd_mesh_connector->create_link();
update();
}
-
diff --git a/confui/mainwindow.h b/confui/mainwindow.h
index ad0e363..3a0b4f7 100644
--- a/confui/mainwindow.h
+++ b/confui/mainwindow.h
@@ -18,14 +18,15 @@ class CDNodeOverviewTabWidget;
*/
class CDMainWindow : public QMainWindow {
Q_OBJECT
+
private:
- QMenuBar* menu_bar = nullptr;
- CDAutomationsTabWidget* automations_tab = nullptr;
- CDNodeOverviewTabWidget* node_overview_tab = nullptr;
+ QMenuBar *menu_bar = nullptr;
+ CDAutomationsTabWidget *automations_tab = nullptr;
+ CDNodeOverviewTabWidget *node_overview_tab = nullptr;
public:
CDMeshConnector *mesh_connector = nullptr;
-
+
CDMainWindow(QWidget *parent = nullptr);
~CDMainWindow();
/** @brief update user interface */
diff --git a/confui/makefile b/confui/makefile
index 20a7c7e..930daed 100644
--- a/confui/makefile
+++ b/confui/makefile
@@ -12,3 +12,15 @@ confui: $(OBJECTS)
../shared/%.o: ../shared/%.c
$(CC) -c $(CFLAGS) -w $< -o $@
+
+FMT_FILES := $(DIST)
+FMT_FILES := $(filter-out .%,$(FMT_FILES)) # filter hidden files
+FMT_FILES := $(filter-out /%,$(FMT_FILES)) # filter files outside working directory
+FMT_FILES := $(filter-out %.conf,$(FMT_FILES)) # filter *.conf
+FMT_FILES := $(filter-out %.pri,$(FMT_FILES)) # filter *.pri
+FMT_FILES := $(filter-out %.prf,$(FMT_FILES)) # filter *.prf
+FMT_FILES := $(filter-out %.pro,$(FMT_FILES)) # filter *.pro
+
+format:
+ clang-format -i $(FMT_FILES)
+ clang-tidy --fix-errors $(FMT_FILES)
diff --git a/confui/mesh_connector.cpp b/confui/mesh_connector.cpp
index a9742cf..5b65d31 100644
--- a/confui/mesh_connector.cpp
+++ b/confui/mesh_connector.cpp
@@ -1,38 +1,34 @@
-#include <stdio.h>
-#include <cstdio>
-#include <cstring>
#include <algorithm>
#include <array>
+#include <cstdio>
+#include <cstring>
+#include <stdio.h>
#include "mesh_connector.h"
using std::pair;
-void CDMeshConnector::refresh_config_sync() { }
-void CDMeshConnector::refresh_nodes_sync() { }
+void CDMeshConnector::refresh_config_sync() {}
+void CDMeshConnector::refresh_nodes_sync() {}
-cd_link_t CDMeshConnector::get_new_link_id() {
- return _fresh_link_id++;
-}
+cd_link_t CDMeshConnector::get_new_link_id() { return _fresh_link_id++; }
-cd_uid_t CDMeshConnector::get_new_node_id() {
- return _fresh_node_id++;
-}
+cd_uid_t CDMeshConnector::get_new_node_id() { return _fresh_node_id++; }
CDMeshConnector::CDMeshConnector() {
cd_uid_t berta = create_node({
- .address = { 0x00, 0xff, 0x21, 0x69, 0xf2, 0x31 },
- .name_len = 5,
- .name = "berta",
- .light_on = false,
+ .address = {0x00, 0xff, 0x21, 0x69, 0xf2, 0x31},
+ .name_len = 5,
+ .name = "berta",
+ .light_on = false,
.provisioned = false,
});
cd_uid_t gerrit = create_node({
- .address = { 0x0e, 0xf9, 0x46, 0x4d, 0xe8, 0x02 },
- .name_len = 6,
- .name = "gerrit",
- .light_on = false,
+ .address = {0x0e, 0xf9, 0x46, 0x4d, 0xe8, 0x02},
+ .name_len = 6,
+ .name = "gerrit",
+ .light_on = false,
.provisioned = false,
});
@@ -44,17 +40,17 @@ CDMeshConnector::CDMeshConnector() {
}
cd_uid_t CDMeshConnector::create_node(cd_s_node node) {
- cd_s_node* _node = (cd_s_node*) malloc(sizeof(cd_s_node));
+ cd_s_node *_node = (cd_s_node *)malloc(sizeof(cd_s_node));
// id
cd_uid_t id = get_new_node_id();
- _node->id = id;
+ _node->id = id;
// address
memcpy(_node->address, node.address, sizeof(cd_mac_addr_t));
// name len
_node->name_len = node.name_len;
// name
- char* name = (char*) malloc(node.name_len);
+ char *name = (char *)malloc(node.name_len);
memcpy(name, node.name, node.name_len);
_node->name = name;
// light on
@@ -62,7 +58,7 @@ cd_uid_t CDMeshConnector::create_node(cd_s_node node) {
// provisioned
_node->provisioned = node.provisioned;
- printf("(new) node[%d] = %.*s\n", id, (int) node.name_len, node.name);
+ printf("(new) node[%d] = %.*s\n", id, (int)node.name_len, node.name);
_nodes[id] = _node;
return id;
@@ -70,44 +66,46 @@ cd_uid_t CDMeshConnector::create_node(cd_s_node node) {
CDMeshConnector::~CDMeshConnector() {
// free all automation structs
- for (pair<cd_link_t, cd_s_automation*> link : _links)
- remove_link(link.first);
+ for (pair<cd_link_t, cd_s_automation *> link : _links) remove_link(link.first);
// free all node structs
- for (pair<cd_uid_t, cd_s_node*> node : _nodes)
- remove_node(node.first);
+ for (pair<cd_uid_t, cd_s_node *> node : _nodes) remove_node(node.first);
return;
}
-map<cd_uid_t, cd_s_node*> CDMeshConnector::get_nodes(bool provisioned) {
+map<cd_uid_t, cd_s_node *> CDMeshConnector::get_nodes(bool provisioned) {
if (provisioned == false) return _nodes;
// filter only if provisioned nodes are desired
- map<cd_uid_t, cd_s_node*> nodes;
- for (pair<cd_uid_t, cd_s_node*> node : _nodes) {
+ map<cd_uid_t, cd_s_node *> nodes;
+ for (pair<cd_uid_t, cd_s_node *> node : _nodes) {
if (node.second->provisioned == false) continue;
nodes[node.first] = node.second;
}
return nodes;
}
-map<cd_link_t, cd_s_automation*> CDMeshConnector::get_links(bool valid) {
+map<cd_link_t, cd_s_automation *> CDMeshConnector::get_links(bool valid) {
if (valid == false) return _links;
// filter only if valid links are desired
- map<cd_link_t, cd_s_automation*> links;
- for (pair<cd_link_t, cd_s_automation*> link : _links) {
+ map<cd_link_t, cd_s_automation *> links;
+ for (pair<cd_link_t, cd_s_automation *> link : _links) {
if (link.second->valid == false) continue;
links[link.first] = link.second;
}
return links;
}
-void CDMeshConnector::update_link(cd_s_automation* automation) {
+void CDMeshConnector::update_link(cd_s_automation *automation) {
printf("link[%d]", automation->id);
if (automation->valid) {
- printf(" = %.*s %s %.*s", (int) automation->button->name_len, automation->button->name, automation->type == CD_AUTOMATION_TYPE_TOGGLE ? "toggles" : automation->type == CD_AUTOMATION_TYPE_TURN_OFF ? "turns off" : "turns on", (int) automation->light->name_len, automation->light->name);
+ printf(" = %.*s %s %.*s", (int)automation->button->name_len, automation->button->name,
+ automation->type == CD_AUTOMATION_TYPE_TOGGLE ? "toggles"
+ : automation->type == CD_AUTOMATION_TYPE_TURN_OFF ? "turns off"
+ : "turns on",
+ (int)automation->light->name_len, automation->light->name);
} else {
printf(" (invalid)");
}
@@ -117,12 +115,12 @@ void CDMeshConnector::update_link(cd_s_automation* automation) {
cd_link_t CDMeshConnector::create_link(cd_uid_t button, cd_uid_t light, enum cd_e_automation_type type) {
cd_link_t id = get_new_link_id();
- cd_s_automation* automation = (cd_s_automation*) malloc(sizeof(cd_s_automation));
- automation->id = id;
- automation->type = type;
- automation->button = _nodes[button];
- automation->light = _nodes[light];
- automation->valid = true;
+ cd_s_automation *automation = (cd_s_automation *)malloc(sizeof(cd_s_automation));
+ automation->id = id;
+ automation->type = type;
+ automation->button = _nodes[button];
+ automation->light = _nodes[light];
+ automation->valid = true;
printf("(new) ");
_links[id] = automation;
@@ -134,12 +132,12 @@ cd_link_t CDMeshConnector::create_link(cd_uid_t button, cd_uid_t light, enum cd_
cd_link_t CDMeshConnector::create_link() {
cd_link_t id = get_new_link_id();
- cd_s_automation* automation = (cd_s_automation*) malloc(sizeof(cd_s_automation));
- automation->id = id;
- automation->type = CD_AUTOMATION_TYPE_TOGGLE;
- automation->button = nullptr;
- automation->light = nullptr;
- automation->valid = false;
+ cd_s_automation *automation = (cd_s_automation *)malloc(sizeof(cd_s_automation));
+ automation->id = id;
+ automation->type = CD_AUTOMATION_TYPE_TOGGLE;
+ automation->button = nullptr;
+ automation->light = nullptr;
+ automation->valid = false;
printf("(new) ");
_links[id] = automation;
@@ -150,50 +148,43 @@ cd_link_t CDMeshConnector::create_link() {
void CDMeshConnector::remove_link(cd_link_t link_handle) {
printf("remove link[%d]\n", link_handle);
- if (_links[link_handle] != nullptr)
- free(_links[link_handle]);
+ if (_links[link_handle] != nullptr) free(_links[link_handle]);
_links[link_handle] = nullptr;
return;
}
void CDMeshConnector::remove_node(cd_uid_t node_handle) {
printf("remove node[%d]\n", node_handle);
- if (_nodes[node_handle] != nullptr)
- free(_nodes[node_handle]);
+ if (_nodes[node_handle] != nullptr) free(_nodes[node_handle]);
_nodes[node_handle] = nullptr;
return;
}
-void CDMeshConnector::update_node(cd_s_node* node_ptr) {
- printf("turning %.*s %s\n", (int) node_ptr->name_len, node_ptr->name, node_ptr->light_on ? "on" : "off");
+void CDMeshConnector::update_node(cd_s_node *node_ptr) {
+ printf("turning %.*s %s\n", (int)node_ptr->name_len, node_ptr->name, node_ptr->light_on ? "on" : "off");
return;
}
-void CDMeshConnector::network_join_node(cd_s_node* node_ptr) {
+void CDMeshConnector::network_join_node(cd_s_node *node_ptr) {
node_ptr->provisioned = true;
- printf("join %.*s into network\n", (int) node_ptr->name_len, node_ptr->name);
+ printf("join %.*s into network\n", (int)node_ptr->name_len, node_ptr->name);
return;
}
-void CDMeshConnector::network_remove_node(cd_s_node* node_ptr) {
+void CDMeshConnector::network_remove_node(cd_s_node *node_ptr) {
node_ptr->provisioned = false;
- printf("remove %.*s from network\n", (int) node_ptr->name_len, node_ptr->name);
+ printf("remove %.*s from network\n", (int)node_ptr->name_len, node_ptr->name);
return;
}
string CDMeshConnector::cd_mac_to_string(cd_mac_addr_t mac) {
- char* addr = nullptr;
+ char *addr = nullptr;
asprintf(&addr, "%02x:%02x:%02x:%02x:%02x:%02x", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
string ret = addr;
free(addr);
return ret;
}
-cd_s_automation* CDMeshConnector::get_link(cd_link_t id) {
- return _links[id];
-}
-
-cd_s_node* CDMeshConnector::get_node(cd_uid_t id) {
- return _nodes[id];
-}
+cd_s_automation *CDMeshConnector::get_link(cd_link_t id) { return _links[id]; }
+cd_s_node *CDMeshConnector::get_node(cd_uid_t id) { return _nodes[id]; }
diff --git a/confui/mesh_connector.h b/confui/mesh_connector.h
index dcab354..176778f 100644
--- a/confui/mesh_connector.h
+++ b/confui/mesh_connector.h
@@ -1,15 +1,15 @@
#pragma once
-#include <stdint.h>
-#include <vector>
#include <map>
+#include <stdint.h>
#include <string>
+#include <vector>
-using std::size_t;
-using std::vector;
+using std::array;
using std::map;
+using std::size_t;
using std::string;
-using std::array;
+using std::vector;
/** @brief node id type, GUI only */
typedef uint32_t cd_uid_t;
@@ -20,33 +20,33 @@ typedef uint8_t cd_mac_addr_t[6];
/** @brief automation types/actions */
enum cd_e_automation_type {
- CD_AUTOMATION_TYPE_TOGGLE, /** @brief button toggles light */
- CD_AUTOMATION_TYPE_TURN_ON, /** @brief button always turns on light (regardless of previous state) */
+ CD_AUTOMATION_TYPE_TOGGLE, /** @brief button toggles light */
+ CD_AUTOMATION_TYPE_TURN_ON, /** @brief button always turns on light (regardless of previous state) */
CD_AUTOMATION_TYPE_TURN_OFF, /** @brief button always turns off light (regardless of previous state) */
};
/** @brief GUI node representation */
typedef struct {
- cd_uid_t id; /** @brief GUI-specific id (used as handle) */
+ cd_uid_t id; /** @brief GUI-specific id (used as handle) */
cd_mac_addr_t address; /** @brief node bluetooth mac address */
- size_t name_len; /** @brief name length in bytes */
- const char* name; /** @brief user-friendly node name */
- bool light_on; /** @brief state of light on node */
- bool provisioned; /** @brief whether the node is provisioned into the network */
+ size_t name_len; /** @brief name length in bytes */
+ const char *name; /** @brief user-friendly node name */
+ bool light_on; /** @brief state of light on node */
+ bool provisioned; /** @brief whether the node is provisioned into the network */
} cd_s_node;
/** @brief automation/link struct */
typedef struct {
- cd_link_t id; /** @brief automation id (also used as handle) */
+ cd_link_t id; /** @brief automation id (also used as handle) */
cd_e_automation_type type; /** @brief automation type/action */
- cd_s_node* button; /** @brief pointer to node with button */
- cd_s_node* light; /** @brief pointer to node with light */
- bool valid; /** @brief whether .button and .light are valid pointers (complete automation) */
+ cd_s_node *button; /** @brief pointer to node with button */
+ cd_s_node *light; /** @brief pointer to node with light */
+ bool valid; /** @brief whether .button and .light are valid pointers (complete automation) */
} cd_s_automation;
/**
* @brief mesh network connector
- *
+ *
* handles communication with the border router over a serial connection and
* exposes current network state through structured data (as defined above).
*
@@ -58,12 +58,12 @@ typedef struct {
class CDMeshConnector {
private:
/** @brief list of links */
- map<cd_link_t, cd_s_automation*> _links;
+ map<cd_link_t, cd_s_automation *> _links;
/** @brief list of nodes */
- map<cd_uid_t, cd_s_node*> _nodes;
+ map<cd_uid_t, cd_s_node *> _nodes;
cd_link_t _fresh_link_id = 0;
- cd_uid_t _fresh_node_id = 0;
+ cd_uid_t _fresh_node_id = 0;
/** @brief get 'fresh' link id and increment */
virtual cd_link_t get_new_link_id();
@@ -89,21 +89,19 @@ public:
/**
* @brief get map of automations and their respective handles
*
- * @param valid `valid` field of automation needs to match this value.
- * `true` by default
+ * @param valid `valid` field of automation needs to match this value. `true` by default
*/
- virtual map<cd_link_t, cd_s_automation*> get_links(bool valid = true);
+ virtual map<cd_link_t, cd_s_automation *> get_links(bool valid = true);
/**
* @brief get map of nodes and their respective handles
*
- * @param provisioned `provisioned` field of node needs to match this value.
- * `false` by default
+ * @param provisioned `provisioned` field of node needs to match this value. `false` by default
*/
- virtual map<cd_uid_t, cd_s_node*> get_nodes(bool provisioned = false);
+ virtual map<cd_uid_t, cd_s_node *> get_nodes(bool provisioned = false);
/** @brief get automation pointer by automation id */
- virtual cd_s_automation* get_link(cd_link_t id);
+ virtual cd_s_automation *get_link(cd_link_t id);
/** @brief get node pointer by node id */
- virtual cd_s_node* get_node(cd_uid_t id);
+ virtual cd_s_node *get_node(cd_uid_t id);
// network modification functions
/** @brief create empty automation */
@@ -112,10 +110,8 @@ public:
* @brief create valid automation with filled-in fields and update on
* network.
*
- * @param button node id for node whose button will be used for this
- * automation.
- * @param light node id for node whose light will be used for this
- * automation.
+ * @param button node id for node whose button will be used for this automation.
+ * @param light node id for node whose light will be used for this automation.
* @param action action/automation type (toggle, on, off).
*/
virtual cd_link_t create_link(cd_uid_t button, cd_uid_t light, enum cd_e_automation_type action);
@@ -128,7 +124,7 @@ public:
*
* @param automation pointer to automation struct (with new/modified values)
*/
- virtual void update_link(cd_s_automation* automation);
+ virtual void update_link(cd_s_automation *automation);
/**
* @brief remove automation and update on network.
*
@@ -144,19 +140,19 @@ public:
*
* @param node_ptr pointer to node struct (with new/modified state)
*/
- virtual void update_node(cd_s_node* node_ptr);
+ virtual void update_node(cd_s_node *node_ptr);
/**
* @brief provision node into network
*
* @param node_ptr pointer to node struct
*/
- virtual void network_join_node(cd_s_node* node_ptr);
+ virtual void network_join_node(cd_s_node *node_ptr);
/**
* @brief provision node out of network (remove from network)
*
* @param node_ptr pointer to node struct
*/
- virtual void network_remove_node(cd_s_node* node_ptr);
+ virtual void network_remove_node(cd_s_node *node_ptr);
// conversion functions
/** @brief convert `cd_mac_addr_t` to `std::string` for printing/GUI */
@@ -164,5 +160,4 @@ public:
};
/** @brief global pointer to mesh connector, initialized in CDMainWindow */
-extern CDMeshConnector* g_cd_mesh_connector;
-
+extern CDMeshConnector *g_cd_mesh_connector;
diff --git a/confui/ui_automation.cpp b/confui/ui_automation.cpp
index d4e84a7..eb6e1f6 100644
--- a/confui/ui_automation.cpp
+++ b/confui/ui_automation.cpp
@@ -1,18 +1,18 @@
-#include "ui_tab_automations.h"
#include "ui_automation.h"
#include "mesh_connector.h"
+#include "ui_tab_automations.h"
using std::pair;
-CDAutomationWidget::~CDAutomationWidget() { }
-CDAutomationWidget::CDAutomationWidget(QWidget* parent) : QWidget(parent) {
- _parent = (CDAutomationsTabWidget*) parent;
+CDAutomationWidget::~CDAutomationWidget() {}
+CDAutomationWidget::CDAutomationWidget(QWidget *parent) : QWidget(parent) {
+ _parent = (CDAutomationsTabWidget *)parent;
main_layout = new QHBoxLayout;
dropdown_button = new QComboBox;
dropdown_action = new QComboBox;
- dropdown_light = new QComboBox;
- button_remove = new QPushButton("Delete");
+ dropdown_light = new QComboBox;
+ button_remove = new QPushButton("Delete");
main_layout->addWidget(dropdown_button);
main_layout->addWidget(dropdown_action);
@@ -31,16 +31,16 @@ CDAutomationWidget::CDAutomationWidget(QWidget* parent) : QWidget(parent) {
}
void CDAutomationWidget::set_automation(cd_link_t link) {
- _id = link;
+ _id = link;
_automation = g_cd_mesh_connector->get_link(link);
}
void CDAutomationWidget::update() {
- map<cd_uid_t, cd_s_node*> nodes = g_cd_mesh_connector->get_nodes(false);
+ map<cd_uid_t, cd_s_node *> nodes = g_cd_mesh_connector->get_nodes(false);
dropdown_button->clear();
dropdown_light->clear();
- for (pair<cd_uid_t, cd_s_node*> node : nodes) {
+ for (pair<cd_uid_t, cd_s_node *> node : nodes) {
QString label = "";
label.append(QString::fromLocal8Bit(node.second->name, node.second->name_len));
label.append(" (");
@@ -74,9 +74,9 @@ void CDAutomationWidget::apply() {
if (!conf_valid()) return;
_automation->button = g_cd_mesh_connector->get_node(dropdown_button->findData(dropdown_button->currentIndex()));
- _automation->type = (enum cd_e_automation_type) dropdown_action->findData(dropdown_action->currentIndex());
- _automation->light = g_cd_mesh_connector->get_node(dropdown_light->findData(dropdown_light->currentIndex()));
- _automation->valid = true;
+ _automation->type = (enum cd_e_automation_type)dropdown_action->findData(dropdown_action->currentIndex());
+ _automation->light = g_cd_mesh_connector->get_node(dropdown_light->findData(dropdown_light->currentIndex()));
+ _automation->valid = true;
g_cd_mesh_connector->update_link(_automation);
}
diff --git a/confui/ui_automation.h b/confui/ui_automation.h
index 69f2bdd..f0608bc 100644
--- a/confui/ui_automation.h
+++ b/confui/ui_automation.h
@@ -1,10 +1,10 @@
#pragma once
-#include <QWidget>
+#include <QComboBox>
#include <QHBoxLayout>
#include <QPushButton>
#include <QString>
-#include <QComboBox>
+#include <QWidget>
#include "mesh_connector.h"
@@ -14,15 +14,15 @@ class CDAutomationWidget : public QWidget {
Q_OBJECT
private:
- cd_s_automation* _automation = nullptr;
+ cd_s_automation *_automation = nullptr;
cd_link_t _id;
- CDAutomationsTabWidget* _parent = nullptr;
+ CDAutomationsTabWidget *_parent = nullptr;
- QHBoxLayout* main_layout;
- QComboBox* dropdown_button;
- QComboBox* dropdown_action;
- QComboBox* dropdown_light;
- QPushButton* button_remove;
+ QHBoxLayout *main_layout;
+ QComboBox *dropdown_button;
+ QComboBox *dropdown_action;
+ QComboBox *dropdown_light;
+ QPushButton *button_remove;
public:
CDAutomationWidget(QWidget *parent = nullptr);
diff --git a/confui/ui_node.cpp b/confui/ui_node.cpp
index 3bb3bc7..552b62a 100644
--- a/confui/ui_node.cpp
+++ b/confui/ui_node.cpp
@@ -1,12 +1,12 @@
#include "ui_node.h"
-CDNodeWidget::~CDNodeWidget() { }
+CDNodeWidget::~CDNodeWidget() {}
CDNodeWidget::CDNodeWidget(QWidget *parent) : QWidget(parent) {
- main_layout = new QHBoxLayout;
- switch_on_off = new QCheckBox;
- button_add_remove = new QPushButton;
+ main_layout = new QHBoxLayout;
+ switch_on_off = new QCheckBox;
+ button_add_remove = new QPushButton;
label_node_address = new QLabel;
- label_node_name = new QLabel;
+ label_node_name = new QLabel;
main_layout->addWidget(label_node_name);
main_layout->addWidget(label_node_address);
@@ -22,14 +22,14 @@ CDNodeWidget::CDNodeWidget(QWidget *parent) : QWidget(parent) {
}
void CDNodeWidget::set_node(cd_uid_t id) {
- _id = id;
+ _id = id;
_node = g_cd_mesh_connector->get_node(id);
}
void CDNodeWidget::update() {
if (_node == nullptr) return;
- QString node_name = QString::fromLocal8Bit(_node->name, _node->name_len);
+ QString node_name = QString::fromLocal8Bit(_node->name, _node->name_len);
label_node_name->setText(node_name);
QString node_address = QString::fromStdString(CDMeshConnector::cd_mac_to_string(_node->address));
@@ -58,4 +58,3 @@ void CDNodeWidget::update_led(bool on) {
update();
}
-
diff --git a/confui/ui_node.h b/confui/ui_node.h
index 3aa16e5..eb07f6d 100644
--- a/confui/ui_node.h
+++ b/confui/ui_node.h
@@ -1,11 +1,11 @@
#pragma once
-#include <QWidget>
-#include <QLabel>
-#include <QHBoxLayout>
#include <QCheckBox>
+#include <QHBoxLayout>
+#include <QLabel>
#include <QPushButton>
#include <QString>
+#include <QWidget>
#include "mesh_connector.h"
@@ -14,14 +14,14 @@ class CDNodeWidget : public QWidget {
Q_OBJECT
private:
- cd_s_node* _node = nullptr;
+ cd_s_node *_node = nullptr;
cd_uid_t _id;
- QHBoxLayout* main_layout;
- QLabel* label_node_name;
- QLabel* label_node_address;
- QCheckBox* switch_on_off;
- QPushButton* button_add_remove;
+ QHBoxLayout *main_layout;
+ QLabel *label_node_name;
+ QLabel *label_node_address;
+ QCheckBox *switch_on_off;
+ QPushButton *button_add_remove;
public:
CDNodeWidget(QWidget *parent = nullptr);
diff --git a/confui/ui_scroll_container.cpp b/confui/ui_scroll_container.cpp
index 6b15221..af7c6fa 100644
--- a/confui/ui_scroll_container.cpp
+++ b/confui/ui_scroll_container.cpp
@@ -1,10 +1,10 @@
#include "ui_scroll_container.h"
-CDScrollContainerLayout::~CDScrollContainerLayout() { }
+CDScrollContainerLayout::~CDScrollContainerLayout() {}
CDScrollContainerLayout::CDScrollContainerLayout(QWidget *parent) : QVBoxLayout(parent) {
- scroll_area = new QScrollArea;
+ scroll_area = new QScrollArea;
scroll_container = new QWidget;
- scroll_inner = new QVBoxLayout;
+ scroll_inner = new QVBoxLayout;
scroll_area->setWidgetResizable(true);
scroll_area->setFrameShape(QFrame::NoFrame);
@@ -20,11 +20,6 @@ CDScrollContainerLayout::CDScrollContainerLayout(QWidget *parent) : QVBoxLayout(
QVBoxLayout::addWidget(scroll_area);
}
-void CDScrollContainerLayout::addWidget(QWidget* widget) {
- scroll_inner->addWidget(widget);
-}
-
-void CDScrollContainerLayout::removeWidget(QWidget* widget) {
- scroll_inner->removeWidget(widget);
-}
+void CDScrollContainerLayout::addWidget(QWidget *widget) { scroll_inner->addWidget(widget); }
+void CDScrollContainerLayout::removeWidget(QWidget *widget) { scroll_inner->removeWidget(widget); }
diff --git a/confui/ui_scroll_container.h b/confui/ui_scroll_container.h
index 716b3c9..bed16a4 100644
--- a/confui/ui_scroll_container.h
+++ b/confui/ui_scroll_container.h
@@ -1,25 +1,24 @@
#pragma once
#include <QScrollArea>
-#include <QWidget>
#include <QVBoxLayout>
+#include <QWidget>
/** @brief generic vertically scrolling layout */
class CDScrollContainerLayout : public QVBoxLayout {
Q_OBJECT
private:
- QVBoxLayout* main_layout;
- QScrollArea* scroll_area;
- QWidget* scroll_container;
- QVBoxLayout* scroll_inner;
+ QVBoxLayout *main_layout;
+ QScrollArea *scroll_area;
+ QWidget *scroll_container;
+ QVBoxLayout *scroll_inner;
public:
CDScrollContainerLayout(QWidget *parent = nullptr);
virtual ~CDScrollContainerLayout();
/** @brief add widget to layout */
- virtual void addWidget(QWidget* widget);
+ virtual void addWidget(QWidget *widget);
/** @brief remove widget from layout */
- virtual void removeWidget(QWidget* widget);
+ virtual void removeWidget(QWidget *widget);
};
-
diff --git a/confui/ui_tab_automations.cpp b/confui/ui_tab_automations.cpp
index 89ad5d4..7dd150e 100644
--- a/confui/ui_tab_automations.cpp
+++ b/confui/ui_tab_automations.cpp
@@ -1,7 +1,7 @@
-#include <QVBoxLayout>
-#include <QWidget>
#include <QLabel>
#include <QPushButton>
+#include <QVBoxLayout>
+#include <QWidget>
#include "ui_tab_automations.h"
@@ -9,7 +9,7 @@ using std::pair;
class CDAddAutomationWidget : public QWidget {
private:
- CDAutomationsTabWidget* _parent;
+ CDAutomationsTabWidget *_parent;
public:
void new_automation() {
@@ -17,11 +17,11 @@ public:
_parent->update();
}
- CDAddAutomationWidget(QWidget* parent) : QWidget(parent) {
- _parent = (CDAutomationsTabWidget*) parent;
+ CDAddAutomationWidget(QWidget *parent) : QWidget(parent) {
+ _parent = (CDAutomationsTabWidget *)parent;
- QHBoxLayout* main_layout = new QHBoxLayout;
- QPushButton* button_add = new QPushButton("Add automation");
+ QHBoxLayout *main_layout = new QHBoxLayout;
+ QPushButton *button_add = new QPushButton("Add automation");
main_layout->addStretch();
main_layout->addWidget(button_add);
@@ -35,15 +35,14 @@ public:
~CDAddAutomationWidget() {}
};
-
-CDAutomationsTabWidget::~CDAutomationsTabWidget() { }
-CDAutomationsTabWidget::CDAutomationsTabWidget(CDMainWindow* main_window) : QWidget(main_window) {
- this->mainwindow = main_window;
- main_layout = new CDScrollContainerLayout(this);
- automations = new QVBoxLayout;
+CDAutomationsTabWidget::~CDAutomationsTabWidget() {}
+CDAutomationsTabWidget::CDAutomationsTabWidget(CDMainWindow *main_window) : QWidget(main_window) {
+ this->mainwindow = main_window;
+ main_layout = new CDScrollContainerLayout(this);
+ automations = new QVBoxLayout;
new_automation_button = new CDAddAutomationWidget(this);
- QWidget* automations_widget = new QWidget(this);
+ QWidget *automations_widget = new QWidget(this);
automations_widget->setLayout(automations);
main_layout->addWidget(automations_widget);
@@ -54,9 +53,9 @@ CDAutomationsTabWidget::CDAutomationsTabWidget(CDMainWindow* main_window) : QWid
}
void CDAutomationsTabWidget::update() {
- map<cd_link_t, cd_s_automation*> links = this->mainwindow->mesh_connector->get_links(false);
+ map<cd_link_t, cd_s_automation *> links = this->mainwindow->mesh_connector->get_links(false);
- for (pair<cd_link_t, cd_s_automation*> link : links) {
+ for (pair<cd_link_t, cd_s_automation *> link : links) {
if (automation_widgets.count(link.first) == 0) {
automation_widgets[link.first] = new CDAutomationWidget(this); // create new automation
automation_widgets[link.first]->set_automation(link.first);
@@ -66,9 +65,8 @@ void CDAutomationsTabWidget::update() {
automation_widgets[link.first]->update(); // update existing widget
} else if (automation_widgets[link.first] != nullptr) {
automations->removeWidget(automation_widgets[link.first]); // remove removed automation
- delete automation_widgets[link.first]; // free automation widget
+ delete automation_widgets[link.first]; // free automation widget
automation_widgets[link.first] = nullptr;
}
}
}
-
diff --git a/confui/ui_tab_automations.h b/confui/ui_tab_automations.h
index 6a1f372..04eac22 100644
--- a/confui/ui_tab_automations.h
+++ b/confui/ui_tab_automations.h
@@ -12,14 +12,14 @@ class CDAutomationsTabWidget : public QWidget {
Q_OBJECT
private:
- CDScrollContainerLayout* main_layout;
- QVBoxLayout* automations;
- CDAddAutomationWidget* new_automation_button;
- map<cd_link_t, CDAutomationWidget*> automation_widgets;
+ CDScrollContainerLayout *main_layout;
+ QVBoxLayout *automations;
+ CDAddAutomationWidget *new_automation_button;
+ map<cd_link_t, CDAutomationWidget *> automation_widgets;
public:
CDMainWindow *mainwindow = nullptr;
-
+
CDAutomationsTabWidget(CDMainWindow *main_window = nullptr);
virtual ~CDAutomationsTabWidget();
/** @brief cascading ui update (add/remove/update automations in scrolling
diff --git a/confui/ui_tab_node_overview.cpp b/confui/ui_tab_node_overview.cpp
index 7b6c53a..ff1df4b 100644
--- a/confui/ui_tab_node_overview.cpp
+++ b/confui/ui_tab_node_overview.cpp
@@ -1,25 +1,25 @@
-#include <QWidget>
#include <QLabel>
-#include <QVBoxLayout>
#include <QScrollArea>
+#include <QVBoxLayout>
+#include <QWidget>
#include "ui_tab_node_overview.h"
using std::pair;
-CDNodeOverviewTabWidget::~CDNodeOverviewTabWidget() { }
-CDNodeOverviewTabWidget::CDNodeOverviewTabWidget(CDMainWindow* main_window) : QWidget(main_window) {
+CDNodeOverviewTabWidget::~CDNodeOverviewTabWidget() {}
+CDNodeOverviewTabWidget::CDNodeOverviewTabWidget(CDMainWindow *main_window) : QWidget(main_window) {
this->mainwindow = main_window;
- main_layout = new CDScrollContainerLayout(this);
+ main_layout = new CDScrollContainerLayout(this);
update();
setLayout(main_layout);
}
void CDNodeOverviewTabWidget::update() {
- map<cd_uid_t, cd_s_node*> nodes = g_cd_mesh_connector->get_nodes(false);
+ map<cd_uid_t, cd_s_node *> nodes = g_cd_mesh_connector->get_nodes(false);
- for (pair<cd_uid_t, cd_s_node*> node : nodes) {
+ for (pair<cd_uid_t, cd_s_node *> node : nodes) {
if (node_widgets.count(node.first) == 0) {
node_widgets[node.first] = new CDNodeWidget(this); // create new node widget
node_widgets[node.first]->set_node(node.first);
@@ -29,7 +29,7 @@ void CDNodeOverviewTabWidget::update() {
node_widgets[node.first]->update(); // update existing widget
} else if (node_widgets[node.first] != nullptr) {
main_layout->removeWidget(node_widgets[node.first]); // remove removed automation
- delete node_widgets[node.first]; // free automation widget
+ delete node_widgets[node.first]; // free automation widget
node_widgets[node.first] = nullptr;
}
}
diff --git a/confui/ui_tab_node_overview.h b/confui/ui_tab_node_overview.h
index dc4a951..278a190 100644
--- a/confui/ui_tab_node_overview.h
+++ b/confui/ui_tab_node_overview.h
@@ -11,14 +11,15 @@ class CDNodeOverviewTabWidget : public QWidget {
Q_OBJECT
private:
- CDScrollContainerLayout* main_layout;
- map<cd_uid_t, CDNodeWidget*> node_widgets;
+ CDScrollContainerLayout *main_layout;
+ map<cd_uid_t, CDNodeWidget *> node_widgets;
public:
CDMainWindow *mainwindow = nullptr;
-
+
CDNodeOverviewTabWidget(CDMainWindow *main_window = nullptr);
virtual ~CDNodeOverviewTabWidget();
- /** @brief cascading ui update (add/remove/update nodes in scrolling view) */
+ /** @brief cascading ui update (add/remove/update nodes in scrolling view)
+ */
virtual void update();
};