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:
|
case mac_dstAddr:
|
||||||
{
|
{
|
||||||
quint64 mac = value.toString().toULongLong(&isOk, BASE_HEX);
|
quint64 mac = value.toULongLong();
|
||||||
if (isOk)
|
data.set_dst_mac(mac);
|
||||||
data.set_dst_mac(mac);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case mac_srcAddr:
|
case mac_srcAddr:
|
||||||
{
|
{
|
||||||
quint64 mac = value.toString().toULongLong(&isOk, BASE_HEX);
|
quint64 mac = value.toULongLong();
|
||||||
if (isOk)
|
data.set_src_mac(mac);
|
||||||
data.set_src_mac(mac);
|
|
||||||
break;
|
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>
|
<class>mac</class>
|
||||||
<widget class="QWidget" name="mac" >
|
<widget class="QWidget" name="mac">
|
||||||
<property name="geometry" >
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
@ -9,191 +10,157 @@
|
|||||||
<height>200</height>
|
<height>200</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle" >
|
<property name="windowTitle">
|
||||||
<string>Form</string>
|
<string>Form</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout" >
|
<layout class="QGridLayout">
|
||||||
<item row="0" column="1" >
|
<item row="0" column="1">
|
||||||
<widget class="QLabel" name="label_6" >
|
<widget class="QLabel" name="label_6">
|
||||||
<property name="text" >
|
<property name="text">
|
||||||
<string>Address</string>
|
<string>Address</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="2" >
|
<item row="0" column="2">
|
||||||
<widget class="QLabel" name="label_2" >
|
<widget class="QLabel" name="label_2">
|
||||||
<property name="text" >
|
<property name="text">
|
||||||
<string>Mode</string>
|
<string>Mode</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="3" >
|
<item row="0" column="3">
|
||||||
<widget class="QLabel" name="label_4" >
|
<widget class="QLabel" name="label_4">
|
||||||
<property name="text" >
|
<property name="text">
|
||||||
<string>Count</string>
|
<string>Count</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="4" >
|
<item row="0" column="4">
|
||||||
<widget class="QLabel" name="label_5" >
|
<widget class="QLabel" name="label_5">
|
||||||
<property name="text" >
|
<property name="text">
|
||||||
<string>Step</string>
|
<string>Step</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="0" >
|
<item row="1" column="0">
|
||||||
<widget class="QLabel" name="label" >
|
<widget class="QLabel" name="label">
|
||||||
<property name="text" >
|
<property name="text">
|
||||||
<string>Destination</string>
|
<string>Destination</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="1" >
|
<item row="1" column="1">
|
||||||
<widget class="QLineEdit" name="leDstMac" >
|
<widget class="MacEdit" name="leDstMac">
|
||||||
<property name="minimumSize" >
|
<property name="minimumSize">
|
||||||
<size>
|
<size>
|
||||||
<width>120</width>
|
<width>120</width>
|
||||||
<height>0</height>
|
<height>0</height>
|
||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
<property name="inputMask" >
|
|
||||||
<string>>HH HH HH HH HH HH; </string>
|
|
||||||
</property>
|
|
||||||
<property name="text" >
|
|
||||||
<string> </string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="2" >
|
<item row="1" column="2">
|
||||||
<widget class="QComboBox" name="cmbDstMacMode" >
|
<widget class="QComboBox" name="cmbDstMacMode">
|
||||||
<item>
|
<item>
|
||||||
<property name="text" >
|
<property name="text">
|
||||||
<string>Fixed</string>
|
<string>Fixed</string>
|
||||||
</property>
|
</property>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<property name="text" >
|
<property name="text">
|
||||||
<string>Increment</string>
|
<string>Increment</string>
|
||||||
</property>
|
</property>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<property name="text" >
|
<property name="text">
|
||||||
<string>Decrement</string>
|
<string>Decrement</string>
|
||||||
</property>
|
</property>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<property name="text" >
|
<property name="text">
|
||||||
<string>Resolve</string>
|
<string>Resolve</string>
|
||||||
</property>
|
</property>
|
||||||
</item>
|
</item>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="3" >
|
<item row="1" column="3">
|
||||||
<widget class="QLineEdit" name="leDstMacCount" >
|
<widget class="IntEdit" name="leDstMacCount">
|
||||||
<property name="enabled" >
|
<property name="enabled">
|
||||||
<bool>false</bool>
|
<bool>false</bool>
|
||||||
</property>
|
</property>
|
||||||
<property name="text" >
|
|
||||||
<string/>
|
|
||||||
</property>
|
|
||||||
<property name="cursorPosition" >
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="4" >
|
<item row="1" column="4">
|
||||||
<widget class="QLineEdit" name="leDstMacStep" >
|
<widget class="IntEdit" name="leDstMacStep">
|
||||||
<property name="enabled" >
|
<property name="enabled">
|
||||||
<bool>false</bool>
|
<bool>false</bool>
|
||||||
</property>
|
</property>
|
||||||
<property name="text" >
|
|
||||||
<string/>
|
|
||||||
</property>
|
|
||||||
<property name="cursorPosition" >
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="0" >
|
<item row="2" column="0">
|
||||||
<widget class="QLabel" name="label_3" >
|
<widget class="QLabel" name="label_3">
|
||||||
<property name="text" >
|
<property name="text">
|
||||||
<string>Source</string>
|
<string>Source</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="1" >
|
<item row="2" column="1">
|
||||||
<widget class="QLineEdit" name="leSrcMac" >
|
<widget class="MacEdit" name="leSrcMac"/>
|
||||||
<property name="inputMask" >
|
|
||||||
<string>>HH HH HH HH HH HH; </string>
|
|
||||||
</property>
|
|
||||||
<property name="text" >
|
|
||||||
<string> </string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="2" >
|
<item row="2" column="2">
|
||||||
<widget class="QComboBox" name="cmbSrcMacMode" >
|
<widget class="QComboBox" name="cmbSrcMacMode">
|
||||||
<item>
|
<item>
|
||||||
<property name="text" >
|
<property name="text">
|
||||||
<string>Fixed</string>
|
<string>Fixed</string>
|
||||||
</property>
|
</property>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<property name="text" >
|
<property name="text">
|
||||||
<string>Increment</string>
|
<string>Increment</string>
|
||||||
</property>
|
</property>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<property name="text" >
|
<property name="text">
|
||||||
<string>Decrement</string>
|
<string>Decrement</string>
|
||||||
</property>
|
</property>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<property name="text" >
|
<property name="text">
|
||||||
<string>Resolve</string>
|
<string>Resolve</string>
|
||||||
</property>
|
</property>
|
||||||
</item>
|
</item>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="3" >
|
<item row="2" column="3">
|
||||||
<widget class="QLineEdit" name="leSrcMacCount" >
|
<widget class="IntEdit" name="leSrcMacCount">
|
||||||
<property name="enabled" >
|
<property name="enabled">
|
||||||
<bool>false</bool>
|
<bool>false</bool>
|
||||||
</property>
|
</property>
|
||||||
<property name="text" >
|
|
||||||
<string/>
|
|
||||||
</property>
|
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="4" >
|
<item row="2" column="4">
|
||||||
<widget class="QLineEdit" name="leSrcMacStep" >
|
<widget class="IntEdit" name="leSrcMacStep">
|
||||||
<property name="enabled" >
|
<property name="enabled">
|
||||||
<bool>false</bool>
|
<bool>false</bool>
|
||||||
</property>
|
</property>
|
||||||
<property name="text" >
|
|
||||||
<string/>
|
|
||||||
</property>
|
|
||||||
<property name="cursorPosition" >
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="3" column="0" colspan="5" >
|
<item row="3" column="0" colspan="5">
|
||||||
<widget class="QLabel" name="resolveInfo" >
|
<widget class="QLabel" name="resolveInfo">
|
||||||
<property name="text" >
|
<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>
|
<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>
|
||||||
<property name="wordWrap" >
|
<property name="wordWrap">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="4" column="0" >
|
<item row="4" column="0">
|
||||||
<spacer>
|
<spacer>
|
||||||
<property name="orientation" >
|
<property name="orientation">
|
||||||
<enum>Qt::Vertical</enum>
|
<enum>Qt::Vertical</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="sizeHint" >
|
<property name="sizeHint" stdset="0">
|
||||||
<size>
|
<size>
|
||||||
<width>20</width>
|
<width>20</width>
|
||||||
<height>40</height>
|
<height>40</height>
|
||||||
@ -203,6 +170,18 @@
|
|||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</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/>
|
<resources/>
|
||||||
<connections/>
|
<connections/>
|
||||||
</ui>
|
</ui>
|
||||||
|
@ -20,12 +20,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
|
|||||||
#include "macconfig.h"
|
#include "macconfig.h"
|
||||||
#include "mac.h"
|
#include "mac.h"
|
||||||
|
|
||||||
#define MAX_MAC_ITER_COUNT 256
|
|
||||||
|
|
||||||
MacConfigForm::MacConfigForm(QWidget *parent)
|
MacConfigForm::MacConfigForm(QWidget *parent)
|
||||||
: AbstractProtocolConfigForm(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);
|
setupUi(this);
|
||||||
resolveInfo->hide();
|
resolveInfo->hide();
|
||||||
@ -34,10 +31,10 @@ MacConfigForm::MacConfigForm(QWidget *parent)
|
|||||||
resolveInfo->setPixmap(resolveInfo->style()->standardIcon(
|
resolveInfo->setPixmap(resolveInfo->style()->standardIcon(
|
||||||
QStyle::SP_MessageBoxInformation).pixmap(128));
|
QStyle::SP_MessageBoxInformation).pixmap(128));
|
||||||
#endif
|
#endif
|
||||||
leDstMac->setValidator(new QRegExpValidator(reMac, this));
|
leDstMacCount->setMinimum(1);
|
||||||
leSrcMac->setValidator(new QRegExpValidator(reMac, this));
|
leSrcMacCount->setMinimum(1);
|
||||||
leDstMacCount->setValidator(new QIntValidator(1, MAX_MAC_ITER_COUNT, this));
|
leDstMacStep->setMinimum(0);
|
||||||
leSrcMacCount->setValidator(new QIntValidator(1, MAX_MAC_ITER_COUNT, this));
|
leSrcMacStep->setMinimum(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
MacConfigForm::~MacConfigForm()
|
MacConfigForm::~MacConfigForm()
|
||||||
@ -100,75 +97,75 @@ void MacConfigForm::on_cmbSrcMacMode_currentIndexChanged(int index)
|
|||||||
|
|
||||||
void MacConfigForm::loadWidget(AbstractProtocol *proto)
|
void MacConfigForm::loadWidget(AbstractProtocol *proto)
|
||||||
{
|
{
|
||||||
leDstMac->setText(
|
leDstMac->setValue(
|
||||||
proto->fieldData(
|
proto->fieldData(
|
||||||
MacProtocol::mac_dstAddr,
|
MacProtocol::mac_dstAddr,
|
||||||
AbstractProtocol::FieldTextValue
|
AbstractProtocol::FieldValue
|
||||||
).toString());
|
).toULongLong());
|
||||||
cmbDstMacMode->setCurrentIndex(
|
cmbDstMacMode->setCurrentIndex(
|
||||||
proto->fieldData(
|
proto->fieldData(
|
||||||
MacProtocol::mac_dstMacMode,
|
MacProtocol::mac_dstMacMode,
|
||||||
AbstractProtocol::FieldValue
|
AbstractProtocol::FieldValue
|
||||||
).toUInt());
|
).toUInt());
|
||||||
leDstMacCount->setText(
|
leDstMacCount->setValue(
|
||||||
proto->fieldData(
|
proto->fieldData(
|
||||||
MacProtocol::mac_dstMacCount,
|
MacProtocol::mac_dstMacCount,
|
||||||
AbstractProtocol::FieldValue
|
AbstractProtocol::FieldValue
|
||||||
).toString());
|
).toUInt());
|
||||||
leDstMacStep->setText(
|
leDstMacStep->setValue(
|
||||||
proto->fieldData(
|
proto->fieldData(
|
||||||
MacProtocol::mac_dstMacStep,
|
MacProtocol::mac_dstMacStep,
|
||||||
AbstractProtocol::FieldValue
|
AbstractProtocol::FieldValue
|
||||||
).toString());
|
).toUInt());
|
||||||
|
|
||||||
leSrcMac->setText(
|
leSrcMac->setValue(
|
||||||
proto->fieldData(
|
proto->fieldData(
|
||||||
MacProtocol::mac_srcAddr,
|
MacProtocol::mac_srcAddr,
|
||||||
AbstractProtocol::FieldTextValue
|
AbstractProtocol::FieldValue
|
||||||
).toString());
|
).toULongLong());
|
||||||
cmbSrcMacMode->setCurrentIndex(
|
cmbSrcMacMode->setCurrentIndex(
|
||||||
proto->fieldData(
|
proto->fieldData(
|
||||||
MacProtocol::mac_srcMacMode,
|
MacProtocol::mac_srcMacMode,
|
||||||
AbstractProtocol::FieldValue
|
AbstractProtocol::FieldValue
|
||||||
).toUInt());
|
).toUInt());
|
||||||
leSrcMacCount->setText(
|
leSrcMacCount->setValue(
|
||||||
proto->fieldData(
|
proto->fieldData(
|
||||||
MacProtocol::mac_srcMacCount,
|
MacProtocol::mac_srcMacCount,
|
||||||
AbstractProtocol::FieldValue
|
AbstractProtocol::FieldValue
|
||||||
).toString());
|
).toUInt());
|
||||||
leSrcMacStep->setText(
|
leSrcMacStep->setValue(
|
||||||
proto->fieldData(
|
proto->fieldData(
|
||||||
MacProtocol::mac_srcMacStep,
|
MacProtocol::mac_srcMacStep,
|
||||||
AbstractProtocol::FieldValue
|
AbstractProtocol::FieldValue
|
||||||
).toString());
|
).toUInt());
|
||||||
}
|
}
|
||||||
|
|
||||||
void MacConfigForm::storeWidget(AbstractProtocol *proto)
|
void MacConfigForm::storeWidget(AbstractProtocol *proto)
|
||||||
{
|
{
|
||||||
proto->setFieldData(
|
proto->setFieldData(
|
||||||
MacProtocol::mac_dstAddr,
|
MacProtocol::mac_dstAddr,
|
||||||
leDstMac->text().remove(QChar(' ')));
|
leDstMac->value());
|
||||||
proto->setFieldData(
|
proto->setFieldData(
|
||||||
MacProtocol::mac_dstMacMode,
|
MacProtocol::mac_dstMacMode,
|
||||||
cmbDstMacMode->currentIndex());
|
cmbDstMacMode->currentIndex());
|
||||||
proto->setFieldData(
|
proto->setFieldData(
|
||||||
MacProtocol::mac_dstMacCount,
|
MacProtocol::mac_dstMacCount,
|
||||||
leDstMacCount->text());
|
leDstMacCount->value());
|
||||||
proto->setFieldData(
|
proto->setFieldData(
|
||||||
MacProtocol::mac_dstMacStep,
|
MacProtocol::mac_dstMacStep,
|
||||||
leDstMacStep->text());
|
leDstMacStep->value());
|
||||||
|
|
||||||
proto->setFieldData(
|
proto->setFieldData(
|
||||||
MacProtocol::mac_srcAddr,
|
MacProtocol::mac_srcAddr,
|
||||||
leSrcMac->text().remove(QChar(' ')));
|
leSrcMac->value());
|
||||||
proto->setFieldData(
|
proto->setFieldData(
|
||||||
MacProtocol::mac_srcMacMode,
|
MacProtocol::mac_srcMacMode,
|
||||||
cmbSrcMacMode->currentIndex());
|
cmbSrcMacMode->currentIndex());
|
||||||
proto->setFieldData(
|
proto->setFieldData(
|
||||||
MacProtocol::mac_srcMacCount,
|
MacProtocol::mac_srcMacCount,
|
||||||
leSrcMacCount->text());
|
leSrcMacCount->value());
|
||||||
proto->setFieldData(
|
proto->setFieldData(
|
||||||
MacProtocol::mac_srcMacStep,
|
MacProtocol::mac_srcMacStep,
|
||||||
leSrcMacStep->text());
|
leSrcMacStep->value());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user