UI improvements/fixes for Mac protocol
* Change count/step to IntEdit with suitable minimums * Change mac address to MacEdit Fixes #224 fixes #188
This commit is contained in:
parent
b3fb053cca
commit
e05fa5a690
@ -278,16 +278,14 @@ bool MacProtocol::setFieldData(int index, const QVariant &value,
|
||||
{
|
||||
case mac_dstAddr:
|
||||
{
|
||||
quint64 mac = value.toString().toULongLong(&isOk, BASE_HEX);
|
||||
if (isOk)
|
||||
data.set_dst_mac(mac);
|
||||
quint64 mac = value.toULongLong();
|
||||
data.set_dst_mac(mac);
|
||||
break;
|
||||
}
|
||||
case mac_srcAddr:
|
||||
{
|
||||
quint64 mac = value.toString().toULongLong(&isOk, BASE_HEX);
|
||||
if (isOk)
|
||||
data.set_src_mac(mac);
|
||||
quint64 mac = value.toULongLong();
|
||||
data.set_src_mac(mac);
|
||||
break;
|
||||
}
|
||||
|
||||
|
165
common/mac.ui
165
common/mac.ui
@ -1,7 +1,8 @@
|
||||
<ui version="4.0" >
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>mac</class>
|
||||
<widget class="QWidget" name="mac" >
|
||||
<property name="geometry" >
|
||||
<widget class="QWidget" name="mac">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
@ -9,191 +10,157 @@
|
||||
<height>200</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle" >
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" >
|
||||
<item row="0" column="1" >
|
||||
<widget class="QLabel" name="label_6" >
|
||||
<property name="text" >
|
||||
<layout class="QGridLayout">
|
||||
<item row="0" column="1">
|
||||
<widget class="QLabel" name="label_6">
|
||||
<property name="text">
|
||||
<string>Address</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2" >
|
||||
<widget class="QLabel" name="label_2" >
|
||||
<property name="text" >
|
||||
<item row="0" column="2">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Mode</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="3" >
|
||||
<widget class="QLabel" name="label_4" >
|
||||
<property name="text" >
|
||||
<item row="0" column="3">
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="text">
|
||||
<string>Count</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="4" >
|
||||
<widget class="QLabel" name="label_5" >
|
||||
<property name="text" >
|
||||
<item row="0" column="4">
|
||||
<widget class="QLabel" name="label_5">
|
||||
<property name="text">
|
||||
<string>Step</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0" >
|
||||
<widget class="QLabel" name="label" >
|
||||
<property name="text" >
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Destination</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1" >
|
||||
<widget class="QLineEdit" name="leDstMac" >
|
||||
<property name="minimumSize" >
|
||||
<item row="1" column="1">
|
||||
<widget class="MacEdit" name="leDstMac">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>120</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="inputMask" >
|
||||
<string>>HH HH HH HH HH HH; </string>
|
||||
</property>
|
||||
<property name="text" >
|
||||
<string> </string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2" >
|
||||
<widget class="QComboBox" name="cmbDstMacMode" >
|
||||
<item row="1" column="2">
|
||||
<widget class="QComboBox" name="cmbDstMacMode">
|
||||
<item>
|
||||
<property name="text" >
|
||||
<property name="text">
|
||||
<string>Fixed</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text" >
|
||||
<property name="text">
|
||||
<string>Increment</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text" >
|
||||
<property name="text">
|
||||
<string>Decrement</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text" >
|
||||
<property name="text">
|
||||
<string>Resolve</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="3" >
|
||||
<widget class="QLineEdit" name="leDstMacCount" >
|
||||
<property name="enabled" >
|
||||
<item row="1" column="3">
|
||||
<widget class="IntEdit" name="leDstMacCount">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text" >
|
||||
<string/>
|
||||
</property>
|
||||
<property name="cursorPosition" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="4" >
|
||||
<widget class="QLineEdit" name="leDstMacStep" >
|
||||
<property name="enabled" >
|
||||
<item row="1" column="4">
|
||||
<widget class="IntEdit" name="leDstMacStep">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text" >
|
||||
<string/>
|
||||
</property>
|
||||
<property name="cursorPosition" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0" >
|
||||
<widget class="QLabel" name="label_3" >
|
||||
<property name="text" >
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>Source</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1" >
|
||||
<widget class="QLineEdit" name="leSrcMac" >
|
||||
<property name="inputMask" >
|
||||
<string>>HH HH HH HH HH HH; </string>
|
||||
</property>
|
||||
<property name="text" >
|
||||
<string> </string>
|
||||
</property>
|
||||
</widget>
|
||||
<item row="2" column="1">
|
||||
<widget class="MacEdit" name="leSrcMac"/>
|
||||
</item>
|
||||
<item row="2" column="2" >
|
||||
<widget class="QComboBox" name="cmbSrcMacMode" >
|
||||
<item row="2" column="2">
|
||||
<widget class="QComboBox" name="cmbSrcMacMode">
|
||||
<item>
|
||||
<property name="text" >
|
||||
<property name="text">
|
||||
<string>Fixed</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text" >
|
||||
<property name="text">
|
||||
<string>Increment</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text" >
|
||||
<property name="text">
|
||||
<string>Decrement</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text" >
|
||||
<property name="text">
|
||||
<string>Resolve</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="3" >
|
||||
<widget class="QLineEdit" name="leSrcMacCount" >
|
||||
<property name="enabled" >
|
||||
<item row="2" column="3">
|
||||
<widget class="IntEdit" name="leSrcMacCount">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text" >
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="4" >
|
||||
<widget class="QLineEdit" name="leSrcMacStep" >
|
||||
<property name="enabled" >
|
||||
<item row="2" column="4">
|
||||
<widget class="IntEdit" name="leSrcMacStep">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text" >
|
||||
<string/>
|
||||
</property>
|
||||
<property name="cursorPosition" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0" colspan="5" >
|
||||
<widget class="QLabel" name="resolveInfo" >
|
||||
<property name="text" >
|
||||
<item row="3" column="0" colspan="5">
|
||||
<widget class="QLabel" name="resolveInfo">
|
||||
<property name="text">
|
||||
<string>Please ensure that a corresponding device is configured on the port to enable source/destination mac address resolution. A corresponding device is one which has VLANs and source/gateway IP corresponding to this stream.</string>
|
||||
</property>
|
||||
<property name="wordWrap" >
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0" >
|
||||
<item row="4" column="0">
|
||||
<spacer>
|
||||
<property name="orientation" >
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" >
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
@ -203,6 +170,18 @@
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>IntEdit</class>
|
||||
<extends>QSpinBox</extends>
|
||||
<header>intedit.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>MacEdit</class>
|
||||
<extends>QLineEdit</extends>
|
||||
<header>macedit.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
|
@ -20,12 +20,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
#include "macconfig.h"
|
||||
#include "mac.h"
|
||||
|
||||
#define MAX_MAC_ITER_COUNT 256
|
||||
|
||||
MacConfigForm::MacConfigForm(QWidget *parent)
|
||||
: AbstractProtocolConfigForm(parent)
|
||||
{
|
||||
QRegExp reMac("([0-9,a-f,A-F]{2,2}[:-]){5,5}[0-9,a-f,A-F]{2,2}");
|
||||
|
||||
setupUi(this);
|
||||
resolveInfo->hide();
|
||||
@ -34,10 +31,10 @@ MacConfigForm::MacConfigForm(QWidget *parent)
|
||||
resolveInfo->setPixmap(resolveInfo->style()->standardIcon(
|
||||
QStyle::SP_MessageBoxInformation).pixmap(128));
|
||||
#endif
|
||||
leDstMac->setValidator(new QRegExpValidator(reMac, this));
|
||||
leSrcMac->setValidator(new QRegExpValidator(reMac, this));
|
||||
leDstMacCount->setValidator(new QIntValidator(1, MAX_MAC_ITER_COUNT, this));
|
||||
leSrcMacCount->setValidator(new QIntValidator(1, MAX_MAC_ITER_COUNT, this));
|
||||
leDstMacCount->setMinimum(1);
|
||||
leSrcMacCount->setMinimum(1);
|
||||
leDstMacStep->setMinimum(0);
|
||||
leSrcMacStep->setMinimum(0);
|
||||
}
|
||||
|
||||
MacConfigForm::~MacConfigForm()
|
||||
@ -100,75 +97,75 @@ void MacConfigForm::on_cmbSrcMacMode_currentIndexChanged(int index)
|
||||
|
||||
void MacConfigForm::loadWidget(AbstractProtocol *proto)
|
||||
{
|
||||
leDstMac->setText(
|
||||
leDstMac->setValue(
|
||||
proto->fieldData(
|
||||
MacProtocol::mac_dstAddr,
|
||||
AbstractProtocol::FieldTextValue
|
||||
).toString());
|
||||
AbstractProtocol::FieldValue
|
||||
).toULongLong());
|
||||
cmbDstMacMode->setCurrentIndex(
|
||||
proto->fieldData(
|
||||
MacProtocol::mac_dstMacMode,
|
||||
AbstractProtocol::FieldValue
|
||||
).toUInt());
|
||||
leDstMacCount->setText(
|
||||
leDstMacCount->setValue(
|
||||
proto->fieldData(
|
||||
MacProtocol::mac_dstMacCount,
|
||||
AbstractProtocol::FieldValue
|
||||
).toString());
|
||||
leDstMacStep->setText(
|
||||
).toUInt());
|
||||
leDstMacStep->setValue(
|
||||
proto->fieldData(
|
||||
MacProtocol::mac_dstMacStep,
|
||||
AbstractProtocol::FieldValue
|
||||
).toString());
|
||||
).toUInt());
|
||||
|
||||
leSrcMac->setText(
|
||||
leSrcMac->setValue(
|
||||
proto->fieldData(
|
||||
MacProtocol::mac_srcAddr,
|
||||
AbstractProtocol::FieldTextValue
|
||||
).toString());
|
||||
AbstractProtocol::FieldValue
|
||||
).toULongLong());
|
||||
cmbSrcMacMode->setCurrentIndex(
|
||||
proto->fieldData(
|
||||
MacProtocol::mac_srcMacMode,
|
||||
AbstractProtocol::FieldValue
|
||||
).toUInt());
|
||||
leSrcMacCount->setText(
|
||||
leSrcMacCount->setValue(
|
||||
proto->fieldData(
|
||||
MacProtocol::mac_srcMacCount,
|
||||
AbstractProtocol::FieldValue
|
||||
).toString());
|
||||
leSrcMacStep->setText(
|
||||
).toUInt());
|
||||
leSrcMacStep->setValue(
|
||||
proto->fieldData(
|
||||
MacProtocol::mac_srcMacStep,
|
||||
AbstractProtocol::FieldValue
|
||||
).toString());
|
||||
).toUInt());
|
||||
}
|
||||
|
||||
void MacConfigForm::storeWidget(AbstractProtocol *proto)
|
||||
{
|
||||
proto->setFieldData(
|
||||
MacProtocol::mac_dstAddr,
|
||||
leDstMac->text().remove(QChar(' ')));
|
||||
leDstMac->value());
|
||||
proto->setFieldData(
|
||||
MacProtocol::mac_dstMacMode,
|
||||
cmbDstMacMode->currentIndex());
|
||||
proto->setFieldData(
|
||||
MacProtocol::mac_dstMacCount,
|
||||
leDstMacCount->text());
|
||||
leDstMacCount->value());
|
||||
proto->setFieldData(
|
||||
MacProtocol::mac_dstMacStep,
|
||||
leDstMacStep->text());
|
||||
leDstMacStep->value());
|
||||
|
||||
proto->setFieldData(
|
||||
MacProtocol::mac_srcAddr,
|
||||
leSrcMac->text().remove(QChar(' ')));
|
||||
leSrcMac->value());
|
||||
proto->setFieldData(
|
||||
MacProtocol::mac_srcMacMode,
|
||||
cmbSrcMacMode->currentIndex());
|
||||
proto->setFieldData(
|
||||
MacProtocol::mac_srcMacCount,
|
||||
leSrcMacCount->text());
|
||||
leSrcMacCount->value());
|
||||
proto->setFieldData(
|
||||
MacProtocol::mac_srcMacStep,
|
||||
leSrcMacStep->text());
|
||||
leSrcMacStep->value());
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user