summaryrefslogtreecommitdiff
path: root/logbook/logbook.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'logbook/logbook.cpp')
-rw-r--r--logbook/logbook.cpp97
1 files changed, 85 insertions, 12 deletions
diff --git a/logbook/logbook.cpp b/logbook/logbook.cpp
index b84b65c1..a154664d 100644
--- a/logbook/logbook.cpp
+++ b/logbook/logbook.cpp
@@ -3,15 +3,25 @@
#include <QDateTime>
#include "Configuration.hpp"
#include "AD1CCty.hpp"
+#include "Multiplier.hpp"
+#include "logbook/AD1CCty.hpp"
+#include "models/CabrilloLog.hpp"
+#include "models/FoxLog.hpp"
#include "moc_logbook.cpp"
LogBook::LogBook (Configuration const * configuration)
: config_ {configuration}
+ , worked_before_ {configuration}
{
+ Q_ASSERT (configuration);
connect (&worked_before_, &WorkedBefore::finished_loading, this, &LogBook::finished_loading);
}
+LogBook::~LogBook ()
+{
+}
+
void LogBook::match (QString const& call, QString const& mode, QString const& grid,
AD1CCty::Record const& looked_up,
bool& callB4,
@@ -69,7 +79,14 @@ QByteArray LogBook::QSOToADIF (QString const& hisCall, QString const& hisGrid, Q
QString t;
t = "<call:" + QString::number(hisCall.length()) + ">" + hisCall;
t += " <gridsquare:" + QString::number(hisGrid.length()) + ">" + hisGrid;
- t += " <mode:" + QString::number(mode.length()) + ">" + mode;
+ if (mode != "FT4")
+ {
+ t += " <mode:" + QString::number(mode.length()) + ">" + mode;
+ }
+ else
+ {
+ t += " <mode:4>MFSK <submode:" + QString::number(mode.length()) + ">" + mode;
+ }
t += " <rst_sent:" + QString::number(rptSent.length()) + ">" + rptSent;
t += " <rst_rcvd:" + QString::number(rptRcvd.length()) + ">" + rptRcvd;
t += " <qso_date:8>" + dateTimeOn.date().toString("yyyyMMdd");
@@ -89,24 +106,80 @@ QByteArray LogBook::QSOToADIF (QString const& hisCall, QString const& hisGrid, Q
auto words = xSent.split (' ', QString::SkipEmptyParts);
if (words.size () > 1)
{
- bool ok;
- auto sn = words.back ().toUInt (&ok);
- if (ok && sn)
+ if (words.back ().toUInt ())
{
// assume last word is a serial if there are at least
// two words and if it is positive numeric
- t += " <STX:" + QString::number (words.back ().size ()) + '>' + words.back ();
+ t += " <stx:" + QString::number (words.back ().size ()) + '>' + words.back ();
+ }
+ else
+ {
+ if (words.front ().toUInt () && words.front ().size () > 3) // EU VHF contest mode
+ {
+ auto sn_text = words.front ().mid (2);
+ // assume first word is report+serial if there are
+ // at least two words and if the first word less the
+ // first two characters is a positive numeric
+ t += " <stx:" + QString::number (sn_text.size ()) + '>' + sn_text;
+ }
}
}
}
if (xRcvd.size ()) {
- QString t1="";
- if(xRcvd.split(" ").size()==2) t1=xRcvd.split(" ").at(1);
- if(t1.toInt()>0) {
- t += " <SRX:" + QString::number(t1.length()) + ">" + t1;
- } else {
- t += " <STATE:" + QString::number(t1.length()) + ">" + t1;
- }
+ auto words = xRcvd.split (' ', QString::SkipEmptyParts);
+ if (words.size () == 2)
+ {
+ if (words.at (1).toUInt ())
+ {
+ t += " <srx:" + QString::number (words.at (1).length ()) + ">" + words.at (1);
+ }
+ else if (words.at (0).toUInt () && words.at (0).size () > 3) // EU VHF contest exchange
+ {
+ // strip report and set SRX to serial
+ t += " <srx:" + QString::number (words.at (0).mid (2).length ()) + ">" + words.at (0).mid (2);
+ }
+ else
+ {
+ t += " <state:" + QString::number (words.at (1).length ()) + ">" + words.at (1);
+ }
+ }
}
return t.toLatin1();
}
+
+CabrilloLog * LogBook::contest_log ()
+{
+ // lazy create of Cabrillo log object instance
+ if (!contest_log_)
+ {
+ contest_log_.reset (new CabrilloLog {config_});
+ if (!multiplier_)
+ {
+ multiplier_.reset (new Multiplier {countries ()});
+ }
+ connect (contest_log_.data (), &CabrilloLog::data_changed, [this] () {
+ multiplier_->reload (contest_log_.data ());
+ });
+ }
+ return contest_log_.data ();
+}
+
+Multiplier const * LogBook::multiplier () const
+{
+ // lazy create of Multiplier object instance
+ if (!multiplier_)
+ {
+ multiplier_.reset (new Multiplier {countries ()});
+ }
+ return multiplier_.data ();
+}
+
+FoxLog * LogBook::fox_log ()
+{
+ // lazy create of Fox log object instance
+ if (!fox_log_)
+ {
+ fox_log_.reset (new FoxLog {config_});
+ }
+ return fox_log_.data ();
+}