Device Emulation (contd.): Added first cut code for the Device Group Configuration Dialog

This commit is contained in:
Srivats P 2016-02-17 21:13:30 +05:30
parent 264fe20c34
commit c63528ebae
6 changed files with 526 additions and 0 deletions

View File

@ -0,0 +1,68 @@
/*
Copyright (C) 2016 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 "devicegroupdialog.h"
enum { kIpNone, kIp4, kIp6, kIpDual };
static QStringList ipStackItems = QStringList()
<< "None" << "IPv4" << "IPv6" << "Dual";
DeviceGroupDialog::DeviceGroupDialog(QWidget *parent, Qt::WindowFlags flags)
: QDialog(parent, flags)
{
// Setup the Dialog
setupUi(this);
vlanTagCount->setRange(0, kMaxVlanTags);
ipStack->insertItems(0, ipStackItems);
}
//
// Private Slots
//
void DeviceGroupDialog::on_vlanTagCount_valueChanged(int value)
{
Q_ASSERT((value >= 0) && (value <= kMaxVlanTags));
vlans->setVisible(value > 0);
}
void DeviceGroupDialog::on_ipStack_currentIndexChanged(int index)
{
switch (index) {
case kIpNone:
ip4->hide();
ip6->hide();
break;
case kIp4:
ip4->show();
ip6->hide();
break;
case kIp6:
ip4->hide();
ip6->show();
break;
case kIpDual:
ip4->show();
ip6->show();
break;
default:
Q_ASSERT(false); // Unreachable!
break;
}
}

View File

@ -0,0 +1,41 @@
/*
Copyright (C) 2016 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 _DEVICE_GROUP_DIALOG_H
#define _DEVICE_GROUP_DIALOG_H
#include "ui_devicegroupdialog.h"
#include <QDialog>
class DeviceGroupDialog: public QDialog, private Ui::DeviceGroupDialog
{
Q_OBJECT
public:
DeviceGroupDialog(QWidget *parent = NULL, Qt::WindowFlags flags = 0);
private slots:
void on_vlanTagCount_valueChanged(int value);
void on_ipStack_currentIndexChanged(int index);
private:
static const int kMaxVlanTags = 4;
};
#endif

399
client/devicegroupdialog.ui Normal file
View File

@ -0,0 +1,399 @@
<ui version="4.0" >
<class>DeviceGroupDialog</class>
<widget class="QDialog" name="DeviceGroupDialog" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>504</width>
<height>465</height>
</rect>
</property>
<property name="windowTitle" >
<string>Dialog</string>
</property>
<layout class="QVBoxLayout" >
<item>
<layout class="QHBoxLayout" >
<item>
<widget class="QLabel" name="label" >
<property name="text" >
<string>Name</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="name" />
</item>
<item>
<widget class="QLabel" name="label_2" >
<property name="text" >
<string>Vlan Tags</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="vlanTagCount" />
</item>
<item>
<spacer>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" >
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<widget class="QTableWidget" name="vlans" >
<column>
<property name="text" >
<string>#</string>
</property>
</column>
<column>
<property name="text" >
<string>Vlan Id</string>
</property>
</column>
<column>
<property name="text" >
<string>Count</string>
</property>
</column>
<column>
<property name="text" >
<string>Step</string>
</property>
</column>
<column>
<property name="text" >
<string>CFI/DE</string>
</property>
</column>
<column>
<property name="text" >
<string>Prio</string>
</property>
</column>
<column>
<property name="text" >
<string>TPID</string>
</property>
</column>
</widget>
</item>
<item>
<layout class="QGridLayout" >
<item row="0" column="0" >
<widget class="QLabel" name="label_11" >
<property name="text" >
<string>Total Vlans</string>
</property>
</widget>
</item>
<item row="0" column="1" >
<widget class="QLineEdit" name="vlanCount" >
<property name="enabled" >
<bool>false</bool>
</property>
</widget>
</item>
<item row="0" column="2" colspan="2" >
<widget class="QLabel" name="label_13" >
<property name="text" >
<string>Devices Per Vlan</string>
</property>
<property name="buddy" >
<cstring>devicePerVlanCount</cstring>
</property>
</widget>
</item>
<item row="0" column="4" >
<widget class="QSpinBox" name="devicePerVlanCount" />
</item>
<item row="0" column="5" >
<widget class="QLabel" name="label_14" >
<property name="text" >
<string>Total Devices</string>
</property>
</widget>
</item>
<item row="0" column="6" >
<widget class="QLineEdit" name="totalDeviceCount" >
<property name="enabled" >
<bool>false</bool>
</property>
</widget>
</item>
<item row="1" column="0" >
<widget class="QLabel" name="label_3" >
<property name="text" >
<string>Mac Address</string>
</property>
</widget>
</item>
<item row="1" column="1" >
<widget class="QLineEdit" name="macAddress" />
</item>
<item row="1" column="2" >
<widget class="QLabel" name="label_5" >
<property name="text" >
<string>Step</string>
</property>
</widget>
</item>
<item row="1" column="3" colspan="2" >
<widget class="QLineEdit" name="macStep" />
</item>
<item row="1" column="5" >
<widget class="QLabel" name="label_4" >
<property name="text" >
<string>IP Stack</string>
</property>
</widget>
</item>
<item row="1" column="6" >
<widget class="QComboBox" name="ipStack" />
</item>
</layout>
</item>
<item>
<widget class="QFrame" name="ip4" >
<property name="frameShape" >
<enum>QFrame::Box</enum>
</property>
<property name="frameShadow" >
<enum>QFrame::Plain</enum>
</property>
<layout class="QGridLayout" >
<item row="0" column="0" >
<widget class="QLabel" name="label_9" >
<property name="text" >
<string>IPv4 Address</string>
</property>
</widget>
</item>
<item row="0" column="1" >
<widget class="QLineEdit" name="ip4Address" />
</item>
<item row="0" column="2" >
<widget class="QLabel" name="label_12" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Preferred" hsizetype="Fixed" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text" >
<string>/</string>
</property>
</widget>
</item>
<item row="0" column="5" >
<widget class="QLabel" name="label_8" >
<property name="text" >
<string>Step</string>
</property>
</widget>
</item>
<item row="0" column="6" >
<widget class="QLineEdit" name="ip4Step" />
</item>
<item row="1" column="0" >
<widget class="QLabel" name="label_7" >
<property name="text" >
<string>Gateway</string>
</property>
</widget>
</item>
<item row="1" column="1" >
<widget class="QLineEdit" name="ip4Gateway" />
</item>
<item row="0" column="3" >
<widget class="QSpinBox" name="ip4PrefixLength" >
<property name="minimum" >
<number>1</number>
</property>
<property name="maximum" >
<number>32</number>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QFrame" name="ip6" >
<property name="frameShape" >
<enum>QFrame::Box</enum>
</property>
<property name="frameShadow" >
<enum>QFrame::Plain</enum>
</property>
<layout class="QGridLayout" >
<item row="0" column="0" >
<widget class="QLabel" name="label_10" >
<property name="text" >
<string>IPv6 Address</string>
</property>
</widget>
</item>
<item row="0" column="1" >
<widget class="QLineEdit" name="ip6Address" />
</item>
<item row="0" column="2" >
<widget class="QLabel" name="label_15" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Preferred" hsizetype="Fixed" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text" >
<string>/</string>
</property>
</widget>
</item>
<item row="0" column="5" >
<widget class="QLabel" name="label_16" >
<property name="text" >
<string>Step</string>
</property>
</widget>
</item>
<item row="0" column="6" >
<widget class="QLineEdit" name="ip6Step" />
</item>
<item row="1" column="0" >
<widget class="QLabel" name="label_17" >
<property name="text" >
<string>Gateway</string>
</property>
</widget>
</item>
<item row="1" column="1" >
<widget class="QLineEdit" name="ip6Gateway" />
</item>
<item row="0" column="3" >
<widget class="QSpinBox" name="ip6PrefixLength" >
<property name="minimum" >
<number>1</number>
</property>
<property name="maximum" >
<number>128</number>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<layout class="QHBoxLayout" >
<item>
<layout class="QHBoxLayout" >
<item>
<widget class="QToolButton" name="prev" >
<property name="text" >
<string>&lt;</string>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="next" >
<property name="text" >
<string>></string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<spacer>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" >
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox" >
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons" >
<set>QDialogButtonBox::Cancel|QDialogButtonBox::NoButton|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<tabstops>
<tabstop>name</tabstop>
<tabstop>vlanTagCount</tabstop>
<tabstop>vlans</tabstop>
<tabstop>devicePerVlanCount</tabstop>
<tabstop>macAddress</tabstop>
<tabstop>macStep</tabstop>
<tabstop>ipStack</tabstop>
<tabstop>ip4Address</tabstop>
<tabstop>ip4PrefixLength</tabstop>
<tabstop>ip4Step</tabstop>
<tabstop>ip4Gateway</tabstop>
<tabstop>ip6Address</tabstop>
<tabstop>ip6PrefixLength</tabstop>
<tabstop>ip6Step</tabstop>
<tabstop>ip6Gateway</tabstop>
<tabstop>prev</tabstop>
<tabstop>next</tabstop>
<tabstop>buttonBox</tabstop>
</tabstops>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>DeviceGroupDialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel" >
<x>227</x>
<y>289</y>
</hint>
<hint type="destinationlabel" >
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>DeviceGroupDialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel" >
<x>295</x>
<y>295</y>
</hint>
<hint type="destinationlabel" >
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>

View File

@ -33,6 +33,7 @@ LIBS += -lprotobuf
LIBS += -L"../extra/qhexedit2/$(OBJECTS_DIR)/" -lqhexedit2
RESOURCES += ostinato.qrc
HEADERS += \
devicegroupdialog.h \
devicegroupmodel.h \
dumpview.h \
hexlineedit.h \
@ -58,6 +59,7 @@ HEADERS += \
FORMS += \
about.ui \
devicegroupdialog.ui \
mainwindow.ui \
portconfigdialog.ui \
portstatsfilter.ui \
@ -68,6 +70,7 @@ FORMS += \
variablefieldswidget.ui
SOURCES += \
devicegroupdialog.cpp \
devicegroupmodel.cpp \
dumpview.cpp \
stream.cpp \

View File

@ -20,6 +20,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
#include "portswindow.h"
#include "abstractfileformat.h"
#include "devicegroupdialog.h"
#include "portconfigdialog.h"
#include "settings.h"
#include "streamconfigdialog.h"
@ -813,3 +814,15 @@ _retry:
_exit:
return;
}
//
// DeviceGroup slots
//
void PortsWindow::on_deviceGroupList_activated(const QModelIndex &index)
{
if (!index.isValid())
return;
DeviceGroupDialog dgd(this);
dgd.exec();
}

View File

@ -80,6 +80,8 @@ private slots:
void on_actionSave_Streams_triggered();
void streamModelDataChanged();
void on_deviceGroupList_activated(const QModelIndex &index);
};
#endif