Add option to include or exclude WAE extra entities in DXCC entity lookups

Also  refactored  object  relationships  as a  start  to  implementing
contest multiplier highlighting.
This commit is contained in:
Bill Somerville 2019-05-29 23:35:18 +01:00
parent a54140582a
commit 381faca99a
No known key found for this signature in database
GPG Key ID: D864B06D1E81618F
15 changed files with 169 additions and 94 deletions

View File

@ -564,6 +564,7 @@ private:
DecodeHighlightingModel decode_highlighing_model_; DecodeHighlightingModel decode_highlighing_model_;
DecodeHighlightingModel next_decode_highlighing_model_; DecodeHighlightingModel next_decode_highlighing_model_;
bool highlight_by_mode_; bool highlight_by_mode_;
bool include_WAE_entities_;
int LotW_days_since_upload_; int LotW_days_since_upload_;
TransceiverFactory::ParameterPack rig_params_; TransceiverFactory::ParameterPack rig_params_;
@ -745,6 +746,7 @@ bool Configuration::pwrBandTuneMemory () const {return m_->pwrBandTuneMemory_;}
LotWUsers const& Configuration::lotw_users () const {return m_->lotw_users_;} LotWUsers const& Configuration::lotw_users () const {return m_->lotw_users_;}
DecodeHighlightingModel const& Configuration::decode_highlighting () const {return m_->decode_highlighing_model_;} DecodeHighlightingModel const& Configuration::decode_highlighting () const {return m_->decode_highlighing_model_;}
bool Configuration::highlight_by_mode () const {return m_->highlight_by_mode_;} bool Configuration::highlight_by_mode () const {return m_->highlight_by_mode_;}
bool Configuration::include_WAE_entities () const {return m_->include_WAE_entities_;}
void Configuration::set_calibration (CalibrationParams params) void Configuration::set_calibration (CalibrationParams params)
{ {
@ -950,6 +952,7 @@ Configuration::impl::impl (Configuration * self, QNetworkAccessManager * network
, station_insert_action_ {tr ("&Insert ..."), nullptr} , station_insert_action_ {tr ("&Insert ..."), nullptr}
, station_dialog_ {new StationDialog {&next_stations_, &bands_, this}} , station_dialog_ {new StationDialog {&next_stations_, &bands_, this}}
, highlight_by_mode_ {false} , highlight_by_mode_ {false}
, include_WAE_entities_ {false}
, LotW_days_since_upload_ {0} , LotW_days_since_upload_ {0}
, last_port_type_ {TransceiverFactory::Capabilities::none} , last_port_type_ {TransceiverFactory::Capabilities::none}
, rig_is_dummy_ {false} , rig_is_dummy_ {false}
@ -1319,6 +1322,7 @@ void Configuration::impl::initialize_models ()
next_decode_highlighing_model_.items (decode_highlighing_model_.items ()); next_decode_highlighing_model_.items (decode_highlighing_model_.items ());
ui_->highlight_by_mode_check_box->setChecked (highlight_by_mode_); ui_->highlight_by_mode_check_box->setChecked (highlight_by_mode_);
ui_->include_WAE_check_box->setChecked (include_WAE_entities_);
ui_->LotW_days_since_upload_spin_box->setValue (LotW_days_since_upload_); ui_->LotW_days_since_upload_spin_box->setValue (LotW_days_since_upload_);
set_rig_invariants (); set_rig_invariants ();
@ -1467,6 +1471,7 @@ void Configuration::impl::read_settings ()
if (!highlight_items.size ()) highlight_items = DecodeHighlightingModel::default_items (); if (!highlight_items.size ()) highlight_items = DecodeHighlightingModel::default_items ();
decode_highlighing_model_.items (highlight_items); decode_highlighing_model_.items (highlight_items);
highlight_by_mode_ = settings_->value("HighlightByMode", false).toBool (); highlight_by_mode_ = settings_->value("HighlightByMode", false).toBool ();
include_WAE_entities_ = settings_->value("IncludeWAEEntities", false).toBool ();
LotW_days_since_upload_ = settings_->value ("LotWDaysSinceLastUpload", 365).toInt (); LotW_days_since_upload_ = settings_->value ("LotWDaysSinceLastUpload", 365).toInt ();
lotw_users_.set_age_constraint (LotW_days_since_upload_); lotw_users_.set_age_constraint (LotW_days_since_upload_);
@ -1579,7 +1584,7 @@ void Configuration::impl::write_settings ()
settings_->setValue ("FrequenciesForRegionModes", QVariant::fromValue (frequencies_.frequency_list ())); settings_->setValue ("FrequenciesForRegionModes", QVariant::fromValue (frequencies_.frequency_list ()));
settings_->setValue ("stations", QVariant::fromValue (stations_.station_list ())); settings_->setValue ("stations", QVariant::fromValue (stations_.station_list ()));
settings_->setValue ("DecodeHighlighting", QVariant::fromValue (decode_highlighing_model_.items ())); settings_->setValue ("DecodeHighlighting", QVariant::fromValue (decode_highlighing_model_.items ()));
settings_->setValue ("HighlightByMode", highlight_by_mode_); settings_->setValue ("IncludeWAEEntities", include_WAE_entities_);
settings_->setValue ("LotWDaysSinceLastUpload", LotW_days_since_upload_); settings_->setValue ("LotWDaysSinceLastUpload", LotW_days_since_upload_);
settings_->setValue ("toRTTY", log_as_RTTY_); settings_->setValue ("toRTTY", log_as_RTTY_);
settings_->setValue ("dBtoComments", report_in_comments_); settings_->setValue ("dBtoComments", report_in_comments_);
@ -2116,6 +2121,7 @@ void Configuration::impl::accept ()
Q_EMIT self_->decode_highlighting_changed (decode_highlighing_model_); Q_EMIT self_->decode_highlighting_changed (decode_highlighing_model_);
} }
highlight_by_mode_ = ui_->highlight_by_mode_check_box->isChecked (); highlight_by_mode_ = ui_->highlight_by_mode_check_box->isChecked ();
include_WAE_entities_ = ui_->include_WAE_check_box->isChecked ();
LotW_days_since_upload_ = ui_->LotW_days_since_upload_spin_box->value (); LotW_days_since_upload_ = ui_->LotW_days_since_upload_spin_box->value ();
lotw_users_.set_age_constraint (LotW_days_since_upload_); lotw_users_.set_age_constraint (LotW_days_since_upload_);

View File

@ -177,6 +177,7 @@ public:
LotWUsers const& lotw_users () const; LotWUsers const& lotw_users () const;
DecodeHighlightingModel const& decode_highlighting () const; DecodeHighlightingModel const& decode_highlighting () const;
bool highlight_by_mode () const; bool highlight_by_mode () const;
bool include_WAE_entities () const;
enum class SpecialOperatingActivity {NONE, NA_VHF, EU_VHF, FIELD_DAY, RTTY, FOX, HOUND}; enum class SpecialOperatingActivity {NONE, NA_VHF, EU_VHF, FIELD_DAY, RTTY, FOX, HOUND};
SpecialOperatingActivity special_op_id () const; SpecialOperatingActivity special_op_id () const;

View File

@ -2294,6 +2294,23 @@ Right click for insert and delete options.</string>
</item> </item>
</layout> </layout>
</item> </item>
<item>
<layout class="QFormLayout" name="formLayout_20">
<item row="0" column="0">
<widget class="QCheckBox" name="include_WAE_check_box"/>
</item>
<item row="0" column="1">
<widget class="QLabel" name="includeExtraWAEEntitiesLabel">
<property name="text">
<string>Include extra WAE entities</string>
</property>
<property name="buddy">
<cstring>include_WAE_check_box</cstring>
</property>
</widget>
</item>
</layout>
</item>
</layout> </layout>
</widget> </widget>
</item> </item>
@ -2306,35 +2323,6 @@ Right click for insert and delete options.</string>
<string>Logbook of the World User Validation</string> <string>Logbook of the World User Validation</string>
</property> </property>
<layout class="QFormLayout" name="formLayout_18"> <layout class="QFormLayout" name="formLayout_18">
<item row="2" column="0">
<widget class="QLabel" name="label_14">
<property name="text">
<string>Age of last upload less than:</string>
</property>
<property name="buddy">
<cstring>LotW_days_since_upload_spin_box</cstring>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QSpinBox" name="LotW_days_since_upload_spin_box">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Adjust this spin box to set the age threshold of LotW user's last upload date that is accepted as a current LotW user.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="suffix">
<string> days</string>
</property>
<property name="minimum">
<number>0</number>
</property>
<property name="maximum">
<number>9999</number>
</property>
<property name="value">
<number>365</number>
</property>
</widget>
</item>
<item row="1" column="0"> <item row="1" column="0">
<widget class="QLabel" name="label_15"> <widget class="QLabel" name="label_15">
<property name="text"> <property name="text">
@ -2369,6 +2357,35 @@ Right click for insert and delete options.</string>
</item> </item>
</layout> </layout>
</item> </item>
<item row="2" column="0">
<widget class="QLabel" name="label_14">
<property name="text">
<string>Age of last upload less than:</string>
</property>
<property name="buddy">
<cstring>LotW_days_since_upload_spin_box</cstring>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QSpinBox" name="LotW_days_since_upload_spin_box">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Adjust this spin box to set the age threshold of LotW user's last upload date that is accepted as a current LotW user.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="suffix">
<string> days</string>
</property>
<property name="minimum">
<number>0</number>
</property>
<property name="maximum">
<number>9999</number>
</property>
<property name="value">
<number>365</number>
</property>
</widget>
</item>
</layout> </layout>
</widget> </widget>
</item> </item>
@ -3085,13 +3102,13 @@ Right click for insert and delete options.</string>
</connection> </connection>
</connections> </connections>
<buttongroups> <buttongroups>
<buttongroup name="split_mode_button_group"/> <buttongroup name="special_op_activity_button_group"/>
<buttongroup name="CAT_data_bits_button_group"/> <buttongroup name="CAT_data_bits_button_group"/>
<buttongroup name="CAT_handshake_button_group"/> <buttongroup name="split_mode_button_group"/>
<buttongroup name="TX_audio_source_button_group"/>
<buttongroup name="TX_mode_button_group"/> <buttongroup name="TX_mode_button_group"/>
<buttongroup name="PTT_method_button_group"/> <buttongroup name="PTT_method_button_group"/>
<buttongroup name="special_op_activity_button_group"/>
<buttongroup name="CAT_stop_bits_button_group"/> <buttongroup name="CAT_stop_bits_button_group"/>
<buttongroup name="CAT_handshake_button_group"/>
<buttongroup name="TX_audio_source_button_group"/>
</buttongroups> </buttongroups>
</ui> </ui>

View File

@ -16,6 +16,7 @@
#include <QTextStream> #include <QTextStream>
#include <QDebug> #include <QDebug>
#include <QDebugStateSaver> #include <QDebugStateSaver>
#include "Configuration.hpp"
#include "Radio.hpp" #include "Radio.hpp"
#include "pimpl_impl.hpp" #include "pimpl_impl.hpp"
@ -155,14 +156,16 @@ typedef multi_index_container<
class AD1CCty::impl final class AD1CCty::impl final
{ {
public: public:
explicit impl () using entity_by_id = entities_type::index<id>::type;
explicit impl (Configuration const * configuration)
: configuration_ {configuration}
{ {
} }
Record fixup (QString call, prefix const& p) const entity_by_id::iterator lookup_entity (QString call, prefix const& p) const
{ {
call = call.toUpper (); call = call.toUpper ();
using entity_by_id = entities_type::index<id>::type;
entity_by_id::iterator e; // iterator into entity set entity_by_id::iterator e; // iterator into entity set
// //
@ -171,23 +174,26 @@ public:
if (call.startsWith ("KG4") && call.size () != 5 && call.size () != 3) if (call.startsWith ("KG4") && call.size () != 5 && call.size () != 3)
{ {
// KG4 2x1 and 2x3 calls that map to Gitmo are mainland US not Gitmo // KG4 2x1 and 2x3 calls that map to Gitmo are mainland US not Gitmo
e = entities_.project<id> (entities_.get<primary_prefix> ().find ("K")); return entities_.project<id> (entities_.get<primary_prefix> ().find ("K"));
} }
else else
{ {
e = entities_.get<id> ().find (p.entity_id_); return entities_.get<id> ().find (p.entity_id_);
} }
}
Record fixup (prefix const& p, entity const& e) const
{
Record result; Record result;
result.continent = e->continent_; result.continent = e.continent_;
result.CQ_zone = e->CQ_zone_; result.CQ_zone = e.CQ_zone_;
result.ITU_zone = e->ITU_zone_; result.ITU_zone = e.ITU_zone_;
result.entity_name = e->name_; result.entity_name = e.name_;
result.WAE_only = e->WAE_only_; result.WAE_only = e.WAE_only_;
result.latitude = e->lat_; result.latitude = e.lat_;
result.longtitude = e->long_; result.longtitude = e.long_;
result.UTC_offset = e->UTC_offset_; result.UTC_offset = e.UTC_offset_;
result.primary_prefix = e->primary_prefix_; result.primary_prefix = e.primary_prefix_;
// check for overrides // check for overrides
bool ok1 {true}, ok2 {true}, ok3 {true}, ok4 {true}, ok5 {true}; bool ok1 {true}, ok2 {true}, ok3 {true}, ok4 {true}, ok5 {true};
@ -220,6 +226,7 @@ public:
return false; return false;
} }
Configuration const * configuration_;
QString path_; QString path_;
entities_type entities_; entities_type entities_;
prefixes_type prefixes_; prefixes_type prefixes_;
@ -307,8 +314,13 @@ char const * AD1CCty::continent (Continent c)
} }
} }
AD1CCty::AD1CCty () AD1CCty::AD1CCty (Configuration const * configuration)
: m_ {configuration}
{ {
Q_ASSERT (configuration);
// TODO: G4WJS - consider doing the following asynchronously to
// speed up startup. Not urgent as it takes less than 1s on a Core
// i7 reading BIG CTY.DAT.
QDir dataPath {QStandardPaths::writableLocation (QStandardPaths::DataLocation)}; QDir dataPath {QStandardPaths::writableLocation (QStandardPaths::DataLocation)};
m_->path_ = dataPath.exists (file_name) m_->path_ = dataPath.exists (file_name)
? dataPath.absoluteFilePath (file_name) // user override ? dataPath.absoluteFilePath (file_name) // user override
@ -389,7 +401,7 @@ auto AD1CCty::lookup (QString const& call) const -> Record
auto p = m_->prefixes_.find (exact_search); auto p = m_->prefixes_.find (exact_search);
if (p != m_->prefixes_.end () && p->exact_) if (p != m_->prefixes_.end () && p->exact_)
{ {
return m_->fixup (call, *p); return m_->fixup (*p, *m_->lookup_entity (call, *p));
} }
} }
while (search_prefix.size ()) while (search_prefix.size ())
@ -397,9 +409,11 @@ auto AD1CCty::lookup (QString const& call) const -> Record
auto p = m_->prefixes_.find (search_prefix); auto p = m_->prefixes_.find (search_prefix);
if (p != m_->prefixes_.end ()) if (p != m_->prefixes_.end ())
{ {
if (!p->exact_ || call.size () == search_prefix.size ()) 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 ()))
{ {
return m_->fixup (call, *p); return m_->fixup (*p, *e);
} }
} }
search_prefix = search_prefix.left (search_prefix.size () - 1); search_prefix = search_prefix.left (search_prefix.size () - 1);

View File

@ -1,17 +1,19 @@
#ifndef AD1C_CTY_HPP_ #ifndef AD1C_CTY_HPP_
#define AD1C_CTY_HPP_ #define AD1C_CTY_HPP_
#include <boost/core/noncopyable.hpp>
#include <QObject> #include <QObject>
#include <QDebug>
#include "pimpl_h.hpp" #include "pimpl_h.hpp"
class QString;
class Configuration;
// //
// AD1CCty - Fast access database of Jim Reisert, AD1C's, cty.dat // AD1CCty - Fast access database of Jim Reisert, AD1C's, cty.dat
// entity and entity override information file. // entity and entity override information file.
// //
class AD1CCty final class AD1CCty final
: public QObject : public QObject
, private boost::noncopyable
{ {
Q_OBJECT Q_OBJECT
@ -39,7 +41,7 @@ public:
QString primary_prefix; QString primary_prefix;
}; };
explicit AD1CCty (); explicit AD1CCty (Configuration const *);
~AD1CCty (); ~AD1CCty ();
Record lookup (QString const& call) const; Record lookup (QString const& call) const;

View File

@ -18,7 +18,7 @@
#include <QFileInfo> #include <QFileInfo>
#include <QFile> #include <QFile>
#include <QTextStream> #include <QTextStream>
#include "Configuration.hpp"
#include "qt_helpers.hpp" #include "qt_helpers.hpp"
#include "pimpl_impl.hpp" #include "pimpl_impl.hpp"
@ -361,8 +361,9 @@ namespace
class WorkedBefore::impl final class WorkedBefore::impl final
{ {
public: public:
impl () impl (Configuration const * configuration)
: path_ {QDir {QStandardPaths::writableLocation (QStandardPaths::DataLocation)}.absoluteFilePath (logFileName)} : path_ {QDir {QStandardPaths::writableLocation (QStandardPaths::DataLocation)}.absoluteFilePath (logFileName)}
, prefixes_ {configuration}
{ {
} }
@ -379,8 +380,10 @@ public:
worked_before_database_type worked_; worked_before_database_type worked_;
}; };
WorkedBefore::WorkedBefore () WorkedBefore::WorkedBefore (Configuration const * configuration)
: m_ {configuration}
{ {
Q_ASSERT (configuration);
connect (&m_->loader_watcher_, &QFutureWatcher<worked_before_database_type>::finished, [this] () { connect (&m_->loader_watcher_, &QFutureWatcher<worked_before_database_type>::finished, [this] () {
QString error; QString error;
size_t n {0}; size_t n {0};

View File

@ -5,6 +5,7 @@
#include "AD1CCty.hpp" #include "AD1CCty.hpp"
#include "pimpl_h.hpp" #include "pimpl_h.hpp"
class Configuration;
class CountryDat; class CountryDat;
class QString; class QString;
class QByteArray; class QByteArray;
@ -17,7 +18,7 @@ class WorkedBefore final
public: public:
using Continent = AD1CCty::Continent; using Continent = AD1CCty::Continent;
explicit WorkedBefore (); explicit WorkedBefore (Configuration const *);
~WorkedBefore (); ~WorkedBefore ();
Q_SLOT void reload (); Q_SLOT void reload ();

View File

@ -3,12 +3,16 @@
#include <QDateTime> #include <QDateTime>
#include "Configuration.hpp" #include "Configuration.hpp"
#include "AD1CCty.hpp" #include "AD1CCty.hpp"
#include "models/CabrilloLog.hpp"
#include "models/FoxLog.hpp"
#include "moc_logbook.cpp" #include "moc_logbook.cpp"
LogBook::LogBook (Configuration const * configuration) LogBook::LogBook (Configuration const * configuration)
: config_ {configuration} : config_ {configuration}
, worked_before_ {configuration}
{ {
Q_ASSERT (configuration);
connect (&worked_before_, &WorkedBefore::finished_loading, this, &LogBook::finished_loading); connect (&worked_before_, &WorkedBefore::finished_loading, this, &LogBook::finished_loading);
} }
@ -136,3 +140,23 @@ QByteArray LogBook::QSOToADIF (QString const& hisCall, QString const& hisGrid, Q
} }
return t.toLatin1(); return t.toLatin1();
} }
CabrilloLog * LogBook::contest_log ()
{
// lazy create of Cabrillo log object instance
if (!m_contest_log)
{
m_contest_log.reset (new CabrilloLog {config_});
}
return m_contest_log.data ();
}
FoxLog * LogBook::fox_log ()
{
// lazy create of Fox log object instance
if (!m_fox_log)
{
m_fox_log.reset (new FoxLog {config_});
}
return m_fox_log.data ();
}

View File

@ -8,12 +8,15 @@
#include <QObject> #include <QObject>
#include <QString> #include <QString>
#include <QScopedPointer>
#include "WorkedBefore.hpp" #include "WorkedBefore.hpp"
class Configuration; class Configuration;
class QByteArray; class QByteArray;
class QDateTime; class QDateTime;
class CabrilloLog;
class FoxLog;
class LogBook final class LogBook final
: public QObject : public QObject
@ -43,9 +46,14 @@ public:
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& error) const;
CabrilloLog * contest_log ();
FoxLog * fox_log ();
private: private:
Configuration const * config_; Configuration const * config_;
WorkedBefore worked_before_; WorkedBefore worked_before_;
QScopedPointer<CabrilloLog> m_contest_log;
QScopedPointer<FoxLog> m_fox_log;
}; };
#endif #endif

View File

@ -12,6 +12,7 @@
#include <QDataStream> #include <QDataStream>
#include "Configuration.hpp" #include "Configuration.hpp"
#include "Bands.hpp" #include "Bands.hpp"
#include "logbook/AD1CCty.hpp"
#include "qt_db_helpers.hpp" #include "qt_db_helpers.hpp"
#include "pimpl_impl.hpp" #include "pimpl_impl.hpp"
@ -232,3 +233,15 @@ void CabrilloLog::export_qsos (QTextStream& stream) const
.arg (m_->export_query_.value (rcvd_index).toString (), -13); .arg (m_->export_query_.value (rcvd_index).toString (), -13);
} }
} }
QSet<QString> CabrilloLog::unique_DXCC_entities (AD1CCty const& countries) const
{
QSqlQuery q {"SELECT UNIQUE CALL FROM cabrillo_log"};
auto call_index = q.record ().indexOf ("call");
QSet<QString> entities;
while (q.next ())
{
entities << countries.lookup (q.value(call_index).toString ()).primary_prefix;
}
return entities;
}

View File

@ -2,14 +2,16 @@
#define CABRILLO_LOG_HPP_ #define CABRILLO_LOG_HPP_
#include <boost/core/noncopyable.hpp> #include <boost/core/noncopyable.hpp>
#include <QSet>
#include <QString>
#include "Radio.hpp" #include "Radio.hpp"
#include "pimpl_h.hpp" #include "pimpl_h.hpp"
class Configuration; class Configuration;
class QDateTime; class QDateTime;
class QString;
class QSqlTableModel; class QSqlTableModel;
class QTextStream; class QTextStream;
class AD1CCty;
class CabrilloLog final class CabrilloLog final
: private boost::noncopyable : private boost::noncopyable
@ -28,6 +30,7 @@ public:
QSqlTableModel * model (); QSqlTableModel * model ();
void reset (); void reset ();
void export_qsos (QTextStream&) const; void export_qsos (QTextStream&) const;
QSet<QString> unique_DXCC_entities (AD1CCty const&) const;
private: private:
class impl; class impl;

View File

@ -16,11 +16,12 @@
#include "moc_logqso.cpp" #include "moc_logqso.cpp"
LogQSO::LogQSO(QString const& programTitle, QSettings * settings LogQSO::LogQSO(QString const& programTitle, QSettings * settings
, Configuration const * config, QWidget *parent) , Configuration const * config, LogBook * log, QWidget *parent)
: QDialog {parent, Qt::WindowStaysOnTopHint | Qt::WindowTitleHint | Qt::WindowSystemMenuHint} : QDialog {parent, Qt::WindowStaysOnTopHint | Qt::WindowTitleHint | Qt::WindowSystemMenuHint}
, ui(new Ui::LogQSO) , ui(new Ui::LogQSO)
, m_settings (settings) , m_settings (settings)
, m_config {config} , m_config {config}
, m_log {log}
{ {
ui->setupUi(this); ui->setupUi(this);
setWindowTitle(programTitle + " - Log QSO"); setWindowTitle(programTitle + " - Log QSO");
@ -57,8 +58,7 @@ void LogQSO::storeSettings () const
void LogQSO::initLogQSO(QString const& hisCall, QString const& hisGrid, QString mode, void LogQSO::initLogQSO(QString const& hisCall, QString const& hisGrid, QString mode,
QString const& rptSent, QString const& rptRcvd, QString const& rptSent, QString const& rptRcvd,
QDateTime const& dateTimeOn, QDateTime const& dateTimeOff, QDateTime const& dateTimeOn, QDateTime const& dateTimeOff,
Radio::Frequency dialFreq, bool noSuffix, QString xSent, QString xRcvd, Radio::Frequency dialFreq, bool noSuffix, QString xSent, QString xRcvd)
CabrilloLog * cabrillo_log)
{ {
if(!isHidden()) return; if(!isHidden()) return;
ui->call->setText (hisCall); ui->call->setText (hisCall);
@ -100,7 +100,6 @@ void LogQSO::initLogQSO(QString const& hisCall, QString const& hisGrid, QString
ui->loggedOperator->setText(m_config->opCall()); ui->loggedOperator->setText(m_config->opCall());
ui->exchSent->setText (xSent); ui->exchSent->setText (xSent);
ui->exchRcvd->setText (xRcvd); ui->exchRcvd->setText (xRcvd);
m_cabrilloLog = cabrillo_log;
using SpOp = Configuration::SpecialOperatingActivity; using SpOp = Configuration::SpecialOperatingActivity;
auto special_op = m_config->special_op_id (); auto special_op = m_config->special_op_id ();
@ -158,7 +157,7 @@ void LogQSO::accept()
return; // without accepting return; // without accepting
} }
if (!m_cabrilloLog->add_QSO (m_dialFreq, dateTimeOff, hisCall, xsent, xrcvd)) if (!m_log->contest_log ()->add_QSO (m_dialFreq, dateTimeOff, hisCall, xsent, xrcvd))
{ {
show (); show ();
MessageBox::warning_message (this, tr ("Invalid QSO Data"), MessageBox::warning_message (this, tr ("Invalid QSO Data"),

View File

@ -17,19 +17,19 @@ namespace Ui {
class QSettings; class QSettings;
class Configuration; class Configuration;
class QByteArray; class QByteArray;
class CabrilloLog; class LogBook;
class LogQSO : public QDialog class LogQSO : public QDialog
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit LogQSO(QString const& programTitle, QSettings *, Configuration const *, QWidget *parent = 0); explicit LogQSO(QString const& programTitle, QSettings *, Configuration const *, LogBook *, QWidget *parent = 0);
~LogQSO(); ~LogQSO();
void initLogQSO(QString const& hisCall, QString const& hisGrid, QString mode, void initLogQSO(QString const& hisCall, QString const& hisGrid, QString mode,
QString const& rptSent, QString const& rptRcvd, QDateTime const& dateTimeOn, QString const& rptSent, QString const& rptRcvd, QDateTime const& dateTimeOn,
QDateTime const& dateTimeOff, Radio::Frequency dialFreq, QDateTime const& dateTimeOff, Radio::Frequency dialFreq,
bool noSuffix, QString xSent, QString xRcvd, CabrilloLog *); bool noSuffix, QString xSent, QString xRcvd);
public slots: public slots:
void accept(); void accept();
@ -54,12 +54,12 @@ private:
QScopedPointer<Ui::LogQSO> ui; QScopedPointer<Ui::LogQSO> ui;
QSettings * m_settings; QSettings * m_settings;
Configuration const * m_config; Configuration const * m_config;
LogBook * m_log;
QString m_txPower; QString m_txPower;
QString m_comments; QString m_comments;
Radio::Frequency m_dialFreq; Radio::Frequency m_dialFreq;
QString m_myCall; QString m_myCall;
QString m_myGrid; QString m_myGrid;
CabrilloLog * m_cabrilloLog;
}; };
#endif // LogQSO_H #endif // LogQSO_H

View File

@ -244,7 +244,7 @@ MainWindow::MainWindow(QDir const& temp_directory, bool multiple,
m_echoGraph (new EchoGraph(m_settings)), m_echoGraph (new EchoGraph(m_settings)),
m_fastGraph (new FastGraph(m_settings)), m_fastGraph (new FastGraph(m_settings)),
// no parent so that it has a taskbar icon // no parent so that it has a taskbar icon
m_logDlg (new LogQSO (program_title (), m_settings, &m_config, nullptr)), m_logDlg (new LogQSO (program_title (), m_settings, &m_config, &m_logBook, nullptr)),
m_lastDialFreq {0}, m_lastDialFreq {0},
m_dialFreqRxWSPR {0}, m_dialFreqRxWSPR {0},
m_detector {new Detector {RX_SAMPLE_RATE, double(NTMAX), downSampleFactor}}, m_detector {new Detector {RX_SAMPLE_RATE, double(NTMAX), downSampleFactor}},
@ -2544,16 +2544,14 @@ void MainWindow::on_actionAstronomical_data_toggled (bool checked)
void MainWindow::on_fox_log_action_triggered() void MainWindow::on_fox_log_action_triggered()
{ {
if (!m_foxLog) m_foxLog.reset (new FoxLog {&m_config});
if (!m_foxLogWindow) if (!m_foxLogWindow)
{ {
m_foxLogWindow.reset (new FoxLogWindow {m_settings, &m_config, m_foxLog.data ()}); m_foxLogWindow.reset (new FoxLogWindow {m_settings, &m_config, m_logBook.fox_log ()});
// Connect signals from fox log window // Connect signals from fox log window
connect (this, &MainWindow::finished, m_foxLogWindow.data (), &FoxLogWindow::close); connect (this, &MainWindow::finished, m_foxLogWindow.data (), &FoxLogWindow::close);
connect (m_foxLogWindow.data (), &FoxLogWindow::reset_log_model, [this] () { connect (m_foxLogWindow.data (), &FoxLogWindow::reset_log_model, [this] () {
if (!m_foxLog) m_foxLog.reset (new FoxLog {&m_config}); m_logBook.fox_log ()->reset ();
m_foxLog->reset ();
}); });
} }
m_foxLogWindow->showNormal (); m_foxLogWindow->showNormal ();
@ -2563,10 +2561,9 @@ void MainWindow::on_fox_log_action_triggered()
void MainWindow::on_contest_log_action_triggered() void MainWindow::on_contest_log_action_triggered()
{ {
if (!m_cabrilloLog) m_cabrilloLog.reset (new CabrilloLog {&m_config});
if (!m_contestLogWindow) if (!m_contestLogWindow)
{ {
m_contestLogWindow.reset (new CabrilloLogWindow {m_settings, &m_config, m_cabrilloLog->model ()}); m_contestLogWindow.reset (new CabrilloLogWindow {m_settings, &m_config, m_logBook.contest_log ()->model ()});
// Connect signals from contest log window // Connect signals from contest log window
connect (this, &MainWindow::finished, m_contestLogWindow.data (), &CabrilloLogWindow::close); connect (this, &MainWindow::finished, m_contestLogWindow.data (), &CabrilloLogWindow::close);
@ -5521,15 +5518,9 @@ void MainWindow::on_logQSOButton_clicked() //Log QSO button
default: break; default: break;
} }
auto special_op = m_config.special_op_id ();
if (SpecOp::NONE < special_op && special_op < SpecOp::FOX)
{
if (!m_cabrilloLog) m_cabrilloLog.reset (new CabrilloLog {&m_config});
}
m_logDlg->initLogQSO (m_hisCall, grid, m_modeTx, m_rptSent, m_rptRcvd, m_logDlg->initLogQSO (m_hisCall, grid, m_modeTx, m_rptSent, m_rptRcvd,
m_dateTimeQSOOn, dateTimeQSOOff, m_freqNominal + m_dateTimeQSOOn, dateTimeQSOOff, m_freqNominal +
ui->TxFreqSpinBox->value(), m_noSuffix, m_xSent, m_xRcvd, ui->TxFreqSpinBox->value(), m_noSuffix, m_xSent, m_xRcvd);
m_cabrilloLog.data ());
m_inQSOwith=""; m_inQSOwith="";
} }
@ -6369,15 +6360,13 @@ void MainWindow::on_reset_cabrillo_log_action_triggered ()
"for export in your Cabrillo log."))) "for export in your Cabrillo log.")))
{ {
if(m_config.RTTY_Exchange()!="SCC") ui->sbSerialNumber->setValue(1); if(m_config.RTTY_Exchange()!="SCC") ui->sbSerialNumber->setValue(1);
if (!m_cabrilloLog) m_cabrilloLog.reset (new CabrilloLog {&m_config}); m_logBook.contest_log ()->reset ();
m_cabrilloLog->reset ();
} }
} }
void MainWindow::on_actionExport_Cabrillo_log_triggered() void MainWindow::on_actionExport_Cabrillo_log_triggered()
{ {
if (!m_cabrilloLog) m_cabrilloLog.reset (new CabrilloLog {&m_config}); if (QDialog::Accepted == ExportCabrillo {m_settings, &m_config, m_logBook.contest_log ()}.exec())
if (QDialog::Accepted == ExportCabrillo {m_settings, &m_config, m_cabrilloLog.data ()}.exec())
{ {
MessageBox::information_message (this, tr ("Cabrillo Log saved")); MessageBox::information_message (this, tr ("Cabrillo Log saved"));
} }
@ -8459,9 +8448,8 @@ list2Done:
m_hisGrid=m_foxQSO[hc1].grid; m_hisGrid=m_foxQSO[hc1].grid;
m_rptSent=m_foxQSO[hc1].sent; m_rptSent=m_foxQSO[hc1].sent;
m_rptRcvd=m_foxQSO[hc1].rcvd; m_rptRcvd=m_foxQSO[hc1].rcvd;
if (!m_foxLog) m_foxLog.reset (new FoxLog {&m_config});
if (!m_foxLogWindow) on_fox_log_action_triggered (); if (!m_foxLogWindow) on_fox_log_action_triggered ();
if (m_foxLog->add_QSO (QSO_time, m_hisCall, m_hisGrid, m_rptSent, m_rptRcvd, m_lastBand)) if (m_logBook.fox_log ()->add_QSO (QSO_time, m_hisCall, m_hisGrid, m_rptSent, m_rptRcvd, m_lastBand))
{ {
writeFoxQSO (QString {" Log: %1 %2 %3 %4 %5"}.arg (m_hisCall).arg (m_hisGrid) writeFoxQSO (QString {" Log: %1 %2 %3 %4 %5"}.arg (m_hisCall).arg (m_hisGrid)
.arg (m_rptSent).arg (m_rptRcvd).arg (m_lastBand)); .arg (m_rptSent).arg (m_rptRcvd).arg (m_lastBand));

View File

@ -72,9 +72,7 @@ class WideGraph;
class LogQSO; class LogQSO;
class Transceiver; class Transceiver;
class MessageAveraging; class MessageAveraging;
class FoxLog;
class FoxLogWindow; class FoxLogWindow;
class CabrilloLog;
class CabrilloLogWindow; class CabrilloLogWindow;
class ColorHighlighting; class ColorHighlighting;
class MessageClient; class MessageClient;
@ -376,9 +374,7 @@ private:
QScopedPointer<HelpTextWindow> m_prefixes; QScopedPointer<HelpTextWindow> m_prefixes;
QScopedPointer<HelpTextWindow> m_mouseCmnds; QScopedPointer<HelpTextWindow> m_mouseCmnds;
QScopedPointer<MessageAveraging> m_msgAvgWidget; QScopedPointer<MessageAveraging> m_msgAvgWidget;
QScopedPointer<FoxLog> m_foxLog;
QScopedPointer<FoxLogWindow> m_foxLogWindow; QScopedPointer<FoxLogWindow> m_foxLogWindow;
QScopedPointer<CabrilloLog> m_cabrilloLog;
QScopedPointer<CabrilloLogWindow> m_contestLogWindow; QScopedPointer<CabrilloLogWindow> m_contestLogWindow;
QScopedPointer<ColorHighlighting> m_colorHighlighting; QScopedPointer<ColorHighlighting> m_colorHighlighting;
Transceiver::TransceiverState m_rigState; Transceiver::TransceiverState m_rigState;