-
Notifications
You must be signed in to change notification settings - Fork 4
/
camconnectdialog.cpp
61 lines (49 loc) · 1.06 KB
/
camconnectdialog.cpp
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
#include "camconnectdialog.h"
#include "ui_camconnectdialog.h"
CamConnectDialog::CamConnectDialog(QList<CamBox *> cams, QWidget *parent) :
QDialog(parent),
ui(new Ui::CamConnectDialog)
{
ui->setupUi(this);
this->cams = cams;
ui->camListWidget->clear();
foreach (CamBox* box, cams)
{
ui->camListWidget->addItem(box->getId());
}
}
CamConnectDialog::~CamConnectDialog()
{
delete ui;
}
void CamConnectDialog::accept()
{
if (ui->camListWidget->selectedItems().length() != 1)
{
return;
}
CamBox* box = getCamById(ui->camListWidget->selectedItems().at(0)->text());
if (box == NULL)
{
return;
}
bool ok = false;
quint16 port = ui->portLineEdit->text().toUShort(&ok);
if (!ok)
{
return;
}
emit connectCam(box, QHostAddress(ui->hostLineEdit->text()), port);
hide();
}
CamBox *CamConnectDialog::getCamById(QString id)
{
foreach (CamBox* box, cams)
{
if (box->getId() == id)
{
return box;
}
}
return NULL;
}