- 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>
<qresource prefix="/" >
<file>icons/arrow_down.png</file>
<file>icons/arrow_left.png</file>
<file>icons/arrow_right.png</file>
<file>icons/arrow_up.png</file>
<file>icons/bullet_error.png</file>

View File

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

View File

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

View File

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

View File

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

View File

@ -32,36 +32,23 @@ bool PortGroupList::isPort(const QModelIndex& index)
PortGroup& PortGroupList::portGroup(const QModelIndex& index)
{
if (mPortGroupListModel.isPortGroup(index))
{
//return *(mPortGroups[mPortGroupListModel.portGroupId(index)]);
return *(mPortGroups[index.row()]);
}
#if 0 // FIXME(MED)
else
return NULL;
#endif
Q_ASSERT(mPortGroupListModel.isPortGroup(index));
return *(mPortGroups[index.row()]);
}
Port& PortGroupList::port(const QModelIndex& index)
{
if (mPortGroupListModel.isPort(index))
{
return (mPortGroups.at(index.parent().row())->
mPorts[index.row()]);
}
#if 0 // FIXME(MED)
else
return NULL;
#endif
Q_ASSERT(mPortGroupListModel.isPort(index));
return (*mPortGroups.at(index.parent().row())->mPorts[index.row()]);
}
void PortGroupList::addPortGroup(PortGroup &portGroup)
{
mPortGroupListModel.portGroupAboutToBeAppended();
connect(&portGroup, SIGNAL(portGroupDataChanged(PortGroup*, int)),
&mPortGroupListModel, SLOT(when_portGroupDataChanged(PortGroup*, int)));
connect(&portGroup, SIGNAL(portGroupDataChanged(int, int)),
&mPortGroupListModel, SLOT(when_portGroupDataChanged(int, int)));
#if 0
connect(&portGroup, SIGNAL(portListAboutToBeChanged(quint32)),
&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)").
arg(pgl->mPortGroups.at(
parent.row())->mPorts[index.row()].id()).
parent.row())->mPorts[index.row()]->id()).
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(pgl->mPortGroups.at(
parent.row())->mPorts[index.row()].description());
parent.row())->mPorts[index.row()]->description());
}
else if ((role == Qt::DecorationRole))
{
DBG0("Exit PortModel data 5\n");
if (pgl->mPortGroups.at(parent.row())->numPorts() == 0)
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:
return QIcon(":/icons/bullet_white.png");
@ -198,7 +198,7 @@ QModelIndex PortModel::index (int row, int col,
else
{
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;
//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
// ----------------------------------------------
void PortModel::when_portGroupDataChanged(PortGroup* portGroup, int portId)
void PortModel::when_portGroupDataChanged(int portGroupId, int portId)
{
QModelIndex index;
int row;
if (!pgl->mPortGroups.contains(portGroup))
{
qDebug("when_portGroupDataChanged(): pg not in list - do nothing");
return;
}
if (portId == 0xFFFF)
row = pgl->indexOfPortGroup(portGroupId);
else
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);
}
@ -308,18 +305,6 @@ void PortModel::portGroupRemoved()
endRemoveRows();
}
#if 0
void PortModel::triggerLayoutAboutToBeChanged()
{
emit layoutAboutToBeChanged();
}
void PortModel::triggerLayoutChanged()
{
emit layoutChanged();
}
#endif
void PortModel::when_portListChanged()
{
reset();

View File

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

View File

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

View File

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

View File

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