-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinverterselection.cpp
More file actions
124 lines (84 loc) · 2.91 KB
/
Copy pathinverterselection.cpp
File metadata and controls
124 lines (84 loc) · 2.91 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
114
115
116
117
118
119
120
121
122
123
124
#include "inverterselection.h"
#include <QPixmap>
#include "configmodel.h"
#include "connector.h"
InverterSelection::InverterSelection(QWidget *parent) :
QDialog(parent)
{
setupUi();
widlist = new widgetlist();
}
InverterSelection::~InverterSelection()
{
delete widlist;
}
void InverterSelection::setupUi()
{
if (this->objectName().isEmpty())
this->setObjectName(QString::fromUtf8("InverterSelection"));
this->resize(400, 300);
buttonBox = new QDialogButtonBox(this);
buttonBox->setObjectName(QString::fromUtf8("buttonBox"));
buttonBox->setGeometry(QRect(30, 240, 341, 32));
buttonBox->setOrientation(Qt::Horizontal);
buttonBox->setStandardButtons(QDialogButtonBox::Cancel|QDialogButtonBox::Ok);
listView = new QListWidget(this);
listView->setObjectName(QString::fromUtf8("listWidget"));
listView->setGeometry(QRect(10, 10, 256, 192));
listView->setSelectionMode(QAbstractItemView::MultiSelection);
retranslateUi();
QObject::connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
QObject::connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
QMetaObject::connectSlotsByName(this);
} // setupUi
void InverterSelection::retranslateUi()
{
this->setWindowTitle(QCoreApplication::translate("InverterSelection", "Dialog", nullptr));
} // retranslateUi
void InverterSelection::addelement(){
ConfigModel *conf = ConfigModel::getConfig();
int i = conf->getelementcount();
for(const auto & [id, name] : *conf->getheaders()){
std::cout<<"header:"<<name<<std::endl;
QListWidgetItem *lwi = new QListWidgetItem(listView);
widlist->push_back(lwi);
QPixmap qpm(inverter_ico);
QIcon qi(qpm);
lwi->setIcon(qi);
lwi->setText(QString::fromStdString(name));
lwi->setData(0x0100, id);
listView->addItem(lwi);
//confname->addItem(QString::fromStdString(name));
}
}
void InverterSelection::on_listView_clicked(const QModelIndex &index)
{
}
void InverterSelection::on_listView_doubleClicked(const QModelIndex &index)
{
}
void InverterSelection::on_listView_activated(const QModelIndex &index)
{
}
void InverterSelection::accept(){
//For all items in listView
//get the id and start thread
//add a thread with config
QList lst = listView->selectedItems();
std::cout<< lst.count() << "selected" <<std::endl;
int id = 0;
if(lst.count() > 0){
const Connector *conn = Connector::getConnector();
for(const auto & item : lst){
id = item->data(0x100).toInt();
std::cout << item->text().toStdString() <<" id:" << id << std::endl;
//Start worker with given id
//Create a Worker class
Worker * worker = new Worker(id);
//Configure Worker - IP, PORT
//Add Worker to pool
conn->addWorker(worker);
}
}
QDialog::accept();
}