Skip to content

Commit

Permalink
Fixed #459 - ADIF Import: Improved a condition when DXCC is updated
Browse files Browse the repository at this point in the history
  • Loading branch information
foldynl committed Sep 11, 2024
1 parent 455e2a6 commit 1363873
Showing 1 changed file with 32 additions and 27 deletions.
59 changes: 32 additions & 27 deletions logformat/LogFormat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -401,37 +401,42 @@ unsigned long LogFormat::runImport(QTextStream& importLogStream,
int recordDXCCId = record.value(RECORDIDX(LogbookModel::COLUMN_DXCC)).toInt(); // 0 = NAN or not present
// otherwise = DXCC ID

const DxccEntity &entity = ( recordDXCCId != 0 ) ? Data::instance()->lookupDxccID(recordDXCCId)
: Data::instance()->lookupDxcc(call.toString());

if ( entity.dxcc == 0 ) // DXCC not found
if ( recordDXCCId != 0 || updateDxcc )
{
writeImportLog(importLogStream,
(updateDxcc) ? ERROR_SEVERITY : WARNING_SEVERITY,
processedRec,
record,
tr("Cannot find DXCC Entity Info"));
( updateDxcc ) ? (*errors)++
: (*warnings)++;
if ( updateDxcc )
continue;
}
else
{
record.setValue(RECORDIDX(LogbookModel::COLUMN_DXCC), entity.dxcc);
record.setValue(RECORDIDX(LogbookModel::COLUMN_COUNTRY), Data::removeAccents(entity.country));
record.setValue(RECORDIDX(LogbookModel::COLUMN_COUNTRY_INTL), entity.country);
const DxccEntity &entity = ( updateDxcc ) ? Data::instance()->lookupDxcc(call.toString())
: Data::instance()->lookupDxccID(recordDXCCId);

// other DXCC related values ​​are not closely related to DXCC value and could have been filled
// therefore check if it is present or not.
if ( record.value(RECORDIDX(LogbookModel::COLUMN_CONTINENT)).toString().isEmpty() )
record.setValue(RECORDIDX(LogbookModel::COLUMN_CONTINENT), entity.cont);
if ( entity.dxcc == 0 ) // DXCC not found
{
writeImportLog(importLogStream,
(updateDxcc) ? ERROR_SEVERITY : WARNING_SEVERITY,
processedRec,
record,
tr("Cannot find DXCC Entity Info"));
if ( updateDxcc )
{
(*errors)++;
continue;
}
(*warnings)++;
}
else
{
record.setValue(RECORDIDX(LogbookModel::COLUMN_DXCC), entity.dxcc);
record.setValue(RECORDIDX(LogbookModel::COLUMN_COUNTRY), Data::removeAccents(entity.country));
record.setValue(RECORDIDX(LogbookModel::COLUMN_COUNTRY_INTL), entity.country);

if ( record.value(RECORDIDX(LogbookModel::COLUMN_ITUZ)).toString().isEmpty() )
record.setValue(RECORDIDX(LogbookModel::COLUMN_ITUZ), QString::number(entity.ituz));
// other DXCC related values ​​are not closely related to DXCC value and could have been filled
// therefore check if it is present or not.
if ( record.value(RECORDIDX(LogbookModel::COLUMN_CONTINENT)).toString().isEmpty() )
record.setValue(RECORDIDX(LogbookModel::COLUMN_CONTINENT), entity.cont);

if ( record.value(RECORDIDX(LogbookModel::COLUMN_CQZ)).toString().isEmpty() )
record.setValue(RECORDIDX(LogbookModel::COLUMN_CQZ), QString::number(entity.cqz));
if ( record.value(RECORDIDX(LogbookModel::COLUMN_ITUZ)).toString().isEmpty() )
record.setValue(RECORDIDX(LogbookModel::COLUMN_ITUZ), QString::number(entity.ituz));

if ( record.value(RECORDIDX(LogbookModel::COLUMN_CQZ)).toString().isEmpty() )
record.setValue(RECORDIDX(LogbookModel::COLUMN_CQZ), QString::number(entity.cqz));
}
}

if ( record.value(RECORDIDX(LogbookModel::COLUMN_PREFIX)).toString().isEmpty() )
Expand Down

0 comments on commit 1363873

Please sign in to comment.