diff options
| author | Christoph Berg <myon@debian.org> | 2025-09-15 23:04:33 +0200 |
|---|---|---|
| committer | Christoph Berg <myon@debian.org> | 2025-09-15 23:04:33 +0200 |
| commit | e1c678ef00f0159bbeb5571e5ebb0d4697121334 (patch) | |
| tree | 6547edef81a62a812a4d0f64e03fda226b5f0a7e /logbook | |
| parent | b9daa22c4c3ad51cd4bc0ef624a19f21d01c9305 (diff) | |
| parent | 0a13f1fdb9928b6d012569dd65f7f6ef18fac2f8 (diff) | |
Update upstream source from tag 'upstream/3.0.0_rc1+repack'
Update to upstream version '3.0.0~rc1+repack'
with Debian dir 68c212e23136fecf9ebc6f12ff355579224d27ee
Diffstat (limited to 'logbook')
| -rwxr-xr-x | logbook/AD1CCty.cpp | 252 | ||||
| -rwxr-xr-x | logbook/AD1CCty.hpp | 5 | ||||
| -rwxr-xr-x | logbook/WorkedBefore.cpp | 13 | ||||
| -rwxr-xr-x | logbook/WorkedBefore.hpp | 3 | ||||
| -rwxr-xr-x | logbook/logbook.cpp | 13 | ||||
| -rwxr-xr-x | logbook/logbook.h | 7 |
6 files changed, 231 insertions, 62 deletions
diff --git a/logbook/AD1CCty.cpp b/logbook/AD1CCty.cpp index 222a4b5a..dc1a4701 100755 --- a/logbook/AD1CCty.cpp +++ b/logbook/AD1CCty.cpp @@ -16,9 +16,11 @@ #include <QTextStream>
#include <QDebug>
#include <QDebugStateSaver>
+#include <QRegularExpression>
#include "Configuration.hpp"
#include "Radio.hpp"
#include "pimpl_impl.hpp"
+#include "Logger.hpp"
#include "moc_AD1CCty.cpp"
@@ -27,6 +29,8 @@ using namespace boost::multi_index; namespace
{
auto const file_name = "cty.dat";
+ auto const grid_file_name = "grid.dat"; // NJ0A
+// auto const logFileName = "wsjtx_log.adi"; // NJ0A
}
struct entity
@@ -68,6 +72,13 @@ struct entity QString primary_prefix_;
};
+#define maxPrefix 25 //NJ0A
+#define maxIndex 100 //NJ0A
+
+QString gridPrefix [maxPrefix]; //NJ0A
+QString gridState [maxPrefix] [maxIndex]; //NJ0A
+int gridNumPrefix; //NJ0A
+
#if !defined (QT_NO_DEBUG_STREAM)
QDebug operator << (QDebug dbg, entity const& e)
{
@@ -163,6 +174,9 @@ public: {
}
+ QString get_cty_path(const Configuration *configuration);
+ void load_cty(QFile &file);
+
entity_by_id::iterator lookup_entity (QString call, prefix const& p) const
{
call = call.toUpper ();
@@ -228,6 +242,9 @@ public: Configuration const * configuration_;
QString path_;
+ QString cty_version_;
+ QString cty_version_date_;
+
entities_type entities_;
prefixes_type prefixes_;
};
@@ -314,6 +331,80 @@ char const * AD1CCty::continent (Continent c) }
}
+QString AD1CCty::impl::get_cty_path(Configuration const * configuration)
+{
+ QDir dataPath {QStandardPaths::writableLocation (QStandardPaths::DataLocation)};
+ auto path = dataPath.exists (file_name)
+ ? dataPath.absoluteFilePath (file_name) // user override
+ : configuration->data_dir ().absoluteFilePath (file_name); // or original
+ return path;
+}
+
+void AD1CCty::impl::load_cty(QFile &file)
+{
+ QRegularExpression version_pattern{R"(VER\d{8})"};
+ int entity_id = 0;
+ int line_number{0};
+
+ entities_.clear();
+ prefixes_.clear();
+ cty_version_ = QString{};
+ cty_version_date_ = QString{};
+
+ QTextStream in{&file};
+ while (!in.atEnd())
+ {
+ auto const &entity_line = in.readLine();
+ ++line_number;
+ if (!in.atEnd())
+ {
+ auto const &entity_parts = entity_line.split(':');
+ if (entity_parts.size() >= 8)
+ {
+ auto primary_prefix = entity_parts[7].trimmed();
+ bool WAE_only{false};
+ if (primary_prefix.startsWith('*'))
+ {
+ primary_prefix = primary_prefix.mid(1);
+ WAE_only = true;
+ }
+ bool ok1, ok2, ok3, ok4, ok5;
+ entities_.emplace(++entity_id, entity_parts[0].trimmed(), WAE_only, entity_parts[1].trimmed().toInt(&ok1),
+ entity_parts[2].trimmed().toInt(&ok2), continent(entity_parts[3].trimmed()),
+ entity_parts[4].trimmed().toFloat(&ok3), entity_parts[5].trimmed().toFloat(&ok4),
+ static_cast<int> (entity_parts[6].trimmed().toFloat(&ok5) * 60 * 60), primary_prefix);
+ if (!(ok1 && ok2 && ok3 && ok4 && ok5))
+ {
+ throw std::domain_error{"Invalid number in cty.dat line " + boost::lexical_cast<std::string>(line_number)};
+ }
+ QString line;
+ QString detail;
+ do
+ {
+ in.readLineInto(&line);
+ ++line_number;
+ } while (detail += line, !detail.endsWith(';'));
+ for (auto prefix: detail.left(detail.size() - 1).split(','))
+ {
+ prefix = prefix.trimmed();
+ bool exact{false};
+ if (prefix.startsWith('='))
+ {
+ prefix = prefix.mid(1);
+ exact = true;
+ // match version pattern to prefix
+ if (version_pattern.match(prefix).hasMatch())
+ {
+ cty_version_date_ = prefix;
+ }
+ }
+ prefixes_.emplace(prefix, exact, entity_id);
+ }
+ }
+ }
+ }
+}
+
AD1CCty::AD1CCty (Configuration const * configuration)
: m_ {configuration}
{
@@ -321,69 +412,92 @@ AD1CCty::AD1CCty (Configuration const * configuration) // TODO: G4WJS - consider doing the following asynchronously to
// speed up startup. Not urgent as it takes less than 0.5s on a Core
// i7 reading BIG CTY.DAT.
+ AD1CCty::reload (configuration);
+
+ //NJ0A
+ gridNumPrefix = 0;
+
+ for (int i = 0; i < maxPrefix ; i ++) {
+ for (int j = 0; j < maxIndex; j ++) {
+ gridState[i] [j] = "**";
+ }
+ }
+
QDir dataPath {QStandardPaths::writableLocation (QStandardPaths::DataLocation)};
m_->path_ = dataPath.exists (file_name)
? dataPath.absoluteFilePath (file_name) // user override
: configuration->data_dir ().absoluteFilePath (file_name); // or original
- QFile file {m_->path_};
- if (file.open (QFile::ReadOnly))
+
+ QString path = dataPath.exists (grid_file_name)
+ ? dataPath.absoluteFilePath (grid_file_name) // user override
+ : configuration->data_dir ().absoluteFilePath (grid_file_name); // or original in the resources FS
+
+
+ QFile file1 {path};
+
+ if (file1.open (QFile::ReadOnly))
{
- int entity_id = 0;
- int line_number {0};
- QTextStream in {&file};
- while (!in.atEnd ())
- {
+ int line_number [[maybe_unused]] {0};
+ QTextStream in {&file1};
+ while (!in.atEnd ())
+ {
auto const& entity_line = in.readLine ();
++line_number;
- if (!in.atEnd ())
- {
- auto const& entity_parts = entity_line.split (':');
- if (entity_parts.size () >= 8)
- {
- auto primary_prefix = entity_parts[7].trimmed ();
- bool WAE_only {false};
- if (primary_prefix.startsWith ('*'))
- {
- primary_prefix = primary_prefix.mid (1);
- WAE_only = true;
- }
- bool ok1, ok2, ok3, ok4, ok5;
- m_->entities_.emplace (++entity_id
- , entity_parts[0].trimmed ()
- , WAE_only
- , entity_parts[1].trimmed ().toInt (&ok1)
- , entity_parts[2].trimmed ().toInt (&ok2)
- , continent (entity_parts[3].trimmed ())
- , entity_parts[4].trimmed ().toFloat (&ok3)
- , entity_parts[5].trimmed ().toFloat (&ok4)
- , static_cast<int> (entity_parts[6].trimmed ().toFloat (&ok5) * 60 * 60)
- , primary_prefix);
- if (!(ok1 && ok2 && ok3 && ok4 && ok5))
- {
- throw std::domain_error {"Invalid number in cty.dat line " + boost::lexical_cast<std::string> (line_number)};
- }
- QString line;
- QString detail;
- do
- {
- in.readLineInto (&line);
- ++line_number;
- } while (detail += line, !detail.endsWith (';'));
- for (auto prefix : detail.left (detail.size () - 1).split (','))
- {
- prefix = prefix.trimmed ();
- bool exact {false};
- if (prefix.startsWith ('='))
- {
- prefix = prefix.mid (1);
- exact = true;
- }
- m_->prefixes_.emplace (prefix, exact, entity_id);
+ if (!in.atEnd () && entity_line.length() > 0 && entity_line.contains("<"))
+ {
+ //std::cout << entity_line.toStdString() << '\n';
+ if (entity_line.contains("<")) {
+ auto const& entity_parts = entity_line.split ('<');
+ //std::cout << "Grid prefix: " << entity_parts[0].toStdString() << '\n';
+ gridPrefix[gridNumPrefix] = entity_parts[0];
+ gridNumPrefix++;
+ while (!in.atEnd()) {
+ auto const& entity_grid_line = in.readLine();
+ if (entity_grid_line.length() > 1 &&
+ entity_grid_line.contains(":") &&
+ entity_grid_line.contains(",")) {
+ auto const& entity_parts = entity_grid_line.split(":");
+ //std::cout << "Grid Indxes: " << entity_parts[0].trimmed().toStdString() << " " ;
+
+ auto const& entity_temp = entity_parts[1].split(",");
+ auto const & entity_state = entity_temp[0];
+ //std::cout << "State: " << entity_state.toStdString() << '\n';
+ gridState[gridNumPrefix - 1] [entity_parts[0].toInt()] = entity_state;
+
+ } else if (entity_grid_line.length() > 1 &&
+ entity_grid_line.contains(":") &&
+ entity_grid_line.contains(">")) {
+ auto const& entity_parts = entity_grid_line.split(":");
+ //std::cout << "Grid Indxes: " << entity_parts[0].trimmed().toStdString() << " ";
+
+ auto const& entity_temp = entity_parts[1].split(">");
+ auto const & entity_state = entity_temp[0];
+ //std::cout << "State: " << entity_state.toStdString() << '\n';
+ gridState[gridNumPrefix - 1] [entity_parts[0].toInt()] = entity_state;
+
+ break;
}
}
- }
- }
+ }
+ }
+ }
}
+ }
+
+void AD1CCty::reload(Configuration const * configuration)
+{
+ m_->path_ = m_->impl::get_cty_path(configuration);
+ QFile file {m_->path_};
+
+ LOG_INFO(QString{"Loading CTY.DAT from %1"}.arg (m_->path_));
+
+ if (file.open (QFile::ReadOnly))
+ {
+ m_->impl::load_cty(file);
+ m_->cty_version_ = AD1CCty::lookup("VERSION").entity_name;
+ Q_EMIT cty_loaded(m_->cty_version_);
+ LOG_INFO(QString{"Loaded CTY.DAT version %1, %2"}.arg (m_->cty_version_date_).arg (m_->cty_version_));
+ }
}
AD1CCty::~AD1CCty ()
@@ -410,8 +524,8 @@ auto AD1CCty::lookup (QString const& call) const -> Record if (p != m_->prefixes_.end ())
{
impl::entity_by_id::iterator e = m_->lookup_entity (call, *p);
- if ((m_->configuration_->include_WAE_entities () || !e->WAE_only_)
- && (!p->exact_ || call.size () == search_prefix.size ()))
+ // always lookup WAE entities, we substitute them later in displaytext.cpp if "Include extra WAE entites" is not selected
+ if (!p->exact_ || call.size () == search_prefix.size ())
{
return m_->fixup (*p, *e);
}
@@ -421,3 +535,31 @@ auto AD1CCty::lookup (QString const& call) const -> Record }
return Record {};
}
+
+auto AD1CCty::version () const -> QString
+{
+ return m_->cty_version_date_;
+}
+
+// NJ0A
+auto AD1CCty::findState ( QString const& grid) const -> QString
+{
+
+
+ auto const& prefix = grid.left(2);
+ int gridIndex = grid.mid(2,2).toInt();
+ //if (gridIndex < 0 || gridIndex > maxIndex) {
+ //std::cout << "Prefix: " << prefix.toStdString() << " Index " << gridIndex << '\n';
+ //}
+ for (int i = 0; i < gridNumPrefix + 1; i ++) {
+ if (gridPrefix[i] == prefix) {
+ QString state = gridState[i] [gridIndex];
+ //if (state.length() < 2 ) {
+ // std::cout << "Prefix: " << prefix.toStdString() << " Index " << gridIndex << '\n';
+ //}
+ return state;
+ }
+ }
+
+ return "**";
+} // NJ0A
diff --git a/logbook/AD1CCty.hpp b/logbook/AD1CCty.hpp index 9bc7529a..4d9f78bd 100755 --- a/logbook/AD1CCty.hpp +++ b/logbook/AD1CCty.hpp @@ -42,8 +42,13 @@ public: };
explicit AD1CCty (Configuration const *);
+ void reload(Configuration const * configuration);
~AD1CCty ();
Record lookup (QString const& call) const;
+ QString version () const;
+ Q_SIGNAL void cty_loaded (QString const& version) const;
+
+ QString findState (QString const& grid) const; //NJ0A
private:
class impl;
diff --git a/logbook/WorkedBefore.cpp b/logbook/WorkedBefore.cpp index f60a4e72..bb5e71e3 100755 --- a/logbook/WorkedBefore.cpp +++ b/logbook/WorkedBefore.cpp @@ -23,6 +23,7 @@ #include <QDateTime>
#include "Configuration.hpp"
#include "revision_utils.hpp"
+#include "Logger.hpp"
#include "qt_helpers.hpp"
#include "pimpl_impl.hpp"
@@ -225,7 +226,7 @@ namespace {
auto const logFileName = "wsjtx_log.adi";
- // Expception class suitable for using with QtConcurrent across
+ // Exception class suitable for using with QtConcurrent across
// thread boundaries
class LoaderException final
: public QException
@@ -374,6 +375,7 @@ public: void reload ()
{
+ prefixes_.reload (configuration_);
async_loader_ = QtConcurrent::run (loader, path_, &prefixes_);
loader_watcher_.setFuture (async_loader_);
}
@@ -402,11 +404,18 @@ WorkedBefore::WorkedBefore (Configuration const * configuration) {
error = e.error ();
}
- Q_EMIT finished_loading (n, error);
+ QString cty_ver = m_->prefixes_.version();
+ LOG_DEBUG(QString{"WorkedBefore::reload: CTY.DAT version %1"}.arg (cty_ver));
+ Q_EMIT finished_loading (n, cty_ver, error);
});
reload ();
}
+QString WorkedBefore::cty_version () const
+{
+ return m_->prefixes_.version ();
+}
+
void WorkedBefore::reload ()
{
m_->reload ();
diff --git a/logbook/WorkedBefore.hpp b/logbook/WorkedBefore.hpp index 59adc91b..c1302f06 100755 --- a/logbook/WorkedBefore.hpp +++ b/logbook/WorkedBefore.hpp @@ -36,8 +36,9 @@ public: bool continent_worked (Continent continent, QString const& mode, QString const& band) const;
bool CQ_zone_worked (int CQ_zone, QString const& mode, QString const& band) const;
bool ITU_zone_worked (int ITU_zone, QString const& mode, QString const& band) const;
+ QString cty_version () const;
- Q_SIGNAL void finished_loading (int worked_before_record_count, QString const& error) const;
+ Q_SIGNAL void finished_loading (int worked_before_record_count, QString const, QString const& error) const;
private:
class impl;
diff --git a/logbook/logbook.cpp b/logbook/logbook.cpp index 8ba47e8f..888c1c89 100755 --- a/logbook/logbook.cpp +++ b/logbook/logbook.cpp @@ -69,12 +69,18 @@ void LogBook::rescan () worked_before_.reload ();
}
+QString const LogBook::cty_version() const
+{
+ return worked_before_.cty_version();
+}
+
QByteArray LogBook::QSOToADIF (QString const& hisCall, QString const& hisGrid, QString const& mode,
QString const& rptSent, QString const& rptRcvd, QDateTime const& dateTimeOn,
QDateTime const& dateTimeOff, QString const& band, QString const& comments,
QString const& name, QString const& strDialFreq, QString const& myCall,
QString const& myGrid, QString const& txPower, QString const& operator_call,
- QString const& xSent, QString const& xRcvd, QString const& propmode)
+ QString const& xSent, QString const& xRcvd, QString const& propmode,
+ QString const& satellite, QString const& satmode, QString const& freqRx)
{
QString t;
t = "<call:" + QString::number(hisCall.size()) + ">" + hisCall;
@@ -96,12 +102,15 @@ QByteArray LogBook::QSOToADIF (QString const& hisCall, QString const& hisGrid, Q t += " <band:" + QString::number(band.size()) + ">" + band;
t += " <freq:" + QString::number(strDialFreq.size()) + ">" + strDialFreq;
t += " <station_callsign:" + QString::number(myCall.size()) + ">" + myCall;
- t += " <my_gridsquare:" + QString::number(myGrid.size()) + ">" + myGrid;
+ if(myGrid!="") t += " <my_gridsquare:" + QString::number(myGrid.size()) + ">" + myGrid;
if(txPower!="") t += " <tx_pwr:" + QString::number(txPower.size()) + ">" + txPower;
if(comments!="") t += " <comment:" + QString::number(comments.size()) + ">" + comments;
if(name!="") t += " <name:" + QString::number(name.size()) + ">" + name;
if(operator_call!="") t+=" <operator:" + QString::number(operator_call.size()) + ">" + operator_call;
if(propmode!="") t += " <prop_mode:" + QString::number(propmode.size()) + ">" + propmode;
+ if(satellite!="") t += " <sat_name:" + QString::number(satellite.size()) + ">" + satellite;
+ if(satmode!="") t += " <sat_mode:" + QString::number(satmode.size()) + ">" + satmode;
+ if(freqRx!="") t += " <freq_rx:" + QString::number(freqRx.size()) + ">" + freqRx;
if (xSent.size ())
{
auto words = xSent.split (' '
diff --git a/logbook/logbook.h b/logbook/logbook.h index 6a515f48..145f5807 100755 --- a/logbook/logbook.h +++ b/logbook/logbook.h @@ -44,9 +44,12 @@ public: QDateTime const& dateTimeOff, QString const& band, QString const& comments,
QString const& name, QString const& strDialFreq, QString const& myCall,
QString const& m_myGrid, QString const& m_txPower, QString const& operator_call,
- QString const& xSent, QString const& xRcvd, QString const& propmode);
+ QString const& xSent, QString const& xRcvd, QString const& propmode,
+ QString const& satellite, QString const& satmode, QString const& freqRx);
- Q_SIGNAL void finished_loading (int worked_before_record_count, QString const& error) const;
+ QString const cty_version() const;
+
+ Q_SIGNAL void finished_loading (int worked_before_record_count, QString const cty_version, QString const& error) const;
CabrilloLog * contest_log ();
Multiplier const * multiplier () const;
|
