| 1565 | } |
| 1566 | |
| 1567 | void NetworkDiagnosticsDialog::refreshTciClientTable() |
| 1568 | { |
| 1569 | if (!m_tci || !m_tciClientTable) |
| 1570 | return; |
| 1571 | |
| 1572 | const QVector<TciClientInfo> list = m_tci->connectedClients(); |
| 1573 | |
| 1574 | // Repopulating fires itemChanged for every setItem — suppress it so the |
| 1575 | // alias-persist handler only ever sees real user edits. |
| 1576 | const QHash<QString, QString> aliases = tciAliasMap(); |
| 1577 | |
| 1578 | QSignalBlocker block(m_tciClientTable); |
| 1579 | m_tciClientTable->setRowCount(list.size()); |
| 1580 | |
| 1581 | auto readOnly = [](const QString& text, bool centre = false) { |
| 1582 | auto* it = new QTableWidgetItem(text); |
| 1583 | it->setFlags(it->flags() & ~Qt::ItemIsEditable); |
| 1584 | if (centre) |
| 1585 | it->setTextAlignment(Qt::AlignCenter); |
| 1586 | return it; |
| 1587 | }; |
| 1588 | |
| 1589 | for (int r = 0; r < list.size(); ++r) { |
| 1590 | const TciClientInfo& c = list[r]; |
| 1591 | |
| 1592 | auto* nameItem = new QTableWidgetItem(aliases.value(c.peerAddress)); |
| 1593 | nameItem->setData(Qt::UserRole, c.peerAddress); |
| 1594 | nameItem->setFlags(nameItem->flags() | Qt::ItemIsEditable); |
| 1595 | nameItem->setToolTip(QStringLiteral( |
| 1596 | "Your own label for this client (saved locally, keyed by IP)")); |
| 1597 | m_tciClientTable->setItem(r, 0, nameItem); |
| 1598 | |
| 1599 | m_tciClientTable->setItem(r, 1, readOnly( |
| 1600 | c.peerAddress + QStringLiteral(":") + QString::number(c.peerPort))); |
| 1601 | m_tciClientTable->setItem(r, 2, readOnly(tciRoleHint(c))); |
| 1602 | const QString audio = c.audio |
| 1603 | ? (c.audioReceiver < 0 |
| 1604 | ? QStringLiteral("Yes (all RX)") |
| 1605 | : QStringLiteral("Yes (RX %1)").arg(c.audioReceiver)) |
| 1606 | : QStringLiteral("—"); |
| 1607 | m_tciClientTable->setItem(r, 3, readOnly(audio, true)); |
| 1608 | m_tciClientTable->setItem(r, 4, readOnly(c.iq ? QStringLiteral("Yes") : QStringLiteral("—"), true)); |
| 1609 | m_tciClientTable->setItem(r, 5, readOnly(c.rxSensors ? QStringLiteral("Yes") : QStringLiteral("—"), true)); |
| 1610 | m_tciClientTable->setItem(r, 6, readOnly(c.txSensors ? QStringLiteral("Yes") : QStringLiteral("—"), true)); |
| 1611 | } |
| 1612 | |
| 1613 | const int n = list.size(); |
| 1614 | m_tciClientSummary->setText( |
| 1615 | n == 0 ? QStringLiteral("No TCI clients connected") |
| 1616 | : QStringLiteral("%1 client%2 connected") |
| 1617 | .arg(n).arg(n == 1 ? QString() : QStringLiteral("s"))); |
| 1618 | } |
| 1619 | |
| 1620 | // Colour a raw TCI line by its command family — same palette as the |
| 1621 | // standalone TCI Monitor so the embedded view reads identically. |
nothing calls this directly
no test coverage detected