Show port name/description in port stats window
By default the port name (ifXXX for Windows) is shown. If a port has a user description, that is shown instead of port name.
This commit is contained in:
parent
42091e5221
commit
32ddf223b6
@ -100,6 +100,9 @@ void PortGroupList::addPortGroup(PortGroup &portGroup)
|
||||
connect(&portGroup, SIGNAL(portListChanged(quint32)),
|
||||
&mPortStatsModel, SLOT(when_portListChanged()));
|
||||
|
||||
connect(&portGroup, SIGNAL(portGroupDataChanged(int, int)),
|
||||
&mPortStatsModel, SLOT(when_portGroupDataChanged(int, int)));
|
||||
|
||||
connect(&portGroup, SIGNAL(statsChanged(quint32)),
|
||||
&mPortStatsModel, SLOT(when_portGroup_stats_update(quint32)));
|
||||
|
||||
|
@ -49,7 +49,8 @@ QList<uint> PortStatsFilterDialog::getItemList(bool* ok,
|
||||
{
|
||||
QStandardItem *item;
|
||||
|
||||
item = new QStandardItem(model->headerData(i, orientation).toString());
|
||||
item = new QStandardItem(model->headerData(i, orientation)
|
||||
.toString().replace('\n', ' '));
|
||||
item->setData(i, kLogicalIndex);
|
||||
item->setData(initial.indexOf(i), kVisualIndex);
|
||||
item->setFlags(Qt::ItemIsSelectable
|
||||
|
@ -280,16 +280,23 @@ QVariant PortStatsModel::headerData(int section, Qt::Orientation orientation, in
|
||||
|
||||
if (numPorts.isEmpty() || section >= numPorts.last())
|
||||
return QVariant();
|
||||
|
||||
getDomainIndexes(index(0, section), portGroupIdx, portIdx);
|
||||
|
||||
PortGroup *portGroup = pgl->mPortGroups.at(portGroupIdx);
|
||||
Port *port = portGroup->mPorts.at(portIdx);
|
||||
|
||||
portName = QString("Port %1-%2")
|
||||
.arg(pgl->mPortGroups.at(portGroupIdx)->id())
|
||||
.arg(pgl->mPortGroups.at(portGroupIdx)->mPorts.at(portIdx)->id());
|
||||
.arg(portGroup->id())
|
||||
.arg(port->id());
|
||||
if (portGroupIdx < (uint) pgl->mPortGroups.size()
|
||||
&& portIdx < (uint) pgl->mPortGroups.at(portGroupIdx)->mPorts.size())
|
||||
&& portIdx < (uint) portGroup->mPorts.size())
|
||||
{
|
||||
if (!pgl->mPortGroups.at(portGroupIdx)->mPorts[portIdx]->notes()
|
||||
.isEmpty())
|
||||
if (!port->notes().isEmpty())
|
||||
portName += " *";
|
||||
portName += "\n";
|
||||
portName += port->userDescription().isEmpty() ?
|
||||
port->userAlias() : port->userDescription();
|
||||
}
|
||||
return portName;
|
||||
}
|
||||
@ -363,6 +370,16 @@ void PortStatsModel::when_portListChanged()
|
||||
endResetModel();
|
||||
}
|
||||
|
||||
void PortStatsModel::when_portGroupDataChanged(int /*portGroupId*/, int /*portId*/)
|
||||
{
|
||||
if (!columnCount())
|
||||
return;
|
||||
|
||||
// Port (user) description may have changed - update column headers
|
||||
// TODO: update only the changed ports, not all
|
||||
emit headerDataChanged(Qt::Horizontal, 0, columnCount()-1);
|
||||
}
|
||||
|
||||
// FIXME: unused? if used, the index calculation row/column needs to be swapped
|
||||
#if 0
|
||||
void PortStatsModel::on_portStatsUpdate(int port, void* /*stats*/)
|
||||
|
@ -136,6 +136,7 @@ class PortStatsModel : public QAbstractTableModel
|
||||
public slots:
|
||||
void when_portListChanged();
|
||||
//void on_portStatsUpdate(int port, void*stats);
|
||||
void when_portGroupDataChanged(int portGroupId, int portId);
|
||||
void when_portGroup_stats_update(quint32 portGroupId);
|
||||
|
||||
private slots:
|
||||
|
Loading…
Reference in New Issue
Block a user