2008-05-03 09:37:10 -05:00
|
|
|
#ifndef _PORT_STATS_MODEL_H
|
|
|
|
#define _PORT_STATS_MODEL_H
|
|
|
|
|
|
|
|
#include <QAbstractTableModel>
|
|
|
|
#include <QStringList>
|
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
e_STAT_FRAMES_RCVD = 0,
|
|
|
|
e_STAT_FRAMES_SENT,
|
|
|
|
e_STAT_FRAME_SEND_RATE,
|
|
|
|
e_STAT_FRAME_RECV_RATE,
|
2008-09-28 13:01:52 -05:00
|
|
|
e_STAT_FRAMES_RCVD_NIC,
|
|
|
|
e_STAT_FRAMES_SENT_NIC,
|
2008-05-03 09:37:10 -05:00
|
|
|
e_STAT_BYTES_RCVD,
|
|
|
|
e_STAT_BYTES_SENT,
|
|
|
|
e_STAT_BYTE_SEND_RATE,
|
|
|
|
e_STAT_BYTE_RECV_RATE,
|
2008-09-28 13:01:52 -05:00
|
|
|
e_STAT_BYTES_RCVD_NIC,
|
|
|
|
e_STAT_BYTES_SENT_NIC,
|
2008-05-03 09:37:10 -05:00
|
|
|
e_STAT_MAX
|
|
|
|
} PortStat;
|
|
|
|
|
|
|
|
static QStringList PortStatName = (QStringList()
|
|
|
|
<< "Frames Received"
|
|
|
|
<< "Frames Sent"
|
|
|
|
<< "Frame Send Rate (fps)"
|
|
|
|
<< "Frame Receive Rate (fps)"
|
2008-09-28 13:01:52 -05:00
|
|
|
<< "Frames Received (NIC)"
|
|
|
|
<< "Frames Sent (NIC)"
|
2008-05-03 09:37:10 -05:00
|
|
|
<< "Bytes Received"
|
|
|
|
<< "Bytes Sent"
|
|
|
|
<< "Byte Send Rate (Bps)"
|
|
|
|
<< "Byte Receive Rate (Bps)"
|
2008-09-28 13:01:52 -05:00
|
|
|
<< "Bytes Received (NIC)"
|
|
|
|
<< "Bytes Sent (NIC)"
|
2008-05-03 09:37:10 -05:00
|
|
|
);
|
|
|
|
|
|
|
|
class PortGroupList;
|
|
|
|
|
|
|
|
class PortStatsModel : public QAbstractTableModel
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2008-09-14 07:03:53 -05:00
|
|
|
|
2008-05-03 09:37:10 -05:00
|
|
|
PortStatsModel(PortGroupList *p, QObject *parent = 0);
|
|
|
|
|
|
|
|
int rowCount(const QModelIndex &parent = QModelIndex()) const;
|
|
|
|
int columnCount(const QModelIndex &parent = QModelIndex()) const;
|
|
|
|
QVariant data(const QModelIndex &index, int role) const;
|
|
|
|
QVariant headerData(int section, Qt::Orientation orientation,
|
|
|
|
int role = Qt::DisplayRole) const;
|
|
|
|
|
2008-09-14 07:03:53 -05:00
|
|
|
class PortGroupAndPortList {
|
2008-09-28 13:01:52 -05:00
|
|
|
public:
|
2008-09-14 07:03:53 -05:00
|
|
|
uint portGroupId;
|
|
|
|
QList<uint> portList;
|
|
|
|
};
|
|
|
|
void portListFromIndex(QModelIndexList indices,
|
|
|
|
QList<PortGroupAndPortList> &portList);
|
|
|
|
|
2008-05-03 09:37:10 -05:00
|
|
|
public slots:
|
|
|
|
void when_portListChanged();
|
|
|
|
void on_portStatsUpdate(int port, void*stats);
|
2008-09-14 07:03:53 -05:00
|
|
|
void when_portGroup_stats_update(quint32 portGroupId);
|
|
|
|
|
|
|
|
private slots:
|
|
|
|
void updateStats();
|
2008-05-03 09:37:10 -05:00
|
|
|
|
|
|
|
private:
|
2008-09-14 07:03:53 -05:00
|
|
|
PortGroupList *pgl;
|
|
|
|
|
2008-05-03 09:37:10 -05:00
|
|
|
// numPorts stores the num of ports per portgroup
|
|
|
|
// in the same order as the portgroups are index in the pgl
|
|
|
|
// Also it stores them as cumulative totals
|
|
|
|
QList<quint16> numPorts;
|
|
|
|
|
2008-09-14 07:03:53 -05:00
|
|
|
void getDomainIndexes(const QModelIndex &index,
|
|
|
|
uint &portGroupIdx, uint &portIdx) const;
|
|
|
|
|
2008-05-03 09:37:10 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|