mirror of
https://github.com/saitohirga/WSJT-X.git
synced 2025-03-21 11:38:34 -04:00
More robust handling of imported ADIF records
Some logging applications export the BAND ADIF field with uppercase characters. This change makes sure that the internal worked before lookup indexes use uppercase throughout when fields that can come from external sources are stored.
This commit is contained in:
parent
5741407070
commit
4b4f65eb9f
@ -136,12 +136,12 @@ namespace Radio
|
|||||||
// the full call if no valid prefix (or prefix as a suffix) is specified
|
// the full call if no valid prefix (or prefix as a suffix) is specified
|
||||||
QString effective_prefix (QString callsign)
|
QString effective_prefix (QString callsign)
|
||||||
{
|
{
|
||||||
auto prefix = callsign.toUpper ();
|
auto prefix = callsign;
|
||||||
auto slash_pos = callsign.indexOf ('/');
|
auto slash_pos = callsign.indexOf ('/');
|
||||||
if (slash_pos >= 0)
|
if (slash_pos >= 0)
|
||||||
{
|
{
|
||||||
auto right_size = callsign.size () - slash_pos - 1;
|
auto right_size = callsign.size () - slash_pos - 1;
|
||||||
if (right_size >= slash_pos) // naive call is longer than
|
if (right_size >= slash_pos) // native call is longer than
|
||||||
// prefix/suffix algorithm
|
// prefix/suffix algorithm
|
||||||
{
|
{
|
||||||
prefix = callsign.left (slash_pos);
|
prefix = callsign.left (slash_pos);
|
||||||
@ -157,6 +157,6 @@ namespace Radio
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return prefix;
|
return prefix.toUpper ();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -159,8 +159,9 @@ public:
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
Record fixup (QString const& call, prefix const& p) const
|
Record fixup (QString call, prefix const& p) const
|
||||||
{
|
{
|
||||||
|
call = call.toUpper ();
|
||||||
using entity_by_id = entities_type::index<id>::type;
|
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
|
||||||
|
|
||||||
|
@ -307,10 +307,10 @@ WorkedBefore::WorkedBefore ()
|
|||||||
if (call.size ())
|
if (call.size ())
|
||||||
{
|
{
|
||||||
auto const& entity = m_->prefixes_.lookup (call);
|
auto const& entity = m_->prefixes_.lookup (call);
|
||||||
m_->worked_.emplace (call
|
m_->worked_.emplace (call.toUpper ()
|
||||||
, extractField (record, "GRIDSQUARE").left (4) // not interested in 6-digit grids
|
, extractField (record, "GRIDSQUARE").left (4).toUpper () // not interested in 6-digit grids
|
||||||
, extractField (record, "BAND")
|
, extractField (record, "BAND").toUpper ()
|
||||||
, extractField (record, "MODE")
|
, extractField (record, "MODE").toUpper ()
|
||||||
, entity.entity_name
|
, entity.entity_name
|
||||||
, entity.continent
|
, entity.continent
|
||||||
, entity.CQ_zone
|
, entity.CQ_zone
|
||||||
@ -357,8 +357,8 @@ bool WorkedBefore::add (QString const& call
|
|||||||
}
|
}
|
||||||
out << ADIF_record << " <eor>" << endl;
|
out << ADIF_record << " <eor>" << endl;
|
||||||
}
|
}
|
||||||
m_->worked_.emplace (call, grid, band, mode, entity.entity_name
|
m_->worked_.emplace (call.toUpper (), grid.left (4).toUpper (), band.toUpper (), mode.toUpper ()
|
||||||
, entity.continent, entity.CQ_zone, entity.ITU_zone);
|
, entity.entity_name, entity.continent, entity.CQ_zone, entity.ITU_zone);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -372,7 +372,7 @@ bool WorkedBefore::country_worked (QString const& country, QString const& mode,
|
|||||||
return
|
return
|
||||||
country.size ()
|
country.size ()
|
||||||
&& m_->worked_.get<entity_mode_band> ().end ()
|
&& m_->worked_.get<entity_mode_band> ().end ()
|
||||||
!= m_->worked_.get<entity_mode_band> ().find (std::make_tuple (country, mode, band));
|
!= m_->worked_.get<entity_mode_band> ().find (std::make_tuple (country, mode.toUpper (), band.toUpper ()));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -380,7 +380,7 @@ bool WorkedBefore::country_worked (QString const& country, QString const& mode,
|
|||||||
return
|
return
|
||||||
country.size ()
|
country.size ()
|
||||||
&& m_->worked_.get<entity_mode_band> ().end ()
|
&& m_->worked_.get<entity_mode_band> ().end ()
|
||||||
!= m_->worked_.get<entity_mode_band> ().find (std::make_tuple (country, mode));
|
!= m_->worked_.get<entity_mode_band> ().find (std::make_tuple (country, mode.toUpper ()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -390,7 +390,7 @@ bool WorkedBefore::country_worked (QString const& country, QString const& mode,
|
|||||||
return
|
return
|
||||||
country.size ()
|
country.size ()
|
||||||
&& m_->worked_.get<entity_band> ().end ()
|
&& m_->worked_.get<entity_band> ().end ()
|
||||||
!= m_->worked_.get<entity_band> ().find (std::make_tuple (country, band));
|
!= m_->worked_.get<entity_band> ().find (std::make_tuple (country, band.toUpper ()));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -410,13 +410,13 @@ bool WorkedBefore::grid_worked (QString const& grid, QString const& mode, QStrin
|
|||||||
if (band.size ())
|
if (band.size ())
|
||||||
{
|
{
|
||||||
return m_->worked_.get<grid_mode_band> ().end ()
|
return m_->worked_.get<grid_mode_band> ().end ()
|
||||||
!= m_->worked_.get<grid_mode_band> ().find (std::make_tuple (grid, mode, band));
|
!= m_->worked_.get<grid_mode_band> ().find (std::make_tuple (grid.left (4).toUpper (), mode.toUpper (), band.toUpper ()));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// partial key lookup
|
// partial key lookup
|
||||||
return m_->worked_.get<grid_mode_band> ().end ()
|
return m_->worked_.get<grid_mode_band> ().end ()
|
||||||
!= m_->worked_.get<grid_mode_band> ().find (std::make_tuple (grid, mode));
|
!= m_->worked_.get<grid_mode_band> ().find (std::make_tuple (grid.left (4).toUpper (), mode.toUpper ()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -424,13 +424,13 @@ bool WorkedBefore::grid_worked (QString const& grid, QString const& mode, QStrin
|
|||||||
if (band.size ())
|
if (band.size ())
|
||||||
{
|
{
|
||||||
return m_->worked_.get<grid_band> ().end ()
|
return m_->worked_.get<grid_band> ().end ()
|
||||||
!= m_->worked_.get<grid_band> ().find (std::make_tuple (grid, band));
|
!= m_->worked_.get<grid_band> ().find (std::make_tuple (grid.left (4).toUpper (), band.toUpper ()));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// partial key lookup
|
// partial key lookup
|
||||||
return m_->worked_.get<grid_band> ().end ()
|
return m_->worked_.get<grid_band> ().end ()
|
||||||
!= m_->worked_.get<grid_band> ().find (grid);
|
!= m_->worked_.get<grid_band> ().find (grid.left (4).toUpper ());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -442,13 +442,13 @@ bool WorkedBefore::call_worked (QString const& call, QString const& mode, QStrin
|
|||||||
if (band.size ())
|
if (band.size ())
|
||||||
{
|
{
|
||||||
return m_->worked_.get<call_mode_band> ().end ()
|
return m_->worked_.get<call_mode_band> ().end ()
|
||||||
!= m_->worked_.get<call_mode_band> ().find (std::make_tuple (call, mode, band));
|
!= m_->worked_.get<call_mode_band> ().find (std::make_tuple (call.toUpper (), mode.toUpper (), band.toUpper ()));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// partial key lookup
|
// partial key lookup
|
||||||
return m_->worked_.get<call_mode_band> ().end ()
|
return m_->worked_.get<call_mode_band> ().end ()
|
||||||
!= m_->worked_.get<call_mode_band> ().find (std::make_tuple (call, mode));
|
!= m_->worked_.get<call_mode_band> ().find (std::make_tuple (call.toUpper (), mode.toUpper ()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -456,13 +456,13 @@ bool WorkedBefore::call_worked (QString const& call, QString const& mode, QStrin
|
|||||||
if (band.size ())
|
if (band.size ())
|
||||||
{
|
{
|
||||||
return m_->worked_.get<call_band> ().end ()
|
return m_->worked_.get<call_band> ().end ()
|
||||||
!= m_->worked_.get<call_band> ().find (std::make_tuple (call, band));
|
!= m_->worked_.get<call_band> ().find (std::make_tuple (call.toUpper (), band.toUpper ()));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// partial key lookup
|
// partial key lookup
|
||||||
return m_->worked_.get<call_band> ().end ()
|
return m_->worked_.get<call_band> ().end ()
|
||||||
!= m_->worked_.get<call_band> ().find (std::make_tuple (call));
|
!= m_->worked_.get<call_band> ().find (std::make_tuple (call.toUpper ()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -474,13 +474,13 @@ bool WorkedBefore::continent_worked (Continent continent, QString const& mode, Q
|
|||||||
if (band.size ())
|
if (band.size ())
|
||||||
{
|
{
|
||||||
return m_->worked_.get<continent_mode_band> ().end ()
|
return m_->worked_.get<continent_mode_band> ().end ()
|
||||||
!= m_->worked_.get<continent_mode_band> ().find (std::make_tuple (continent, mode, band));
|
!= m_->worked_.get<continent_mode_band> ().find (std::make_tuple (continent, mode.toUpper (), band.toUpper ()));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// partial key lookup
|
// partial key lookup
|
||||||
return m_->worked_.get<continent_mode_band> ().end ()
|
return m_->worked_.get<continent_mode_band> ().end ()
|
||||||
!= m_->worked_.get<continent_mode_band> ().find (std::make_tuple (continent, mode));
|
!= m_->worked_.get<continent_mode_band> ().find (std::make_tuple (continent, mode.toUpper ()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -488,7 +488,7 @@ bool WorkedBefore::continent_worked (Continent continent, QString const& mode, Q
|
|||||||
if (band.size ())
|
if (band.size ())
|
||||||
{
|
{
|
||||||
return m_->worked_.get<continent_band> ().end ()
|
return m_->worked_.get<continent_band> ().end ()
|
||||||
!= m_->worked_.get<continent_band> ().find (std::make_tuple (continent, band));
|
!= m_->worked_.get<continent_band> ().find (std::make_tuple (continent, band.toUpper ()));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -506,13 +506,13 @@ bool WorkedBefore::CQ_zone_worked (int CQ_zone, QString const& mode, QString con
|
|||||||
if (band.size ())
|
if (band.size ())
|
||||||
{
|
{
|
||||||
return m_->worked_.get<CQ_zone_mode_band> ().end ()
|
return m_->worked_.get<CQ_zone_mode_band> ().end ()
|
||||||
!= m_->worked_.get<CQ_zone_mode_band> ().find (std::make_tuple (CQ_zone, mode, band));
|
!= m_->worked_.get<CQ_zone_mode_band> ().find (std::make_tuple (CQ_zone, mode.toUpper (), band.toUpper ()));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// partial key lookup
|
// partial key lookup
|
||||||
return m_->worked_.get<CQ_zone_mode_band> ().end ()
|
return m_->worked_.get<CQ_zone_mode_band> ().end ()
|
||||||
!= m_->worked_.get<CQ_zone_mode_band> ().find (std::make_tuple (CQ_zone, mode));
|
!= m_->worked_.get<CQ_zone_mode_band> ().find (std::make_tuple (CQ_zone, mode.toUpper ()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -520,7 +520,7 @@ bool WorkedBefore::CQ_zone_worked (int CQ_zone, QString const& mode, QString con
|
|||||||
if (band.size ())
|
if (band.size ())
|
||||||
{
|
{
|
||||||
return m_->worked_.get<CQ_zone_band> ().end ()
|
return m_->worked_.get<CQ_zone_band> ().end ()
|
||||||
!= m_->worked_.get<CQ_zone_band> ().find (std::make_tuple (CQ_zone, band));
|
!= m_->worked_.get<CQ_zone_band> ().find (std::make_tuple (CQ_zone, band.toUpper ()));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -538,13 +538,13 @@ bool WorkedBefore::ITU_zone_worked (int ITU_zone, QString const& mode, QString c
|
|||||||
if (band.size ())
|
if (band.size ())
|
||||||
{
|
{
|
||||||
return m_->worked_.get<ITU_zone_mode_band> ().end ()
|
return m_->worked_.get<ITU_zone_mode_band> ().end ()
|
||||||
!= m_->worked_.get<ITU_zone_mode_band> ().find (std::make_tuple (ITU_zone, mode, band));
|
!= m_->worked_.get<ITU_zone_mode_band> ().find (std::make_tuple (ITU_zone, mode.toUpper (), band.toUpper ()));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// partial key lookup
|
// partial key lookup
|
||||||
return m_->worked_.get<ITU_zone_mode_band> ().end ()
|
return m_->worked_.get<ITU_zone_mode_band> ().end ()
|
||||||
!= m_->worked_.get<ITU_zone_mode_band> ().find (std::make_tuple (ITU_zone, mode));
|
!= m_->worked_.get<ITU_zone_mode_band> ().find (std::make_tuple (ITU_zone, mode.toUpper ()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -552,7 +552,7 @@ bool WorkedBefore::ITU_zone_worked (int ITU_zone, QString const& mode, QString c
|
|||||||
if (band.size ())
|
if (band.size ())
|
||||||
{
|
{
|
||||||
return m_->worked_.get<ITU_zone_band> ().end ()
|
return m_->worked_.get<ITU_zone_band> ().end ()
|
||||||
!= m_->worked_.get<ITU_zone_band> ().find (std::make_tuple (ITU_zone, band));
|
!= m_->worked_.get<ITU_zone_band> ().find (std::make_tuple (ITU_zone, band.toUpper ()));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user