Skip to content

Commit fb04fae

Browse files
committed
Several refactors and bugfix
world is still not working on the first setup
1 parent 2cfe514 commit fb04fae

34 files changed

+553
-912
lines changed

src/Changelog

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
1+
On first start, Locator is not identified
2+
BUG: When adding EA KLog finds Spain, if EA4 is added, it fails to find the DXCC.
3+
Find ONE single master place to do that calculation. Maybe World()??
24

35
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)
46
Complete: void MainWindow::slotQSOReceived(const QSO &_qso) to add the QSO

src/DEADJOE

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
2+
*** These modified files were found in JOE when it aborted on Mon Jan 6 21:46:04 2025
3+
*** JOE was aborted by UNIX signal 1
4+
5+
*** File '(Unnamed)'
6+
QVERIFY
7+
8+
*** File '(Unnamed)'
9+
gco
10+
QVerify
11+
Atho
12+
CO7WT/6
13+
Bahama
14+
VP7
15+
VP7
16+
VP6D
17+
NewC
18+
New
19+
20+
*** File '(Unnamed)'
21+
a
22+
a
23+
cty.csv
24+
cty.csv
25+
generate-coverage.sh
26+
generate-coverage.sh
27+
generate-coverage.sh
28+
cty.csv
29+
klogrc
30+
klogrc
31+
/home/devel/GitHub/klog/src/awardswidget.h
32+
33+
*** File '* Startup Log *'
34+
Processing '/etc/joe/jmacsrc'...
35+
Processing '/etc/joe/ftyperc'...
36+
Finished processing /etc/joe/ftyperc
37+
Finished processing /etc/joe/jmacsrc

src/awards.cpp

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,17 @@
2929
Awards::Awards(DataProxy_SQLite *dp, const QString &_parentFunction)
3030
{
3131
Q_UNUSED(_parentFunction);
32-
//qDebug() << "Awards::Awards- from: " << _parentFunction;
32+
//qDebug() << "Awards::Awards- from: " << _parentFunction;
3333
dataProxy = dp;
3434
//QSqlDatabase db = QSqlDatabase::database("QSQLITE");
3535
world = new World(dataProxy, Q_FUNC_INFO);
3636

3737
//qDebug() << "Awards::Awards - Before DXMarathon" ;
3838
dxMarathon = new DXMarathon(dataProxy);
3939
//qDebug() << "Awards::Awards - After DXMarathon" ;
40-
util = new Utilities(Q_FUNC_INFO);
40+
41+
42+
4143
//world->create();
4244
/*
4345
newOneColor.setNamedColor("#ff0000");
@@ -60,14 +62,13 @@ Awards::Awards(DataProxy_SQLite *dp, const QString &_parentFunction)
6062
wazWorked.clear();
6163
wazConfirmed.clear();
6264
manageModes = false;
63-
//qDebug() << "Awards::Awards - END" ;
65+
//qDebug() << "Awards::Awards - END" ;
6466
}
6567

6668
Awards::~Awards()
6769
{
6870
delete(world);
6971
delete(dxMarathon);
70-
delete(util);
7172
}
7273

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

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

361363

362364

363-
//qDebug() << Q_FUNC_INFO<< ": dxccEntity: " << QString::number(dxccEntity);
365+
//qDebug() << Q_FUNC_INFO<< ": dxccEntity: " << QString::number(_entityStatus.entityId);
364366
if (_entityStatus.entityId<=0)
365367
{
366-
//qDebug() << Q_FUNC_INFO<< ": dxccEntity <= 0, return -1";
368+
//qDebug() << Q_FUNC_INFO<< ": dxccEntity <= 0, return -1";
367369
return -1;
368370
}
369371

370372
bool checkingMode = true;
371373
if ( (_entityStatus.modeId==-1) || (manageModes==false))
372374
{
373375
checkingMode = false;
374-
//qDebug() << Q_FUNC_INFO<< ": checkingMode = FALSE";
376+
//qDebug() << Q_FUNC_INFO<< ": checkingMode = FALSE";
375377
}
376378

377379
int wb = dxccStatusBand(_entityStatus.entityId, _entityStatus.bandId, _entityStatus.log); //-1 error / 0 Not worked / 1 worked / 2 confirmed
@@ -541,7 +543,7 @@ int Awards::dxccStatusBandMode(const int _ent, const int _band, const int _mode,
541543
else
542544
{
543545
//qDebug() << "Awards::dxccStatusBandMode: Checking Mode FALSE";
544-
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));
546+
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));
545547
}
546548

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

733735
QColor Awards::getQRZDXStatusColor(EntityStatus _entitystatus)
734736
{
735-
//qDebug() << Q_FUNC_INFO << " - Start";
737+
738+
//qDebug() << Q_FUNC_INFO << " - Start: " ;
739+
//qDebug() << Q_FUNC_INFO << " - Entityd: " << _entitystatus.entityId;
740+
//qDebug() << Q_FUNC_INFO << " - BandId: " << _entitystatus.bandId;
741+
//qDebug() << Q_FUNC_INFO << " - ModeId: " << _entitystatus.modeId;
742+
//qDebug() << Q_FUNC_INFO << " - Log: " << _entitystatus.log;
743+
736744

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

746754
int status = getDXStatus(_entitystatus);
747755

748-
//qDebug() << Q_FUNC_INFO<< ": status: " << QString::number(status) << "/" << getDXStatusString(status);
749-
//qDebug() << Q_FUNC_INFO<< ": status: " << QString::number(status);
756+
//qDebug() << Q_FUNC_INFO<< ": status: " << QString::number(status) << "/" << getDXStatusString(status);
757+
//qDebug() << Q_FUNC_INFO<< ": status: " << QString::number(status);
750758

751759
switch (status) {
752760
case 0:
@@ -1196,10 +1204,8 @@ void Awards::setColors (const QColor &_newOne, const QColor &_needed, const QCol
11961204
newOneColor = _newOne;
11971205
}
11981206

1199-
QColor Awards::getDefaultColor()
1200-
{
1201-
return defaultColor;
1202-
}
1207+
QColor Awards::getDefaultColor(){return defaultColor;}
1208+
12031209

12041210
void Awards::recalculateAwards()
12051211
{

src/awards.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@
4242
#include "world.h"
4343
#include "awarddxmarathon.h"
4444
#include "dataproxy_sqlite.h"
45-
#include "utilities.h"
4645
#include "klogdefinitions.h"
4746

4847
class QProgressDialog;
@@ -159,7 +158,6 @@ class Awards : public QObject {
159158
World *world;
160159
DataProxy_SQLite *dataProxy;
161160
DXMarathon *dxMarathon;
162-
Utilities *util;
163161

164162
typedef QMultiHash<int, int> DXStatus;
165163

src/callsign.cpp

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ bool Callsign::isSimple()
370370
return false;
371371
if (fullCall.contains('\\'))
372372
return false;
373-
return true;
373+
return valid;
374374
}
375375

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

393+
bool Callsign::isAOneLetterHostPrefix()
394+
{
395+
QList<QChar> validFirstLettersOnly = {'B', 'F', 'G', 'I', 'K', 'M', 'N', 'R', 'U', 'W'};
396+
if (hostPrefix.length() == 1)
397+
return validFirstLettersOnly.contains (hostPrefix);
398+
return false;
399+
}
400+
393401
// Based on wiki information
394402
// https://en.wikipedia.org/wiki/Amateur_radio_call_signs
395403
/*
@@ -404,6 +412,16 @@ QStringList Callsign::secondarySpecialSuffixes =
404412
"R", // repeaters
405413
"B", // beacon
406414
"LGT" // 'LIGHTHOUSE' or 'LIGHTSHIP' - unofficial
415+
"LH" // LightHouse
416+
417+
bool Utilities::isAValidOperatingSuffix (const QString &_c)
418+
{
419+
//TODO: This list should be moved to Callsign
420+
//qDebug() << QString("%1-%2").arg(Q_FUNC_INFO).arg(parentName) << _c;
421+
QStringList validSuffixes = {"A", "P", "Q", "AM", "M", "MM", "LH", "R", "J", "FF", "QRP", "QRPP", "1", "2", "3", "4", "5", "6", "7", "8", "9", "0"};
422+
return validSuffixes.contains (_c);
423+
}
424+
407425
};
408426
*/
409427
// https:// cqwpx.com/rules.htm

src/callsign.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
*****************************************************************************/
2828
/*
2929
This class implements the object callsign to centralize all about callsigns
30-
This code is mainly coming from QLog: https://github.com/foldynl/QLog/blob/master/core/Callsign.h
30+
The inspiration and part of the code is coming from QLog: https://github.com/foldynl/QLog/blob/master/core/Callsign.h
3131
Thank you Lada, OK1MLG.
3232

3333
Important: https://cqwpx.com/rules.htm
@@ -73,9 +73,10 @@ class Callsign : public QObject
7373
QString getHomeSuffix(); // The suffix of the home call (homeSuffix)
7474
QString getSuffix(); // Additional suffixes like /P, /QRP, /MM, ... (generalSuffix)
7575

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

8182
private:

src/dataproxy_sqlite.cpp

Lines changed: 22 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
*****************************************************************************/
2626

2727
#include "dataproxy_sqlite.h"
28+
#include "callsign.h"
2829

2930
//#include <QDebug>
3031

@@ -652,11 +653,11 @@ QStringList DataProxy_SQLite::getFields()
652653
return fields;
653654
}
654655

655-
QStringList DataProxy_SQLite::getBands()
656-
{
656+
//QStringList DataProxy_SQLite::getBands()
657+
//{
657658
//qDebug() << "DataProxy_SQLite::getBands - DEPRECATED please use getBandNames - TODO: Remove this function and change the calls";
658-
return getBandNames();
659-
}
659+
// return getBandNames();
660+
//}
660661

661662
QStringList DataProxy_SQLite::getBandNames()
662663
{
@@ -7345,47 +7346,46 @@ int DataProxy_SQLite::getEntityIdFromMainPrefix(const QString &_e)
73457346

73467347
int DataProxy_SQLite::getDXCCFromPrefix(const QString &_p)
73477348
{
7348-
//qDebug() << "DataProxy_SQLite::getDXCCFromPrefix - " << Q_FUNC_INFO << "-" << _p << "-";
7349+
//qDebug() << Q_FUNC_INFO << " - " << _p << "-";
73497350

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

73547355
if (sqlOK)
73557356
{
7356-
//qDebug() << "DataProxy_SQLite::getDXCCFromPrefix: query OK: query: " << queryString;
7357+
//qDebug() << Q_FUNC_INFO << ": query OK: query: " << queryString;
73577358
if (query.next())
73587359
{
73597360
if (query.isValid())
73607361
{
73617362
int v = (query.value(0)).toInt();
73627363
query.finish();
7363-
//qDebug() << "DataProxy_SQLite::getDXCCFromPrefix: return 0: " << QString::number(v) ;
7364+
//qDebug() << Q_FUNC_INFO << ": return 0: " << QString::number(v) ;
73647365
return v;
73657366
}
73667367
else
73677368
{
73687369
query.finish();
7369-
//qDebug() << "DataProxy_SQLite::getDXCCFromPrefix: return -1: ";
7370+
//qDebug() << Q_FUNC_INFO << ": return -1: ";
73707371
return -1;
73717372
}
73727373
}
73737374
else
73747375
{
73757376
query.finish();
7376-
//qDebug() << "DataProxy_SQLite::getDXCCFromPrefix: return -2: ";
7377+
//qDebug() << Q_FUNC_INFO << ": return -2: ";
73777378
return -2;
73787379
}
73797380
}
73807381
else
73817382
{
7382-
//qDebug() << "DataProxy_SQLite::getDXCCFromPrefix: query NOK: query: " << queryString;
7383+
//qDebug() << Q_FUNC_INFO << ": query NOK: query: " << queryString;
73837384
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().text(), query.lastQuery());
73847385
query.finish();
7385-
//qDebug() << "DataProxy_SQLite::getDXCCFromPrefix: return -3: ";
7386+
//qDebug() << Q_FUNC_INFO << ": return -3: ";
73867387
return -3;
73877388
}
7388-
//return -4;
73897389
}
73907390

73917391
bool DataProxy_SQLite::isNewCQz(int _c)
@@ -7876,31 +7876,30 @@ QString DataProxy_SQLite::getISOName(const int _n)
78767876

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

7883+
Callsign callsign(_qrz);
7884+
if (!callsign.isValid())
7885+
return -1;
7886+
if (!callsign.isValidPrefix())
7887+
return -2;
78907888

7891-
//QString aux = changeSlashAndFindPrefix((_qrz).toUpper());
7889+
QString aux = callsign.getHostFullPrefix();
7890+
int entityID = 0;
78927891

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

7897-
//qDebug() << "DataProxy_SQLite::getPrefixId: in the while" << aux << " = " << QString::number(entityID);
7896+
//qDebug() << Q_FUNC_INFO << ": in the while" << aux << " = " << QString::number(entityID);
78987897
if (entityID<=0)
78997898
{
79007899
aux.chop(1);
79017900
}
79027901
}
7903-
//qDebug() << "DataProxy_SQLite::getPrefixId: " << _qrz << QString::number(entityID);
7902+
//qDebug() << Q_FUNC_INFO << ": " << _qrz << QString::number(entityID);
79047903
return entityID;
79057904
}
79067905

src/dataproxy_sqlite.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ class DataProxy_SQLite : public QObject
7070
int getModeIdFromSubModeId(const int _sm);
7171
void setCallValidation(const bool _v);
7272
QStringList getFields();
73-
KLOG_DEPRECATED QStringList getBands();
73+
//KLOG_DEPRECATED QStringList getBands();
7474
QStringList getModes(); // Returns the list of submodes
7575
QStringList sortBandNamesBottonUp(const QStringList _qs);
7676
QStringList getBandIDs();
@@ -209,7 +209,7 @@ class DataProxy_SQLite : public QObject
209209
bool isNewEntity(int _e);
210210
double getLongitudeFromEntity(const int _e);
211211
double getLatitudeFromEntity(const int _e);
212-
int getDXCCFromPrefix(const QString &_p);
212+
KLOG_DEPRECATED int getDXCCFromPrefix(const QString &_p); // TODO: Replace by int World::getPrefixId(const QString &_prefix)
213213
QString getEntityPrefixes(const int _enti);
214214
QStringList getLongPrefixes();
215215
QStringList getSpecialCallsigns();
@@ -333,13 +333,13 @@ class DataProxy_SQLite : public QObject
333333
bool dbCreated;
334334
DataBase *db;
335335
QStringList sortBandIdBottonUp(const QStringList _qs);
336-
double getFreqFromRange(QString _fr, int _pair = 0); //May even receive: 145.900-146.00 and should return the mid in the range (145.950)
336+
double getFreqFromRange(QString _fr, int _pair = 0); //May even receive: 145.900-146.00 and should return the mid in the range (145.950)
337337
QStringList getColumnNamesFromTable(const QString &_tableName);
338-
QString getStringQueryStationCallSign (const QString &_a); // Creates part of a query regarding the station_call field
339-
QString getStringQueryMyGrid (const QString &_a); // Creates part of a query regarding the my_gridsquare field
340-
QString getStringQueryLogNumber (const int _a); // Creates part of a query regarding the lognumber field
341-
int getPrefixId(const QString &_qrz);
342-
int getHowManyEmptyDXCCorCont(); // Refactored from fillEmptyDXCCInTheLog
338+
QString getStringQueryStationCallSign (const QString &_a); // Creates part of a query regarding the station_call field
339+
QString getStringQueryMyGrid (const QString &_a); // Creates part of a query regarding the my_gridsquare field
340+
QString getStringQueryLogNumber (const int _a); // Creates part of a query regarding the lognumber field
341+
KLOG_DEPRECATED int getPrefixId(const QString &_qrz); // TODO: Replace by int World::getPrefixId(const QString &_prefix)
342+
int getHowManyEmptyDXCCorCont(); // Refactored from fillEmptyDXCCInTheLog
343343
bool updateDXCCAndContinent(const int _id, const int _dxcc, const QString &_cont); // Refactored from fillEmptyDXCCInTheLog
344344
//QString changeSlashAndFindPrefix(const QString &_qrz);
345345
void logEvent(const QString &_func, const QString &_msg, DebugLogLevel _level);

0 commit comments

Comments
 (0)