blob: 18b3073ec20755c1bd64ead2c181476835a2f7e6 (
plain)
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
#include <QVBoxLayout>
#include <QWidget>
#include <QLabel>
#include <QPushButton>
#include "ui_tab_automations.h"
#include "ui_automation.h"
using std::pair;
class CDAddAutomationWidget : public QWidget {
public:
CDAddAutomationWidget(QWidget* parent) : QWidget(parent) {
QHBoxLayout* main_layout = new QHBoxLayout;
QPushButton* button_add = new QPushButton("Add automation");
main_layout->addStretch();
main_layout->addWidget(button_add);
main_layout->addStretch();
setLayout(main_layout);
}
~CDAddAutomationWidget() {}
};
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);
automations_widget->setLayout(automations);
main_layout->addWidget(automations_widget);
main_layout->addWidget(new_automation_button);
update();
setLayout(main_layout);
}
void CDAutomationsTabWidget::update() {
map<cd_link_t, cd_s_automation*> links = this->mainwindow->mesh_connector->get_links();
map<cd_link_t, CDAutomationWidget*> widgets;
for (pair<cd_link_t, cd_s_automation*> link : links) {
if (widgets.count(link.first)) { // node is already in list
widgets[link.first]->update();
} else {
widgets[link.first] = new CDAutomationWidget(link.second, this);
}
automations->addWidget(widgets[link.first]);
}
}
|