1 Star 0 Fork 0

zhouws-chn/EndpointCli

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
ixchariotpairdialog.cpp 2.79 KB
一键复制 编辑 原始数据 按行查看 历史
zhouws-chn 提交于 2023-05-29 20:36 . 添加源代码
#include "ixchariotpairdialog.h"
#include "ui_ixchariotpairdialog.h"
#include <QFileDialog>
#include <QMessageBox>
#include <QDebug>
IxchariotPairDialog::IxchariotPairDialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::IxchariotPairDialog)
{
ui->setupUi(this);
}
IxchariotPairDialog::~IxchariotPairDialog()
{
delete ui;
}
int IxchariotPairDialog::CheckIpAddressFormat(QString ip)
{
if(ip.length()<6)
{
return 0;
}
QStringList ipItemList = ip.split(".");
if(ipItemList.length() != 4)
{
return 0;
}
for (int i=0; i<4; i++) {
if(ipItemList.at(i).length()==0)
{
return 0;
}
int num = ipItemList.at(i).toInt();
if((num<0) || (num>255))
{
return 0;
}
}
return 1;
}
void IxchariotPairDialog::on_choosePairBtn_clicked()
{
QString filename = QFileDialog::getOpenFileName(
this,
tr("选择跑流脚本"),
"C:\\Program Files (x86)\\Ixia\\IxChariot\\Scripts",//QDir::currentPath(),
"Script files (*.scr);;All files(*.*)");
if(filename.length()>0)
{
ui->pairPathEdit->setText(filename);
}
}
PairInfo IxchariotPairDialog::GetIxchariotPairInfo()
{
return m_pairInfo;
}
void IxchariotPairDialog::SetIxchariotPairInfo(PairInfo pairInfo)
{
// m_pairInfo = pairInfo;
ui->ip1Edit->setText(pairInfo.ip1);
ui->ip2Edit->setText(pairInfo.ip2);
ui->pairCountBox->setValue(pairInfo.pairCount);
ui->pairPathEdit->setText(pairInfo.pairScriptPath);
ui->networkProtocolBox->setCurrentText(pairInfo.networkProtocol);
}
void IxchariotPairDialog::SetIxchariotModeForCreat(int mode)
{
if(mode)
{
setWindowTitle(tr("新建"));
ui->addPairBtn->setText(tr("添加"));
ui->pushButton->setEnabled(false);
} else {
setWindowTitle(tr("编辑"));
ui->addPairBtn->setText(tr("保存"));
ui->pushButton->setEnabled(true);
}
}
void IxchariotPairDialog::on_addPairBtn_clicked()
{
if(!CheckIpAddressFormat(ui->ip1Edit->text()) || !CheckIpAddressFormat(ui->ip2Edit->text()))
{
QMessageBox::information(this, "tips", "IP地址格式错误-IPV4");
return ;
}
if(ui->pairPathEdit->text().length()==0)
{
QMessageBox::information(this, "tips", tr("please choose script file"));
return ;
}
m_pairInfo.ip1 = ui->ip1Edit->text();
m_pairInfo.ip2 = ui->ip2Edit->text();
m_pairInfo.pairCount = ui->pairCountBox->value();
m_pairInfo.pairScriptPath = ui->pairPathEdit->text();
m_pairInfo.networkProtocol = ui->networkProtocolBox->currentText();
this->accept();
}
void IxchariotPairDialog::on_cancelBtn_clicked()
{
this->close();
}
void IxchariotPairDialog::on_pushButton_clicked()
{
this->done(2);
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C++
1
https://gitee.com/zhouws-chn/endpoint-cli.git
[email protected]:zhouws-chn/endpoint-cli.git
zhouws-chn
endpoint-cli
EndpointCli
master

搜索帮助