Detect when port config has changed and needs to APPLY'd
For now we prompt user to click Apply, in future we can use this to do a "Auto Apply"
This commit is contained in:
parent
4d13ecf15d
commit
cca2e94bb3
@ -57,6 +57,7 @@ Port::Port(quint32 id, quint32 portGroupId)
|
|||||||
stats.mutable_port_id()->set_id(id);
|
stats.mutable_port_id()->set_id(id);
|
||||||
mPortGroupId = portGroupId;
|
mPortGroupId = portGroupId;
|
||||||
capFile_ = NULL;
|
capFile_ = NULL;
|
||||||
|
dirty_ = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Port::~Port()
|
Port::~Port()
|
||||||
@ -100,6 +101,15 @@ void Port::reorderStreamsByOrdinals()
|
|||||||
qSort(mStreams.begin(), mStreams.end(), StreamBase::StreamLessThan);
|
qSort(mStreams.begin(), mStreams.end(), StreamBase::StreamLessThan);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Port::setDirty(bool dirty)
|
||||||
|
{
|
||||||
|
if (dirty == dirty_)
|
||||||
|
return;
|
||||||
|
|
||||||
|
dirty_ = dirty;
|
||||||
|
emit localConfigChanged(dirty_);
|
||||||
|
}
|
||||||
|
|
||||||
void Port::recalculateAverageRates()
|
void Port::recalculateAverageRates()
|
||||||
{
|
{
|
||||||
double pps = 0;
|
double pps = 0;
|
||||||
@ -209,6 +219,7 @@ void Port::setAveragePacketRate(double packetsPerSec)
|
|||||||
Q_ASSERT(false); // Unreachable!!
|
Q_ASSERT(false); // Unreachable!!
|
||||||
}
|
}
|
||||||
numActiveStreams_ = n;
|
numActiveStreams_ = n;
|
||||||
|
setDirty(true);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
avgPacketsPerSec_ = avgBitsPerSec_ = numActiveStreams_ = 0;
|
avgPacketsPerSec_ = avgBitsPerSec_ = numActiveStreams_ = 0;
|
||||||
@ -282,6 +293,7 @@ void Port::setAverageBitRate(double bitsPerSec)
|
|||||||
Q_ASSERT(false); // Unreachable!!
|
Q_ASSERT(false); // Unreachable!!
|
||||||
}
|
}
|
||||||
numActiveStreams_ = n;
|
numActiveStreams_ = n;
|
||||||
|
setDirty(true);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
avgPacketsPerSec_ = avgBitsPerSec_ = numActiveStreams_ = 0;
|
avgPacketsPerSec_ = avgBitsPerSec_ = numActiveStreams_ = 0;
|
||||||
@ -305,6 +317,7 @@ bool Port::newStreamAt(int index, OstProto::Stream const *stream)
|
|||||||
mStreams.insert(index, s);
|
mStreams.insert(index, s);
|
||||||
updateStreamOrdinalsFromIndex();
|
updateStreamOrdinalsFromIndex();
|
||||||
recalculateAverageRates();
|
recalculateAverageRates();
|
||||||
|
setDirty(true);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -317,6 +330,7 @@ bool Port::deleteStreamAt(int index)
|
|||||||
delete mStreams.takeAt(index);
|
delete mStreams.takeAt(index);
|
||||||
updateStreamOrdinalsFromIndex();
|
updateStreamOrdinalsFromIndex();
|
||||||
recalculateAverageRates();
|
recalculateAverageRates();
|
||||||
|
setDirty(true);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -506,6 +520,8 @@ void Port::when_syncComplete()
|
|||||||
deviceGroups_.at(i)->device_group_id().id());
|
deviceGroups_.at(i)->device_group_id().id());
|
||||||
}
|
}
|
||||||
modifiedDeviceGroupList_.clear();
|
modifiedDeviceGroupList_.clear();
|
||||||
|
|
||||||
|
setDirty(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Port::updateStats(OstProto::PortStats *portStats)
|
void Port::updateStats(OstProto::PortStats *portStats)
|
||||||
@ -543,6 +559,7 @@ void Port::duplicateStreams(const QList<int> &list, int count)
|
|||||||
insertAt++;
|
insertAt++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
setDirty(true);
|
||||||
|
|
||||||
emit streamListChanged(mPortGroupId, mPortId);
|
emit streamListChanged(mPortGroupId, mPortId);
|
||||||
}
|
}
|
||||||
@ -625,6 +642,7 @@ bool Port::openStreams(QString fileName, bool append, QString &error)
|
|||||||
if (i % 32 == 0)
|
if (i % 32 == 0)
|
||||||
qApp->processEvents();
|
qApp->processEvents();
|
||||||
}
|
}
|
||||||
|
setDirty(true);
|
||||||
|
|
||||||
_user_cancel:
|
_user_cancel:
|
||||||
emit streamListChanged(mPortGroupId, mPortId);
|
emit streamListChanged(mPortGroupId, mPortId);
|
||||||
@ -743,11 +761,12 @@ OstProto::DeviceGroup* Port::mutableDeviceGroupByIndex(int index)
|
|||||||
|
|
||||||
// Caller can modify DeviceGroup - assume she will
|
// Caller can modify DeviceGroup - assume she will
|
||||||
modifiedDeviceGroupList_.insert(devGrp->device_group_id().id());
|
modifiedDeviceGroupList_.insert(devGrp->device_group_id().id());
|
||||||
|
setDirty(true);
|
||||||
|
|
||||||
return devGrp;
|
return devGrp;
|
||||||
}
|
}
|
||||||
|
|
||||||
OstProto::DeviceGroup* Port::deviceGroupById(uint deviceGroupId)
|
const OstProto::DeviceGroup* Port::deviceGroupById(uint deviceGroupId) const
|
||||||
{
|
{
|
||||||
for (int i = 0; i < deviceGroups_.size(); i++) {
|
for (int i = 0; i < deviceGroups_.size(); i++) {
|
||||||
OstProto::DeviceGroup *devGrp = deviceGroups_.at(i);
|
OstProto::DeviceGroup *devGrp = deviceGroups_.at(i);
|
||||||
@ -776,6 +795,7 @@ bool Port::newDeviceGroupAt(int index, const OstProto::DeviceGroup *deviceGroup)
|
|||||||
devGrp->mutable_device_group_id()->set_id(newDeviceGroupId());
|
devGrp->mutable_device_group_id()->set_id(newDeviceGroupId());
|
||||||
deviceGroups_.insert(index, devGrp);
|
deviceGroups_.insert(index, devGrp);
|
||||||
modifiedDeviceGroupList_.insert(devGrp->device_group_id().id());
|
modifiedDeviceGroupList_.insert(devGrp->device_group_id().id());
|
||||||
|
setDirty(true);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -788,6 +808,7 @@ bool Port::deleteDeviceGroupAt(int index)
|
|||||||
OstProto::DeviceGroup *devGrp = deviceGroups_.takeAt(index);
|
OstProto::DeviceGroup *devGrp = deviceGroups_.takeAt(index);
|
||||||
modifiedDeviceGroupList_.remove(devGrp->device_group_id().id());
|
modifiedDeviceGroupList_.remove(devGrp->device_group_id().id());
|
||||||
delete devGrp;
|
delete devGrp;
|
||||||
|
setDirty(true);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -818,7 +839,12 @@ bool Port::updateDeviceGroup(
|
|||||||
uint deviceGroupId,
|
uint deviceGroupId,
|
||||||
OstProto::DeviceGroup *deviceGroup)
|
OstProto::DeviceGroup *deviceGroup)
|
||||||
{
|
{
|
||||||
OstProto::DeviceGroup *devGrp = deviceGroupById(deviceGroupId);
|
using OstProto::DeviceGroup;
|
||||||
|
|
||||||
|
// XXX: We should not call mutableDeviceGroupById() because that will
|
||||||
|
// implicitly set the port as dirty, so we use a const_cast hack instead
|
||||||
|
DeviceGroup *devGrp = const_cast<DeviceGroup*>(
|
||||||
|
deviceGroupById(deviceGroupId));
|
||||||
|
|
||||||
if (!devGrp) {
|
if (!devGrp) {
|
||||||
qDebug("%s: deviceGroup id %u does not exist", __FUNCTION__,
|
qDebug("%s: deviceGroup id %u does not exist", __FUNCTION__,
|
||||||
|
@ -50,6 +50,7 @@ class Port : public QObject {
|
|||||||
quint32 mPortId;
|
quint32 mPortId;
|
||||||
quint32 mPortGroupId;
|
quint32 mPortGroupId;
|
||||||
QString mUserAlias; // user defined
|
QString mUserAlias; // user defined
|
||||||
|
bool dirty_;
|
||||||
|
|
||||||
double avgPacketsPerSec_;
|
double avgPacketsPerSec_;
|
||||||
double avgBitsPerSec_;
|
double avgBitsPerSec_;
|
||||||
@ -70,6 +71,7 @@ class Port : public QObject {
|
|||||||
void updateStreamOrdinalsFromIndex();
|
void updateStreamOrdinalsFromIndex();
|
||||||
void reorderStreamsByOrdinals();
|
void reorderStreamsByOrdinals();
|
||||||
|
|
||||||
|
void setDirty(bool dirty);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
enum AdminStatus { AdminDisable, AdminEnable };
|
enum AdminStatus { AdminDisable, AdminEnable };
|
||||||
@ -108,11 +110,17 @@ public:
|
|||||||
//void setExclusive(bool flag);
|
//void setExclusive(bool flag);
|
||||||
|
|
||||||
int numStreams() { return mStreams.size(); }
|
int numStreams() { return mStreams.size(); }
|
||||||
Stream* streamByIndex(int index)
|
const Stream* streamByIndex(int index) const
|
||||||
{
|
{
|
||||||
Q_ASSERT(index < mStreams.size());
|
Q_ASSERT(index < mStreams.size());
|
||||||
return mStreams[index];
|
return mStreams[index];
|
||||||
}
|
}
|
||||||
|
Stream* mutableStreamByIndex(int index)
|
||||||
|
{
|
||||||
|
Q_ASSERT(index < mStreams.size());
|
||||||
|
setDirty(true); // assume - that's the best we can do atm
|
||||||
|
return mStreams[index];
|
||||||
|
}
|
||||||
OstProto::LinkState linkState()
|
OstProto::LinkState linkState()
|
||||||
{ return stats.state().link_state(); }
|
{ return stats.state().link_state(); }
|
||||||
|
|
||||||
@ -129,6 +137,7 @@ public:
|
|||||||
|
|
||||||
void protoDataCopyInto(OstProto::Port *data);
|
void protoDataCopyInto(OstProto::Port *data);
|
||||||
|
|
||||||
|
//! Used when config received from server
|
||||||
// FIXME(MED): naming inconsistency - PortConfig/Stream; also retVal
|
// FIXME(MED): naming inconsistency - PortConfig/Stream; also retVal
|
||||||
void updatePortConfig(OstProto::Port *port);
|
void updatePortConfig(OstProto::Port *port);
|
||||||
|
|
||||||
@ -144,6 +153,7 @@ public:
|
|||||||
bool updateStream(uint streamId, OstProto::Stream *stream);
|
bool updateStream(uint streamId, OstProto::Stream *stream);
|
||||||
//@}
|
//@}
|
||||||
|
|
||||||
|
bool isDirty() { return dirty_; }
|
||||||
void getDeletedStreamsSinceLastSync(OstProto::StreamIdList &streamIdList);
|
void getDeletedStreamsSinceLastSync(OstProto::StreamIdList &streamIdList);
|
||||||
void getNewStreamsSinceLastSync(OstProto::StreamIdList &streamIdList);
|
void getNewStreamsSinceLastSync(OstProto::StreamIdList &streamIdList);
|
||||||
void getModifiedStreamsSinceLastSync(
|
void getModifiedStreamsSinceLastSync(
|
||||||
@ -178,7 +188,7 @@ public:
|
|||||||
int numDeviceGroups() const;
|
int numDeviceGroups() const;
|
||||||
const OstProto::DeviceGroup* deviceGroupByIndex(int index) const;
|
const OstProto::DeviceGroup* deviceGroupByIndex(int index) const;
|
||||||
OstProto::DeviceGroup* mutableDeviceGroupByIndex(int index);
|
OstProto::DeviceGroup* mutableDeviceGroupByIndex(int index);
|
||||||
OstProto::DeviceGroup* deviceGroupById(uint deviceGroupId);
|
const OstProto::DeviceGroup* deviceGroupById(uint deviceGroupId) const;
|
||||||
|
|
||||||
//! Used by StreamModel
|
//! Used by StreamModel
|
||||||
//@{
|
//@{
|
||||||
@ -216,11 +226,20 @@ public:
|
|||||||
void deviceInfoRefreshed();
|
void deviceInfoRefreshed();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
//! Used when local config changed and when config received from server
|
||||||
void portRateChanged(int portGroupId, int portId);
|
void portRateChanged(int portGroupId, int portId);
|
||||||
void portDataChanged(int portGroupId, int portId);
|
|
||||||
void streamListChanged(int portGroupId, int portId);
|
|
||||||
void deviceInfoChanged();
|
|
||||||
|
|
||||||
|
//! Used by MyService::Stub to update from config received from server
|
||||||
|
//@{
|
||||||
|
void portDataChanged(int portGroupId, int portId);
|
||||||
|
void deviceInfoChanged();
|
||||||
|
//@}
|
||||||
|
|
||||||
|
//! Used when local config changed
|
||||||
|
//@{
|
||||||
|
void streamListChanged(int portGroupId, int portId);
|
||||||
|
void localConfigChanged(bool changed);
|
||||||
|
//@}
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -345,6 +345,8 @@ void PortsWindow::when_portView_currentChanged(const QModelIndex& currentIndex,
|
|||||||
{
|
{
|
||||||
disconnect(&(plm->port(previous)), SIGNAL(portRateChanged(int, int)),
|
disconnect(&(plm->port(previous)), SIGNAL(portRateChanged(int, int)),
|
||||||
this, SLOT(updatePortRates()));
|
this, SLOT(updatePortRates()));
|
||||||
|
disconnect(&(plm->port(previous)), SIGNAL(localConfigChanged(bool)),
|
||||||
|
this, SLOT(updateApplyHint(bool)));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!current.isValid())
|
if (!current.isValid())
|
||||||
@ -364,6 +366,15 @@ void PortsWindow::when_portView_currentChanged(const QModelIndex& currentIndex,
|
|||||||
updatePortRates();
|
updatePortRates();
|
||||||
connect(&(plm->port(current)), SIGNAL(portRateChanged(int, int)),
|
connect(&(plm->port(current)), SIGNAL(portRateChanged(int, int)),
|
||||||
SLOT(updatePortRates()));
|
SLOT(updatePortRates()));
|
||||||
|
connect(&(plm->port(current)), SIGNAL(localConfigChanged(bool)),
|
||||||
|
SLOT(updateApplyHint(bool)));
|
||||||
|
if (plm->port(current).isDirty())
|
||||||
|
updateApplyHint(true);
|
||||||
|
else if (plm->port(current).numStreams())
|
||||||
|
applyHint->setText("Use the Statistics window to transmit "
|
||||||
|
"packets");
|
||||||
|
else
|
||||||
|
applyHint->setText("");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -511,6 +522,16 @@ void PortsWindow::updateStreamViewActions()
|
|||||||
actionSave_Streams->setEnabled(tvStreamList->model()->rowCount() > 0);
|
actionSave_Streams->setEnabled(tvStreamList->model()->rowCount() > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PortsWindow::updateApplyHint(bool configChanged)
|
||||||
|
{
|
||||||
|
if (configChanged)
|
||||||
|
applyHint->setText("Configuration has changed - <b>click Apply</b> "
|
||||||
|
"to activate the changes");
|
||||||
|
else
|
||||||
|
applyHint->setText("Configuration activated. Use the Statistics "
|
||||||
|
"window to transmit packets");
|
||||||
|
}
|
||||||
|
|
||||||
void PortsWindow::updatePortViewActions(const QModelIndex& currentIndex)
|
void PortsWindow::updatePortViewActions(const QModelIndex& currentIndex)
|
||||||
{
|
{
|
||||||
QModelIndex current = currentIndex;
|
QModelIndex current = currentIndex;
|
||||||
|
@ -66,6 +66,7 @@ public slots:
|
|||||||
void showMyReservedPortsOnly(bool enabled);
|
void showMyReservedPortsOnly(bool enabled);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
void updateApplyHint(bool configChanged);
|
||||||
void updatePortViewActions(const QModelIndex& currentIndex);
|
void updatePortViewActions(const QModelIndex& currentIndex);
|
||||||
void updateStreamViewActions();
|
void updateStreamViewActions();
|
||||||
|
|
||||||
|
@ -150,12 +150,25 @@
|
|||||||
</spacer>
|
</spacer>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="label_3">
|
<widget class="QLabel" name="applyHint">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Configuration Changed? Click Apply on the right to activate the changes</string>
|
<string>Apply Hint</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="horizontalSpacer">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>40</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QPushButton" name="pbApply">
|
<widget class="QPushButton" name="pbApply">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
|
@ -1222,7 +1222,7 @@ void StreamConfigDialog::on_pbOk_clicked()
|
|||||||
|
|
||||||
// Copy the data from the "local working copy of stream" to "actual stream"
|
// Copy the data from the "local working copy of stream" to "actual stream"
|
||||||
mpStream->protoDataCopyInto(s);
|
mpStream->protoDataCopyInto(s);
|
||||||
mPort.streamByIndex(mCurrentStreamIndex)->protoDataCopyFrom(s);
|
mPort.mutableStreamByIndex(mCurrentStreamIndex)->protoDataCopyFrom(s);
|
||||||
|
|
||||||
qDebug("stream stored");
|
qDebug("stream stored");
|
||||||
|
|
||||||
|
@ -155,19 +155,21 @@ bool StreamModel::setData(const QModelIndex &index, const QVariant &value, int r
|
|||||||
{
|
{
|
||||||
// Edit Supported Fields
|
// Edit Supported Fields
|
||||||
case StreamName:
|
case StreamName:
|
||||||
mCurrentPort->streamByIndex(index.row())->setName(value.toString());
|
mCurrentPort->mutableStreamByIndex(index.row())
|
||||||
|
->setName(value.toString());
|
||||||
emit(dataChanged(index, index));
|
emit(dataChanged(index, index));
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
case StreamStatus:
|
case StreamStatus:
|
||||||
mCurrentPort->streamByIndex(index.row())->setEnabled(value.toBool());
|
mCurrentPort->mutableStreamByIndex(index.row())
|
||||||
|
->setEnabled(value.toBool());
|
||||||
emit(dataChanged(index, index));
|
emit(dataChanged(index, index));
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
case StreamNextWhat:
|
case StreamNextWhat:
|
||||||
if (role == Qt::EditRole)
|
if (role == Qt::EditRole)
|
||||||
{
|
{
|
||||||
mCurrentPort->streamByIndex(index.row())->setNextWhat(
|
mCurrentPort->mutableStreamByIndex(index.row())->setNextWhat(
|
||||||
(Stream::NextWhat)value.toInt());
|
(Stream::NextWhat)value.toInt());
|
||||||
emit(dataChanged(index, index));
|
emit(dataChanged(index, index));
|
||||||
return true;
|
return true;
|
||||||
|
@ -145,7 +145,7 @@ ProtocolListIterator* StreamBase::createProtocolListIterator() const
|
|||||||
return new ProtocolListIterator(*currentFrameProtocols);
|
return new ProtocolListIterator(*currentFrameProtocols);
|
||||||
}
|
}
|
||||||
|
|
||||||
quint32 StreamBase::id()
|
quint32 StreamBase::id() const
|
||||||
{
|
{
|
||||||
return mStreamId->id();
|
return mStreamId->id();
|
||||||
}
|
}
|
||||||
|
@ -68,7 +68,7 @@ public:
|
|||||||
e_nw_goto_id
|
e_nw_goto_id
|
||||||
};
|
};
|
||||||
|
|
||||||
quint32 id();
|
quint32 id() const;
|
||||||
bool setId(quint32 id);
|
bool setId(quint32 id);
|
||||||
|
|
||||||
#if 0 // FIXME(HI): needed?
|
#if 0 // FIXME(HI): needed?
|
||||||
|
Loading…
Reference in New Issue
Block a user