diff --git a/src/Changelog b/src/Changelog index 421f6ae2..dfe922e4 100644 --- a/src/Changelog +++ b/src/Changelog @@ -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 diff --git a/src/DEADJOE b/src/DEADJOE new file mode 100644 index 00000000..77060fbd --- /dev/null +++ b/src/DEADJOE @@ -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 diff --git a/src/awards.cpp b/src/awards.cpp index b17ad811..8db6acde 100644 --- a/src/awards.cpp +++ b/src/awards.cpp @@ -29,7 +29,7 @@ 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); @@ -37,7 +37,9 @@ Awards::Awards(DataProxy_SQLite *dp, const QString &_parentFunction) //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"); @@ -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) @@ -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 @@ -360,10 +362,10 @@ 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; } @@ -371,7 +373,7 @@ int Awards::getDXStatus (EntityStatus _entityStatus) 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 @@ -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; @@ -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 @@ -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: @@ -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() { diff --git a/src/awards.h b/src/awards.h index 7aa55775..705578e0 100644 --- a/src/awards.h +++ b/src/awards.h @@ -42,7 +42,6 @@ #include "world.h" #include "awarddxmarathon.h" #include "dataproxy_sqlite.h" -#include "utilities.h" #include "klogdefinitions.h" class QProgressDialog; @@ -159,7 +158,6 @@ class Awards : public QObject { World *world; DataProxy_SQLite *dataProxy; DXMarathon *dxMarathon; - Utilities *util; typedef QMultiHash DXStatus; diff --git a/src/callsign.cpp b/src/callsign.cpp index 77971c41..240d0637 100644 --- a/src/callsign.cpp +++ b/src/callsign.cpp @@ -370,7 +370,7 @@ bool Callsign::isSimple() return false; if (fullCall.contains('\\')) return false; - return true; + return valid; } void Callsign::clear() @@ -390,6 +390,14 @@ void Callsign::clear() prefValid = false; // The entered string is a correct prefix } +bool Callsign::isAOneLetterHostPrefix() +{ + QList 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 /* @@ -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 diff --git a/src/callsign.h b/src/callsign.h index 607e0a9e..e69e8b52 100644 --- a/src/callsign.h +++ b/src/callsign.h @@ -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 @@ -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: diff --git a/src/dataproxy_sqlite.cpp b/src/dataproxy_sqlite.cpp index 2a21bccc..41a0d014 100644 --- a/src/dataproxy_sqlite.cpp +++ b/src/dataproxy_sqlite.cpp @@ -25,6 +25,7 @@ *****************************************************************************/ #include "dataproxy_sqlite.h" +#include "callsign.h" //#include @@ -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() { @@ -7345,7 +7346,7 @@ 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); @@ -7353,39 +7354,38 @@ int DataProxy_SQLite::getDXCCFromPrefix(const QString &_p) 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) @@ -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; } diff --git a/src/dataproxy_sqlite.h b/src/dataproxy_sqlite.h index 3efcd891..2f5f4441 100644 --- a/src/dataproxy_sqlite.h +++ b/src/dataproxy_sqlite.h @@ -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(); @@ -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(); @@ -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); diff --git a/src/dxccstatuswidget.cpp b/src/dxccstatuswidget.cpp index f5c9b8c1..98ae81ad 100644 --- a/src/dxccstatuswidget.cpp +++ b/src/dxccstatuswidget.cpp @@ -47,6 +47,7 @@ DXCCStatusWidget::DXCCStatusWidget(DataProxy_SQLite *dp, const QString &_parentF locator = new Locator(); awards = new Awards(dataProxy, Q_FUNC_INFO); //qDebug() << "DXCCStatusWidget::DXCCStatusWidget-1"; + world = new World(dataProxy,Q_FUNC_INFO); //qDebug() << "DXCCStatusWidget::DXCCStatusWidget-2"; @@ -814,6 +815,15 @@ void DXCCStatusWidget::setMyLocator(const QString &_loc) loc = l.toUpper(); } } + + +void DXCCStatusWidget::setColors (const QColor &_newOne, const QColor &_needed, const QColor &_worked, const QColor &_confirmed, const QColor &_default) +{ + //qDebug() << Q_FUNC_INFO << ": " << _newOne.name(QColor::HexRgb) << "/" << _needed.name(QColor::HexRgb) << "/" << _worked.name(QColor::HexRgb) << "/" << _confirmed.name(QColor::HexRgb) << "/" << _default.name(QColor::HexRgb); + // Just to pass the colors to the awards class + awards->setColors(_newOne, _needed, _worked, _confirmed, _default); +} + /* void DXCCStatusWidget::slotRightButton(const QPoint& pos) { diff --git a/src/dxccstatuswidget.h b/src/dxccstatuswidget.h index f6949b25..bfb3a637 100644 --- a/src/dxccstatuswidget.h +++ b/src/dxccstatuswidget.h @@ -48,6 +48,7 @@ class DXCCStatusWidget : public QWidget void update(); //void awardsUpdated(); void setBands(const QString &_callingFunc, const QStringList &_listOfNewBands, const bool _creating = false); // Receives the list of bandIDs + void setColors (const QColor &_newOne, const QColor &_needed, const QColor &_worked, const QColor &_confirmed, const QColor &_default); void setCurrentLog(const int _logN); void setMyLocator(const QString &_loc); void refresh(); diff --git a/src/dxcluster/dxcluster.cpp b/src/dxcluster/dxcluster.cpp index 0b2b1a5b..71ff4eb7 100644 --- a/src/dxcluster/dxcluster.cpp +++ b/src/dxcluster/dxcluster.cpp @@ -39,8 +39,8 @@ DXClusterWidget::DXClusterWidget(DataProxy_SQLite *dp, QWidget *parent) dataProxy = dp; util = new Utilities(Q_FUNC_INFO); - util->setLongPrefixes(dataProxy->getLongPrefixes()); - util->setSpecialCalls(dataProxy->getSpecialCallsigns()); + //util->setLongPrefixes(dataProxy->getLongPrefixes()); + //util->setSpecialCalls(dataProxy->getSpecialCallsigns()); world = new World(dataProxy, Q_FUNC_INFO); awards = new Awards(dataProxy, Q_FUNC_INFO); @@ -169,7 +169,7 @@ void DXClusterWidget::addData() void DXClusterWidget::slotClusterDXClusterWidgetItemDoubleClicked( QListWidgetItem * item ) { - //qDebug() << Q_FUNC_INFO << item->text(); + qDebug() << Q_FUNC_INFO << item->text(); QStringList ql; ql.clear(); @@ -231,7 +231,7 @@ void DXClusterWidget::slotClusterDisplayError(QAbstractSocket::SocketError socke .arg(tcpSocket->errorString()); } - qDebug() << Q_FUNC_INFO << errorMessage; + //qDebug() << Q_FUNC_INFO << errorMessage; QMessageBox::warning(this, tr("KLog DXCluster"), errorMessage); } @@ -355,16 +355,32 @@ void DXClusterWidget::slotClusterDataArrived() DXSpot spot = readItem(dxClusterString); //qDebug() << Q_FUNC_INFO << " - While 11"; + + _entityStatus.entityId = -1; + _entityStatus.log = currentLog; if (spot.isValid()) { //qDebug() << Q_FUNC_INFO << " - Spot is Valid"; + //qDebug() << Q_FUNC_INFO << ": spot-dxCall : " << spot.getDxCall(); + //qDebug() << Q_FUNC_INFO << ": spot-Spotter : " << spot.getSpotter(); + //qDebug() << Q_FUNC_INFO << ": spot-Freq : " << spot.getFrequency().toQString(); + //qDebug() << Q_FUNC_INFO << ": spot-Comment : " << spot.getComment(); + + _entityStatus.entityId = world->getQRZARRLId(spot.getDxCall()); + + //qDebug() << Q_FUNC_INFO << ": ARRL-ID: : " << world->getQRZARRLId(spot.getDxCall()); + //qDebug() << Q_FUNC_INFO << ": ARRL-ID2: : " << _entityStatus.entityId; + spotBand = QString::number(dataProxy->getBandIdFromFreq(spot.getFrequency().toDouble()) ); _entityStatus.bandId = spotBand.toInt(); + + dxSpotColor = awards->getQRZDXStatusColor(_entityStatus); + qDebug() << Q_FUNC_INFO << " - Color Status-1 " << dxSpotColor.name(); if (showDxMarathon) { if (awards->isDXMarathonNeed(_entityStatus.entityId, world->getQRZCqz(spot.getDxCall()), QDateTime::currentDateTime().date().year(), currentLog)) @@ -385,9 +401,10 @@ void DXClusterWidget::slotClusterDataArrived() { //qDebug() << Q_FUNC_INFO << " - Spot is NOT Valid"; dxSpotColor = awards->getDefaultColor(); + //qDebug() << Q_FUNC_INFO << " - Color Status-2 " << dxSpotColor.name(); } - qDebug() << Q_FUNC_INFO << " - While 70 - Color: " << dxSpotColor.name(QColor::HexRgb); + //qDebug() << Q_FUNC_INFO << " - Color Status-3 " << dxSpotColor.name(); addItemToClusterList(dxClusterString, dxSpotColor); @@ -517,7 +534,7 @@ void DXClusterWidget::slotClusterInputTextChanged() void DXClusterWidget::setColors (const QColor &_newOne, const QColor &_needed, const QColor &_worked, const QColor &_confirmed, const QColor &_default) { - qDebug() << Q_FUNC_INFO << ": " << _newOne.name(QColor::HexRgb) << "/" << _needed.name(QColor::HexRgb) << "/" << _worked.name(QColor::HexRgb) << "/" << _confirmed.name(QColor::HexRgb) << "/" << _default.name(QColor::HexRgb); + //qDebug() << Q_FUNC_INFO << ": " << _newOne.name(QColor::HexRgb) << "/" << _needed.name(QColor::HexRgb) << "/" << _worked.name(QColor::HexRgb) << "/" << _confirmed.name(QColor::HexRgb) << "/" << _default.name(QColor::HexRgb); // Just to pass the colors to the awards class awards->setColors(_newOne, _needed, _worked, _confirmed, _default); } @@ -548,10 +565,6 @@ void DXClusterWidget::slotClusterDXClusterWidgetItemSelected() void DXClusterWidget::slotClusterDXClusterWidgetItemEntered( QListWidgetItem * item ) { //qDebug() << Q_FUNC_INFO; -/* - This code comes from slotClusterDXClusterWidgetItemDoubleClicked -*/ - QString tip; tip.clear(); @@ -575,11 +588,11 @@ bool DXClusterWidget::isConnected() DXSpot DXClusterWidget::readItem(const QString _stringSpot) { - //qDebug() << Q_FUNC_INFO << _stringSpot; + //qDebug() << Q_FUNC_INFO << _stringSpot; DXSpot spot = DXSpot(); spot.clear(); - + spot.setDateTime(QDateTime::currentDateTimeUtc()); if (_stringSpot.length()<5) return spot; //qDebug() << Q_FUNC_INFO << "05"; @@ -590,22 +603,24 @@ DXSpot DXClusterWidget::readItem(const QString _stringSpot) //qDebug() << Q_FUNC_INFO << "10"; if ( (fields.at(0) == "DX" ) && (fields.at(1) == "de" ) ) { // DX de EA0XXX: 21200.1 EA0K The comment 1550 - //qDebug() << Q_FUNC_INFO << ": Identified: DX de"; - //qDebug() << Q_FUNC_INFO << ": 0: " << fields.at(0); - //qDebug() << Q_FUNC_INFO << ": 1: " << fields.at(1); - //qDebug() << Q_FUNC_INFO << ": 2: " << fields.at(2); - //qDebug() << Q_FUNC_INFO << ": 3: " << fields.at(3); - //qDebug() << Q_FUNC_INFO << ": 4: " << fields.at(4); - //qDebug() << Q_FUNC_INFO << ": 5: " << fields.at(5); - spot.setSpotter(fields.at(2)); - //qDebug() << Q_FUNC_INFO << "11"; + //qDebug() << Q_FUNC_INFO << ": Identified : DX de"; + //qDebug() << Q_FUNC_INFO << ": 0-DX : " << fields.at(0); + //qDebug() << Q_FUNC_INFO << ": 1-de : " << fields.at(1); + //qDebug() << Q_FUNC_INFO << ": 2-Spotter : " << fields.at(2); + //qDebug() << Q_FUNC_INFO << ": 3-Freq : " << fields.at(3); + //qDebug() << Q_FUNC_INFO << ": 4-DX : " << fields.at(4); + //qDebug() << Q_FUNC_INFO << ": 5-Comment : " << fields.at(5); + QString aux = fields.at(2); + aux.remove(':'); + spot.setSpotter(aux.trimmed()); + //qDebug() << Q_FUNC_INFO << "11"; Frequency freq; freq.fromQString((fields.at(3)), KHz); spot.setFrequency(freq); - //qDebug() << Q_FUNC_INFO << "12"; + //qDebug() << Q_FUNC_INFO << "12"; spot.setDXCall(fields.at(4)); - //qDebug() << Q_FUNC_INFO << "13"; - spot.setValid(true); + //qDebug() << Q_FUNC_INFO << "13"; + //qDebug() << Q_FUNC_INFO << "14"; //qDebug() << Q_FUNC_INFO << ": Identified: Freq1: " << spot.getFrequency().toQString(); } @@ -631,23 +646,25 @@ DXSpot DXClusterWidget::readItem(const QString _stringSpot) //qDebug() << Q_FUNC_INFO << " - DXCall: " << fields.at(1); spot.setDXCall(fields.at(1)); //qDebug() << Q_FUNC_INFO << "24"; - spot.setValid(true); //qDebug() << Q_FUNC_INFO << ": Identified: Freq2: " << spot.getFrequency().toQString(); } - else if ((fields.at(0) == "To" ) && (fields.at(1) == "ALL" )) - { // To ALL Comment - //qDebug() << Q_FUNC_INFO << ": Identified: To ALL"; - //qDebug() << Q_FUNC_INFO << "30"; - spot.setValid(false); - } - else - { - //qDebug() << Q_FUNC_INFO << ": Identified: just Text: " << _stringSpot; - //qDebug() << Q_FUNC_INFO << "40"; - spot.setValid(false); - } + //qDebug() << Q_FUNC_INFO << "100"; + + QString dxcall; + Frequency freq; + QString spotter; + QString comment; + QDateTime dateTime; + MouseClicks clickStatus; //qDebug() << Q_FUNC_INFO << " - END"; + + //qDebug() << Q_FUNC_INFO << ": Spot-dxCall : " << spot.getDxCall(); + //qDebug() << Q_FUNC_INFO << ": Spot-Spotter : " << spot.getSpotter(); + //qDebug() << Q_FUNC_INFO << ": Spot-Freq : " << spot.getFrequency().toQString(); + //qDebug() << Q_FUNC_INFO << ": Spot-Comment : " << spot.getComment(); + //qDebug() << Q_FUNC_INFO << ": Spot-Valid : " << util->boolToQString(spot.isValid()); + return spot; } diff --git a/src/dxcluster/dxclusterassistant.cpp b/src/dxcluster/dxclusterassistant.cpp index 221e6acd..2227f399 100644 --- a/src/dxcluster/dxclusterassistant.cpp +++ b/src/dxcluster/dxclusterassistant.cpp @@ -82,35 +82,6 @@ void DXClusterAssistant::newDXClusterSpot(proposedQSOs _q) addCall(); } -/* -void DXClusterAssistant::newDXClusterSpot(const QString &_call, const QSOStatus _status, double _freq) -{ - //qDebug() << Q_FUNC_INFO << " - Start"; - //Utilities util(Q_FUNC_INFO); - //if (!util.isValidCall(_call, true)) - //{ - // //qDebug() << Q_FUNC_INFO << " - Not Valid Call: " << _call; - // return; - //} - - //qDebug() << Q_FUNC_INFO << ": Call: " << _call; - //qDebug() << Q_FUNC_INFO << ": Freq: " << QString::number(_freq); - //qDebug() << Q_FUNC_INFO << ": Status: " << ; - proposedQSOs newArrival; - newArrival.call = _call; - newArrival.freq().fromDouble(_freq); - newArrival.status = _status; - newArrival.priority = 1; - list.append(newArrival); - //qDebug() << Q_FUNC_INFO << " - 50"; - - //qDebug() << Q_FUNC_INFO << " - 60"; - //qDebug() << Q_FUNC_INFO << QString("Data received: Call: %1 - Freq: %2 - Status: %3").arg(_call).arg(_freq).arg(getStringFromStatus(_status)); - addCall(); - //qDebug() << Q_FUNC_INFO << " - END"; -} -*/ - QString DXClusterAssistant::getStringFromStatus(QSOStatus _s) { switch (_s) { diff --git a/src/dxcluster/dxspot.cpp b/src/dxcluster/dxspot.cpp index 5073991c..5d103656 100644 --- a/src/dxcluster/dxspot.cpp +++ b/src/dxcluster/dxspot.cpp @@ -24,26 +24,13 @@ * * *****************************************************************************/ #include "dxspot.h" +#include "../callsign.h" DXSpot::DXSpot() { - valid = false; - clickStatus = NoClick; -} -/* -DXSpot::DXSpot(DXSpot *_other) -{ - dxcall = _other->dxcall; - spotter = _other->spotter; - if (_other->freq.isValid()) - freq = _other->freq; // Might need a copy constructor for Frequency as well - comment = _other->comment; - if (_other->dateTime.isValid()) - dateTime = _other->dateTime; - clickStatus = _other->clickStatus; - valid = _other->valid; + clear(); } -*/ + DXSpot::~DXSpot(){} @@ -55,7 +42,6 @@ DXSpot::DXSpot(const DXSpot& other) comment = other.comment; dateTime = other.dateTime; clickStatus = other.clickStatus; - valid = other.valid; } void DXSpot::clear() @@ -64,7 +50,6 @@ void DXSpot::clear() freq.clear(); spotter.clear(); dateTime.currentDateTimeUtc(); - valid = false; clickStatus = NoClick; } @@ -77,23 +62,54 @@ void DXSpot::operator=(DXSpot const &_other) if (_other.dateTime.isValid()) dateTime = _other.dateTime; clickStatus = _other.clickStatus; - valid = _other.valid; + } -void DXSpot::setValid(const bool _v){valid = _v;} -bool DXSpot::isValid(){return valid;} +bool DXSpot::isValid() +{ + //qDebug() << Q_FUNC_INFO << " - 010"; + Callsign dxc(dxcall); + if (!dxc.isValid()) + return false; + + //qDebug() << Q_FUNC_INFO << " - 020"; + Callsign spo(spotter); + if (!spo.isValid()) + return false; + + //qDebug() << Q_FUNC_INFO << " - 030"; + if (!freq.isValid()) + return false; -void DXSpot::setDXCall(const QString &_c){dxcall = _c;} + //qDebug() << Q_FUNC_INFO << " - 040"; + + if (!dateTime.isValid()) + return false; + + //qDebug() << Q_FUNC_INFO << " - 050"; + return true; +} + +void DXSpot::setDXCall(const QString &_c) +{ + Callsign callsing(_c); + if (callsing.isValid()) + dxcall = _c; +} QString DXSpot::getDxCall() {return dxcall;} -void DXSpot::setSpotter(const QString &_c){spotter = _c;} +void DXSpot::setSpotter(const QString &_c){ + Callsign callsing(_c); + if (callsing.isValid()) + spotter = _c; +} QString DXSpot::getSpotter(){return spotter;} void DXSpot::setComment(const QString &c){comment = c;} QString DXSpot::getComment(){return comment;} -void DXSpot::setDateTime(const QDateTime &d){if (d.isValid()) dateTime = d;} -QDateTime DXSpot::getDateTime(){ return dateTime;} +void DXSpot::setDateTime(const QDateTime &d){if (d.isValid()) dateTime = d; } +QDateTime DXSpot::getDateTime(){ return dateTime;} void DXSpot::setClickStatus(const MouseClicks &_s ){clickStatus = _s;} MouseClicks DXSpot::getClickStatus(){return clickStatus;} @@ -102,6 +118,7 @@ void DXSpot::setFrequency(Frequency f) { if (f.isValid()) freq = f; + qDebug() << Q_FUNC_INFO << ": " << freq.toQString(MHz); } Frequency DXSpot::getFrequency() diff --git a/src/dxcluster/dxspot.h b/src/dxcluster/dxspot.h index 5ad693f5..d7c05c04 100644 --- a/src/dxcluster/dxspot.h +++ b/src/dxcluster/dxspot.h @@ -46,7 +46,6 @@ class DXSpot void operator=(DXSpot const &_other); void clear(); - void setValid(const bool _v); bool isValid (); void setDXCall(const QString &c); @@ -74,8 +73,7 @@ class DXSpot QString spotter; QString comment; QDateTime dateTime; - MouseClicks clickStatus; - bool valid; + MouseClicks clickStatus; }; #endif // KLOG_CLUSTER_DXSPOT_H diff --git a/src/elogqrzlog.cpp b/src/elogqrzlog.cpp index dbf42f42..d75f2c21 100644 --- a/src/elogqrzlog.cpp +++ b/src/elogqrzlog.cpp @@ -29,6 +29,7 @@ #include #include #include +#include "callsign.h" //#include eLogQrzLog::eLogQrzLog(DataProxy_SQLite *dp, const QString &_parentFunction, const QString &_klogVersion) @@ -579,7 +580,8 @@ void eLogQrzLog::checkQRZ(const QString &_qrz) { //qDebug() << Q_FUNC_INFO << ": " + _qrz; showDebugLog (Q_FUNC_INFO, "Start: " + _qrz); - if (!util->isValidCall(_qrz)) + Callsign callsign(_qrz); + if (!callsign.isValid()) { //qDebug()<< "eLogQrzLog::checkQRZ: CALL not valid" ; showDebugLog (Q_FUNC_INFO, "CALL not valid"); diff --git a/src/filemanager.cpp b/src/filemanager.cpp index 292001a7..610d0ea3 100644 --- a/src/filemanager.cpp +++ b/src/filemanager.cpp @@ -24,6 +24,7 @@ * * *****************************************************************************/ #include "filemanager.h" +#include "callsign.h" //#include @@ -31,7 +32,7 @@ FileManager::FileManager(DataProxy_SQLite *dp) //FileManager::FileManager(const QString &_klogDir, const QString &_softVersion, DataBase _db) { - //qDebug() << "FileManager::FileManager()-3: Dir(2)" << _klogDir; + //qDebug() << Q_FUNC_INFO << " -3: Dir(2)" << _klogDir; dataProxy = dp; util = new Utilities(Q_FUNC_INFO); util->setLongPrefixes(dataProxy->getLongPrefixes()); @@ -40,7 +41,7 @@ FileManager::FileManager(DataProxy_SQLite *dp) db = new DataBase(Q_FUNC_INFO, klogVersion, util->getKLogDBFile()); world = new World(dataProxy, Q_FUNC_INFO); awards = new Awards(dataProxy, Q_FUNC_INFO); - //qDebug() << "FileManager::FileManager()-3: Dir(2) - END" ; + //qDebug() << Q_FUNC_INFO << " -3: Dir(2) - END" ; } FileManager::~FileManager() @@ -94,8 +95,8 @@ bool FileManager::checkADIFValidFormat(const QStringList &_qs) QString q0 = qs.at(0); QString q1 = qs.at(1); - //qDebug() << "FileManager::checkADIFValidFormat: " << qs.at(0); - //qDebug() << "FileManager::checkADIFValidFormat: " << qs.at(1); + //qDebug() << Q_FUNC_INFO << qs.at(0); + //qDebug() << Q_FUNC_INFO << qs.at(1); int len = 0; int i = (qs.at(0)).count(":"); @@ -110,7 +111,7 @@ bool FileManager::checkADIFValidFormat(const QStringList &_qs) } else { - //qDebug() << "FileManager::checkADIFValidFormat-1 "; + //qDebug() << Q_FUNC_INFO << " -1 "; return false; } @@ -124,24 +125,24 @@ bool FileManager::checkADIFValidFormat(const QStringList &_qs) if ( (q1).length() != len ) { - //qDebug() << "FileManager::checkADIFValidFormat-2: " << (qs.at(1)) << " - " << QString::number((qs.at(1)).length()) << "/" << QString::number(len); + //qDebug() << Q_FUNC_INFO << " -2: " << (qs.at(1)) << " - " << QString::number((qs.at(1)).length()) << "/" << QString::number(len); return false; } if (len <= 0) { - //qDebug() << "FileManager::checkADIFValidFormat-3 "; + //qDebug() << Q_FUNC_INFO << " -3 "; return false; } - //qDebug() << "FileManager::checkADIFValidFormat-4 (true)"; + //qDebug() << Q_FUNC_INFO << " -4 (true)"; return true; } bool FileManager::adifLogExport(const QString& _fileName, const int _logN) { - //qDebug() << "FileManager::adifLogExport" << _fileName; + //qDebug() << Q_FUNC_INFO << _fileName; return adifLogExportToFile(_fileName, _logN, false, false, false); } @@ -170,8 +171,8 @@ QList FileManager::adifLogExportReturnList(const QString& _fileName, const //qDebug() << Q_FUNC_INFO << ": Start)" << _fileName << "/" << _callsign << "/ " << _grid; QList qsos; qsos.clear(); - - if ((!util->isValidCall(_callsign)) && (_callsign != "ALL") && (_callsign !="NOT")) + Callsign call(_callsign); + if ((!call.isValid()) && (_callsign != "ALL") && (_callsign !="NOT")) { showError(tr("The selected callsign (%1) is not valid, please check it again to export the log.").arg(_callsign)); return qsos; @@ -434,8 +435,9 @@ QList FileManager::adifLogExportReturnList2(const QString& _fileName, const //qDebug() << Q_FUNC_INFO << ": Start)" << _fileName << "/" << _callsign << "/ " << _grid; QList qsos; qsos.clear(); + Callsign call(_callsign); - if ((!util->isValidCall(_callsign)) && (_callsign != "ALL") && (_callsign !="NOT")) + if ((!call.isValid()) && (_callsign != "ALL") && (_callsign !="NOT")) { showError(tr("The selected callsign (%1) is not valid, please check it again to export the log.").arg(_callsign)); return qsos; @@ -473,7 +475,7 @@ QList FileManager::adifLogExportReturnList2(const QString& _fileName, const bool FileManager::adifQSOsExport(const QString& _fileName, QList _qsos) { - //qDebug() << "FileManager::adifQSOsExport: " << _fileName; + //qDebug() << Q_FUNC_INFO << _fileName; int numberOfQSOs = _qsos.length(); if (numberOfQSOs<1) { @@ -481,19 +483,19 @@ bool FileManager::adifQSOsExport(const QString& _fileName, QList _qsos) //qDebug() << "FileManager::adifQSOsExport: No QSOs received to be exported"; } noMoreQso = false; - //qDebug() << "FileManager::adifQSOsExport - 01"; + //qDebug() << Q_FUNC_INFO << " - 01"; QFile file(_fileName); if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) /* Flawfinder: ignore */ return false; - //qDebug() << "FileManager::adifQSOsExport - 02"; + //qDebug() << Q_FUNC_INFO << " - 02"; QTextStream out(&file); QSqlQuery query; - //qDebug() << "FileManager::adifQSOsExport - 10"; + //qDebug() << Q_FUNC_INFO << " - 10"; QString numbers = QString(); foreach (int i, _qsos) { - //qDebug() << "FileManager::adifQSOsExport - query: " << QString("id = '%1'").arg(i) ; + //qDebug() << Q_FUNC_INFO << " - query: " << QString("id = '%1'").arg(i) ; numbers = numbers + QString::number(i) ; if (i != _qsos.last()) { @@ -502,14 +504,14 @@ bool FileManager::adifQSOsExport(const QString& _fileName, QList _qsos) } QString queryString = QString("SELECT * FROM log WHERE id IN (%1)").arg(numbers); - //qDebug() << "FileManager::adifQSOsExport: writing the header"; + //qDebug() << Q_FUNC_INFO << " - writing the header"; writeADIFHeader(out, ModeADIF, _qsos.length()); - //qDebug() << "FileManager::adifQSOsExport: writing the body"; + //qDebug() << Q_FUNC_INFO << " - writing the body"; bool sqlOK = query.exec(queryString); if (!sqlOK) { - //qDebug() << "FileManager::adifQSOsExport: query error: " << query.lastQuery(); + //qDebug() << Q_FUNC_INFO << " - query error: " << query.lastQuery(); emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().text(), query.lastQuery()); } //qDebug() << "FileManager::adifQSOsExport: query: " << query.lastQuery(); @@ -973,8 +975,8 @@ int FileManager::adifLoTWReadLog2(const QString& fileName, const int logN) if (line.contains("OWNCALL:")) { stationCallSign = (line.section(": ", 1, 1)).simplified(); - - if (!util->isValidCall(stationCallSign)) + Callsign callsign(stationCallSign); + if (!callsign.isValid()) { stationCallSign = QString(); } @@ -1054,9 +1056,9 @@ int FileManager::adifReadLog2(const QString& tfileName, QString _stationCallsign { //qDebug() << Q_FUNC_INFO << QString(": EOR detected, QSO added"); qso.setLogId (logN); - - if ((util->isValidCall(_stationCallsign)) && (!util->isValidCall(qso.getStationCallsign()))) - + Callsign call1(_stationCallsign); + Callsign call2(qso.getStationCallsign()); + if ((call1.isValid()) && (!call2.isValid())) { qso.setStationCallsign(_stationCallsign); } @@ -1297,8 +1299,8 @@ bool FileManager::getStationCallsignFromUser(const QString &_qrzDX, const QDate { _date = ", on "+ util->getDateSQLiteStringFromDate(_dt) ; } - - if (util->isValidCall(_qrzDX)) + Callsign callsign(_qrzDX); + if (callsign.isValid()) { aux = tr("KLog has found one QSO without the Station Callsign defined.\n\nEnter the Station Callsign that was used to do this QSO with %1 on %2:").arg(_qrzDX).arg(_date); text = QInputDialog::getText(this, tr("KLog - QSO without Station Callsign"), @@ -1310,8 +1312,8 @@ bool FileManager::getStationCallsignFromUser(const QString &_qrzDX, const QDate tr("KLog has found one QSO without the Station Callsign defined.\n\nEnter the Station Callsign that was used to do this QSO on %1:").arg(_date), QLineEdit::Normal, "", &ok); } - - if (ok && util->isValidCall(text)) + callsign(text); + if (ok && callsign.isValid()) { defaultStationCallsign = text.toUpper(); return true; @@ -1715,26 +1717,26 @@ bool FileManager::writeBackupDate() void FileManager::setStationCallSign(const QString& _st) { - //qDebug() << "FileManager::setStationCallSign: " << _st; - - if (util->isValidCall(_st, true)) + //qDebug() << Q_FUNC_INFO << " - " << _st; + Callsign callsign(_st); + if (callsign.isValid()) { - //qDebug() << "FileManager::setStationCallSign: True"; + //qDebug() << Q_FUNC_INFO << " - True"; defaultStationCallsign = _st; - //qDebug() << "FileManager::setStationCallSign: " << defaultStationCallsign; + //qDebug() << Q_FUNC_INFO << " - " << defaultStationCallsign; } else { - //qDebug() << "FileManager::setStationCallSign: FALSE"; + //qDebug() << Q_FUNC_INFO << " - FALSE"; } - //qDebug() << "FileManager::setStationCallSign: -" << defaultStationCallsign << "-END"; + //qDebug() << Q_FUNC_INFO << " - -" << defaultStationCallsign << "-END"; } bool FileManager::askUserToUseAlwaysSameAnswer() { - //qDebug() << "FileManager::askUserToUseAlwaysSameAnswer: " ; + //qDebug() << Q_FUNC_INFO << " - Start " ; QMessageBox msgBox; msgBox.setIcon(QMessageBox::Warning); @@ -1757,13 +1759,13 @@ bool FileManager::askUserToUseAlwaysSameAnswer() return false; } - //qDebug() << "FileManager::askUserToUseAlwaysSameAnswer: - END"; + //qDebug() << Q_FUNC_INFO << " - - END"; } bool FileManager::askUserToAddThisQSOToLog(const QString &_call, const QDateTime _datetime, const QString &_mode, const QString &_band, const double _freq) { Q_UNUSED(_freq); - //qDebug() << "FileManager::askUserToAddThisQSOToLog: " << _call; + //qDebug() << Q_FUNC_INFO << " - " << _call; QString qsoData = QString(tr("
  • Date/Time: %1
  • Callsign: %2
  • Band: %3
  • Mode: %4
")).arg(util->getDateTimeSQLiteStringFromDateTime(_datetime)).arg(_call).arg(_band).arg(_mode); QMessageBox msgBox; msgBox.setTextFormat(Qt::RichText); @@ -1787,7 +1789,7 @@ bool FileManager::askUserToAddThisQSOToLog(const QString &_call, const QDateTime return false; } - //qDebug() << "FileManager::askUserToAddThisQSOToLog: - END"; + //qDebug() << Q_FUNC_INFO << " - - END"; } bool FileManager::showInvalidCallMessage(const QString &_call){ diff --git a/src/inputwidgets/mainwindowinputothers.cpp b/src/inputwidgets/mainwindowinputothers.cpp index 0be0ea9c..a39e862e 100644 --- a/src/inputwidgets/mainwindowinputothers.cpp +++ b/src/inputwidgets/mainwindowinputothers.cpp @@ -796,6 +796,9 @@ void MainWindowInputOthers::setEntityAndPrefix(const int _entity, const QString setEntity(_entity); Callsign callsign(_qrz); + if (callsign.isValid() || callsign.isValidPrefix()) + currentPref = callsign.getHostFullPrefix(); + QString prefixFromEntityNumber = dataProxy->getEntityMainPrefix(_entity); // The main prefix of the entity. QString hostFullPrefix = callsign.getHostFullPrefix(); // The default is that showAll is not checked. Main prefix+ the area QString hostPrefix = callsign.getHostPrefix(); // The default is that showAll is not checked @@ -830,17 +833,19 @@ void MainWindowInputOthers::setEntityAndPrefix(const int _entity, const QString else { primarySubdivisions.append(dataProxy->getPrimarySubDivisions(currentInt, hostFullPrefix)); - + currentPref = hostFullPrefix; if (primarySubdivisions.isEmpty()) { //qDebug() << Q_FUNC_INFO << " - 50"; //qDebug() << Q_FUNC_INFO << " - primarySubdivisions is empty with hostPrefix, running for the main prefix"; primarySubdivisions.append(dataProxy->getPrimarySubDivisions(currentInt, hostPrefix)); + currentPref = hostPrefix; if (primarySubdivisions.isEmpty()) { //qDebug() << Q_FUNC_INFO << " - 55"; //qDebug() << Q_FUNC_INFO << " - primarySubdivisions is empty with mainprefix, running just with the entity"; primarySubdivisions.append(dataProxy->getPrimarySubDivisions(currentInt, QString())); + currentPref = QString(); } //qDebug() << Q_FUNC_INFO << " - 59"; } @@ -960,7 +965,6 @@ void MainWindowInputOthers::setColorsForUserDefinedADIFValueLineEdit() logEvent (Q_FUNC_INFO, "END", Debug); } - bool MainWindowInputOthers::setSOTA(const QString &_op) { //qDebug() << Q_FUNC_INFO << ": " << _op; diff --git a/src/inputwidgets/mainwindowinputothers.h b/src/inputwidgets/mainwindowinputothers.h index ea04bc9b..93160eb4 100644 --- a/src/inputwidgets/mainwindowinputothers.h +++ b/src/inputwidgets/mainwindowinputothers.h @@ -135,7 +135,7 @@ private slots: QLineEdit *userDefinedADIFValueLineEdit; QStringList adifValidTypes; - KLOG_DEPRECATED QString currentPref; // Just a cache to be able to rewrite the subdivisions combobox + QString currentPref; int currentInt; // if the showAllCheckBox is toggled QString sota_ref, vucc_grids, pota_ref, sig, sig_info, wwff_ref; diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 34aa006c..37969fa6 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -30,6 +30,7 @@ #include #include #include +#include "callsign.h" #include "updatesettings.h" //#include "database.h" #include "mainwindow.h" @@ -398,7 +399,7 @@ void MainWindow::init_variables() palBlack.setColor(QPalette::Text, Qt::black); clublogAnswer = -1; - qDebug() << Q_FUNC_INFO << " - Changing colors to default"; + //qDebug() << Q_FUNC_INFO << " - Changing colors to default"; #if QT_VERSION >= QT_VERSION_CHECK(6, 6, 0) defaultColor.fromString(QAnyStringView("slategrey")); //To be replaced by .fromString in Qt6.6 neededColor.fromString(QAnyStringView("yellow")); @@ -412,7 +413,7 @@ void MainWindow::init_variables() confirmedColor.setNamedColor("red"); newOneColor.setNamedColor("green"); #endif - qDebug() << Q_FUNC_INFO << " - END"; + //qDebug() << Q_FUNC_INFO << " - END"; } void MainWindow::checkDebugFile() @@ -538,7 +539,7 @@ void MainWindow::init() infoWidget->showInfo(-1); //qDebug() << Q_FUNC_INFO << " - 120"; //lotwTQSLpath = util->getTQSLsPath() + util->getTQSLsFileName(); - world->readWorld (); + //world->readWorld (); upAndRunning = true; mainQSOEntryWidget->setUpAndRunning(upAndRunning); //qDebug() << Q_FUNC_INFO << " - 130"; @@ -1206,7 +1207,8 @@ bool MainWindow::readQSOFromUI() qso->clear (); QString tqrz = (mainQSOEntryWidget->getQrz()).toUpper(); - if (!util->isValidCall(tqrz)) + Callsign callsign(tqrz); + if (!callsign.isValid()) { QMessageBox msgBox; msgBox.setIcon(QMessageBox::Question); @@ -2085,8 +2087,6 @@ void MainWindow::slotQRZTextChanged(QString _qrz) logEvent(Q_FUNC_INFO, QString("Entity: %1").arg(currentEntity), Devel); - //othersTabWidget->setEntityAndPrefix(currentEntity, util->getPrefixFromCall(_qrz, !othersTabWidget->getShowAll())); - //othersTabWidget->setEntityAndPrefix(currentEntity, util->getPrefixFromCall(_qrz, true)); //othersTabWidget->setEntity(currentEntity); dxE_CQz = world->getEntityCqz(currentEntity); dx_CQz = world->getQRZCqz(_qrz); @@ -2965,8 +2965,9 @@ QString MainWindow::selectStationCallsign() bool ok; stationCallToUse = QInputDialog::getItem(this, tr("Station Callsign:"), msg, stationCallSigns, 0, false, &ok); + Callsign callsign(stationCallToUse); - if (ok && util->isValidCall(stationCallToUse)) + if (ok && callsign.isValid()) //if (ok && !stationCallToUse.isEmpty()) { logEvent(Q_FUNC_INFO, "END-1", Debug); @@ -2979,7 +2980,8 @@ QString MainWindow::selectStationCallsign() "", &ok)).toUpper(); if (ok) { - if (util->isValidCall(stationCallToUse)) + callsign(stationCallToUse); + if (callsign.isValid()) { logEvent(Q_FUNC_INFO, "END-2", Debug); return stationCallToUse; @@ -3498,14 +3500,15 @@ void MainWindow::slotOpenWiki() void MainWindow::setColors (const QColor &_newOne, const QColor &_needed, const QColor &_worked, const QColor &_confirmed, const QColor &_default) { - qDebug() << Q_FUNC_INFO << "Confirmed: " << _newOne.name(QColor::HexRgb) << " / Needed: " << _needed.name(QColor::HexRgb) << - " / Worked: " << _worked.name(QColor::HexRgb) << " / Confirmed: " << _confirmed.name(QColor::HexRgb) << - " / Default: " << _default.name(QColor::HexRgb); + //qDebug() << Q_FUNC_INFO << "Confirmed: " << _newOne.name(QColor::HexRgb) << " / Needed: " << _needed.name(QColor::HexRgb)" << + // " / Worked: " << _worked.name(QColor::HexRgb) << " / Confirmed: " << _confirmed.name(QColor::HexRgb) << + // " / Default: " << _default.name(QColor::HexRgb); searchWidget->setColors(_newOne, _needed, _worked, _confirmed, _default); awards->setColors (_newOne, _needed, _worked, _confirmed, _default); mapWindow->setColors (_worked, _confirmed, _default); dxClusterWidget->setColors (_newOne, _needed, _worked, _confirmed, _default); infoWidget->setColors(_newOne, _needed, _worked, _confirmed, _default); + dxccStatusWidget->setColors(_newOne, _needed, _worked, _confirmed, _default); } bool MainWindow::applySettings() @@ -5343,16 +5346,25 @@ void MainWindow::slotAnalyzeDxClusterSignal(const DXSpot &_spot) //qDebug() << Q_FUNC_INFO; logEvent(Q_FUNC_INFO, "Start", Debug); - DXSpot sp = _spot; + DXSpot spot = _spot; + if (spot.isValid()) + qDebug() << Q_FUNC_INFO << " - Spot is Valid"; + else + qDebug() << Q_FUNC_INFO << " - Spot is NOT Valid"; + qDebug() << Q_FUNC_INFO << ": spot-dxCall : " << spot.getDxCall(); + qDebug() << Q_FUNC_INFO << ": spot-Spotter : " << spot.getSpotter(); + qDebug() << Q_FUNC_INFO << ": spot-Freq : " << spot.getFrequency().toQString(); + qDebug() << Q_FUNC_INFO << ": spot-Comment : " << spot.getComment(); + EntityStatus _entityStatus; - _entityStatus.entityId = world->getQRZARRLId(sp.getDxCall()); + _entityStatus.entityId = world->getQRZARRLId(spot.getDxCall()); if (!manageMode) { _entityStatus.modeId = -1; } - if (sp.getClickStatus() == SingleClick) + if (spot.getClickStatus() == SingleClick) { infoLabel2->setText(world->getEntityName(_entityStatus.entityId)); infoWidget->showEntityInfo(_entityStatus.entityId ); @@ -5360,14 +5372,13 @@ void MainWindow::slotAnalyzeDxClusterSignal(const DXSpot &_spot) // Becareful, he Frecuency arrives in KHz instead of bandid!! // db.getBandFromFreq expects a MHz! //(ql.at(1)).toDouble() - _entityStatus.bandId = dataProxy->getBandIdFromFreq((sp.getFrequency().toDouble())); + _entityStatus.bandId = dataProxy->getBandIdFromFreq((spot.getFrequency().toDouble())); //qls << QRZ << BandId << ModeId << lognumber; showStatusOfDXCC(_entityStatus); } - else if (sp.getClickStatus() == DoubleClick) + else if (spot.getClickStatus() == DoubleClick) { - clusterSpotToLog(sp.getDxCall(), sp.getFrequency().toQString()); - + clusterSpotToLog(spot.getDxCall(), spot.getFrequency()); } int statusI = awards->getDXStatus (_entityStatus); @@ -5376,9 +5387,9 @@ void MainWindow::slotAnalyzeDxClusterSignal(const DXSpot &_spot) pQSO.status = awards->getQSOStatus(statusI); - if (util->isValidCall(sp.getDxCall(), true)) + if (util->isValidCall(spot.getDxCall(), true)) { - pQSO.call = sp.getDxCall(); + pQSO.call = spot.getDxCall(); dxClusterAssistant->newDXClusterSpot(pQSO); } @@ -5425,29 +5436,29 @@ void MainWindow::slotDXClusterSpotArrived(const DXSpot &_spot) logEvent(Q_FUNC_INFO, "END", Debug); } -//void MainWindow::clusterSpotToLog(const QStringList _qs) -void MainWindow::clusterSpotToLog(const QString &_call, const QString &_freq) +void MainWindow::clusterSpotToLog(const QString &_call, Frequency _fr) { logEvent(Q_FUNC_INFO, "Start", Debug); QString _aux; - double _freqN = (_freq.toDouble()) / 1000; + double _freqN = _fr.toDouble(MHz); //qDebug() << Q_FUNC_INFO << " - calling setQRZ-2" ; mainQSOEntryWidget->setQRZ(_call); QSOTabWidget->setTXFreq (_freqN); + QSOTabWidget->setRXFreq(_freqN); //freqQLCDNumber->display(_freqN); - _aux = QString::number(_freqN); + //_aux = QString::number(_freqN); - //qDebug() << "MainWindow::clusterSpotToLog - Freq: " << _aux ; + //qDebug() << Q_FUNC_INFO << " - Freq: " << _aux ; - int _bandi = dataProxy->getBandIdFromFreq(_aux.toDouble()); - //qDebug() << "MainWindow::clusterSpotToLog - Bandi: " << QString::number(_bandi) ; + int _bandi = dataProxy->getBandIdFromFreq(_freqN); + //qDebug() << Q_FUNC_INFO << " - Bandi: " << QString::number(_bandi) ; _aux = QString::number(_bandi); _aux = QString("SELECT name FROM band WHERE id ='%1'").arg(_aux); - //qDebug() << "MainWindow::clusterSpotToLog - Band: " << _aux ; + //qDebug() << Q_FUNC_INFO << " - Band: " << _aux ; QSqlQuery query(_aux); query.next(); @@ -5463,7 +5474,7 @@ void MainWindow::clusterSpotToLog(const QString &_call, const QString &_freq) //bandComboBox->setCurrentIndex(bandComboBox->findText(dataProxy->getNameFromBandId(defaultBand), Qt::MatchCaseSensitive)); //bandComboBox->setCurrentIndex(defaultBand); } - //qDebug() << "MainWindow::clusterSpotToLog - END " ; + //qDebug() << Q_FUNC_INFO << " - END " ; logEvent(Q_FUNC_INFO, "END", Debug); } //DX-CLUSTER - DXCLUSTER @@ -6575,7 +6586,6 @@ bool MainWindow::loadSettings() readActiveBands (settings.value("Bands", listAux).toStringList ()); settings.endGroup (); - //qDebug() << Q_FUNC_INFO << " - 40 - logview";setColors logWindow->setColumns(settings.value ("LogViewFields").toStringList ()); //qDebug() << Q_FUNC_INFO << " - 41 - logs"; @@ -6597,31 +6607,19 @@ bool MainWindow::loadSettings() //qDebug() << Q_FUNC_INFO << " - 60 - colors"; settings.beginGroup ("Colors"); + newOneColor = settings.value("NewOneColor").value(); + neededColor = settings.value("NeededColor").value(); + workedColor = settings.value("WorkedColor").value(); + confirmedColor = settings.value("ConfirmedColor").value(); + defaultColor = settings.value("DefaultColor").value(); + + //qDebug() << Q_FUNC_INFO << " - NewOneColor: " << newOneColor.name(QColor::HexRgb); + //qDebug() << Q_FUNC_INFO << " - NewOneColor: " << newOneColor.name(); + //qDebug() << Q_FUNC_INFO << " - NeededColor: " << neededColor.name(QColor::HexRgb); + //qDebug() << Q_FUNC_INFO << " - WorkedColor: " << workedColor.name(QColor::HexRgb); + //qDebug() << Q_FUNC_INFO << " - ConfirmedColor: " << confirmedColor.name(QColor::HexRgb); + //qDebug() << Q_FUNC_INFO << " - DefaultColor: " << defaultColor.name(QColor::HexRgb); -#if QT_VERSION >= QT_VERSION_CHECK(6, 6, 0) - qDebug() << Q_FUNC_INFO << " - 61 - NewOneColor: " << settings.value("NewOneColor").toString(); - if (QColor::isValidColor(settings.value("NewOneColor").toString())) - { - qDebug() << Q_FUNC_INFO << " - Color is valid: "; - } - else - { - qDebug() << Q_FUNC_INFO << " - Color is NOT valid: "; - } - newOneColor.fromString(QAnyStringView((settings.value ("NewOneColor", "#FF0000").toString ()))); - qDebug() << Q_FUNC_INFO << " - 62 - NewOneColor: " << settings.value("NewOneColor").toString(); - neededColor.fromString(QAnyStringView((settings.value ("NeededColor","#FF8C00").toString ()))); - workedColor.fromString(QAnyStringView((settings.value ("WorkedColor", "#FFD700").toString ()))); - confirmedColor.fromString(QAnyStringView((settings.value ("ConfirmedColor", "#32CD32").toString ()))); - defaultColor.fromString(QAnyStringView((settings.value ("DefaultColor", "#00BFFF").toString ()))); -#else - qDebug() << Q_FUNC_INFO << " - 61-2 - NewOneColor: " << settings.value("NewOneColor").toString(); - newOneColor.setNamedColor(settings.value ("NewOneColor", "#FF0000").toString ()); - neededColor.setNamedColor(settings.value ("NeededColor","#FF8C00").toString ()); - workedColor.setNamedColor(settings.value ("WorkedColor", "#FFD700").toString ()); - confirmedColor.setNamedColor(settings.value ("ConfirmedColor", "#32CD32").toString ()); - defaultColor.setNamedColor(settings.value ("DefaultColor", "#00BFFF").toString ()); -#endif settings.endGroup (); setColors(newOneColor, neededColor, workedColor, confirmedColor, defaultColor); diff --git a/src/mainwindow.h b/src/mainwindow.h index 71096aa7..2400c624 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -441,7 +441,7 @@ private slots: // CLUSTER - void clusterSpotToLog(const QString &_call, const QString &_freq); + void clusterSpotToLog(const QString &_call, Frequency _fr); QStringList dxclusterServersList; //QString dxclusterServerToConnect; //int dxclusterServerPort; diff --git a/src/qso.cpp b/src/qso.cpp index da52f7cb..463edffd 100644 --- a/src/qso.cpp +++ b/src/qso.cpp @@ -28,7 +28,8 @@ #include "qsqlrecord.h" #include "callsign.h" -QSO::QSO() +QSO::QSO(QObject *parent) + : QObject(parent) { logLevel = None; qsoId = -1; @@ -38,7 +39,8 @@ QSO::QSO() //db = new DataBase(Q_FUNC_INFO, klogVersion, util->getKLogDBFile()); } -QSO::QSO(const QSO& other) +QSO::QSO(const QSO &other) + : QObject(other.parent()) { util = new Utilities(Q_FUNC_INFO); util->setCallValidation(false); @@ -717,7 +719,8 @@ bool QSO::isValid() bool QSO::setCall(const QString &_c) { logEvent (Q_FUNC_INFO, QString("Start: %1").arg(_c), Debug); - if (util->isValidCall(_c)) + Callsign call(_c); + if (call.isValid()) { logEvent (Q_FUNC_INFO, QString("END - true"), Debug); callsign = _c; @@ -1745,8 +1748,8 @@ bool QSO::setOperatorCallsign(const QString &_c) { //qDebug() << Q_FUNC_INFO << "Start: " << _c; //logEvent(Q_FUNC_INFO, "Start", Debug); - - if (util->isValidCall(_c)) + Callsign call(_c); + if (call.isValid()) { operatorCall = _c; //qDebug() << Q_FUNC_INFO << "END - true"; @@ -1770,9 +1773,9 @@ bool QSO::setStationCallsign(const QString &_c) { //qDebug() << Q_FUNC_INFO << "Start: " << _c; - if (util->isValidCall(_c)) + Callsign call(_c); + if (call.isValid()) //qDebug() << Q_FUNC_INFO << " - 010"; - //if (util->isValidCall(aux)) { //qDebug() << Q_FUNC_INFO << " - True"; stationCallsign = _c; @@ -2030,8 +2033,9 @@ double QSO::getDistance() } bool QSO::setOwnerCallsign(const QString &_c) -{ - if (util->isValidCall(_c)) +{ + Callsign call(_c); + if (call.isValid()) { ownerCall = _c; return true; @@ -2048,7 +2052,8 @@ QString QSO::getOwnerCallsign() bool QSO::setEQ_Call(const QString &_c) { - if (util->isValidCall(_c)) + Callsign call(_c); + if (call.isValid()) { contacted_owner = _c; return true; @@ -2248,7 +2253,8 @@ QString QSO::getCounty() bool QSO::setContactedOperator(const QString &_c) { - if (util->isValidCall(_c)) + Callsign call(_c); + if (call.isValid()) { contacted_op = _c; return true; diff --git a/src/qso.h b/src/qso.h index c8cc25f6..fbe163b0 100644 --- a/src/qso.h +++ b/src/qso.h @@ -32,16 +32,9 @@ #include #include #include -//#include -#include "global.h" #include "utilities.h" -#include "callsign.h" #include "klogdefinitions.h" #include "adif.h" -//#include "database.h" - - -//#include class QSO : public QObject { @@ -49,9 +42,10 @@ class QSO : public QObject friend class tst_QSO; public: - QSO(); + QSO(QObject *parent = nullptr); QSO(const QSO& other); ~QSO(); + //QSO& operator=(const QSO &other); bool copy(const QSO& other); void setLogLevel (const DebugLogLevel _b); void setRealTime(const bool _rt); // Not QSO info but KLog status diff --git a/src/setuppages/setuppagebandmode.cpp b/src/setuppages/setuppagebandmode.cpp index abbecec1..46531b70 100644 --- a/src/setuppages/setuppagebandmode.cpp +++ b/src/setuppages/setuppagebandmode.cpp @@ -46,7 +46,7 @@ SetupPageBandMode::SetupPageBandMode(DataProxy_SQLite *dp, QWidget *parent) : QW modesLabel->setText(tr("Modes")); modesLabel->setAlignment(Qt::AlignVCenter| Qt::AlignCenter); - addBands(dataProxy->getBands()); + addBands(dataProxy->getBandNames()); addModes(dataProxy->getModes()); bLayout->addWidget(bandsLabel); diff --git a/src/setuppages/setuppageuserdata.cpp b/src/setuppages/setuppageuserdata.cpp index b15356dc..7a1681fe 100644 --- a/src/setuppages/setuppageuserdata.cpp +++ b/src/setuppages/setuppageuserdata.cpp @@ -25,9 +25,10 @@ *****************************************************************************/ #include "setuppageuserdata.h" +#include "../callsign.h" SetupPageUserDataPage::SetupPageUserDataPage(DataProxy_SQLite *dp, QWidget *parent) : QWidget(parent){ - //qDebug() << Q_FUNC_INFO << " - Start"; + qDebug() << Q_FUNC_INFO << " - Start"; slotQRZRunning = false; locator = new Locator(); util = new Utilities(Q_FUNC_INFO); @@ -254,14 +255,15 @@ void SetupPageUserDataPage::setPrefixes() { util->setLongPrefixes(dataProxy->getLongPrefixes()); util->setSpecialCalls(dataProxy->getSpecialCallsigns()); - world->readWorld (); + //world->readWorld (); } QString SetupPageUserDataPage::getMainCallsign() { - if (util->isValidCall(maincallsignLineEdit->text())) + Callsign callsign (maincallsignLineEdit->text()); + if (callsign.isValid()) { - return maincallsignLineEdit->text(); + return maincallsignLineEdit->text().toUpper(); } else { @@ -283,7 +285,7 @@ void SetupPageUserDataPage::slotQRZTextChanged() return; } slotQRZRunning = true; - //qDebug() << "SetupPageUserDataPage::slotQRZTextChanged: " << maincallsignLineEdit->text() << " / Length: " << QString::number((maincallsignLineEdit->text()).size()); + //qDebug() << Q_FUNC_INFO << " - " << maincallsignLineEdit->text() << " / Length: " << QString::number((maincallsignLineEdit->text()).size()); int i = maincallsignLineEdit->cursorPosition(); @@ -612,7 +614,7 @@ bool SetupPageUserDataPage::setAntenna3 (const QString &_aux) void SetupPageUserDataPage::slotOperatorsChanged() { - //qDebug() << "SetupPageUserDataPage::slotOperatorsChanged"; + //qDebug() << Q_FUNC_INFO << " - Start"; //QString _operators = operatorsLineEdit->text(); @@ -632,30 +634,30 @@ void SetupPageUserDataPage::slotOperatorsChanged() QStringList operators = _a.split(",", QT_SKIP); - //qDebug() << "SetupPageUserDataPage::slotOperatorsChanged-02"; - //qDebug() << "SetupPageUserDataPage::slotOperatorsChanged-02.5 Size: " << QString::number(operators.size()); + //qDebug() << Q_FUNC_INFO << " -02"; + //qDebug() << Q_FUNC_INFO << " -02.5 Size: " << QString::number(operators.size()); for (int ii = 0; ii < operators.size(); ++ii) { - //qDebug() << "SetupPageUserDataPage::slotOperatorsChanged-03 - " << QString::number(ii); + //qDebug() << Q_FUNC_INFO << " -03 - " << QString::number(ii); operatorsOK = util->isValidCall(operators.at(ii)); //operatorsOK = world->checkQRZValidFormat(operators.at(ii)); } - //qDebug() << "SetupPageUserDataPage::slotOperatorsChanged-04"; + //qDebug() << Q_FUNC_INFO << " -04"; if (operatorsOK) { - //qDebug() << "SetupPageUserDataPage::slotOperatorsChanged: VALID FORMAT"; + //qDebug() << Q_FUNC_INFO << " VALID FORMAT"; operatorsLineEdit->setPalette(*defaultPalette); emit operatorsSignal(operatorsLineEdit->text()); } else { operatorsLineEdit->setPalette(*wrongPalette); - //qDebug() << "SetupPageUserDataPage::slotOperatorsChanged: NOT VALID FORMAT"; + //qDebug() << Q_FUNC_INFO << " NOT VALID FORMAT"; } - //qDebug() << "SetupPageUserDataPage::slotOperatorsChanged-05"; + //qDebug() << Q_FUNC_INFO << " -05"; operatorsLineEdit->setCursorPosition(i); - //qDebug() << "SetupPageUserDataPage::slotOperatorsChanged-END"; + //qDebug() << Q_FUNC_INFO << " -END"; } QString SetupPageUserDataPage::getOperators() diff --git a/src/src.pro b/src/src.pro index 30c5b38d..c782fd41 100644 --- a/src/src.pro +++ b/src/src.pro @@ -95,10 +95,10 @@ HEADERS += setupdialog.h \ database/db_adif_primary_subdvisions_data.h \ database/queryexecutor.h \ dataproxy_sqlite.h \ - downloadcty.h \ \ - dxcluster/dxspot.h \ + downloadcty.h \ \ frequency.h \ dxccstatuswidget.h \ + dxcluster/dxspot.h \ dxcluster/dxcluster.h \ dxcluster/dxclusterassistant.h \ elogqrzlog.h \ @@ -177,9 +177,9 @@ SOURCES += main.cpp \ charts/statsfieldperbandwidget.cpp \ database/db_adif_primary_subdvisions_data.cpp \ database/queryexecutor.cpp \ + dxcluster/dxspot.cpp \ dxcluster/dxcluster.cpp \ dxcluster/dxclusterassistant.cpp \ - dxcluster/dxspot.cpp \ elogqrzlog.cpp \ eqslutilities.cpp \ frequency.cpp \ diff --git a/src/utilities.cpp b/src/utilities.cpp index bd8e0bd7..825e3788 100644 --- a/src/utilities.cpp +++ b/src/utilities.cpp @@ -708,155 +708,27 @@ bool Utilities::isValidDateTime(const QString &_d) return false; } -bool Utilities::isValidSimpleCall(const QString &_c) -{ - //logEvent (QString("%1-%2").arg(Q_FUNC_INFO).arg(parentName), QString("Start: %1").arg(_c), Debug); - // This functions only checks simple calls like EA4K, not composed like EA4K/F of F/EA4K/QRP - //Rules: http://life.itu.int/radioclub/rr/art19.pdf - //qDebug() << QString("%1-%2").arg(Q_FUNC_INFO).arg(parentName) << QString(" - 000 - %1").arg(_c); - if ((_c.contains('/')) || (_c.contains('\\'))) - { - //qDebug() << Q_FUNC_INFO << " -001"; - return false; - } - int length = _c.length(); - //qDebug() << QString("%1-%2").arg(Q_FUNC_INFO).arg(parentName) << " - 010"; - if (length<3) - { - //logEvent (QString("%1-%2").arg(Q_FUNC_INFO).arg(parentName), QString("Less than 3 chars - FALSE"), Debug); - //qDebug() << Q_FUNC_INFO << " - END2"; - return false; - } - //qDebug() << Q_FUNC_INFO << " - 020"; - QString call = _c; - if (isAKnownCall(call)) - { - //qDebug() << Q_FUNC_INFO << " - 020.5"; - return true; - } - //qDebug() << Q_FUNC_INFO << " - 021"; - // Does it contain any digit? - bool hasDigit = false; - for (int i=0;i<=length-1;i++) - { - if (!_c.at(i).isLetterOrNumber ()) - { - // Non valid chars - //logEvent (QString("%1-%2").arg(Q_FUNC_INFO).arg(parentName), QString("Non valid chars - FALSE"), Debug); - //qDebug() << Q_FUNC_INFO << " - END3"; - return false; - } - if ((_c.at(i)).isDigit()) - hasDigit = true; - } - if (!hasDigit) - { - //qDebug() << Q_FUNC_INFO << " - END4"; - return false; - } - //qDebug() << Q_FUNC_INFO << " - 030"; - if (!(_c.at(length-1).isLetter ())) - { - logEvent (QString("%1-%2").arg(Q_FUNC_INFO).arg(parentName), QString("Does not end with a char - FALSE"), Debug); - //qDebug() << Q_FUNC_INFO << " - END6"; - return false; - } - //qDebug() << Q_FUNC_INFO << " - 040"; - if (length<=5) - { //This may fail with JY1 Special call or others special 4 or 5 letter callsigns listed in - //qDebug() << Q_FUNC_INFO << " - 031 - " << _c; - if (isAKnownPrefix(_c)) - { - //qDebug() << Q_FUNC_INFO << " - END5"; - return false; - } - } - //qDebug() << QString("%1-%2").arg(Q_FUNC_INFO).arg(parentName) << " - 040"; - //logEvent (QString("%1-%2").arg(Q_FUNC_INFO).arg(parentName), QString("prefixLength: %1").arg(prefixLength), Devel); - //logEvent (QString("%1-%2").arg(Q_FUNC_INFO).arg(parentName), QString("Call: %1").arg(_c), Devel); - bool firstCharNumber = _c.at(0).isDigit(); - bool secondCharNumber = _c.at(1).isDigit(); - bool thirdCharNumber = _c.at(2).isDigit(); - - //EA4, 2E3, E33, K1A, 3DA, FB1K !2EE - if (firstCharNumber && secondCharNumber) - { // 11, 22 - //qDebug() << Q_FUNC_INFO << "END - 060 "; - return false; - } - else if(firstCharNumber && !secondCharNumber && !thirdCharNumber) - { // 2EE - if (_c.left(3) != "3DA") - { - //qDebug() << Q_FUNC_INFO << "END - 070 "; - return false; - } - } - //qDebug() << Q_FUNC_INFO << "END"; - logEvent (QString("%1-%2").arg(Q_FUNC_INFO).arg(parentName), QString("END - TRUE"), Debug); - return true; -} - -bool Utilities::isAValidOperatingSuffix (const QString &_c) -{ - //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); -} - -bool Utilities::isAPrefix (const QString &_c) -{ - // Returns -1 if it is not a prefix or valid call. - // Returns an int with the lenght of the prefix: - // The length would be including the number, if possible EA4 or; - // including just the country prefix: EA if the number is not included. - // Prefixes are at least 1 chars (like in K), for K1K it should be 2 (K1) - //logEvent (QString("%1-%2").arg(Q_FUNC_INFO).arg(parentName), QString("Start: %1").arg(_c), Debug); - //qDebug() << Q_FUNC_INFO << "Call/Pref" << _c; - QString aux = _c; - if (aux.length()<1) - { - return false; - } - //qDebug() << Q_FUNC_INFO << "Call/Pref" << _c << "/" << getPrefixFromCall(_c); - int length = (getPrefixFromCall(aux)).length(); - return (length>0); -} void Utilities::setLongPrefixes (const QStringList &_p) { - //qDebug() << Q_FUNC_INFO << ": Start count: " << QString::number(_p.count()); + //qDebug() << Q_FUNC_INFO << ": Start count: " << QString::number(_p.count()); + //qDebug() << Q_FUNC_INFO << ": Called from: " << parentName; + //TODO: The list of known prefixes may be in thge World class longPrefixes.clear(); longPrefixes.append(_p); - //qDebug() << Q_FUNC_INFO << ": count: " << QString::number(longPrefixes.count()); + //qDebug() << Q_FUNC_INFO << ": count: " << QString::number(longPrefixes.count()); } void Utilities::setSpecialCalls (const QStringList &_p) -{ - //qDebug() << Q_FUNC_INFO << ": Start count: " << QString::number(_p.count()); +{//TODO: The list of known Special Calls may be in thge World class + //qDebug() << Q_FUNC_INFO << ": Start count: " << QString::number(_p.count()); specialCalls.clear(); specialCalls.append(_p); - //qDebug() << Q_FUNC_INFO << ": count: " << QString::number(specialCalls.count()); + //qDebug() << Q_FUNC_INFO << ": count: " << QString::number(specialCalls.count()); } -bool Utilities::isAKnownPrefix(const QString &_c) -{// TODO: Complete with https://rsgb.org/main/operating/licensing-novs-visitors/international-prefixes/ - //qDebug() << Q_FUNC_INFO << ": " << _c; - // QString aux; - if (_c.isNull() ) - { - //qDebug() << Q_FUNC_INFO << ": END - 1"; - return false; - } - if (longPrefixes.count()<100) - { - //qDebug() << Q_FUNC_INFO << ": ********** END - FAIL"; - } - //qDebug() << Q_FUNC_INFO << QString(": END - 2 - %1 - %2").arg(_c).arg(boolToQString(longPrefixes.contains(_c))); - return longPrefixes.contains(_c); -} bool Utilities::isAKnownCall(const QString &_c) { @@ -880,6 +752,8 @@ void Utilities::setCallValidation(const bool _b) validateCalls = _b; } +/* + QString Utilities::getCheckedComplexCall(const QString &_c) { // Normalices calls //qDebug() << Q_FUNC_INFO << " - Start: " << _c; @@ -915,6 +789,7 @@ QString Utilities::getCheckedComplexCall(const QString &_c) //qDebug() << Q_FUNC_INFO << " - END: " << call; return call; } +*/ QString Utilities::getMainCallFromComplexCall(const QString &_complexCall) { //TODO: To be replaced by QString Callsign::getHostFullPrefix(bool getHomeIfEmpty=true); @@ -930,93 +805,6 @@ QString Utilities::getMainCallFromComplexCall(const QString &_complexCall) return calls.getHostFullPrefix(); return QString(); - QString call = _complexCall; - if (call.length() == 1) - { - if ((call.at(0)).isLetterOrNumber()) - { - return call; - } - else - { - return QString(); - } - } - - //qDebug() << Q_FUNC_INFO << ": " << _complexCall; - if (call.count('/') >1) - { //Things like F/EA4K/P will become F/EA4K - //logEvent (Q_FUNC_INFO, QString("With 2 /"), Debug); - call = call.section("/", 0,1); - } - //qDebug() << Q_FUNC_INFO << ": First cut: " << call; - call = getCheckedComplexCall(call); - //qDebug() << Q_FUNC_INFO << ": Second cut: " << call; - //qDebug() << Q_FUNC_INFO << " - 010" ; - if (call.count('/') == 1) - {// Complex calls (like F/EA4K - EA4K/F -EA4K/P - EA4K/1 - EA4K/qrp - VK9M/EA4K - EA4K/VK9M - // K1B/QRP - B1A/VK9M - QStringList parts; - parts.clear(); - parts << call.split('/'); - QString first = parts.at(0); - QString second = parts.at(1); - // First identify normal suffixes /P, /1, /QRP... - bool firstCountry = !isAValidOperatingSuffix(first); - bool secondCountry = !isAValidOperatingSuffix(second); - //qDebug() << QString("First = %1, Second = %2").arg(boolToQString(firstCountry)).arg(boolToQString(secondCountry)); - if (!firstCountry) - { - if ((parts.at(0)) == "MM") - { // Special case for Scotland EA4K/MM colliding as maritime movil - // Scotland requires the prefix first like in MM/EA4K - firstCountry=true; - } - } - //qDebug() << Q_FUNC_INFO << " - 020" ; - if (firstCountry && secondCountry) - { // EA4K/VK9M - //qDebug() << Q_FUNC_INFO << " - 030" ; - bool firstIsPrefix = isAKnownPrefix(first); - bool secondIsPrefix = isAKnownPrefix(second); - if (firstIsPrefix && !secondIsPrefix) - { - //qDebug() << Q_FUNC_INFO << " END first - 033" ; - return first; - } - else if (!firstIsPrefix && secondIsPrefix) - { - //qDebug() << Q_FUNC_INFO << "END second - 034" ; - return second; - } - else - { - if (first.length()>second.length()) - { - call = second; - } - else - { - call = first; - } - } - } - else if (isAValidOperatingSuffix(first)) - {// 1/EA4K - // TODO: Here the perfect way should be to obtain the country and - // add the number, if area is requested - call = second; - } - else if (isAValidOperatingSuffix(second)) - {// EA4K/2 - call = first; - } - else - { // None is a normal country prefix - return QString(); - } - } - return call; } bool Utilities::isValidCall(const QString &_c, bool _force) @@ -1024,7 +812,6 @@ bool Utilities::isValidCall(const QString &_c, bool _force) //logEvent (QString("%1-%2").arg(Q_FUNC_INFO).arg(parentName), QString("Start = %1").arg(_c), Debug); //qDebug() << QString("%1-%2").arg(Q_FUNC_INFO).arg(parentName) << "Start: " << _c; //qDebug() << Q_FUNC_INFO << ": " << _c; - // Prefixes are at least 2 chars if ((!validateCalls) && (!_force)) { @@ -1033,22 +820,6 @@ bool Utilities::isValidCall(const QString &_c, bool _force) return true; } - //qDebug() << Q_FUNC_INFO << " - Long prefixes: " << QString::number(longPrefixes.count()); - if (longPrefixes.count()<100) - { // Reporting a problem with the DB - //TODO: This should be managed differently, maybe issuing a signal and show a message stating a - // potential error with the DB - //qDebug() << Q_FUNC_INFO << "Long prefixes < 100 " << _c; - return false; - } - //qDebug() << Q_FUNC_INFO << "000 " << _c; - if (isAKnownCall(_c)) - { - //qDebug() << Q_FUNC_INFO << "001 - Known call: " << _c; - return true; - } - //qDebug() << Q_FUNC_INFO << "- 002 " << call; - Callsign callsign(_c); return callsign.isValid(); } @@ -1075,215 +846,20 @@ int Utilities::getAreaNumberFromCall(const QString &_c) QString Utilities::getPrefixFromCall(const QString &_c, bool withAreaNumber) { //qDebug() << Q_FUNC_INFO << ": " << _c << " - WithAreaNumber=" << boolToQString(withAreaNumber); - if (_c.isNull()) - { - //qDebug() << Q_FUNC_INFO << " - END null"; - return QString(); - } - //qDebug() << Q_FUNC_INFO << " - 010"; + Callsign _callsign(_c); if (!_callsign.isValid() && !_callsign.isValidPrefix()) { //qDebug() << Q_FUNC_INFO << " - 020"; return QString(); } - QString pref; - - int areaNumber = _callsign.getHostAreaNumber(); - //qDebug() << Q_FUNC_INFO << " - 030" << " - AreaNumber: " << QString::number(areaNumber); - if (areaNumber>=0) - { - pref = _callsign.getHostFullPrefix(); - //qDebug() << Q_FUNC_INFO << " - 040" << " - pref: " << pref; - } + if (withAreaNumber) + return _callsign.getHostFullPrefix(); else - { - pref = _callsign.getHostPrefix(); - //qDebug() << Q_FUNC_INFO << " - 050" << " - pref: " << pref; - } - if (isAKnownPrefix(pref)) - { - //qDebug() << Q_FUNC_INFO << " - 060"; - return pref; - } - else - { - //qDebug() << Q_FUNC_INFO << " - 070"; - pref = _callsign.getHostPrefix(); - //qDebug() << Q_FUNC_INFO << " - 071" << " - pref: " << pref; - if (isAKnownPrefix(pref)) - { - //qDebug() << Q_FUNC_INFO << " - 075"; - return pref; - } - } - //qDebug() << Q_FUNC_INFO << " - 0100 - " << pref; - return pref; - - - - //qDebug() << Q_FUNC_INFO << " - 000"; - QString call = _c; - int length = call.length(); - //qDebug() << Q_FUNC_INFO << " - 010"; - bool firstSpecial = isAOneLetterPrefix(call.at(0)); - if (length==1) - { - //qDebug() << Q_FUNC_INFO << " - 011"; - if (firstSpecial) - { - //qDebug() << Q_FUNC_INFO << " - 012 - END"; - return _c; - } - else - { - //qDebug() << Q_FUNC_INFO << " - 016 - END"; - return QString(); - } - } - //qDebug() << Q_FUNC_INFO << " - 020 - Going to calculate - length = " << QString::number(length); - if (length>2) - { - //qDebug() << Q_FUNC_INFO << " - 021 - Going to Look for a known call" ; - if (isAKnownCall(_c)) - { - //qDebug() << Q_FUNC_INFO << " - 022 - END: Known CALL found: " << _c; - return _c; - } - //qDebug() << Q_FUNC_INFO << " - 29 - Call not found!" ; - } - - //qDebug() << Q_FUNC_INFO << " - 030"; - call = getMainCallFromComplexCall(call); - //qDebug() << Q_FUNC_INFO << " - 031 CallfromComplexCall: " << call; - QString callShort; // Call with lenght -1 - QString callVeryShort; - - int i = length; - while (i>0) - { - //qDebug() << Q_FUNC_INFO << QString(" 40 - While (i=%1) = ").arg(i) << call; - if (isAKnownPrefix(call)) - {// EA, EA6, VK9N, VP2E, K, K1, KN1, 4U1I, W6 (W6 and other normal prefix are also a known prefix due to the specific CQ/ITU) - //qDebug() << Q_FUNC_INFO << QString(" - 41 - Known prefix found: %1").arg(call); - return call; - } - - if(withAreaNumber) - { - if (isAKnownPrefix(callShort)) - return call; - } - call.chop(1); - callShort = call; - callShort.chop(1); - i = call.length(); - } - return QString(); -} - -/* - -QString Utilities::getPrefixFromCall(const QString &_c, bool withAreaNumber) -{ - //qDebug() << Q_FUNC_INFO << ": " << _c << " - WithAreaNumber=" << boolToQString(withAreaNumber); - if (_c.isNull()) - { - //qDebug() << Q_FUNC_INFO << " - END null"; - return QString(); - } - //qDebug() << Q_FUNC_INFO << " - 000"; - QString call = _c; - int length = call.length(); - //qDebug() << Q_FUNC_INFO << " - 010"; - bool firstSpecial = isAOneLetterPrefix(call.at(0)); - if (length==1) - { - //qDebug() << Q_FUNC_INFO << " - 011"; - if (firstSpecial) - { - //qDebug() << Q_FUNC_INFO << " - 012 - END"; - return _c; - } - else - { - //qDebug() << Q_FUNC_INFO << " - 016 - END"; - return QString(); - } - } - //qDebug() << Q_FUNC_INFO << " - 020 - Going to calculate - length = " << QString::number(length); - if (length>2) - { - //qDebug() << Q_FUNC_INFO << " - 021 - Going to Look for a known call" ; - if (isAKnownCall(_c)) - { - //qDebug() << Q_FUNC_INFO << " - 022 - END: Known CALL found: " << _c; - return _c; - } - //qDebug() << Q_FUNC_INFO << " - 29 - Call not found!" ; - } - - //qDebug() << Q_FUNC_INFO << " - 030"; - call = getMainCallFromComplexCall(call); - //qDebug() << Q_FUNC_INFO << " - 031 CallfromComplexCall: " << call; - - QString call2 = call; - QString call3 = call; - int i = length; - while (i>0) - { - //qDebug() << Q_FUNC_INFO << QString(" 40 - While (i=%1) = ").arg(i) << call; - if (isAKnownPrefix(call)) - {// EA, EA6, VK9N, VP2E, K, K1, KN1, 4U1I, W6 (W6 and other normal prefix are also a known prefix due to the specific CQ/ITU) - //qDebug() << Q_FUNC_INFO << QString(" - 41 - Known prefix found: %1").arg(call); - if (withAreaNumber) - { - //qDebug() << Q_FUNC_INFO << QString(" - 42 - With Area number"); - if ( (call2.back()).isDigit() ) - { - //qDebug() << Q_FUNC_INFO << QString(" - 43 - With Area number -call2- & last is a digit: ") << call2; - return call2; - } - else if((call3.back()).isDigit()) - { - //qDebug() << Q_FUNC_INFO << QString(" - 44 - With Area number -call3- & last is a digit"); - return call3; - } - //qDebug() << Q_FUNC_INFO << QString(" - 44 - With Area number -call returned: ") << call; - return call; - } - else - { // Here I am receiving known prefixes and I need to remove the area number - //qDebug() << Q_FUNC_INFO << QString(" - 45 - Looking without area number") ; - if ( !((call.back()).isDigit()) ) - { - //qDebug() << Q_FUNC_INFO << QString(" - 46 - Without Area number -call- & last is NOT a digit. Returning: %1").arg(call); - return call; - } - } - //qDebug() << Q_FUNC_INFO << QString(" - 47 - With NO Area number"); - - } - //qDebug() << Q_FUNC_INFO << QString(" - 50 - Known prefix NOT found: %1").arg(call); - call3 = call2; - call2 = call; - call.chop(1); - i--; - //qDebug() << Q_FUNC_INFO << QString(" - 55 - Reducing call: %1").arg(call); - } - //qDebug() << Q_FUNC_INFO << QString(" - END empty"); - return QString(); + return _callsign.getHostPrefix(); } -*/ - - -bool Utilities::isAOneLetterPrefix(const QChar &_c) -{ - QList validFirstLettersOnly = {'B', 'F', 'G', 'I', 'K', 'M', 'N', 'R', 'W'}; - return validFirstLettersOnly.contains (_c); -} bool Utilities::isSameFreq(const double fr1, const double fr2) { diff --git a/src/utilities.h b/src/utilities.h index c3cdecad..ba3e8f61 100644 --- a/src/utilities.h +++ b/src/utilities.h @@ -134,11 +134,11 @@ class Utilities : public QObject { bool areThoseListsTheSame(const QStringList &_list1, const QStringList &_list2); //QString getADIFField(const QString &_fieldName, const QString &_data); - KLOG_DEPRECATED QString getMainCallFromComplexCall(const QString &_complexCall); //TODO: To be replaced by QString Callsign::getHostFullPrefix(bool getHomeIfEmpty=true); + KLOG_DEPRECATED QString getMainCallFromComplexCall(const QString &_complexCall); //TODO: To be replaced by QString Callsign::getHostFullPrefix(bool getHomeIfEmpty=true); QString getAValidCall (const QString &_wrongCall); QString getPrefixFromCall(const QString &_c, bool withAreaNumber = false); int getAreaNumberFromCall(const QString &_c); - bool isAOneLetterPrefix(const QChar &_c); + // Write DATE/TIME to DB @@ -198,11 +198,9 @@ class Utilities : public QObject { void setLogColumnNames(); // Creates the map of column Names (should be called from init() ) QString getKLogDefaultDatabaseFile(); //bool isCountrySuffix (const QString &_c); - bool isAValidOperatingSuffix (const QString &_c); - bool isAPrefix(const QString &_c); // Returns true if it is the country prefix or it includes the area number - bool isAKnownPrefix(const QString &_c); + bool isAKnownCall(const QString &_c); - bool isValidSimpleCall(const QString &_c); + //QStringList getPrefixRunningTheCall(const QString &_c, bool withAreaNumber = false); //Goes char by char identifying the prefix and area Number @@ -211,7 +209,7 @@ class Utilities : public QObject { void setARRLSect(); void setContinent(); void setSponsorsList(); - QString getCheckedComplexCall(const QString &_c); + //QString getCheckedComplexCall(const QString &_c); void logEvent(const QString &_func, const QString &_msg, DebugLogLevel _level); //bool darkMode; QString getDBPath(); @@ -221,7 +219,7 @@ class Utilities : public QObject { QStringList ARRL_sects, continent, sponsorsList, logLevels; DebugLogLevel logLevel; - QStringList longPrefixes, specialCalls; + KLOG_DEPRECATED QStringList longPrefixes, specialCalls; // To be moved to World classl QMap columnNames; bool validateCalls; QHash ADIFHash; // Name, type diff --git a/src/world.cpp b/src/world.cpp index 2967b0e0..75a477c6 100644 --- a/src/world.cpp +++ b/src/world.cpp @@ -25,6 +25,7 @@ *****************************************************************************/ #include "world.h" +#include "callsign.h" /* QHash worldPrefixes; To insert a (key, value) pair into the hash, you can use operator[](): @@ -36,11 +37,6 @@ To insert a (key, value) pair into the hash, you can use operator[](): World::World(DataProxy_SQLite *dp, const QString &_parentFunction) { Q_UNUSED(_parentFunction); - //qDebug() << Q_FUNC_INFO << " - Start"; - //worldModel = new QSqlRelationalTableModel(this); - //qDebug() << Q_FUNC_INFO << " - Start"; - //numberOfEntities = 0; - //progressBarPosition = 0; worldPrefixes.clear(); cqz = -1; ituz = -1; @@ -51,21 +47,9 @@ World::World(DataProxy_SQLite *dp, const QString &_parentFunction) utc = 0.0; locator = new Locator(); created = false; + read = readWorld(); dataProxy = dp; - util = new Utilities(Q_FUNC_INFO); - - - /* - if (readWorld()) - { - //qDebug() << Q_FUNC_INFO << " - World TRUE"; - } - else - { - //qDebug() << Q_FUNC_INFO << " - World FALSE"; - } - //qDebug() << Q_FUNC_INFO << " - END"; - */ + util = new Utilities(Q_FUNC_INFO); } World::~World() @@ -77,18 +61,23 @@ World::~World() bool World::readWorld() { // Used to link a prefix with an Entity quickly, without quering the DB. - //qDebug() << Q_FUNC_INFO << " - Start"; + qDebug() << Q_FUNC_INFO << " - Start"; + specialCalls.clear(); + longPrefixes.clear(); worldPrefixes.clear(); + worldPrefixes = dataProxy->getWorldData(); - if (worldPrefixes.size()>100) - { - //qDebug() << Q_FUNC_INFO << " - END true"; - util->setLongPrefixes(dataProxy->getLongPrefixes()); - util->setSpecialCalls(dataProxy->getSpecialCallsigns()); - return true; - } - //qDebug() << Q_FUNC_INFO << " - END false"; - return false; + specialCalls << dataProxy->getSpecialCallsigns(); + longPrefixes << dataProxy->getLongPrefixes(); + qDebug() << Q_FUNC_INFO << " - worldPrefixes: " << worldPrefixes.count(); + qDebug() << Q_FUNC_INFO << " - specialCalls : " << specialCalls.count(); + qDebug() << Q_FUNC_INFO << " - longPrefixes : " << longPrefixes.count(); + + if (worldPrefixes.isEmpty()) + return false; + if (specialCalls.isEmpty()) + return false; + return !longPrefixes.isEmpty(); } bool World::recreate(const QString &_worldFile) @@ -102,11 +91,6 @@ bool World::recreate(const QString &_worldFile) { //qDebug() << Q_FUNC_INFO << ": EMPTY prefixesofentity - END-1" ; return create(_worldFile); - - //if (create(_worldFile)) - // { - // return insertSpecialEntities (); - // } } else {//TODO: Manage the query error @@ -129,20 +113,7 @@ bool World::create(const QString &_worldFile) { //qDebug() << Q_FUNC_INFO << " " << _worldFile; - if (readCTYCSV(_worldFile)) - { - //qDebug() << Q_FUNC_INFO << " - 10" ; - util->setLongPrefixes(dataProxy->getLongPrefixes()); - util->setSpecialCalls(dataProxy->getSpecialCallsigns()); - created = true; - //qDebug() << Q_FUNC_INFO << " - TRUE" ; - } - else - { - //qDebug() << Q_FUNC_INFO << " - 20" ; - created = false; - //qDebug() << Q_FUNC_INFO << " - FALSE" ; - } + created = readCTYCSV(_worldFile); //qDebug() << Q_FUNC_INFO << " - 30" ; if (created) @@ -170,7 +141,7 @@ bool World::create(const QString &_worldFile) created = dataProxy->addPrimarySubdivisions(); } //qDebug() << Q_FUNC_INFO << " - 90" ; - readWorld (); + read = readWorld (); //qDebug() << Q_FUNC_INFO << " - END" ; return created; } @@ -219,17 +190,7 @@ QStringList World::readZones (const QString &pref, const int _cq, const int _itu return result; } -int World::getPrefixId(const QString &_prefix) -{ - //qDebug() << Q_FUNC_INFO << " - Start: " << _prefix << "/" << QString::number(worldPrefixes.value(_prefix, -2)); - //This function receives the final prefix. - if (_prefix.length() < 1) - { - return -1; - } - return worldPrefixes.value(_prefix, -2); -} QString World::getQRZEntityName(const QString &_qrz) { @@ -298,14 +259,24 @@ int World::getEntityItuz(const int _enti) int World::getQRZARRLId(const QString &_qrz) { - //qDebug() << Q_FUNC_INFO << ": " << _qrz; - if (_qrz.length() < 1 ) - { + qDebug() << Q_FUNC_INFO << ": " << _qrz; + + Callsign callsign(_qrz); + if ((!callsign.isValid()) && (!callsign.isValidPrefix())) return -1; + + QString prefix = callsign.getHostFullPrefix(); + int entID = worldPrefixes.value(prefix, -2); + while ((prefix.length()>1) && (entID<=0)) + { + qDebug() << Q_FUNC_INFO << " - " << QString("Pref: %1 / EntID: %2").arg(prefix).arg(entID); + if (entID<=0) + prefix.chop(1); + entID = worldPrefixes.value(prefix, -2); + qDebug() << Q_FUNC_INFO << " - " << QString("New Pref: %1 / New EntID: %2").arg(prefix).arg(entID); } - QString pref = util->getPrefixFromCall(_qrz); - //qDebug() << Q_FUNC_INFO << ": prefix: " << pref; - return getPrefixId(pref); + qDebug() << Q_FUNC_INFO << " - " << QString("Callsign: %1 / Final EntID: %2").arg(_qrz).arg(entID); + return entID; } QString World::getQRZEntityMainPrefix(const QString &_qrz) @@ -316,6 +287,7 @@ QString World::getQRZEntityMainPrefix(const QString &_qrz) return ""; } int i = getQRZARRLId(_qrz); + return getEntityMainPrefix(i); } @@ -404,14 +376,14 @@ double World::getLatitude(const int _enti) QString World::getQRZLocator(const QString &_qrz) { - //qDebug() << Q_FUNC_INFO << " - Start: " << _qrz; + qDebug() << Q_FUNC_INFO << " - Start: " << _qrz; if (_qrz.length() < 1) { return ""; } - int i = getQRZARRLId (_qrz); - //qDebug() << Q_FUNC_INFO << " - 2"; - return locator->getLocator(getLongitude(i), getLatitude (i)); + int entity = getQRZARRLId (_qrz); + qDebug() << Q_FUNC_INFO << " - Entity: " << entity; + return locator->getLocator(getLongitude(entity), getLatitude (entity)); } QString World::getLocator(const int _entityN) @@ -765,4 +737,14 @@ bool World::hasSpecialEntities() return false; } +bool World::isAKnownCall(const QString &_callsign) +{ + //qDebug() << Q_FUNC_INFO << ": " << _callsign; + return specialCalls.contains(_callsign); +} +bool World::isAKnownPrefix(const QString &_prefix) +{ + //qDebug() << Q_FUNC_INFO << ": " << _prefix; + return longPrefixes.contains(_prefix); +} diff --git a/src/world.h b/src/world.h index 73aa4046..a035516e 100644 --- a/src/world.h +++ b/src/world.h @@ -99,6 +99,8 @@ class World : public QObject bool isNewEntity(const int _entityN); //int getBandIdFromFreq(const QString fr); QString getEntityPrefixes(const int _enti); + bool isAKnownCall(const QString &_callsign); + bool isAKnownPrefix(const QString &_prefix); //QStringList getEntitiesNames(); int getHowManyEntities(); @@ -123,7 +125,7 @@ private slots: int extractEntityNumber(const QStringList &stringList); //int progressBarPosition; - bool created; + bool created, read; //QString klogVersion; int cqz, ituz;//, numberOfEntities; QString entityName; @@ -143,6 +145,8 @@ private slots: DataProxy_SQLite *dataProxy; Utilities *util; QHash worldPrefixes; + QStringList specialCalls, longPrefixes; + //int constrid; // Just an id for the constructor to check who is being executed at one specific time //Awards *awards; diff --git a/tests/tst_callsign/tst_callsign.cpp b/tests/tst_callsign/tst_callsign.cpp index bd053079..972fa5a0 100644 --- a/tests/tst_callsign/tst_callsign.cpp +++ b/tests/tst_callsign/tst_callsign.cpp @@ -133,6 +133,10 @@ void tst_Callsign::test_callsigns_data() QTest::newRow("S50K") << "S50K" << "S50K" << "S50" << "S5" << 0 << "S50K" << "S50" << "S5" << 0 << "K" << "" << true << true; QTest::newRow("B7D") << "B7D" << "B7D" << "B7" << "B" << 7 << "B7D" << "B7" << "B" << 7 << "D" << "" << true << true; QTest::newRow("5Z4RT/Y2K") << "5Z4RT/Y2K" << "5Z4RT/Y2K" << "5Z4" << "5Z" << 4 << "5Z4RT" << "5Z4" << "5Z" << 4 << "RT" << "Y2K" << true << true; + QTest::newRow("3A/4Z5KJ/LH") << "3A/4Z5KJ/LH" << "3A/4Z5KJ/LH" << "3A" << "3A" << 0 << "4Z5KJ" << "4Z5" << "4Z" << 5 << "KJ" << "LH" << true << true; + + + //QTest::newRow("VP6UU/VP6D") << "VP6UU/VP6D" << "VP6UU/VP6D" << "VP6D" << "VP6D"<< -1 << "VP6UU" << "VP6" << "VP6" << -1 << "RT" << "Y2K" << true << true; QTest::newRow("CO7WT/6Y") << "CO7WT/6Y" << "CO7WT/6Y" << "6Y" << "6Y" << -1 << "CO7WT" << "CO7" << "CO" << 7 << "WT" << "" << true << true; QTest::newRow("AM100") << "AM100" << "" << "AM100" << "AM" << 100 << "" << "" << "" << -1 << "" << "" << true << false; diff --git a/tests/tst_dxspot/moc_callsign.cpp b/tests/tst_dxspot/moc_callsign.cpp new file mode 100644 index 00000000..279f911d --- /dev/null +++ b/tests/tst_dxspot/moc_callsign.cpp @@ -0,0 +1,100 @@ +/**************************************************************************** +** Meta object code from reading C++ file 'callsign.h' +** +** Created by: The Qt Meta Object Compiler version 68 (Qt 6.7.2) +** +** WARNING! All changes made in this file will be lost! +*****************************************************************************/ + +#include "../../src/callsign.h" +#include + +#include + +#include + + +#include +#if !defined(Q_MOC_OUTPUT_REVISION) +#error "The header file 'callsign.h' doesn't include ." +#elif Q_MOC_OUTPUT_REVISION != 68 +#error "This file was generated using the moc from 6.7.2. It" +#error "cannot be used with the include files from this version of Qt." +#error "(The moc has changed too much.)" +#endif + +#ifndef Q_CONSTINIT +#define Q_CONSTINIT +#endif + +QT_WARNING_PUSH +QT_WARNING_DISABLE_DEPRECATED +QT_WARNING_DISABLE_GCC("-Wuseless-cast") +namespace { + +#ifdef QT_MOC_HAS_STRINGDATA +struct qt_meta_stringdata_CLASSCallsignENDCLASS_t {}; +constexpr auto qt_meta_stringdata_CLASSCallsignENDCLASS = QtMocHelpers::stringData( + "Callsign" +); +#else // !QT_MOC_HAS_STRINGDATA +#error "qtmochelpers.h not found or too old." +#endif // !QT_MOC_HAS_STRINGDATA +} // unnamed namespace + +Q_CONSTINIT static const uint qt_meta_data_CLASSCallsignENDCLASS[] = { + + // content: + 12, // revision + 0, // classname + 0, 0, // classinfo + 0, 0, // methods + 0, 0, // properties + 0, 0, // enums/sets + 0, 0, // constructors + 0, // flags + 0, // signalCount + + 0 // eod +}; + +Q_CONSTINIT const QMetaObject Callsign::staticMetaObject = { { + QMetaObject::SuperData::link(), + qt_meta_stringdata_CLASSCallsignENDCLASS.offsetsAndSizes, + qt_meta_data_CLASSCallsignENDCLASS, + qt_static_metacall, + nullptr, + qt_incomplete_metaTypeArray + >, + nullptr +} }; + +void Callsign::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a) +{ + (void)_o; + (void)_id; + (void)_c; + (void)_a; +} + +const QMetaObject *Callsign::metaObject() const +{ + return QObject::d_ptr->metaObject ? QObject::d_ptr->dynamicMetaObject() : &staticMetaObject; +} + +void *Callsign::qt_metacast(const char *_clname) +{ + if (!_clname) return nullptr; + if (!strcmp(_clname, qt_meta_stringdata_CLASSCallsignENDCLASS.stringdata0)) + return static_cast(this); + return QObject::qt_metacast(_clname); +} + +int Callsign::qt_metacall(QMetaObject::Call _c, int _id, void **_a) +{ + _id = QObject::qt_metacall(_c, _id, _a); + return _id; +} +QT_WARNING_POP diff --git a/tests/tst_dxspot/tst_dxspot.cpp b/tests/tst_dxspot/tst_dxspot.cpp index 50687cef..33b20e18 100644 --- a/tests/tst_dxspot/tst_dxspot.cpp +++ b/tests/tst_dxspot/tst_dxspot.cpp @@ -79,17 +79,10 @@ void tst_DXSpot::test_Constructors() { DXSpot spot1; QVERIFY2(!spot1.isValid(), "Constructor-1 not working"); - spot1.setValid(true); - DXSpot spot2(spot1); - QVERIFY2(spot2.isValid(), "Constructor-2 not working"); } void tst_DXSpot::test_Basic() { - spot->clear(); - QVERIFY2(!spot->isValid(), "Clear not working"); - spot->setValid(true); - QVERIFY2(spot->isValid(), "setValid not working"); spot->setDXCall("EA0XX"); QVERIFY2(spot->getDxCall() == "EA0XX", "dxCall not working"); diff --git a/tests/tst_dxspot/tst_dxspot.pro b/tests/tst_dxspot/tst_dxspot.pro index 3d0db22b..fc531d35 100644 --- a/tests/tst_dxspot/tst_dxspot.pro +++ b/tests/tst_dxspot/tst_dxspot.pro @@ -11,12 +11,15 @@ TEMPLATE = app HEADERS += \ ../../src/frequency.h \ + ../../src/callsign.h \ ../../src/dxcluster/dxspot.h \ ../../src/klogdefinitions.h -SOURCES += tst_dxspot.cpp \ +SOURCES += \ + ../../src/frequency.cpp \ + ../../src/callsign.cpp \ ../../src/dxcluster/dxspot.cpp \ - ../../src/frequency.cpp + tst_dxspot.cpp diff --git a/tests/tst_utilities/tst_utilities.cpp b/tests/tst_utilities/tst_utilities.cpp index b4b29e19..16829916 100644 --- a/tests/tst_utilities/tst_utilities.cpp +++ b/tests/tst_utilities/tst_utilities.cpp @@ -49,7 +49,6 @@ private slots: void test_Constructor(); void test_getProgresStepForDialog(); void test_trueOrFalse(); - void test_isAPrefix(); void test_boolToCharToSQLite(); void test_boolToQString(); void test_getGlobalAgent(); @@ -61,9 +60,7 @@ private slots: void test_isValidVUCC(); void test_isValidADIFField(); void test_logLevels(); - void test_isValidSimpleCall(); - void test_getPrefixFromCall(); - void test_getMainCallFromComplexCall(); + void test_getPrefixFromCall(); void test_isValidEmail(); void test_QSL(); @@ -102,23 +99,6 @@ void tst_Utilities::test_Constructor() QVERIFY(util->getVersion() == "0.0"); } -void tst_Utilities::test_isAPrefix() -{ - /* - QVERIFY2(util->isAPrefix("EA") , "EA"); - QVERIFY2(util->isAPrefix("EA1"), "EA1"); - QVERIFY2(util->isAPrefix("EA6") , "EA6"); - //qDebug() << Q_FUNC_INFO <<": --" << QString::number(util->isAPrefix("K1") ); - QVERIFY2(util->isAPrefix("K"), "K"); - QVERIFY2(util->isAPrefix("K1") , "K1"); - //qDebug() << QString::number(util->isAPrefix("CE0X") ); - QVERIFY2(util->isAPrefix("CE0X"), "CE0X"); - QVERIFY2(util->isAPrefix("VK9M"), "VK0M"); - QVERIFY2(util->isAPrefix("PY0F"), "PY0F"); - QVERIFY2(util->isAPrefix("T30"), "T30"); - */ -} - void tst_Utilities::test_getProgresStepForDialog() { QVERIFY(util->getVersion() == "0.0"); @@ -414,89 +394,7 @@ void tst_Utilities::test_logLevels() QVERIFY2(!util->isValidLogLevel("Other"), "Other logLevel not detected"); } -void tst_Utilities::test_isValidSimpleCall() -{ - QVERIFY2(util->isValidSimpleCall("B1A"), "B1A"); - QVERIFY2(util->isValidSimpleCall("B1AA"), "B1AA"); - QVERIFY2(util->isValidSimpleCall("B1AAA"), "B1AAA"); - QVERIFY2(util->isValidSimpleCall("B1AAAA"), "B1AAAA"); - QVERIFY2(!util->isValidSimpleCall("B11"), "B11"); - - //2) or–two characters and a single digit, - // followed by a group of not more than four characters, the last of which shall be a letter. - - QVERIFY2(util->isValidSimpleCall("EA4K"), "EA4K"); - QVERIFY2(util->isValidSimpleCall("EA4KK"), "EA4KK"); - QVERIFY2(util->isValidSimpleCall("EA4KKK"), "EA4KKK"); - QVERIFY2(util->isValidSimpleCall("EA4KKKK"), "EA4KKKK"); - QVERIFY2(util->isValidSimpleCall("AM500MMM"), "AM500MMM"); - QVERIFY2(util->isValidSimpleCall("2E1A"), "2E1A"); - QVERIFY2(util->isValidSimpleCall("2E1AA"), "2E1AA" ); - QVERIFY2(util->isValidSimpleCall("E33E"), "E33E"); - QVERIFY2(util->isValidSimpleCall("E73E"), "E73E"); - QVERIFY2(util->isValidSimpleCall("EA5666K"), "EA5666K"); - QVERIFY2(!util->isValidSimpleCall("VK0M/ZL4DB/P"), "VK0M/ZL4DB/P"); - - QVERIFY2(util->isValidSimpleCall("K4X"), "K4X"); - QVERIFY2(util->isValidSimpleCall("B2AA"), "B2AA"); - QVERIFY2(util->isValidSimpleCall("N2ASD"), "N2ASD"); - QVERIFY2(util->isValidSimpleCall("A22A"), "A22A"); - QVERIFY2(util->isValidSimpleCall("I20000X"), "I20000X"); - QVERIFY2(util->isValidSimpleCall("4X4AAA"), "4X4AAA"); - QVERIFY2(util->isValidSimpleCall("3DA0RS"), "3DA0RS"); - QVERIFY2(util->isValidSimpleCall("VP2EE"), "VP2EE"); - QVERIFY2(util->isValidSimpleCall("EA6A"), "EA6A"); - - QVERIFY2(util->isValidSimpleCall("AM200A"), "AM200A"); - QVERIFY2(util->isValidSimpleCall("VK9AA"), "VK9AA"); - QVERIFY2(util->isValidSimpleCall("VK9MA"), "VK9MA"); - QVERIFY2(util->isValidSimpleCall("4U2STAYHOME") , "4U2STAYHOME"); - - // 5(WRC-03)19.68A1A) On special occasions, for temporary use, administrations may authorize - // use of call signs with more than the four characters referred to in No. 19.68.(WRC-03 - //qDebug() << Q_FUNC_INFO << " Complex"; - QVERIFY2(!util->isValidSimpleCall("EA4K/P"), "EA4K/P"); - //qDebug() << Q_FUNC_INFO << " Complex-1"; - QVERIFY2(!util->isValidSimpleCall("K/EA4K/P"), "EA4K/K"); - //qDebug() << Q_FUNC_INFO << " Complex-2"; - QVERIFY2(!util->isValidSimpleCall("K1/EA4K"), "K1/EA4K"); - QVERIFY2(!util->isValidSimpleCall("K/EA4K"), "K/EA4K"); - - QVERIFY2(!util->isValidSimpleCall("G1"), "G1"); - QVERIFY2(!util->isValidSimpleCall("I100"), "I100"); - QVERIFY2(util->isValidSimpleCall("K100A"), "K1"); - QVERIFY2(util->isValidSimpleCall("I100KK"), "I100KK"); - QVERIFY2(util->isValidSimpleCall("FB1K") , "FB1K"); - QVERIFY2(!util->isValidSimpleCall("E"), "E"); - QVERIFY2(!util->isValidSimpleCall("EA"), "EA"); - QVERIFY2(!util->isValidSimpleCall("EA4"), "EA4-EA"); - - QVERIFY2(!util->isValidSimpleCall("-"), "-"); - QVERIFY2(!util->isValidSimpleCall("EAK4"), "EAK4"); - QVERIFY2(!util->isValidSimpleCall("QQQ/EA4K"), "QQQ/EA4K"); - - QVERIFY2(!util->isValidSimpleCall("EA6"), "EA6 is just a prefix"); - QVERIFY2(util->isValidSimpleCall("EE6AAA"), "EE6AAA"); - QVERIFY2(!util->isValidSimpleCall("VP2E"), "VP2E is just a prefix"); - QVERIFY2(util->isValidSimpleCall("EA4K"), "EA4K"); - QVERIFY2(!util->isValidSimpleCall("EA4K/p"), "EA4K/p"); - QVERIFY2(!util->isValidSimpleCall("VK9M"), "VK9M"); - QVERIFY2(util->isValidSimpleCall("VK9MA"), "VK9MA"); - QVERIFY2(!util->isValidSimpleCall("XXXX"), "XXXX"); -} - -void tst_Utilities::test_getMainCallFromComplexCall() -{ - QVERIFY2(util->getMainCallFromComplexCall("EA4K")=="EA4K", "EA4K"); - QVERIFY2(util->getMainCallFromComplexCall("EA4K/P")=="EA4K", "EA4K/P"); - QVERIFY2(util->getMainCallFromComplexCall("EA4K/MM")=="EA4K", "EA4K/MM"); - QVERIFY2(util->getMainCallFromComplexCall("MM/EA4K")=="MM", "MM/EA4K"); - QVERIFY2(util->getMainCallFromComplexCall("EA4K/F")=="F", "EA4K/F"); - QVERIFY2(util->getMainCallFromComplexCall("EA4K/1")=="EA4K", "EA4K/1"); - QVERIFY2(util->getMainCallFromComplexCall("VK9/EA4K")=="VK9", "VK9/EA4K"); - //QVERIFY2(util->getMainCallFromComplexCall("5B/LY1DF/LGT")=="LY1DF", "5B/LY1DF/LGT"); -} void tst_Utilities::test_isValidEmail() {