Skip to content

Commit

Permalink
Closes #680
Browse files Browse the repository at this point in the history
  • Loading branch information
d authored and d committed Feb 23, 2024
1 parent d9ce8d9 commit f4b69bf
Show file tree
Hide file tree
Showing 10 changed files with 408 additions and 13 deletions.
1 change: 1 addition & 0 deletions src/Changelog
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ WIP: - Bugfix: Keep data of SAT tab when entering a QSO stopped working. (TNX EA
- BugFix: Minor CQz & ITUz bugfixes that could, potentially accept CQ or ITU zones being 0.
- Bugfix: Several fields do not meet ADIF specification (Closes #669)
- Bugfix: DX-Cluster activity file can't be edit with normal txt file. (Closes #682)
- Bugfix: QSO_COMPLETE field in database needs to be redefined (Closes #680)
- Translations: Danish (TNX Peter), Russian (YL3GBC), Spanish (EA4K), Ukrainian (YL3GBC)

Dec 2023 - 2.3.3
Expand Down
5 changes: 4 additions & 1 deletion src/adif.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,10 @@ bool Adif::isValidAntPath(const QString &_s)
return ((_s == "G") || (_s == "O") || (_s == "S") || (_s == "L"));
}


bool Adif::isValidQSO_COMPLETE(const QString &_s)
{ // "Y", "N", "NIL", "?"
return ((_s == "Y") || (_s == "N") || (_s == "NIL") || (_s == "?"));
}

/*
bool Utilities::isValidComment(const QString &_b)
Expand Down
1 change: 1 addition & 0 deletions src/adif.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ class Adif : public QObject {
bool isValidTenTen(const QString &_b); //>0
bool isValidLogId(const QString &_b); //>0
bool isValidAntPath(const QString &_s);
bool isValidQSO_COMPLETE(const QString &_s); // "Y", "N", "NIL", "?"

void setLogLevel(DebugLogLevel _l);
QString getADIFField(const QString &_fieldName, const QString &_data);
Expand Down
5 changes: 3 additions & 2 deletions src/filemanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3133,7 +3133,8 @@ bool FileManager::processQsoReadingADIF(const QStringList &_line, const int logN
}
break;
case(113):
preparedQuery.bindValue(":qso_complete", data);
//preparedQuery.bindValue(":qso_complete", data);
preparedQuery.bindValue(":qso_complete", util->getQSO_CompleteFromADIF(data));
break;
case(114):
preparedQuery.bindValue(":qso_random", data);
Expand Down Expand Up @@ -4769,7 +4770,7 @@ void FileManager::writeQuery(QSqlQuery query, QTextStream &out, const ExportMode
if (nameCol>=0)
{
aux = (query.value(nameCol)).toString(); aux = util->checkAndFixASCIIinADIF(aux);
qso.setQSOComplete(aux);
qso.setQSOComplete(util->getADIFQSO_CompleteFromDB(aux));
}
nameCol = rec.indexOf("qso_random");
if (nameCol>=0)
Expand Down
5 changes: 5 additions & 0 deletions src/logmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,11 @@ This should be coherent with the logview
setRelation(nameCol, QSqlRelation("entity", "dxcc", "name"));
}

if (_columns.contains("qso_complete"))
{
nameCol = rec.indexOf("qso_complete");
setRelation(nameCol, QSqlRelation("qso_complete_enumeration", "id", "shortname"));
}

nameCol = rec.indexOf("id");
setSort(nameCol, Qt::AscendingOrder);
Expand Down
15 changes: 7 additions & 8 deletions src/qso.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2005,13 +2005,12 @@ QString QSO::getMsShower()
}

bool QSO::setQSOComplete(const QString &_c)
{
if ((_c == "Y") || (_c == "N") || (_c == "NIL") || (_c == "?"))
{
qso_complete = _c;
return true;
}
return false;
{ // Y, N, I, ? are the valid chars.
// Here we store the short version just for the DB
// If we need to export it to ADIF, we need to call util->getADIFQSO_CompleteFromDB()
qso_complete = util->getQSO_CompleteFromADIF(_c);
//qDebug() << Q_FUNC_INFO << ": " << qso_complete;
return true;
}

QString QSO::getQSOComplete()
Expand Down Expand Up @@ -3364,7 +3363,7 @@ QString QSO::getADIF()
if (getQSL_SENT()=="Y") // Valid case to use qslsentVia
adifStr.append(adif->getADIFField ("qsl_sent_via", qslSenVia));
adifStr.append(adif->getADIFField ("qsl_via", qslVia));
adifStr.append(adif->getADIFField ("qso_complete", getQSOComplete()));
adifStr.append(adif->getADIFField ("qso_complete", util->getADIFQSO_CompleteFromDB(getQSOComplete())));

//TODO: Check wether it makes sense to use this field for ALL QSOs or just when it is not random.
if (getQSORandom())
Expand Down
2 changes: 1 addition & 1 deletion src/qso.h
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ class QSO : public QObject
QString getLatitude();
bool setLongitude(const QString &_c);
QString getLongitude();
bool setQSOComplete(const QString &_c);
bool setQSOComplete(const QString &_c); // Receives valid ADIF data (Y/N/NIL/?)
QString getQSOComplete();
bool setNrBursts(const int _i);
int getNrBursts();
Expand Down
58 changes: 58 additions & 0 deletions src/utilities.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1861,6 +1861,64 @@ QString Utilities::getCabrilloTimeFromQDateTime(const QDateTime &_d)
}
}

QString Utilities::getQSO_CompleteFromADIF(const QString &_s)
{ // Receives a valid QSO_COMPLETE ADIF data and returns
// one char to be stored in the data base.
// Default value is Y
//Parece que falla al guardar este campo que no se traduce a un varchar(1)
//qDebug() << Q_FUNC_INFO << ": " << _s;

Adif adif(Q_FUNC_INFO);
if (!adif.isValidQSO_COMPLETE(_s))
{
//qDebug() << Q_FUNC_INFO << " No valid";
return "1";
}
if (_s == "N")
{
return "2";
}
else if (_s == "NIL")
{
return "3";
}
else if (_s == "?")
{
return "4";
}
else
{
return "1";
}
}

QString Utilities::getADIFQSO_CompleteFromDB(const QString &_s)
{// Returns the ADIF QSO_COMPLETE
//1=Y, 2=N, 3=NIL, 4=?
//qDebug() << Q_FUNC_INFO << ": " << _s;
int i = _s.toInt();
switch (i)
{
case 2:
{
return "N";
}
case 3:
{
return "NIL";
}
case 4:
{
return "?";
}
default:
{
return "Y";
}
}
}


QString Utilities::getOnlineServiceName(OnLineProvider _service)
{//enum OnLineProvider {ClubLog, LoTW, eQSL, QRZ}; //, HamQTH, HRDLog
switch (_service)
Expand Down
6 changes: 6 additions & 0 deletions src/utilities.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
#include <QtDebug>
#include "locator.h"
#include "klogdefinitions.h"
#include "adif.h"
//#include "dataproxy_sqlite.h"

class Utilities : public QObject {
Expand Down Expand Up @@ -164,6 +165,11 @@ class Utilities : public QObject {
QString getCabrilloDateFromQDate(const QDate &_d); // Will produce the Cabrillo DATE format: "YYYY-MM-DD"
QString getCabrilloTimeFromQDateTime(const QDateTime &_d); // Will produce the Cabrillo TIME format: "HHMM"

// Parse QSO_COMPLETE from ADIF
QString getQSO_CompleteFromADIF(const QString &_s); // Expect a string and returns 1char string for DB
QString getADIFQSO_CompleteFromDB(const QString &_s); // Returns the ADIF QSO_COMPLETE


QString getOnlineServiceName(OnLineProvider _service);

bool isValidDistance(const double _d);
Expand Down
Loading

0 comments on commit f4b69bf

Please sign in to comment.