- LinkState is now updated in PortWindow as soon as a change is detected; the required minimal refactoring of the Port class usage has been done
	- Fixed a compiler warning in portgrouplist.cpp


Others
	- PortStatsFilter: Ui change - added left and right arrow icons
This commit is contained in:
Srivats P. 2009-11-14 15:09:19 +00:00
parent 17792b8253
commit 3602d24767
12 changed files with 71 additions and 94 deletions

BIN
client/icons/arrow_left.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 345 B

View File

@ -1,6 +1,7 @@
<RCC> <RCC>
<qresource prefix="/" > <qresource prefix="/" >
<file>icons/arrow_down.png</file> <file>icons/arrow_down.png</file>
<file>icons/arrow_left.png</file>
<file>icons/arrow_right.png</file> <file>icons/arrow_right.png</file>
<file>icons/arrow_up.png</file> <file>icons/arrow_up.png</file>
<file>icons/bullet_error.png</file> <file>icons/bullet_error.png</file>

View File

@ -187,9 +187,11 @@ void Port::updateStats(OstProto::PortStats *portStats)
oldState = stats.state(); oldState = stats.state();
stats.MergeFrom(*portStats); stats.MergeFrom(*portStats);
#if 0
if (oldState.link_state() != stats.state().link_state()) if (oldState.link_state() != stats.state().link_state())
{
qDebug("portstate changed");
emit portDataChanged(mPortGroupId, mPortId); emit portDataChanged(mPortGroupId, mPortId);
#endif }
} }

View File

@ -1,18 +1,17 @@
#ifndef _PORT_H #ifndef _PORT_H
#define _PORT_H #define _PORT_H
#include <Qt> #include <QObject>
#include <QString> #include <QString>
#include <QList> #include <QList>
#include "stream.h" #include "stream.h"
//class StreamModel; //class StreamModel;
class Port { class Port : public QObject {
//friend class StreamModel; Q_OBJECT
private:
static uint mAllocStreamId; static uint mAllocStreamId;
OstProto::Port d; OstProto::Port d;
OstProto::PortStats stats; OstProto::PortStats stats;
@ -28,6 +27,7 @@ private:
uint newStreamId(); uint newStreamId();
void updateStreamOrdinalsFromIndex(); void updateStreamOrdinalsFromIndex();
void reorderStreamsByOrdinals(); void reorderStreamsByOrdinals();
public: public:
enum AdminStatus { AdminDisable, AdminEnable }; enum AdminStatus { AdminDisable, AdminEnable };
enum ControlMode { ControlShared, ControlExclusive }; enum ControlMode { ControlShared, ControlExclusive };
@ -50,13 +50,6 @@ public:
ControlMode controlMode() ControlMode controlMode()
{ return (d.is_exclusive_control()?ControlExclusive:ControlShared); } { return (d.is_exclusive_control()?ControlExclusive:ControlShared); }
#if 0
void setName(QString &name) { d.name; }
void setName(const char* name) { mName = QString(name); }
void setDescription(QString &description) { mDescription = description; }
void setDescription(const char *description)
{ mDescription = QString(description); }
#endif
//void setAdminEnable(AdminStatus status) { mAdminStatus = status; } //void setAdminEnable(AdminStatus status) { mAdminStatus = status; }
void setAlias(QString &alias) { mUserAlias = alias; } void setAlias(QString &alias) { mUserAlias = alias; }
//void setExclusive(bool flag); //void setExclusive(bool flag);
@ -97,10 +90,8 @@ public:
void updateStats(OstProto::PortStats *portStats); void updateStats(OstProto::PortStats *portStats);
#if 0
signals: signals:
void portDataChanged(int portGroupId, int portId); void portDataChanged(int portGroupId, int portId);
#endif
}; };

View File

@ -51,7 +51,7 @@ PortGroup::~PortGroup()
void PortGroup::on_rpcChannel_stateChanged() void PortGroup::on_rpcChannel_stateChanged()
{ {
qDebug("state changed"); qDebug("state changed");
emit portGroupDataChanged(this); emit portGroupDataChanged(mPortGroupId);
} }
void PortGroup::on_rpcChannel_connected() void PortGroup::on_rpcChannel_connected()
@ -60,7 +60,7 @@ void PortGroup::on_rpcChannel_connected()
OstProto::PortIdList *portIdList; OstProto::PortIdList *portIdList;
qDebug("connected\n"); qDebug("connected\n");
emit portGroupDataChanged(this); emit portGroupDataChanged(mPortGroupId);
qDebug("requesting portlist ..."); qDebug("requesting portlist ...");
portIdList = new OstProto::PortIdList(); portIdList = new OstProto::PortIdList();
@ -73,15 +73,18 @@ void PortGroup::on_rpcChannel_disconnected()
{ {
qDebug("disconnected\n"); qDebug("disconnected\n");
emit portListAboutToBeChanged(mPortGroupId); emit portListAboutToBeChanged(mPortGroupId);
mPorts.clear();
while (!mPorts.isEmpty())
delete mPorts.takeFirst();
emit portListChanged(mPortGroupId); emit portListChanged(mPortGroupId);
emit portGroupDataChanged(this); emit portGroupDataChanged(mPortGroupId);
} }
void PortGroup::on_rpcChannel_error(QAbstractSocket::SocketError socketError) void PortGroup::on_rpcChannel_error(QAbstractSocket::SocketError socketError)
{ {
qDebug("error\n"); qDebug("error\n");
emit portGroupDataChanged(this); emit portGroupDataChanged(mPortGroupId);
} }
void PortGroup::when_configApply(int portIndex, uint *cookie) void PortGroup::when_configApply(int portIndex, uint *cookie)
@ -124,8 +127,8 @@ void PortGroup::when_configApply(int portIndex, uint *cookie)
qDebug("applying 'deleted streams' ..."); qDebug("applying 'deleted streams' ...");
streamIdList.mutable_port_id()->set_id(mPorts[portIndex].id()); streamIdList.mutable_port_id()->set_id(mPorts[portIndex]->id());
mPorts[portIndex].getDeletedStreamsSinceLastSync(streamIdList); mPorts[portIndex]->getDeletedStreamsSinceLastSync(streamIdList);
(*op)++; (*op)++;
rpcController->Reset(); rpcController->Reset();
@ -140,8 +143,8 @@ void PortGroup::when_configApply(int portIndex, uint *cookie)
qDebug("applying 'new streams' ..."); qDebug("applying 'new streams' ...");
streamIdList.mutable_port_id()->set_id(mPorts[portIndex].id()); streamIdList.mutable_port_id()->set_id(mPorts[portIndex]->id());
mPorts[portIndex].getNewStreamsSinceLastSync(streamIdList); mPorts[portIndex]->getNewStreamsSinceLastSync(streamIdList);
(*op)++; (*op)++;
rpcController->Reset(); rpcController->Reset();
@ -156,8 +159,8 @@ void PortGroup::when_configApply(int portIndex, uint *cookie)
qDebug("applying 'modified streams' ..."); qDebug("applying 'modified streams' ...");
streamConfigList.mutable_port_id()->set_id(mPorts[portIndex].id()); streamConfigList.mutable_port_id()->set_id(mPorts[portIndex]->id());
mPorts[portIndex].getModifiedStreamsSinceLastSync(streamConfigList); mPorts[portIndex]->getModifiedStreamsSinceLastSync(streamConfigList);
(*op)++; (*op)++;
rpcController->Reset(); rpcController->Reset();
@ -168,7 +171,7 @@ void PortGroup::when_configApply(int portIndex, uint *cookie)
case 3: case 3:
qDebug("apply completed"); qDebug("apply completed");
mPorts[portIndex].when_syncComplete(); mPorts[portIndex]->when_syncComplete();
delete cookie; delete cookie;
break; break;
@ -195,8 +198,10 @@ void PortGroup::processPortIdList(OstProto::PortIdList *portIdList)
Port *p; Port *p;
p = new Port(portIdList->port_id(i).id(), mPortGroupId); p = new Port(portIdList->port_id(i).id(), mPortGroupId);
connect(p, SIGNAL(portDataChanged(int, int)),
this, SIGNAL(portGroupDataChanged(int, int)));
qDebug("before port append\n"); qDebug("before port append\n");
mPorts.append(*p); mPorts.append(p);
} }
emit portListChanged(mPortGroupId); emit portListChanged(mPortGroupId);
@ -240,7 +245,7 @@ void PortGroup::processPortConfigList(OstProto::PortConfigList *portConfigList)
id = portConfigList->port(i).port_id().id(); id = portConfigList->port(i).port_id().id();
// FIXME: don't mix port id & index into mPorts[] // FIXME: don't mix port id & index into mPorts[]
mPorts[id].updatePortConfig(portConfigList->mutable_port(i)); mPorts[id]->updatePortConfig(portConfigList->mutable_port(i));
} }
emit portListChanged(mPortGroupId); emit portListChanged(mPortGroupId);
@ -284,10 +289,10 @@ void PortGroup::getStreamIdList(int portIndex,
Q_ASSERT(portIndex < numPorts()); Q_ASSERT(portIndex < numPorts());
if (streamIdList->port_id().id() != mPorts[portIndex].id()) if (streamIdList->port_id().id() != mPorts[portIndex]->id())
{ {
qDebug("%s: Invalid portId %d (expected %d) received for portIndex %d", qDebug("%s: Invalid portId %d (expected %d) received for portIndex %d",
__FUNCTION__, streamIdList->port_id().id(), mPorts[portIndex].id(), __FUNCTION__, streamIdList->port_id().id(), mPorts[portIndex]->id(),
portIndex); portIndex);
goto _next_port; // FIXME(MED): Partial RPC goto _next_port; // FIXME(MED): Partial RPC
} }
@ -298,14 +303,14 @@ void PortGroup::getStreamIdList(int portIndex,
uint streamId; uint streamId;
streamId = streamIdList->stream_id(i).id(); streamId = streamIdList->stream_id(i).id();
mPorts[portIndex].insertStream(streamId); mPorts[portIndex]->insertStream(streamId);
} }
_next_port: _next_port:
// FIXME(HI): ideally we shd use signals/slots but this means // FIXME(HI): ideally we shd use signals/slots but this means
// we will have to use Port* instead of Port with QList<> - // we will have to use Port* instead of Port with QList<> -
// need to find a way for this // need to find a way for this
mPorts[portIndex].when_syncComplete(); mPorts[portIndex]->when_syncComplete();
portIndex++; portIndex++;
if (portIndex >= numPorts()) if (portIndex >= numPorts())
{ {
@ -322,7 +327,7 @@ _next_port:
} }
_request: _request:
portId.set_id(mPorts[portIndex].id()); portId.set_id(mPorts[portIndex]->id());
streamIdList->Clear(); streamIdList->Clear();
rpcController->Reset(); rpcController->Reset();
@ -368,11 +373,11 @@ void PortGroup::getStreamConfigList(int portIndex,
Q_ASSERT(portIndex < numPorts()); Q_ASSERT(portIndex < numPorts());
if (streamConfigList->port_id().id() != mPorts[portIndex].id()) if (streamConfigList->port_id().id() != mPorts[portIndex]->id())
{ {
qDebug("%s: Invalid portId %d (expected %d) received for portIndex %d", qDebug("%s: Invalid portId %d (expected %d) received for portIndex %d",
__FUNCTION__, streamConfigList->port_id().id(), __FUNCTION__, streamConfigList->port_id().id(),
mPorts[portIndex].id(), portIndex); mPorts[portIndex]->id(), portIndex);
goto _next_port; // FIXME(MED): Partial RPC goto _next_port; // FIXME(MED): Partial RPC
} }
@ -382,7 +387,7 @@ void PortGroup::getStreamConfigList(int portIndex,
uint streamId; uint streamId;
streamId = streamConfigList->stream(i).stream_id().id(); streamId = streamConfigList->stream(i).stream_id().id();
mPorts[portIndex].updateStream(streamId, mPorts[portIndex]->updateStream(streamId,
streamConfigList->mutable_stream(i)); streamConfigList->mutable_stream(i));
} }
@ -403,13 +408,13 @@ _request:
qDebug("requesting stream config list ..."); qDebug("requesting stream config list ...");
streamIdList.Clear(); streamIdList.Clear();
streamIdList.mutable_port_id()->set_id(mPorts[portIndex].id()); streamIdList.mutable_port_id()->set_id(mPorts[portIndex]->id());
for (int j = 0; j < mPorts[portIndex].numStreams(); j++) for (int j = 0; j < mPorts[portIndex]->numStreams(); j++)
{ {
OstProto::StreamId *s; OstProto::StreamId *s;
s = streamIdList.add_stream_id(); s = streamIdList.add_stream_id();
s->set_id(mPorts[portIndex].streamByIndex(j)->id()); s->set_id(mPorts[portIndex]->streamByIndex(j)->id());
} }
streamConfigList->Clear(); streamConfigList->Clear();
@ -657,7 +662,7 @@ void PortGroup::processPortStatsList(OstProto::PortStatsList *portStatsList)
id = portStatsList->port_stats(i).port_id().id(); id = portStatsList->port_stats(i).port_id().id();
// FIXME: don't mix port id & index into mPorts[] // FIXME: don't mix port id & index into mPorts[]
mPorts[id].updateStats(portStatsList->mutable_port_stats(i)); mPorts[id]->updateStats(portStatsList->mutable_port_stats(i));
} }
emit statsChanged(mPortGroupId); emit statsChanged(mPortGroupId);

View File

@ -38,7 +38,7 @@ private:
::OstProto::PortIdList portIdList; ::OstProto::PortIdList portIdList;
public: // FIXME(HIGH): member access public: // FIXME(HIGH): member access
QList<Port> mPorts; QList<Port*> mPorts;
public: public:
PortGroup(QHostAddress ip = QHostAddress::LocalHost, PortGroup(QHostAddress ip = QHostAddress::LocalHost,
@ -91,7 +91,7 @@ public:
void processClearStatsAck(OstProto::Ack *ack); void processClearStatsAck(OstProto::Ack *ack);
signals: signals:
void portGroupDataChanged(PortGroup* portGroup, int portId = 0xFFFF); void portGroupDataChanged(int portGroupId, int portId = 0xFFFF);
void portListAboutToBeChanged(quint32 portGroupId); void portListAboutToBeChanged(quint32 portGroupId);
void portListChanged(quint32 portGroupId); void portListChanged(quint32 portGroupId);
void statsChanged(quint32 portGroupId); void statsChanged(quint32 portGroupId);

View File

@ -32,36 +32,23 @@ bool PortGroupList::isPort(const QModelIndex& index)
PortGroup& PortGroupList::portGroup(const QModelIndex& index) PortGroup& PortGroupList::portGroup(const QModelIndex& index)
{ {
if (mPortGroupListModel.isPortGroup(index)) Q_ASSERT(mPortGroupListModel.isPortGroup(index));
{
//return *(mPortGroups[mPortGroupListModel.portGroupId(index)]); return *(mPortGroups[index.row()]);
return *(mPortGroups[index.row()]);
}
#if 0 // FIXME(MED)
else
return NULL;
#endif
} }
Port& PortGroupList::port(const QModelIndex& index) Port& PortGroupList::port(const QModelIndex& index)
{ {
if (mPortGroupListModel.isPort(index)) Q_ASSERT(mPortGroupListModel.isPort(index));
{ return (*mPortGroups.at(index.parent().row())->mPorts[index.row()]);
return (mPortGroups.at(index.parent().row())->
mPorts[index.row()]);
}
#if 0 // FIXME(MED)
else
return NULL;
#endif
} }
void PortGroupList::addPortGroup(PortGroup &portGroup) void PortGroupList::addPortGroup(PortGroup &portGroup)
{ {
mPortGroupListModel.portGroupAboutToBeAppended(); mPortGroupListModel.portGroupAboutToBeAppended();
connect(&portGroup, SIGNAL(portGroupDataChanged(PortGroup*, int)), connect(&portGroup, SIGNAL(portGroupDataChanged(int, int)),
&mPortGroupListModel, SLOT(when_portGroupDataChanged(PortGroup*, int))); &mPortGroupListModel, SLOT(when_portGroupDataChanged(int, int)));
#if 0 #if 0
connect(&portGroup, SIGNAL(portListAboutToBeChanged(quint32)), connect(&portGroup, SIGNAL(portListAboutToBeChanged(quint32)),
&mPortGroupListModel, SLOT(triggerLayoutAboutToBeChanged())); &mPortGroupListModel, SLOT(triggerLayoutAboutToBeChanged()));

View File

@ -132,19 +132,19 @@ QVariant PortModel::data(const QModelIndex &index, int role) const
return QString("Port %1: %2 [%3] (%4)"). return QString("Port %1: %2 [%3] (%4)").
arg(pgl->mPortGroups.at( arg(pgl->mPortGroups.at(
parent.row())->mPorts[index.row()].id()). parent.row())->mPorts[index.row()]->id()).
arg(pgl->mPortGroups.at( arg(pgl->mPortGroups.at(
parent.row())->mPorts[index.row()].name()). parent.row())->mPorts[index.row()]->name()).
arg(QHostAddress("0.0.0.0").toString()). // FIXME(LOW) arg(QHostAddress("0.0.0.0").toString()). // FIXME(LOW)
arg(pgl->mPortGroups.at( arg(pgl->mPortGroups.at(
parent.row())->mPorts[index.row()].description()); parent.row())->mPorts[index.row()]->description());
} }
else if ((role == Qt::DecorationRole)) else if ((role == Qt::DecorationRole))
{ {
DBG0("Exit PortModel data 5\n"); DBG0("Exit PortModel data 5\n");
if (pgl->mPortGroups.at(parent.row())->numPorts() == 0) if (pgl->mPortGroups.at(parent.row())->numPorts() == 0)
return QVariant(); return QVariant();
switch(pgl->mPortGroups.at(parent.row())->mPorts[index.row()].linkState()) switch(pgl->mPortGroups.at(parent.row())->mPorts[index.row()]->linkState())
{ {
case OstProto::LinkStateUnknown: case OstProto::LinkStateUnknown:
return QIcon(":/icons/bullet_white.png"); return QIcon(":/icons/bullet_white.png");
@ -198,7 +198,7 @@ QModelIndex PortModel::index (int row, int col,
else else
{ {
quint16 pg = parent.internalId() >> 16; quint16 pg = parent.internalId() >> 16;
quint16 p = pgl->mPortGroups.value(parent.row())->mPorts.value(row).id(); quint16 p = pgl->mPortGroups.value(parent.row())->mPorts.value(row)->id();
quint32 id = (pg << 16) | p; quint32 id = (pg << 16) | p;
//qDebug("index (nontop) dbg: PG=%d, P=%d, ID=%x\n", pg, p, id); //qDebug("index (nontop) dbg: PG=%d, P=%d, ID=%x\n", pg, p, id);
@ -264,21 +264,18 @@ quint32 PortModel::portId(const QModelIndex& index)
// ---------------------------------------------- // ----------------------------------------------
// Slots // Slots
// ---------------------------------------------- // ----------------------------------------------
void PortModel::when_portGroupDataChanged(PortGroup* portGroup, int portId) void PortModel::when_portGroupDataChanged(int portGroupId, int portId)
{ {
QModelIndex index; QModelIndex index;
int row;
if (!pgl->mPortGroups.contains(portGroup)) if (portId == 0xFFFF)
{ row = pgl->indexOfPortGroup(portGroupId);
qDebug("when_portGroupDataChanged(): pg not in list - do nothing"); else
return; row = portId;
}
index = createIndex(row, 0, (portGroupId << 16) | portId);
qDebug("when_portGroupDataChanged pgid = %d", portGroup->id());
qDebug("when_portGroupDataChanged idx = %d", pgl->mPortGroups.indexOf(portGroup));
index = createIndex(pgl->mPortGroups.indexOf(portGroup), 0,
(portGroup->id() << 16) | portId);
emit dataChanged(index, index); emit dataChanged(index, index);
} }
@ -308,18 +305,6 @@ void PortModel::portGroupRemoved()
endRemoveRows(); endRemoveRows();
} }
#if 0
void PortModel::triggerLayoutAboutToBeChanged()
{
emit layoutAboutToBeChanged();
}
void PortModel::triggerLayoutChanged()
{
emit layoutChanged();
}
#endif
void PortModel::when_portListChanged() void PortModel::when_portListChanged()
{ {
reset(); reset();

View File

@ -32,7 +32,7 @@ class PortModel : public QAbstractItemModel
private slots: private slots:
void when_portGroupDataChanged(PortGroup *portGroup, int portId); void when_portGroupDataChanged(int portGroupId, int portId);
void portGroupAboutToBeAppended(); void portGroupAboutToBeAppended();
void portGroupAppended(); void portGroupAppended();

View File

@ -57,6 +57,9 @@
<property name="text" > <property name="text" >
<string>></string> <string>></string>
</property> </property>
<property name="icon" >
<iconset resource="ostinato.qrc" >:/icons/arrow_right.png</iconset>
</property>
</widget> </widget>
</item> </item>
<item> <item>
@ -64,6 +67,9 @@
<property name="text" > <property name="text" >
<string>&lt;</string> <string>&lt;</string>
</property> </property>
<property name="icon" >
<iconset resource="ostinato.qrc" >:/icons/arrow_left.png</iconset>
</property>
</widget> </widget>
</item> </item>
<item> <item>

View File

@ -91,7 +91,7 @@ QVariant PortStatsModel::data(const QModelIndex &index, int role) const
{ {
OstProto::PortStats stats; OstProto::PortStats stats;
stats = pgl->mPortGroups.at(pgidx)->mPorts[pidx].getStats(); stats = pgl->mPortGroups.at(pgidx)->mPorts[pidx]->getStats();
switch(row) switch(row)
{ {

View File

@ -236,7 +236,7 @@ void StreamModel::setCurrentPortIndex(const QModelIndex &current)
{ {
qDebug("change to valid port"); qDebug("change to valid port");
quint16 pg = current.internalId() >> 16; quint16 pg = current.internalId() >> 16;
mCurrentPort = &pgl->mPortGroups[pgl->indexOfPortGroup(pg)]->mPorts[current.row()]; mCurrentPort = pgl->mPortGroups[pgl->indexOfPortGroup(pg)]->mPorts[current.row()];
} }
reset(); reset();
} }