Device Emulation (contd.): Get and display Device List
This commit is contained in:
parent
f742cdbc7a
commit
0503c8acaf
211
client/devicemodel.cpp
Normal file
211
client/devicemodel.cpp
Normal file
@ -0,0 +1,211 @@
|
|||||||
|
/*
|
||||||
|
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 "devicemodel.h"
|
||||||
|
|
||||||
|
#include "port.h"
|
||||||
|
|
||||||
|
#include "emulproto.pb.h"
|
||||||
|
#include "uint128.h"
|
||||||
|
|
||||||
|
#include <QHostAddress>
|
||||||
|
|
||||||
|
enum {
|
||||||
|
kMacAddress,
|
||||||
|
kVlans,
|
||||||
|
kIp4Address,
|
||||||
|
kIp4Gateway,
|
||||||
|
kIp6Address,
|
||||||
|
kIp6Gateway,
|
||||||
|
kFieldCount
|
||||||
|
};
|
||||||
|
|
||||||
|
static QStringList columns_ = QStringList()
|
||||||
|
<< "Mac"
|
||||||
|
<< "Vlans"
|
||||||
|
<< "IPv4 Address"
|
||||||
|
<< "IPv4 Gateway"
|
||||||
|
<< "IPv6 Address"
|
||||||
|
<< "IPv6 Gateway";
|
||||||
|
|
||||||
|
DeviceModel::DeviceModel(QObject *parent)
|
||||||
|
: QAbstractTableModel(parent)
|
||||||
|
{
|
||||||
|
port_ = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
int DeviceModel::rowCount(const QModelIndex &parent) const
|
||||||
|
{
|
||||||
|
if (!port_ || parent.isValid())
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
return port_->numDevices();
|
||||||
|
}
|
||||||
|
|
||||||
|
int DeviceModel::columnCount(const QModelIndex &parent) const
|
||||||
|
{
|
||||||
|
if (parent.isValid())
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
return columns_.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
QVariant DeviceModel::headerData(
|
||||||
|
int section,
|
||||||
|
Qt::Orientation orientation,
|
||||||
|
int role) const
|
||||||
|
{
|
||||||
|
if (role != Qt::DisplayRole)
|
||||||
|
return QVariant();
|
||||||
|
|
||||||
|
switch (orientation) {
|
||||||
|
case Qt::Horizontal:
|
||||||
|
return columns_[section];
|
||||||
|
case Qt::Vertical:
|
||||||
|
return QString("%1").arg(section + 1);
|
||||||
|
default:
|
||||||
|
Q_ASSERT(false); // Unreachable
|
||||||
|
}
|
||||||
|
|
||||||
|
return QVariant();
|
||||||
|
}
|
||||||
|
|
||||||
|
QVariant DeviceModel::data(const QModelIndex &index, int role) const
|
||||||
|
{
|
||||||
|
QString str;
|
||||||
|
|
||||||
|
if (!port_ || !index.isValid())
|
||||||
|
return QVariant();
|
||||||
|
|
||||||
|
int devIdx = index.row();
|
||||||
|
int field = index.column();
|
||||||
|
|
||||||
|
Q_ASSERT(devIdx < port_->numDevices());
|
||||||
|
Q_ASSERT(field < kFieldCount);
|
||||||
|
|
||||||
|
const OstEmul::Device *dev = port_->deviceByIndex(devIdx);
|
||||||
|
|
||||||
|
Q_ASSERT(dev);
|
||||||
|
|
||||||
|
switch (field) {
|
||||||
|
case kMacAddress:
|
||||||
|
switch (role) {
|
||||||
|
case Qt::DisplayRole:
|
||||||
|
return QString("%1").arg(dev->mac(), 6*2, 16, QChar('0'))
|
||||||
|
.replace(QRegExp("([0-9a-fA-F]{2}\\B)"), "\\1:")
|
||||||
|
.toUpper();
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return QVariant();
|
||||||
|
|
||||||
|
case kVlans:
|
||||||
|
switch (role) {
|
||||||
|
case Qt::DisplayRole:
|
||||||
|
if (!dev->vlan_size())
|
||||||
|
return QString("None");
|
||||||
|
for (int i = 0; i < dev->vlan_size(); i++)
|
||||||
|
str.append(i == 0 ? "" : ", ")
|
||||||
|
.append(QString::number(dev->vlan(i) & 0xfff));
|
||||||
|
return str;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return QVariant();
|
||||||
|
|
||||||
|
case kIp4Address:
|
||||||
|
switch (role) {
|
||||||
|
case Qt::DisplayRole:
|
||||||
|
if (dev->has_ip4_prefix_length())
|
||||||
|
return QString("%1/%2")
|
||||||
|
.arg(QHostAddress(dev->ip4()).toString())
|
||||||
|
.arg(dev->ip4_prefix_length());
|
||||||
|
else
|
||||||
|
return QString("--");
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return QVariant();
|
||||||
|
|
||||||
|
case kIp4Gateway:
|
||||||
|
switch (role) {
|
||||||
|
case Qt::DisplayRole:
|
||||||
|
if (dev->has_ip4_prefix_length())
|
||||||
|
return QHostAddress(dev->ip4_default_gateway())
|
||||||
|
.toString();
|
||||||
|
else
|
||||||
|
return QString("--");
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return QVariant();
|
||||||
|
|
||||||
|
case kIp6Address:
|
||||||
|
switch (role) {
|
||||||
|
case Qt::DisplayRole:
|
||||||
|
if (dev->has_ip6_prefix_length()) {
|
||||||
|
OstEmul::Ip6Address ip = dev->ip6();
|
||||||
|
return QHostAddress(
|
||||||
|
UInt128(ip.hi(), ip.lo()).toArray())
|
||||||
|
.toString();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return QString("--");
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return QVariant();
|
||||||
|
|
||||||
|
case kIp6Gateway:
|
||||||
|
switch (role) {
|
||||||
|
case Qt::DisplayRole:
|
||||||
|
if (dev->has_ip6_prefix_length()) {
|
||||||
|
OstEmul::Ip6Address ip = dev->ip6_default_gateway();
|
||||||
|
return QHostAddress(
|
||||||
|
UInt128(ip.hi(), ip.lo()).toArray())
|
||||||
|
.toString();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return QString("--");
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return QVariant();
|
||||||
|
|
||||||
|
default:
|
||||||
|
Q_ASSERT(false); // unreachable!
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
qWarning("%s: Unsupported field #%d", __FUNCTION__, field);
|
||||||
|
return QVariant();
|
||||||
|
}
|
||||||
|
|
||||||
|
void DeviceModel::setPort(Port *port)
|
||||||
|
{
|
||||||
|
port_ = port;
|
||||||
|
if (port_)
|
||||||
|
connect(port_, SIGNAL(deviceListChanged()), SLOT(updateDeviceList()));
|
||||||
|
reset();
|
||||||
|
}
|
||||||
|
|
||||||
|
void DeviceModel::updateDeviceList()
|
||||||
|
{
|
||||||
|
reset();
|
||||||
|
}
|
49
client/devicemodel.h
Normal file
49
client/devicemodel.h
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
/*
|
||||||
|
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_MODEL_H
|
||||||
|
#define _DEVICE_MODEL_H
|
||||||
|
|
||||||
|
#include <QAbstractTableModel>
|
||||||
|
|
||||||
|
class Port;
|
||||||
|
class DeviceModel: public QAbstractTableModel
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
DeviceModel(QObject *parent = 0);
|
||||||
|
|
||||||
|
int rowCount(const QModelIndex &parent = QModelIndex()) const;
|
||||||
|
int columnCount(const QModelIndex &parent = QModelIndex()) const;
|
||||||
|
|
||||||
|
QVariant headerData(int section, Qt::Orientation orientation,
|
||||||
|
int role = Qt::DisplayRole) const;
|
||||||
|
QVariant data(const QModelIndex &index, int role) const;
|
||||||
|
|
||||||
|
void setPort(Port *port);
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void updateDeviceList();
|
||||||
|
|
||||||
|
private:
|
||||||
|
Port *port_;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
@ -35,6 +35,7 @@ RESOURCES += ostinato.qrc
|
|||||||
HEADERS += \
|
HEADERS += \
|
||||||
devicegroupdialog.h \
|
devicegroupdialog.h \
|
||||||
devicegroupmodel.h \
|
devicegroupmodel.h \
|
||||||
|
devicemodel.h \
|
||||||
dumpview.h \
|
dumpview.h \
|
||||||
hexlineedit.h \
|
hexlineedit.h \
|
||||||
mainwindow.h \
|
mainwindow.h \
|
||||||
@ -72,6 +73,7 @@ FORMS += \
|
|||||||
SOURCES += \
|
SOURCES += \
|
||||||
devicegroupdialog.cpp \
|
devicegroupdialog.cpp \
|
||||||
devicegroupmodel.cpp \
|
devicegroupmodel.cpp \
|
||||||
|
devicemodel.cpp \
|
||||||
dumpview.cpp \
|
dumpview.cpp \
|
||||||
stream.cpp \
|
stream.cpp \
|
||||||
hexlineedit.cpp \
|
hexlineedit.cpp \
|
||||||
|
@ -766,3 +766,39 @@ bool Port::updateDeviceGroup(
|
|||||||
devGrp->CopyFrom(*deviceGroup);
|
devGrp->CopyFrom(*deviceGroup);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ------------ Devices ----------- //
|
||||||
|
|
||||||
|
int Port::numDevices()
|
||||||
|
{
|
||||||
|
return devices_.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
const OstEmul::Device* Port::deviceByIndex(int index)
|
||||||
|
{
|
||||||
|
if ((index < 0) || (index >= numDevices())) {
|
||||||
|
qWarning("%s: index %d out of range (0 - %d)", __FUNCTION__,
|
||||||
|
index, numDevices() - 1);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return devices_.at(index);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Port::clearDeviceList()
|
||||||
|
{
|
||||||
|
while (devices_.size())
|
||||||
|
delete devices_.takeFirst();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Port::insertDevice(const OstEmul::Device &device)
|
||||||
|
{
|
||||||
|
OstEmul::Device *dev = new OstEmul::Device(device);
|
||||||
|
devices_.append(dev);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Port::deviceListRefreshed()
|
||||||
|
{
|
||||||
|
emit deviceListChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -28,6 +28,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
|
|||||||
#include "stream.h"
|
#include "stream.h"
|
||||||
|
|
||||||
//class StreamModel;
|
//class StreamModel;
|
||||||
|
namespace OstEmul {
|
||||||
|
class Device;
|
||||||
|
}
|
||||||
|
|
||||||
class Port : public QObject {
|
class Port : public QObject {
|
||||||
|
|
||||||
@ -54,6 +57,7 @@ class Port : public QObject {
|
|||||||
|
|
||||||
QList<quint32> lastSyncDeviceGroupList_;
|
QList<quint32> lastSyncDeviceGroupList_;
|
||||||
QList<OstProto::DeviceGroup*> deviceGroups_;
|
QList<OstProto::DeviceGroup*> deviceGroups_;
|
||||||
|
QList<OstEmul::Device*> devices_;
|
||||||
|
|
||||||
uint newStreamId();
|
uint newStreamId();
|
||||||
void updateStreamOrdinalsFromIndex();
|
void updateStreamOrdinalsFromIndex();
|
||||||
@ -177,10 +181,21 @@ public:
|
|||||||
OstProto::DeviceGroup *deviceGroup);
|
OstProto::DeviceGroup *deviceGroup);
|
||||||
//@}
|
//@}
|
||||||
|
|
||||||
|
// ------------ Device ----------- //
|
||||||
|
|
||||||
|
int numDevices();
|
||||||
|
const OstEmul::Device* deviceByIndex(int index);
|
||||||
|
|
||||||
|
//! Used by MyService::Stub to update from config received from server
|
||||||
|
void clearDeviceList();
|
||||||
|
void insertDevice(const OstEmul::Device &device);
|
||||||
|
void deviceListRefreshed();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void portRateChanged(int portGroupId, int portId);
|
void portRateChanged(int portGroupId, int portId);
|
||||||
void portDataChanged(int portGroupId, int portId);
|
void portDataChanged(int portGroupId, int portId);
|
||||||
void streamListChanged(int portGroupId, int portId);
|
void streamListChanged(int portGroupId, int portId);
|
||||||
|
void deviceListChanged();
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -21,6 +21,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
|
|||||||
|
|
||||||
#include "settings.h"
|
#include "settings.h"
|
||||||
|
|
||||||
|
#include "emulproto.pb.h"
|
||||||
|
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QCursor>
|
#include <QCursor>
|
||||||
#include <QMainWindow>
|
#include <QMainWindow>
|
||||||
@ -520,6 +522,61 @@ void PortGroup::processModifyStreamAck(int portIndex,
|
|||||||
delete controller;
|
delete controller;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PortGroup::getDeviceList(int portIndex)
|
||||||
|
{
|
||||||
|
OstProto::PortId *portId;
|
||||||
|
OstProto::PortDeviceList *deviceList;
|
||||||
|
PbRpcController *controller;
|
||||||
|
|
||||||
|
Q_ASSERT(portIndex < mPorts.size());
|
||||||
|
|
||||||
|
if (state() != QAbstractSocket::ConnectedState)
|
||||||
|
return;
|
||||||
|
|
||||||
|
portId = new OstProto::PortId;
|
||||||
|
portId->set_id(mPorts[portIndex]->id());
|
||||||
|
deviceList = new OstProto::PortDeviceList;
|
||||||
|
controller = new PbRpcController(portId, deviceList);
|
||||||
|
|
||||||
|
serviceStub->getDeviceList(controller, portId, deviceList,
|
||||||
|
NewCallback(this, &PortGroup::processDeviceList,
|
||||||
|
portIndex, controller));
|
||||||
|
}
|
||||||
|
|
||||||
|
void PortGroup::processDeviceList(int portIndex, PbRpcController *controller)
|
||||||
|
{
|
||||||
|
OstProto::PortDeviceList *deviceList
|
||||||
|
= static_cast<OstProto::PortDeviceList*>(controller->response());
|
||||||
|
|
||||||
|
qDebug("In %s (portIndex = %d)", __FUNCTION__, portIndex);
|
||||||
|
|
||||||
|
if (controller->Failed())
|
||||||
|
{
|
||||||
|
qDebug("%s: rpc failed(%s)", __FUNCTION__,
|
||||||
|
qPrintable(controller->ErrorString()));
|
||||||
|
goto _exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
Q_ASSERT(portIndex < numPorts());
|
||||||
|
|
||||||
|
if (deviceList->port_id().id() != mPorts[portIndex]->id())
|
||||||
|
{
|
||||||
|
qDebug("Invalid portId %d (expected %d) received for portIndex %d",
|
||||||
|
deviceList->port_id().id(), mPorts[portIndex]->id(), portIndex);
|
||||||
|
goto _exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
mPorts[portIndex]->clearDeviceList();
|
||||||
|
for(int i = 0; i < deviceList->ExtensionSize(OstEmul::port_device); i++) {
|
||||||
|
mPorts[portIndex]->insertDevice(
|
||||||
|
deviceList->GetExtension(OstEmul::port_device, i));
|
||||||
|
}
|
||||||
|
mPorts[portIndex]->deviceListRefreshed();
|
||||||
|
|
||||||
|
_exit:
|
||||||
|
delete controller;
|
||||||
|
}
|
||||||
|
|
||||||
void PortGroup::modifyPort(int portIndex, OstProto::Port portConfig)
|
void PortGroup::modifyPort(int portIndex, OstProto::Port portConfig)
|
||||||
{
|
{
|
||||||
OstProto::PortConfigList *portConfigList = new OstProto::PortConfigList;
|
OstProto::PortConfigList *portConfigList = new OstProto::PortConfigList;
|
||||||
|
@ -110,6 +110,8 @@ public:
|
|||||||
void processDeleteDeviceGroupAck(PbRpcController *controller);
|
void processDeleteDeviceGroupAck(PbRpcController *controller);
|
||||||
void processModifyDeviceGroupAck(int portIndex, PbRpcController *controller);
|
void processModifyDeviceGroupAck(int portIndex, PbRpcController *controller);
|
||||||
|
|
||||||
|
void processDeviceList(int portIndex, PbRpcController *controller);
|
||||||
|
|
||||||
void modifyPort(int portId, OstProto::Port portConfig);
|
void modifyPort(int portId, OstProto::Port portConfig);
|
||||||
void processModifyPortAck(PbRpcController *controller);
|
void processModifyPortAck(PbRpcController *controller);
|
||||||
void processUpdatedPortConfig(PbRpcController *controller);
|
void processUpdatedPortConfig(PbRpcController *controller);
|
||||||
@ -170,6 +172,7 @@ private slots:
|
|||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void when_configApply(int portIndex);
|
void when_configApply(int portIndex);
|
||||||
|
void getDeviceList(int portIndex);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -26,7 +26,8 @@ PortGroupList::PortGroupList()
|
|||||||
: mPortGroupListModel(this),
|
: mPortGroupListModel(this),
|
||||||
mStreamListModel(this),
|
mStreamListModel(this),
|
||||||
mPortStatsModel(this, this),
|
mPortStatsModel(this, this),
|
||||||
mDeviceGroupModel(this)
|
mDeviceGroupModel(this),
|
||||||
|
mDeviceModel(this)
|
||||||
{
|
{
|
||||||
PortGroup *pg;
|
PortGroup *pg;
|
||||||
|
|
||||||
@ -35,11 +36,13 @@ PortGroupList::PortGroupList()
|
|||||||
portModelTester_ = NULL;
|
portModelTester_ = NULL;
|
||||||
portStatsModelTester_ = NULL;
|
portStatsModelTester_ = NULL;
|
||||||
deviceGroupModelTester_ = NULL;
|
deviceGroupModelTester_ = NULL;
|
||||||
|
deviceModelTester_ = NULL;
|
||||||
#else
|
#else
|
||||||
streamModelTester_ = new ModelTest(getStreamModel());
|
streamModelTester_ = new ModelTest(getStreamModel());
|
||||||
portModelTester_ = new ModelTest(getPortModel());
|
portModelTester_ = new ModelTest(getPortModel());
|
||||||
portStatsModelTester_ = new ModelTest(getPortStatsModel());
|
portStatsModelTester_ = new ModelTest(getPortStatsModel());
|
||||||
deviceGroupModelTester_ = new ModelTest(getPortStatsModel());
|
deviceGroupModelTester_ = new ModelTest(getDeviceGroupModel());
|
||||||
|
deviceModelTester_ = new ModelTest(getDeviceModel());
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Add the "Local" Port Group
|
// Add the "Local" Port Group
|
||||||
|
@ -21,6 +21,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
|
|||||||
#define _PORT_GROUP_LIST_H
|
#define _PORT_GROUP_LIST_H
|
||||||
|
|
||||||
#include "devicegroupmodel.h"
|
#include "devicegroupmodel.h"
|
||||||
|
#include "devicemodel.h"
|
||||||
#include "portgroup.h"
|
#include "portgroup.h"
|
||||||
#include "portmodel.h"
|
#include "portmodel.h"
|
||||||
#include "portstatsmodel.h"
|
#include "portstatsmodel.h"
|
||||||
@ -42,11 +43,13 @@ class PortGroupList : public QObject {
|
|||||||
StreamModel mStreamListModel;
|
StreamModel mStreamListModel;
|
||||||
PortStatsModel mPortStatsModel;
|
PortStatsModel mPortStatsModel;
|
||||||
DeviceGroupModel mDeviceGroupModel;
|
DeviceGroupModel mDeviceGroupModel;
|
||||||
|
DeviceModel mDeviceModel;
|
||||||
|
|
||||||
QObject *streamModelTester_;
|
QObject *streamModelTester_;
|
||||||
QObject *portModelTester_;
|
QObject *portModelTester_;
|
||||||
QObject *portStatsModelTester_;
|
QObject *portStatsModelTester_;
|
||||||
QObject *deviceGroupModelTester_;
|
QObject *deviceGroupModelTester_;
|
||||||
|
QObject *deviceModelTester_;
|
||||||
|
|
||||||
// Methods
|
// Methods
|
||||||
public:
|
public:
|
||||||
@ -57,6 +60,7 @@ public:
|
|||||||
PortStatsModel* getPortStatsModel() { return &mPortStatsModel; }
|
PortStatsModel* getPortStatsModel() { return &mPortStatsModel; }
|
||||||
StreamModel* getStreamModel() { return &mStreamListModel; }
|
StreamModel* getStreamModel() { return &mStreamListModel; }
|
||||||
DeviceGroupModel* getDeviceGroupModel() { return &mDeviceGroupModel; }
|
DeviceGroupModel* getDeviceGroupModel() { return &mDeviceGroupModel; }
|
||||||
|
DeviceModel* getDeviceModel() { return &mDeviceModel; }
|
||||||
|
|
||||||
bool isPortGroup(const QModelIndex& index);
|
bool isPortGroup(const QModelIndex& index);
|
||||||
bool isPort(const QModelIndex& index);
|
bool isPort(const QModelIndex& index);
|
||||||
|
@ -255,6 +255,7 @@ void PortsWindow::when_portView_currentChanged(const QModelIndex& currentIndex,
|
|||||||
if (plm->isPort(current))
|
if (plm->isPort(current))
|
||||||
port = &(plm->port(current));
|
port = &(plm->port(current));
|
||||||
plm->getDeviceGroupModel()->setPort(port);
|
plm->getDeviceGroupModel()->setPort(port);
|
||||||
|
plm->getDeviceModel()->setPort(port);
|
||||||
|
|
||||||
if (previous.isValid() && plm->isPort(previous))
|
if (previous.isValid() && plm->isPort(previous))
|
||||||
{
|
{
|
||||||
@ -896,8 +897,10 @@ void PortsWindow::on_deviceInfo_toggled(bool checked)
|
|||||||
{
|
{
|
||||||
refresh->setVisible(checked);
|
refresh->setVisible(checked);
|
||||||
|
|
||||||
// TODO: deviceInfo
|
if (checked)
|
||||||
deviceGroupList->setModel(checked ? NULL : plm->getDeviceGroupModel());
|
deviceGroupList->setModel(plm->getDeviceModel());
|
||||||
|
else
|
||||||
|
deviceGroupList->setModel(plm->getDeviceGroupModel());
|
||||||
}
|
}
|
||||||
|
|
||||||
void PortsWindow::on_actionNewDeviceGroup_triggered()
|
void PortsWindow::on_actionNewDeviceGroup_triggered()
|
||||||
@ -952,3 +955,21 @@ void PortsWindow::on_deviceGroupList_activated(const QModelIndex &index)
|
|||||||
DeviceGroupDialog dgd(&plm->port(currentPort), index.row(), this);
|
DeviceGroupDialog dgd(&plm->port(currentPort), index.row(), this);
|
||||||
dgd.exec();
|
dgd.exec();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PortsWindow::on_refresh_clicked()
|
||||||
|
{
|
||||||
|
QModelIndex curPort;
|
||||||
|
QModelIndex curPortGroup;
|
||||||
|
|
||||||
|
curPort = tvPortList->selectionModel()->currentIndex();
|
||||||
|
if (proxyPortModel)
|
||||||
|
curPort = proxyPortModel->mapToSource(curPort);
|
||||||
|
Q_ASSERT(curPort.isValid());
|
||||||
|
Q_ASSERT(plm->isPort(curPort));
|
||||||
|
|
||||||
|
curPortGroup = plm->getPortModel()->parent(curPort);
|
||||||
|
Q_ASSERT(curPortGroup.isValid());
|
||||||
|
Q_ASSERT(plm->isPortGroup(curPortGroup));
|
||||||
|
|
||||||
|
plm->portGroup(curPortGroup).getDeviceList(plm->port(curPort).id());
|
||||||
|
}
|
||||||
|
@ -83,10 +83,13 @@ private slots:
|
|||||||
void streamModelDataChanged();
|
void streamModelDataChanged();
|
||||||
|
|
||||||
void on_deviceInfo_toggled(bool checked);
|
void on_deviceInfo_toggled(bool checked);
|
||||||
|
|
||||||
void on_actionNewDeviceGroup_triggered();
|
void on_actionNewDeviceGroup_triggered();
|
||||||
void on_actionDeleteDeviceGroup_triggered();
|
void on_actionDeleteDeviceGroup_triggered();
|
||||||
void on_actionEditDeviceGroup_triggered();
|
void on_actionEditDeviceGroup_triggered();
|
||||||
void on_deviceGroupList_activated(const QModelIndex &index);
|
void on_deviceGroupList_activated(const QModelIndex &index);
|
||||||
|
|
||||||
|
void on_refresh_clicked();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user