Skip to content

Commit

Permalink
Several refactors and bugfix
Browse files Browse the repository at this point in the history
world is still not working on the first setup
  • Loading branch information
ea4k committed Jan 7, 2025
1 parent 2cfe514 commit fb04fae
Show file tree
Hide file tree
Showing 34 changed files with 553 additions and 912 deletions.
4 changes: 3 additions & 1 deletion src/Changelog
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@

On first start, Locator is not identified
BUG: When adding EA KLog finds Spain, if EA4 is added, it fails to find the DXCC.
Find ONE single master place to do that calculation. Maybe World()??

TODO-Bug: Add QSOs from wsjtx does not work. Failure close to int QSO::toDB(int _qsoId) Maybe related to QSO dupe (it was already fixed)
Complete: void MainWindow::slotQSOReceived(const QSO &_qso) to add the QSO
Expand Down
37 changes: 37 additions & 0 deletions src/DEADJOE
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@

*** These modified files were found in JOE when it aborted on Mon Jan 6 21:46:04 2025
*** JOE was aborted by UNIX signal 1

*** File '(Unnamed)'
QVERIFY

*** File '(Unnamed)'
gco
QVerify
Atho
CO7WT/6
Bahama
VP7
VP7
VP6D
NewC
New

*** File '(Unnamed)'
a
a
cty.csv
cty.csv
generate-coverage.sh
generate-coverage.sh
generate-coverage.sh
cty.csv
klogrc
klogrc
/home/devel/GitHub/klog/src/awardswidget.h

*** File '* Startup Log *'
Processing '/etc/joe/jmacsrc'...
Processing '/etc/joe/ftyperc'...
Finished processing /etc/joe/ftyperc
Finished processing /etc/joe/jmacsrc
36 changes: 21 additions & 15 deletions src/awards.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,17 @@
Awards::Awards(DataProxy_SQLite *dp, const QString &_parentFunction)
{
Q_UNUSED(_parentFunction);
//qDebug() << "Awards::Awards- from: " << _parentFunction;
//qDebug() << "Awards::Awards- from: " << _parentFunction;
dataProxy = dp;
//QSqlDatabase db = QSqlDatabase::database("QSQLITE");
world = new World(dataProxy, Q_FUNC_INFO);

//qDebug() << "Awards::Awards - Before DXMarathon" ;
dxMarathon = new DXMarathon(dataProxy);
//qDebug() << "Awards::Awards - After DXMarathon" ;
util = new Utilities(Q_FUNC_INFO);



//world->create();
/*
newOneColor.setNamedColor("#ff0000");
Expand All @@ -60,14 +62,13 @@ Awards::Awards(DataProxy_SQLite *dp, const QString &_parentFunction)
wazWorked.clear();
wazConfirmed.clear();
manageModes = false;
//qDebug() << "Awards::Awards - END" ;
//qDebug() << "Awards::Awards - END" ;
}

Awards::~Awards()
{
delete(world);
delete(dxMarathon);
delete(util);
}

void Awards::setAwardDXCC(const int _qsoId)
Expand Down Expand Up @@ -323,6 +324,7 @@ int Awards::getDXStatus (EntityStatus _entityStatus)
// Receives: QStringList _qs;
//_qs << Entity << BandId << << ModeId << lognumber;

// TODO: Maybe a status per band/mode... check how WSJTX is doing it
/* Not mode
-1 - Error. - ERROR - ERROR
0 - New one - New One - New One - 0
Expand Down Expand Up @@ -360,18 +362,18 @@ int Awards::getDXStatus (EntityStatus _entityStatus)



//qDebug() << Q_FUNC_INFO<< ": dxccEntity: " << QString::number(dxccEntity);
//qDebug() << Q_FUNC_INFO<< ": dxccEntity: " << QString::number(_entityStatus.entityId);
if (_entityStatus.entityId<=0)
{
//qDebug() << Q_FUNC_INFO<< ": dxccEntity <= 0, return -1";
//qDebug() << Q_FUNC_INFO<< ": dxccEntity <= 0, return -1";
return -1;
}

bool checkingMode = true;
if ( (_entityStatus.modeId==-1) || (manageModes==false))
{
checkingMode = false;
//qDebug() << Q_FUNC_INFO<< ": checkingMode = FALSE";
//qDebug() << Q_FUNC_INFO<< ": checkingMode = FALSE";
}

int wb = dxccStatusBand(_entityStatus.entityId, _entityStatus.bandId, _entityStatus.log); //-1 error / 0 Not worked / 1 worked / 2 confirmed
Expand Down Expand Up @@ -541,7 +543,7 @@ int Awards::dxccStatusBandMode(const int _ent, const int _band, const int _mode,
else
{
//qDebug() << "Awards::dxccStatusBandMode: Checking Mode FALSE";
queryString = QString("SELECT DISTINCT qsl_rcvd, lotw_qsl_rcvd FROM log WHERE dxcc='%1' AND bandid='%2' AND lognumber='%3' ").arg(QString::number(_ent)).arg(QString::number(_band)).arg(QString::number(_logNumber));
queryString = QString("SELECT DISTINCT qsl_rcvd, lotw_qsl_rcvd FROM log WHERE dxcc='%1' AND bandid='%2' AND lognumber='%3'").arg(QString::number(_ent)).arg(QString::number(_band)).arg(QString::number(_logNumber));
}

int status = 0;
Expand Down Expand Up @@ -732,7 +734,13 @@ int Awards::dxccStatus(const int _ent, const int _logNumber)

QColor Awards::getQRZDXStatusColor(EntityStatus _entitystatus)
{
//qDebug() << Q_FUNC_INFO << " - Start";

//qDebug() << Q_FUNC_INFO << " - Start: " ;
//qDebug() << Q_FUNC_INFO << " - Entityd: " << _entitystatus.entityId;
//qDebug() << Q_FUNC_INFO << " - BandId: " << _entitystatus.bandId;
//qDebug() << Q_FUNC_INFO << " - ModeId: " << _entitystatus.modeId;
//qDebug() << Q_FUNC_INFO << " - Log: " << _entitystatus.log;


/*
0 - New One
Expand All @@ -745,8 +753,8 @@ QColor Awards::getQRZDXStatusColor(EntityStatus _entitystatus)

int status = getDXStatus(_entitystatus);

//qDebug() << Q_FUNC_INFO<< ": status: " << QString::number(status) << "/" << getDXStatusString(status);
//qDebug() << Q_FUNC_INFO<< ": status: " << QString::number(status);
//qDebug() << Q_FUNC_INFO<< ": status: " << QString::number(status) << "/" << getDXStatusString(status);
//qDebug() << Q_FUNC_INFO<< ": status: " << QString::number(status);

switch (status) {
case 0:
Expand Down Expand Up @@ -1196,10 +1204,8 @@ void Awards::setColors (const QColor &_newOne, const QColor &_needed, const QCol
newOneColor = _newOne;
}

QColor Awards::getDefaultColor()
{
return defaultColor;
}
QColor Awards::getDefaultColor(){return defaultColor;}


void Awards::recalculateAwards()
{
Expand Down
2 changes: 0 additions & 2 deletions src/awards.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
#include "world.h"
#include "awarddxmarathon.h"
#include "dataproxy_sqlite.h"
#include "utilities.h"
#include "klogdefinitions.h"

class QProgressDialog;
Expand Down Expand Up @@ -159,7 +158,6 @@ class Awards : public QObject {
World *world;
DataProxy_SQLite *dataProxy;
DXMarathon *dxMarathon;
Utilities *util;

typedef QMultiHash<int, int> DXStatus;

Expand Down
20 changes: 19 additions & 1 deletion src/callsign.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ bool Callsign::isSimple()
return false;
if (fullCall.contains('\\'))
return false;
return true;
return valid;
}

void Callsign::clear()
Expand All @@ -390,6 +390,14 @@ void Callsign::clear()
prefValid = false; // The entered string is a correct prefix
}

bool Callsign::isAOneLetterHostPrefix()
{
QList<QChar> validFirstLettersOnly = {'B', 'F', 'G', 'I', 'K', 'M', 'N', 'R', 'U', 'W'};
if (hostPrefix.length() == 1)
return validFirstLettersOnly.contains (hostPrefix);
return false;
}

// Based on wiki information
// https://en.wikipedia.org/wiki/Amateur_radio_call_signs
/*
Expand All @@ -404,6 +412,16 @@ QStringList Callsign::secondarySpecialSuffixes =
"R", // repeaters
"B", // beacon
"LGT" // 'LIGHTHOUSE' or 'LIGHTSHIP' - unofficial
"LH" // LightHouse
bool Utilities::isAValidOperatingSuffix (const QString &_c)
{
//TODO: This list should be moved to Callsign
//qDebug() << QString("%1-%2").arg(Q_FUNC_INFO).arg(parentName) << _c;
QStringList validSuffixes = {"A", "P", "Q", "AM", "M", "MM", "LH", "R", "J", "FF", "QRP", "QRPP", "1", "2", "3", "4", "5", "6", "7", "8", "9", "0"};
return validSuffixes.contains (_c);
}
};
*/
// https:// cqwpx.com/rules.htm
Expand Down
9 changes: 5 additions & 4 deletions src/callsign.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
*****************************************************************************/
/*
This class implements the object callsign to centralize all about callsigns
This code is mainly coming from QLog: https://github.com/foldynl/QLog/blob/master/core/Callsign.h
The inspiration and part of the code is coming from QLog: https://github.com/foldynl/QLog/blob/master/core/Callsign.h
Thank you Lada, OK1MLG.
Important: https://cqwpx.com/rules.htm
Expand Down Expand Up @@ -73,9 +73,10 @@ class Callsign : public QObject
QString getHomeSuffix(); // The suffix of the home call (homeSuffix)
QString getSuffix(); // Additional suffixes like /P, /QRP, /MM, ... (generalSuffix)

bool isValid(); // True if it is a full callsign
bool isValidPrefix(); // True if it is a prefix, but not a call
bool isSimple(); // True if it has no / nor \ characters, no prefix nor suffix
bool isValid(); // True if it is a full callsign
bool isValidPrefix(); // True if it is a prefix, but not a call
bool isSimple(); // True if it has no / nor \ characters, no prefix nor suffix
bool isAOneLetterHostPrefix(); // True if is the prefix starts by B|F|G|I|K|M|N|R|U|W and is valid
void clear();

private:
Expand Down
45 changes: 22 additions & 23 deletions src/dataproxy_sqlite.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
*****************************************************************************/

#include "dataproxy_sqlite.h"
#include "callsign.h"

//#include <QDebug>

Expand Down Expand Up @@ -652,11 +653,11 @@ QStringList DataProxy_SQLite::getFields()
return fields;
}

QStringList DataProxy_SQLite::getBands()
{
//QStringList DataProxy_SQLite::getBands()
//{
//qDebug() << "DataProxy_SQLite::getBands - DEPRECATED please use getBandNames - TODO: Remove this function and change the calls";
return getBandNames();
}
// return getBandNames();
//}

QStringList DataProxy_SQLite::getBandNames()
{
Expand Down Expand Up @@ -7345,47 +7346,46 @@ int DataProxy_SQLite::getEntityIdFromMainPrefix(const QString &_e)

int DataProxy_SQLite::getDXCCFromPrefix(const QString &_p)
{
//qDebug() << "DataProxy_SQLite::getDXCCFromPrefix - " << Q_FUNC_INFO << "-" << _p << "-";
//qDebug() << Q_FUNC_INFO << " - " << _p << "-";

QSqlQuery query;
QString queryString = QString("SELECT dxcc FROM prefixesofentity WHERE prefix='%1'").arg(_p);
bool sqlOK = query.exec(queryString);

if (sqlOK)
{
//qDebug() << "DataProxy_SQLite::getDXCCFromPrefix: query OK: query: " << queryString;
//qDebug() << Q_FUNC_INFO << ": query OK: query: " << queryString;
if (query.next())
{
if (query.isValid())
{
int v = (query.value(0)).toInt();
query.finish();
//qDebug() << "DataProxy_SQLite::getDXCCFromPrefix: return 0: " << QString::number(v) ;
//qDebug() << Q_FUNC_INFO << ": return 0: " << QString::number(v) ;
return v;
}
else
{
query.finish();
//qDebug() << "DataProxy_SQLite::getDXCCFromPrefix: return -1: ";
//qDebug() << Q_FUNC_INFO << ": return -1: ";
return -1;
}
}
else
{
query.finish();
//qDebug() << "DataProxy_SQLite::getDXCCFromPrefix: return -2: ";
//qDebug() << Q_FUNC_INFO << ": return -2: ";
return -2;
}
}
else
{
//qDebug() << "DataProxy_SQLite::getDXCCFromPrefix: query NOK: query: " << queryString;
//qDebug() << Q_FUNC_INFO << ": query NOK: query: " << queryString;
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().text(), query.lastQuery());
query.finish();
//qDebug() << "DataProxy_SQLite::getDXCCFromPrefix: return -3: ";
//qDebug() << Q_FUNC_INFO << ": return -3: ";
return -3;
}
//return -4;
}

bool DataProxy_SQLite::isNewCQz(int _c)
Expand Down Expand Up @@ -7876,31 +7876,30 @@ QString DataProxy_SQLite::getISOName(const int _n)

int DataProxy_SQLite::getPrefixId(const QString &_qrz)
{
//qDebug() << "DataProxy_SQLite::getPrefixId: -" << _qrz <<"-";
//qDebug() << Q_FUNC_INFO << ": -" << _qrz <<"-";
//TODO: Instead of going from long to short, identify prefixes from the begining:
// character(may be number) + number
QString aux = util->getMainCallFromComplexCall((_qrz).toUpper());
if (!util->isValidCall(aux))
//if (_qrz.length() < 1)
{
return -1;
}
int entityID = 0;

Callsign callsign(_qrz);
if (!callsign.isValid())
return -1;
if (!callsign.isValidPrefix())
return -2;

//QString aux = changeSlashAndFindPrefix((_qrz).toUpper());
QString aux = callsign.getHostFullPrefix();
int entityID = 0;

while ((entityID <= 0) && (aux.length()>=1) )
{
entityID = getDXCCFromPrefix(aux);

//qDebug() << "DataProxy_SQLite::getPrefixId: in the while" << aux << " = " << QString::number(entityID);
//qDebug() << Q_FUNC_INFO << ": in the while" << aux << " = " << QString::number(entityID);
if (entityID<=0)
{
aux.chop(1);
}
}
//qDebug() << "DataProxy_SQLite::getPrefixId: " << _qrz << QString::number(entityID);
//qDebug() << Q_FUNC_INFO << ": " << _qrz << QString::number(entityID);
return entityID;
}

Expand Down
16 changes: 8 additions & 8 deletions src/dataproxy_sqlite.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class DataProxy_SQLite : public QObject
int getModeIdFromSubModeId(const int _sm);
void setCallValidation(const bool _v);
QStringList getFields();
KLOG_DEPRECATED QStringList getBands();
//KLOG_DEPRECATED QStringList getBands();
QStringList getModes(); // Returns the list of submodes
QStringList sortBandNamesBottonUp(const QStringList _qs);
QStringList getBandIDs();
Expand Down Expand Up @@ -209,7 +209,7 @@ class DataProxy_SQLite : public QObject
bool isNewEntity(int _e);
double getLongitudeFromEntity(const int _e);
double getLatitudeFromEntity(const int _e);
int getDXCCFromPrefix(const QString &_p);
KLOG_DEPRECATED int getDXCCFromPrefix(const QString &_p); // TODO: Replace by int World::getPrefixId(const QString &_prefix)
QString getEntityPrefixes(const int _enti);
QStringList getLongPrefixes();
QStringList getSpecialCallsigns();
Expand Down Expand Up @@ -333,13 +333,13 @@ class DataProxy_SQLite : public QObject
bool dbCreated;
DataBase *db;
QStringList sortBandIdBottonUp(const QStringList _qs);
double getFreqFromRange(QString _fr, int _pair = 0); //May even receive: 145.900-146.00 and should return the mid in the range (145.950)
double getFreqFromRange(QString _fr, int _pair = 0); //May even receive: 145.900-146.00 and should return the mid in the range (145.950)
QStringList getColumnNamesFromTable(const QString &_tableName);
QString getStringQueryStationCallSign (const QString &_a); // Creates part of a query regarding the station_call field
QString getStringQueryMyGrid (const QString &_a); // Creates part of a query regarding the my_gridsquare field
QString getStringQueryLogNumber (const int _a); // Creates part of a query regarding the lognumber field
int getPrefixId(const QString &_qrz);
int getHowManyEmptyDXCCorCont(); // Refactored from fillEmptyDXCCInTheLog
QString getStringQueryStationCallSign (const QString &_a); // Creates part of a query regarding the station_call field
QString getStringQueryMyGrid (const QString &_a); // Creates part of a query regarding the my_gridsquare field
QString getStringQueryLogNumber (const int _a); // Creates part of a query regarding the lognumber field
KLOG_DEPRECATED int getPrefixId(const QString &_qrz); // TODO: Replace by int World::getPrefixId(const QString &_prefix)
int getHowManyEmptyDXCCorCont(); // Refactored from fillEmptyDXCCInTheLog
bool updateDXCCAndContinent(const int _id, const int _dxcc, const QString &_cont); // Refactored from fillEmptyDXCCInTheLog
//QString changeSlashAndFindPrefix(const QString &_qrz);
void logEvent(const QString &_func, const QString &_msg, DebugLogLevel _level);
Expand Down
Loading

0 comments on commit fb04fae

Please sign in to comment.