From b6b1f3b3b63cde6f66c7dcbd9acbafad6c0f2a84 Mon Sep 17 00:00:00 2001 From: Bill Somerville Date: Mon, 21 Jan 2019 22:03:33 +0000 Subject: [PATCH] Correctly report 6m and up frequencies in Cabrillo export Cabrillo format expects specific frequency strings for 6m and up bands rather than the actual QSO frequency. --- models/CabrilloLog.cpp | 34 ++++++++++++++++++++++++++++++---- 1 file changed, 30 insertions(+), 4 deletions(-) diff --git a/models/CabrilloLog.cpp b/models/CabrilloLog.cpp index 3a30380e3..1fee9b148 100644 --- a/models/CabrilloLog.cpp +++ b/models/CabrilloLog.cpp @@ -21,6 +21,8 @@ class CabrilloLog::impl final public: impl (Configuration const *); + QString cabrillo_frequency_string (Radio::Frequency frequency) const; + Configuration const * configuration_; QSqlQuery mutable dupe_query_; QSqlQuery mutable export_query_; @@ -83,6 +85,32 @@ CabrilloLog::impl::impl (Configuration const * configuration) SQL_error_check (*this, &QSqlTableModel::select); } +// frequency here is in kHz +QString CabrilloLog::impl::cabrillo_frequency_string (Radio::Frequency frequency) const +{ + QString result; + auto band = configuration_->bands ()->find (frequency * 1000ull); + if ("1mm" == band) result = "LIGHT"; + else if ("2mm" == band) result = "241G"; + else if ("2.5mm" == band) result = "134G"; + else if ("4mm" == band) result = "75G"; + else if ("6mm" == band) result = "47G"; + else if ("1.25cm" == band) result = "24G"; + else if ("3cm" == band) result = "10G"; + else if ("6cm" == band) result = "5.7G"; + else if ("9cm" == band) result = "3.4G"; + else if ("13cm" == band) result = "2.3G"; + else if ("23cm" == band) result = "1.2G"; + else if ("33cm" == band) result = "902"; + else if ("70cm" == band) result = "432"; + else if ("1.25m" == band) result = "222"; + else if ("2m" == band) result = "144"; + else if ("4m" == band) result = "70"; + else if ("6m" == band) result = "50"; + else result = QString::number (frequency); + return result; +} + CabrilloLog::CabrilloLog (Configuration const * configuration) : m_ {configuration} { @@ -177,12 +205,10 @@ void CabrilloLog::export_qsos (QTextStream& stream) const auto rcvd_index = record.indexOf ("exchange_rcvd"); while (m_->export_query_.next ()) { - auto frequency = m_->export_query_.value (frequency_index).value (); auto my_call = m_->configuration_->my_callsign (); - frequency = frequency > 50000000ull ? frequency / 1000ull : frequency; stream << QString {"QSO: %1 DG %2 %3 %4 %5 %6\n"} - .arg (frequency, 5) - .arg (QDateTime::fromMSecsSinceEpoch (m_->export_query_.value (when_index).toULongLong () * 1000ull, Qt::UTC).toString ("yyyy-MM-dd hhmm")) + .arg (m_->cabrillo_frequency_string (m_->export_query_.value (frequency_index).value ()), 5) + .arg (QDateTime::fromMSecsSinceEpoch (m_->export_query_.value (when_index).toULongLong () * 1000ull, Qt::UTC).toString ("yyyy-MM-dd hhmm")) .arg (my_call, -12) .arg (m_->export_query_.value (sent_index).toString (), -13) .arg (m_->export_query_.value (call_index).toString (), -12)