summaryrefslogtreecommitdiff
path: root/FoxOperatorActions.hpp
diff options
context:
space:
mode:
authorhibby <d@vehibberd.com>2026-10-06 21:24:40 +0100
committerhibby <d@vehibberd.com>2026-10-06 21:24:40 +0100
commitc25cbdf6fb6d946175f4335fab77bfea601b56db (patch)
tree6f7a94b7b81f999e434f61b73d47e337dfd26bf2 /FoxOperatorActions.hpp
parent71f5689252c9f13e70e1c24856904475b2307809 (diff)
parent0685fcada9f95fe90f70b387cd7d757da8209624 (diff)
Merge tag 'debian/3.2.0_rc1+dfsg-2' into debian/trixie-backportsdebian/trixie-backports
tagging wsjtx 3.2.0~rc1+dfsg-2
Diffstat (limited to 'FoxOperatorActions.hpp')
-rw-r--r--FoxOperatorActions.hpp71
1 files changed, 71 insertions, 0 deletions
diff --git a/FoxOperatorActions.hpp b/FoxOperatorActions.hpp
new file mode 100644
index 00000000..d104b6a2
--- /dev/null
+++ b/FoxOperatorActions.hpp
@@ -0,0 +1,71 @@
+#ifndef FOX_OPERATOR_ACTIONS_HPP
+#define FOX_OPERATOR_ACTIONS_HPP
+
+#include <QQueue>
+#include <QString>
+
+namespace FoxOperatorActions
+{
+ inline QString callsign (QString const& line)
+ {
+ return line.left (12).trimmed ();
+ }
+
+ inline int queuedHoundIndex (QQueue<QString> const& queue, QString const& line)
+ {
+ auto const target = callsign (line);
+ if (target.isEmpty ()) return -1;
+
+ for (int index = 0; index < queue.size (); ++index)
+ {
+ if (callsign (queue.at (index)) == target) return index;
+ }
+ return -1;
+ }
+
+ inline bool moveQueuedHoundToFront (QQueue<QString>& queue, QString const& line)
+ {
+ auto const index = queuedHoundIndex (queue, line);
+ if (index < 0) return false;
+
+ if (index > 0)
+ {
+ auto const live_line = queue.takeAt (index);
+ queue.prepend (live_line);
+ }
+ return true;
+ }
+
+ inline bool removeQueuedHound (QQueue<QString>& queue, QString const& line)
+ {
+ auto const target = callsign (line);
+ if (target.isEmpty ()) return false;
+
+ bool removed {false};
+ for (int index = queue.size () - 1; index >= 0; --index)
+ {
+ if (callsign (queue.at (index)) == target)
+ {
+ queue.removeAt (index);
+ removed = true;
+ }
+ }
+ return removed;
+ }
+
+ template<typename QsoMap>
+ bool timeoutIfActive (QQueue<QString> const& in_progress, QsoMap& qsos,
+ QString const& line, int timeout_value)
+ {
+ auto const target = callsign (line);
+ if (target.isEmpty () || !in_progress.contains (target)) return false;
+
+ auto qso = qsos.find (target);
+ if (qso == qsos.end ()) return false;
+
+ qso.value ().ncall = timeout_value;
+ return true;
+ }
+}
+
+#endif // FOX_OPERATOR_ACTIONS_HPP