76 lines
2.1 KiB
C++
76 lines
2.1 KiB
C++
|
|
#include "Adddeviceform.h"
|
|||
|
|
#include "ui_Adddeviceform.h"
|
|||
|
|
#include <QUdpSocket>
|
|||
|
|
#include "cidwudp.h"
|
|||
|
|
#include <synchapi.h>
|
|||
|
|
#include <qvalidator.h>
|
|||
|
|
#include "QMessageBox"
|
|||
|
|
|
|||
|
|
AddDeviceForm::AddDeviceForm(QWidget *parent) :
|
|||
|
|
BaseWgt(parent),
|
|||
|
|
ui(new Ui::AddDeviceForm)
|
|||
|
|
{
|
|||
|
|
ui->setupUi(m_pMainWgt);
|
|||
|
|
resize(500,320);
|
|||
|
|
setWindowTitle("增加终端");
|
|||
|
|
strIP = "";
|
|||
|
|
|
|||
|
|
connect(ui->Btn_AutoSearch, SIGNAL(clicked()), this, SLOT(AutoSearch()));
|
|||
|
|
connect(ui->Btn_Search, SIGNAL(clicked()), this, SLOT(Search()));
|
|||
|
|
connect(ui->Btn_OK, SIGNAL(clicked()), this, SLOT(AddDevice()));
|
|||
|
|
connect(ui->Btn_Cancel, SIGNAL(clicked()), this, SLOT(Cancel()));
|
|||
|
|
QRegExp rx("\\b(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.)"
|
|||
|
|
"{3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\b");
|
|||
|
|
QRegExpValidator *validator = new QRegExpValidator(rx, this);
|
|||
|
|
ui->lineEdit->setValidator(validator);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
AddDeviceForm::~AddDeviceForm()
|
|||
|
|
{
|
|||
|
|
delete ui;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void AddDeviceForm::AutoSearch()
|
|||
|
|
{
|
|||
|
|
emit AutoSearchIP();
|
|||
|
|
}
|
|||
|
|
void AddDeviceForm::Search()
|
|||
|
|
{
|
|||
|
|
ui->label_4->setText("");
|
|||
|
|
ui->label_5->setText("");
|
|||
|
|
strIP = ui->lineEdit->text();
|
|||
|
|
if(strIP == ""){
|
|||
|
|
MyMsgBox(QMessageBox::Question,"问题","请输入完整信息");
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
emit AddDeviceIP(strIP,false);
|
|||
|
|
}
|
|||
|
|
void AddDeviceForm::AddDevice()
|
|||
|
|
{
|
|||
|
|
strIP = ui->lineEdit->text();
|
|||
|
|
if(strIP == ""){
|
|||
|
|
MyMsgBox(QMessageBox::Question,"问题","请输入完整信息");
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
emit AddDeviceIP(strIP,false);
|
|||
|
|
}
|
|||
|
|
void AddDeviceForm::UpdateDeviceInfo()
|
|||
|
|
{
|
|||
|
|
qDebug() << "MacAddr_G:" << global::MacAddr_G;
|
|||
|
|
ui->label_4->setText(global::MacAddr_G);
|
|||
|
|
ui->label_5->setText("正常");
|
|||
|
|
qDebug() << "DeviceNO:" << DeviceNO;
|
|||
|
|
}
|
|||
|
|
void AddDeviceForm::Cancel()
|
|||
|
|
{
|
|||
|
|
this->close();
|
|||
|
|
}
|
|||
|
|
void AddDeviceForm::keyPressEvent(QKeyEvent *event)
|
|||
|
|
{
|
|||
|
|
//Enter事件好像这两个都要写,只写event->key() == Qt::Key_Enter,无法实现
|
|||
|
|
if (event->key() == Qt::Key_Enter || event->key() == Qt::Key_Return)
|
|||
|
|
{
|
|||
|
|
Search();
|
|||
|
|
}
|
|||
|
|
}
|