* Refactor network package.
This commit is contained in:
66
src/network/GetRouteDialog.cpp
Normal file
66
src/network/GetRouteDialog.cpp
Normal file
@@ -0,0 +1,66 @@
|
||||
//
|
||||
// Created by Krad on 2021/11/11.
|
||||
//
|
||||
|
||||
#include "GetRouteDialog.h"
|
||||
|
||||
#include <QFormLayout>
|
||||
#include <QLabel>
|
||||
#include <QtWidgets/QLineEdit>
|
||||
|
||||
#include "device/networkmanager.h"
|
||||
|
||||
GetRouteDialog::GetRouteDialog(QWidget* parent, Qt::WindowFlags f)
|
||||
: GUIFormBaseDialog(parent, f)
|
||||
, mDestination(new QLineEdit(this))
|
||||
, mNetmask(new QLineEdit(this))
|
||||
, mGateway(new QLineEdit(this))
|
||||
, mLabelError(new QLabel(this))
|
||||
{
|
||||
setWindowModality(Qt::WindowModal);
|
||||
QFormLayout* formLayout = new QFormLayout(formWidget);
|
||||
formLayout->addRow(QString(tr("Destination")), mDestination);
|
||||
formLayout->addRow(QString(tr("Netmask")), mNetmask);
|
||||
formLayout->addRow(QString(tr("Gateway")), mGateway);
|
||||
mLabelError->setObjectName("warn");
|
||||
formLayout->addRow("", mLabelError);
|
||||
}
|
||||
|
||||
GetRouteDialog::~GetRouteDialog()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
QStringList GetRouteDialog::getList()const
|
||||
{
|
||||
return QStringList() << mDestination->text() << mNetmask->text() << mGateway->text();;
|
||||
}
|
||||
void GetRouteDialog::setList(const QStringList& list)
|
||||
{
|
||||
if (!list.empty())
|
||||
{
|
||||
mDestination->setText(list[0]);
|
||||
mNetmask->setText(list[1]);
|
||||
mGateway->setText(list[2]);
|
||||
}
|
||||
}
|
||||
|
||||
bool GetRouteDialog::updateReferenceData()
|
||||
{
|
||||
if (!NetworkManager::validate(mDestination->text()))
|
||||
{
|
||||
mLabelError->setText(tr("Wrong Destination!"));
|
||||
return false;
|
||||
}
|
||||
if (!NetworkManager::validate(mNetmask->text()))
|
||||
{
|
||||
mLabelError->setText(tr("Wrong Netmask!"));
|
||||
return false;
|
||||
}
|
||||
if (!NetworkManager::validate(mGateway->text()))
|
||||
{
|
||||
mLabelError->setText(tr("Wrong Gateway!"));
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
Reference in New Issue
Block a user