diff options
| author | Christoph Berg <myon@debian.org> | 2026-09-26 23:24:03 +0200 |
|---|---|---|
| committer | Christoph Berg <myon@debian.org> | 2026-09-26 23:24:03 +0200 |
| commit | 059831534c7e884f0a607ed86b582fd00d821731 (patch) | |
| tree | 76bcb67a78f8aa2654fd34c2ad801a62136b0170 /FoxOperatorActions.hpp | |
| parent | d83a420f0517d7fc47aeb288a6a0cf4891784fcc (diff) | |
New upstream version 3.2.0~rc1+dfsgupstream/3.2.0_rc1+dfsg
Diffstat (limited to 'FoxOperatorActions.hpp')
| -rw-r--r-- | FoxOperatorActions.hpp | 71 |
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 |
