NOX: Eth2 - Separated protocol and widget as per new framework
This commit is contained in:
parent
37ca28ca94
commit
c0f009c44a
@ -17,26 +17,15 @@ You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
*/
|
||||
|
||||
#include <qendian.h>
|
||||
#include <QHostAddress>
|
||||
|
||||
#include "eth2.h"
|
||||
|
||||
Eth2ConfigForm::Eth2ConfigForm(QWidget *parent)
|
||||
: QWidget(parent)
|
||||
{
|
||||
setupUi(this);
|
||||
}
|
||||
|
||||
Eth2Protocol::Eth2Protocol(StreamBase *stream, AbstractProtocol *parent)
|
||||
: AbstractProtocol(stream, parent)
|
||||
{
|
||||
configForm = NULL;
|
||||
}
|
||||
|
||||
Eth2Protocol::~Eth2Protocol()
|
||||
{
|
||||
delete configForm;
|
||||
}
|
||||
|
||||
AbstractProtocol* Eth2Protocol::createInstance(StreamBase *stream,
|
||||
@ -197,35 +186,3 @@ bool Eth2Protocol::setFieldData(int index, const QVariant &value,
|
||||
}
|
||||
return isOk;
|
||||
}
|
||||
|
||||
QWidget* Eth2Protocol::configWidget()
|
||||
{
|
||||
if (configForm == NULL)
|
||||
{
|
||||
configForm = new Eth2ConfigForm;
|
||||
loadConfigWidget();
|
||||
}
|
||||
return configForm;
|
||||
}
|
||||
|
||||
void Eth2Protocol::loadConfigWidget()
|
||||
{
|
||||
configWidget();
|
||||
|
||||
configForm->cbOverrideType->setChecked(
|
||||
fieldData(eth2_is_override_type, FieldValue).toBool());
|
||||
configForm->leType->setText(uintToHexStr(
|
||||
fieldData(eth2_type, FieldValue).toUInt(), 2));
|
||||
}
|
||||
|
||||
void Eth2Protocol::storeConfigWidget()
|
||||
{
|
||||
bool isOk;
|
||||
|
||||
configWidget();
|
||||
|
||||
setFieldData(eth2_is_override_type,
|
||||
configForm->cbOverrideType->isChecked());
|
||||
data.set_type(configForm->leType->text().remove(QChar(' ')).toULong(&isOk, 16));
|
||||
}
|
||||
|
||||
|
@ -23,20 +23,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
#include "abstractprotocol.h"
|
||||
|
||||
#include "eth2.pb.h"
|
||||
#include "ui_eth2.h"
|
||||
|
||||
class Eth2ConfigForm : public QWidget, public Ui::eth2
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
Eth2ConfigForm(QWidget *parent = 0);
|
||||
};
|
||||
|
||||
class Eth2Protocol : public AbstractProtocol
|
||||
{
|
||||
private:
|
||||
OstProto::Eth2 data;
|
||||
Eth2ConfigForm *configForm;
|
||||
public:
|
||||
enum eth2field
|
||||
{
|
||||
eth2_type = 0,
|
||||
@ -46,7 +37,6 @@ private:
|
||||
eth2_fieldCount
|
||||
};
|
||||
|
||||
public:
|
||||
Eth2Protocol(StreamBase *stream, AbstractProtocol *parent = 0);
|
||||
virtual ~Eth2Protocol();
|
||||
|
||||
@ -69,10 +59,8 @@ public:
|
||||
int streamIndex = 0) const;
|
||||
virtual bool setFieldData(int index, const QVariant &value,
|
||||
FieldAttrib attrib = FieldValue);
|
||||
|
||||
virtual QWidget* configWidget();
|
||||
virtual void loadConfigWidget();
|
||||
virtual void storeConfigWidget();
|
||||
private:
|
||||
OstProto::Eth2 data;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
63
common/eth2config.cpp
Normal file
63
common/eth2config.cpp
Normal file
@ -0,0 +1,63 @@
|
||||
/*
|
||||
Copyright (C) 2010,2014 Srivats P.
|
||||
|
||||
This file is part of "Ostinato"
|
||||
|
||||
This is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
*/
|
||||
|
||||
#include "eth2config.h"
|
||||
#include "eth2.h"
|
||||
|
||||
Eth2ConfigForm::Eth2ConfigForm(QWidget *parent)
|
||||
: AbstractProtocolConfigForm(parent)
|
||||
{
|
||||
setupUi(this);
|
||||
}
|
||||
|
||||
Eth2ConfigForm::~Eth2ConfigForm()
|
||||
{
|
||||
}
|
||||
|
||||
Eth2ConfigForm* Eth2ConfigForm::createInstance()
|
||||
{
|
||||
return new Eth2ConfigForm;
|
||||
}
|
||||
|
||||
void Eth2ConfigForm::loadWidget(AbstractProtocol *proto)
|
||||
{
|
||||
cbOverrideType->setChecked(
|
||||
proto->fieldData(
|
||||
Eth2Protocol::eth2_is_override_type,
|
||||
AbstractProtocol::FieldValue
|
||||
).toBool());
|
||||
leType->setText(uintToHexStr(
|
||||
proto->fieldData(
|
||||
Eth2Protocol::eth2_type,
|
||||
AbstractProtocol::FieldValue
|
||||
).toUInt(), 2));
|
||||
}
|
||||
|
||||
void Eth2ConfigForm::storeWidget(AbstractProtocol *proto)
|
||||
{
|
||||
bool isOk;
|
||||
|
||||
proto->setFieldData(
|
||||
Eth2Protocol::eth2_is_override_type,
|
||||
cbOverrideType->isChecked());
|
||||
proto->setFieldData(
|
||||
Eth2Protocol::eth2_type,
|
||||
leType->text().remove(QChar(' ')).toUInt(&isOk, BASE_HEX));
|
||||
}
|
||||
|
41
common/eth2config.h
Normal file
41
common/eth2config.h
Normal file
@ -0,0 +1,41 @@
|
||||
/*
|
||||
Copyright (C) 2010,2014 Srivats P.
|
||||
|
||||
This file is part of "Ostinato"
|
||||
|
||||
This is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
*/
|
||||
|
||||
#ifndef _ETH2_CONFIG_H
|
||||
#define _ETH2_CONFIG_H
|
||||
|
||||
#include "abstractprotocolconfig.h"
|
||||
|
||||
#include "eth2.pb.h"
|
||||
#include "ui_eth2.h"
|
||||
|
||||
class Eth2ConfigForm :
|
||||
public AbstractProtocolConfigForm,
|
||||
public Ui::eth2
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
Eth2ConfigForm(QWidget *parent = 0);
|
||||
virtual ~Eth2ConfigForm();
|
||||
|
||||
static Eth2ConfigForm* createInstance();
|
||||
virtual void loadWidget(AbstractProtocol *proto);
|
||||
virtual void storeWidget(AbstractProtocol *proto);
|
||||
};
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user