summaryrefslogtreecommitdiff
path: root/JttyReceiveResultController.cpp
diff options
context:
space:
mode:
authorDave Hibberd <hibby@debian.org>2026-10-20 22:35:06 +0100
committerDave Hibberd <hibby@debian.org>2026-10-20 22:35:06 +0100
commit82ebb1ed1af30cee4dfbb1c628431d32885a00e0 (patch)
tree1a1f782d3e576b758be0bc61171574a7cd8f2376 /JttyReceiveResultController.cpp
parent061658210acb6425517733ea012dda803a7f72a1 (diff)
parent61d684922b0f1c8455cc60eb3d123df058c9e1f5 (diff)
Merge tag 'debian/3.3.0_beta2+dfsg-1' into hibbian/trixie-backports
tagging wsjtx 3.3.0~beta2+dfsg-1
Diffstat (limited to 'JttyReceiveResultController.cpp')
-rw-r--r--JttyReceiveResultController.cpp112
1 files changed, 112 insertions, 0 deletions
diff --git a/JttyReceiveResultController.cpp b/JttyReceiveResultController.cpp
new file mode 100644
index 00000000..3a29130f
--- /dev/null
+++ b/JttyReceiveResultController.cpp
@@ -0,0 +1,112 @@
+#include "JttyReceiveResultController.hpp"
+#include "JttyReceiveTiming.hpp"
+
+#include <QRegularExpression>
+
+namespace Jtty {
+
+void ReceiveResultController::apply(QVector<ReceiveUpdate> const& updates,
+ Reception const& reception,
+ Inputs const& inputs, Effects const& effects)
+{
+ auto& lines = reception.source == Source::Live ? liveLines_ : replayLines_;
+ for (auto const& update : updates) {
+ if (update.text.isEmpty()) continue;
+ if (reception.source == Source::Review && !reviewHeading_) {
+ effects.reviewHeading(Pane::All);
+ effects.reviewHeading(Pane::Qso);
+ reviewHeading_ = true;
+ }
+ bool const known = lines.contains(update.messageId);
+ auto& line = lines[update.messageId];
+ if (!known) {
+ line.context = reception.context;
+ line.context.sequenceStart = reception.anchor.addMSecs(qRound64(update.startSeconds * 1000.0));
+ }
+ // Idle-padding (MainWindow::sendJttyFillerPadding) travels gaplessly inside the same growing message as the real content around it, so it shows up embedded mid-string here rather than as an isolated update; strip it before anything gets displayed, logged, or forwarded, but keep comparing/storing the raw text so continuation tracking (line.text) stays consistent.
+ QString const displayText = stripJttyFillerText(update.text);
+ auto const change = compareMessages(line.text, update.text);
+ auto const options = inputs.display();
+ if (!displayText.isEmpty()) {
+ JttyReceiveLine::Presentation const presentation {reception.displayGroup, update.messageId,
+ reception.displayAnchor.addMSecs(qRound64(update.startSeconds * 1000.0)), update.startSeconds,
+ qRound(update.frequency), displayText, update.snr};
+ effects.render(Pane::All, line.allLine, presentation, options);
+ auto const selection = inputs.selection();
+ bool const current = reception.source == Source::Live && selection.jttyActive
+ && reception.contextId == selection.contextId;
+ float const center = current ? selection.center : reception.center;
+ float const tolerance = current ? selection.tolerance : reception.tolerance;
+ bool const wasAdmitted = line.admitted;
+ line.admitted = shouldApplyToQsoHistory(line.admitted, update.frequency, center, tolerance);
+ if (line.admitted) {
+ effects.render(Pane::Qso, line.qsoLine, presentation, options);
+ if (reception.source != Source::Review) {
+ auto const echo = inputs.echo();
+ if (echo.enabled && (change.messageChanged || !wasAdmitted)) {
+ QString delta = wasAdmitted && change.extendsMessage
+ ? collapseJttyFillerRuns(change.appendedText) : displayText;
+ if (!delta.trimmed().isEmpty()) {
+ if (!wasAdmitted || !change.extendsMessage) delta.prepend("\r\n");
+ if (echo.lowerCase) delta = delta.toLower();
+ effects.echo(delta);
+ }
+ }
+ }
+ }
+ }
+ line.text = update.text;
+ if (reception.source == Source::Live) {
+ auto const start = qRound64(update.latestSeconds * 12000.0);
+ effects.noteDecoded(start, start + receiveFrameSamples);
+ }
+ if (!displayText.isEmpty() && reception.source != Source::Review
+ && update.terminal != ReceiveTerminal::Growing) {
+ effects.log(formatJttyDecodeLine(qRound(update.frequency), update.snr, displayText), line.context);
+ if (reception.source == Source::Live && update.terminal == ReceiveTerminal::Complete
+ && inputs.reporting()) {
+ auto const fields = displayText.simplified().split(QChar{' '}, Qt::SkipEmptyParts);
+ if (fields.size() >= 2) {
+ auto const& first = fields.at(0);
+ auto const& sender = fields.at(1);
+ bool const structured = (first.compare(QStringLiteral("CQ"), Qt::CaseInsensitive) == 0
+ || first.compare(QStringLiteral("DE"), Qt::CaseInsensitive) == 0
+ || Radio::is_standard_callsign(first))
+ && Radio::is_standard_callsign(sender);
+ bool const selfSpot = sender.compare(line.context.myCall, Qt::CaseInsensitive) == 0;
+ if (structured && !selfSpot) {
+ QString grid;
+ if (fields.size() >= 3 && fields.at(2).contains(Radio::decoded_grid_pattern()))
+ grid = fields.at(2);
+ auto const frequency = line.context.periodFrequency + qRound(update.frequency);
+ auto const spotTime = line.context.sequenceStart.toUTC();
+ if (spotTime.isValid())
+ effects.spot({sender, grid, frequency, QStringLiteral("JTTY"), update.snr, spotTime});
+ }
+ }
+ }
+ }
+ if (!displayText.isEmpty()) {
+ snrHistory_.push_back({displayText, update.snr, line.admitted});
+ if (snrHistory_.size() > 500) snrHistory_.pop_front();
+ }
+ if (update.terminal != ReceiveTerminal::Growing) lines.remove(update.messageId);
+ }
+}
+
+void ReceiveResultController::resetReplay()
+{
+ reviewHeading_ = false;
+ replayLines_.clear();
+}
+
+int ReceiveResultController::snrForSelectedWord(QString const& word, Pane pane) const
+{
+ for (auto it = snrHistory_.crbegin(); it != snrHistory_.crend(); ++it) {
+ if (pane == Pane::Qso && !it->admitted) continue;
+ if (it->text.split(QChar{' '}, Qt::SkipEmptyParts).contains(word)) return it->snr;
+ }
+ return -10;
+}
+
+}