* @brief Assembles per-source replay payloads in stored column order and injects them. In * QuickPlot mode every column is emitted as one row (no source mapping exists). */
| 916 | * QuickPlot mode every column is emitted as one row (no source mapping exists). |
| 917 | */ |
| 918 | void Sessions::Player::injectFrame(const QHash<int, QString>& uidValues) |
| 919 | { |
| 920 | if (uidValues.isEmpty()) |
| 921 | return; |
| 922 | |
| 923 | if (AppState::instance().operationMode() != SerialStudio::ProjectFile) { |
| 924 | QStringList cells; |
| 925 | cells.reserve(static_cast<int>(m_columnUniqueIds.size())); |
| 926 | for (int uid : m_columnUniqueIds) |
| 927 | cells.append(uidValues.value(uid)); |
| 928 | |
| 929 | QByteArray payload = DataModel::joinReplayRow(cells); |
| 930 | payload.append('\n'); |
| 931 | IO::ConnectionManager::instance().processPayload(payload); |
| 932 | return; |
| 933 | } |
| 934 | |
| 935 | if (m_sourcesAtCurrentTs.isEmpty()) |
| 936 | return; |
| 937 | |
| 938 | QMap<int, QByteArray> sourcePayloads; |
| 939 | for (int srcId : std::as_const(m_sourcesAtCurrentTs)) { |
| 940 | const auto colsIt = m_sourceColumns.constFind(srcId); |
| 941 | if (colsIt == m_sourceColumns.constEnd() || colsIt.value().empty()) |
| 942 | continue; |
| 943 | |
| 944 | QStringList cells; |
| 945 | cells.reserve(static_cast<int>(colsIt.value().size())); |
| 946 | for (int uid : colsIt.value()) |
| 947 | cells.append(uidValues.value(uid)); |
| 948 | |
| 949 | QByteArray payload = DataModel::joinReplayRow(cells); |
| 950 | payload.append('\n'); |
| 951 | sourcePayloads.insert(srcId, std::move(payload)); |
| 952 | } |
| 953 | |
| 954 | if (sourcePayloads.isEmpty()) |
| 955 | return; |
| 956 | |
| 957 | if (!m_multiSource) { |
| 958 | IO::ConnectionManager::instance().processPayload(sourcePayloads.first()); |
| 959 | return; |
| 960 | } |
| 961 | |
| 962 | QByteArray combined; |
| 963 | for (auto it = sourcePayloads.constBegin(); it != sourcePayloads.constEnd(); ++it) { |
| 964 | if (!combined.isEmpty()) |
| 965 | combined.append(' '); |
| 966 | |
| 967 | combined.append(it.value().chopped(1)); |
| 968 | } |
| 969 | |
| 970 | combined.append('\n'); |
| 971 | IO::ConnectionManager::instance().processMultiSourcePayload(combined, sourcePayloads); |
| 972 | } |
| 973 | |
| 974 | //-------------------------------------------------------------------------------------------------- |
| 975 | // Display helpers |
nothing calls this directly
no test coverage detected