-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathModifyView.cpp
More file actions
113 lines (92 loc) · 3.39 KB
/
ModifyView.cpp
File metadata and controls
113 lines (92 loc) · 3.39 KB
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
#include "ModifyView.h"
#include "SensorsViewerManager.h"
ModifyView::ModifyView(QWidget *parent) : QWidget(parent), nameInput(new QLineEdit()), modelInput((new QLineEdit())), descriptionInput((new QLineEdit()))
{
}
ModifyView::~ModifyView()
{
delete nameInput;
delete modelInput;
delete descriptionInput;
}
QFrame *ModifyView::addModifySensorsView()
{
QFrame *frame = new QFrame();
frame->setStyleSheet("background-color: #f5f5f5;");
QVBoxLayout *layoutV1 = new QVBoxLayout(frame);
layoutV1->setAlignment(Qt::AlignHCenter);
layoutV1->setAlignment(Qt::AlignTop);
QVBoxLayout *layoutV2 = new QVBoxLayout();
QVBoxLayout *layoutV3 = new QVBoxLayout();
QVBoxLayout *layoutV4 = new QVBoxLayout();
QVBoxLayout *layoutV5 = new QVBoxLayout();
QLabel *label1 = new QLabel();
label1->setText("Modify name sensor");
label1->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
label1->setStyleSheet(Style::getLabelStyle());
label1->setAlignment(Qt::AlignHCenter);
label1->setFont(QFont("Arial", 15));
nameInput->setMinimumSize(0, 150);
nameInput->setStyleSheet(Style::getLineEditStyle());
QLabel *label2 = new QLabel();
label2->setText("Modify model sensor");
label2->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
label2->setStyleSheet(Style::getLabelStyle());
label2->setAlignment(Qt::AlignHCenter);
label2->setFont(QFont("Arial", 15));
modelInput->setMinimumSize(0, 150);
modelInput->setStyleSheet(Style::getLineEditStyle());
QLabel *label3 = new QLabel();
label3->setText("Modify description sensor");
label3->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
label3->setStyleSheet(Style::getLabelStyle());
label3->setAlignment(Qt::AlignHCenter);
label3->setFont(QFont("Arial", 15));
descriptionInput->setMinimumSize(0, 150);
descriptionInput->setStyleSheet(Style::getLineEditStyle());
QPushButton *commit = new QPushButton();
commit->setText("Modify sensor");
commit->setMinimumSize(150, 30);
commit->setStyleSheet(Style::getButton());
connect(commit, &QPushButton::clicked, this, [=](){manager->modifySensor(nameInput->text().toStdString(), modelInput->text().toStdString(), descriptionInput->text().toStdString());});
layoutV2->addWidget(label1);
layoutV2->addWidget(nameInput);
layoutV3->addWidget(label2);
layoutV3->addWidget(modelInput);
layoutV4->addWidget(label3);
layoutV4->addWidget(descriptionInput);
layoutV5->addWidget(commit);
layoutV5->setAlignment(Qt::AlignHCenter);
layoutV1->addLayout(layoutV2);
layoutV1->addLayout(layoutV3);
layoutV1->addLayout(layoutV4);
layoutV1->addLayout(layoutV5);
return frame;
}
void ModifyView::setManager(SensorsViewerManager *manager)
{
this->manager = manager;
}
void ModifyView::setSensorRef(const unsigned int& index)
{
this->index = index;
}
unsigned int ModifyView::getSensorRef() const
{
return index;
}
void ModifyView::setName(const std::string &name)
{
this->name = name;
nameInput->setText(QString::fromStdString(name));
}
void ModifyView::setModel(const std::string &model)
{
this->model = model;
modelInput->setText(QString::fromStdString(model));
}
void ModifyView::setDescription(const std::string &description)
{
this->description = description;
descriptionInput->setText(QString::fromStdString(description));
}