diff --git a/displaytext.cpp b/displaytext.cpp index b9a8c813f..ba53eca14 100644 --- a/displaytext.cpp +++ b/displaytext.cpp @@ -151,8 +151,8 @@ void DisplayText::appendText(QString const& text, QColor bg, QString const& call document ()->setMaximumBlockCount (document ()->maximumBlockCount ()); } -QString DisplayText::appendDXCCWorkedB4(QString message, QString const& callsign, QColor * bg, - LogBook const& logBook, QString currentBand) +QString DisplayText::appendWorkedB4(QString message, QString const& callsign, QString grid, + QColor * bg, LogBook const& logBook, QString currentBand) { // allow for seconds int padding {message.indexOf (" ") > 4 ? 2 : 0}; @@ -162,6 +162,9 @@ QString DisplayText::appendDXCCWorkedB4(QString message, QString const& callsign bool callB4onBand; bool countryWorkedBefore; bool countryB4onBand; + bool gridB4; + bool gridB4onBand; + if(call.length()==2) { int i0=message.indexOf("CQ "+call); @@ -172,8 +175,8 @@ QString DisplayText::appendDXCCWorkedB4(QString message, QString const& callsign if(call.length()<3) return message; if(!call.contains(QRegExp("[0-9]|[A-Z]"))) return message; - logBook.match(/*in*/call,/*out*/countryName,callWorkedBefore,countryWorkedBefore); - logBook.match(/*in*/call,/*out*/countryName,callB4onBand,countryB4onBand, + logBook.match(/*in*/call,grid,/*out*/countryName,callWorkedBefore,countryWorkedBefore,gridB4); + logBook.match(/*in*/call,grid,/*out*/countryName,callB4onBand,countryB4onBand,gridB4onBand, /*in*/ currentBand); message = message.trimmed (); @@ -232,12 +235,10 @@ QString DisplayText::appendDXCCWorkedB4(QString message, QString const& callsign // it again later, align appended data at a fixed column if // there is space otherwise let it float to the right int space_count {40 + padding - message.size ()}; - if (space_count > 0) - { - message += QString {space_count, QChar {' '}}; - } + if (space_count > 0) { + message += QString {space_count, QChar {' '}}; + } message += QChar::Nbsp + appendage; - return message; } @@ -267,12 +268,14 @@ void DisplayText::displayDecodedText(DecodedText const& decodedText, QString con auto message = decodedText.string(); QString dxCall; QString dxGrid; - decodedText.deCallAndGrid (dxCall, dxGrid); + decodedText.deCallAndGrid (/*out*/ dxCall, dxGrid); + QRegularExpression m_grid_regexp {"\\A(?![Rr]{2}73)[A-Ra-r]{2}[0-9]{2}([A-Xa-x]{2}){0,1}\\z"}; + if(!dxGrid.contains(m_grid_regexp)) dxGrid=""; message = message.left (message.indexOf (QChar::Nbsp)); // strip appended info if (displayDXCCEntity && CQcall) // if enabled add the DXCC entity and B4 status to the end of the // preformated text line t1 - message = appendDXCCWorkedB4 (message, decodedText.CQersCall (), &bg, logBook, currentBand); + message = appendWorkedB4 (message, decodedText.CQersCall(), dxGrid, &bg, logBook, currentBand); appendText (message.trimmed (), bg, decodedText.call (), dxCall); } diff --git a/displaytext.h b/displaytext.h index 75f0dbb68..8fb1d8bd7 100644 --- a/displaytext.h +++ b/displaytext.h @@ -45,7 +45,7 @@ protected: private: bool m_bPrincipalPrefix; - QString appendDXCCWorkedB4(QString message, QString const& callsign, QColor * bg, + QString appendWorkedB4(QString message, QString const& callsign, QString grid, QColor * bg, LogBook const& logBook, QString currentBand); QFont char_font_; diff --git a/logbook/adif.cpp b/logbook/adif.cpp index 4e69a54b8..e512c2868 100644 --- a/logbook/adif.cpp +++ b/logbook/adif.cpp @@ -124,35 +124,29 @@ void ADIF::add(QString const& call, QString const& band, QString const& mode, QS // return true if in the log same band and mode (where JT65 == JT9 == FT8) bool ADIF::match(QString const& call, QString const& band, QString const& mode) const { - QList qsos = _data.values(call); - if (qsos.size()>0) - { - QSO q; - foreach(q,qsos) - { - if ( (band.compare(q.band,Qt::CaseInsensitive) == 0) - || (band=="") - || (q.band=="")) - { - if ( - ( - ((mode.compare("JT65",Qt::CaseInsensitive)==0) || - (mode.compare("JT9",Qt::CaseInsensitive)==0) || - (mode.compare("FT8",Qt::CaseInsensitive)==0)) - && - ((q.mode.compare("JT65",Qt::CaseInsensitive)==0) || - (q.mode.compare("JT9",Qt::CaseInsensitive)==0) || - (q.mode.compare("FT8",Qt::CaseInsensitive)==0)) - ) - || (mode.compare(q.mode,Qt::CaseInsensitive)==0) - || (mode=="") - || (q.mode=="") - ) - return true; - } - } + QList qsos = _data.values(call); + if (qsos.size()>0) { + QSO q; + foreach(q,qsos) { + if((band.compare(q.band,Qt::CaseInsensitive) == 0) || (band=="") || (q.band=="")) { + if(( + ((mode.compare("JT65",Qt::CaseInsensitive)==0) || + (mode.compare("JT9",Qt::CaseInsensitive)==0) || + (mode.compare("FT8",Qt::CaseInsensitive)==0)) + && + ((q.mode.compare("JT65",Qt::CaseInsensitive)==0) || + (q.mode.compare("JT9",Qt::CaseInsensitive)==0) || + (q.mode.compare("FT8",Qt::CaseInsensitive)==0)) + ) + || (mode.compare(q.mode,Qt::CaseInsensitive)==0) + || (mode=="") + || (q.mode=="") + ) + return true; + } } - return false; + } + return false; } QList ADIF::getCallList() const diff --git a/logbook/logbook.cpp b/logbook/logbook.cpp index 41da0b393..68b6663fd 100644 --- a/logbook/logbook.cpp +++ b/logbook/logbook.cpp @@ -43,7 +43,7 @@ void LogBook::init() // QString call = "ok1ct"; // QString countryName; // bool callWorkedBefore,countryWorkedBefore; - // match(/*in*/call, /*out*/ countryName,callWorkedBefore,countryWorkedBefore); + // match(/*in*/call,grid, /*out*/ countryName,callWorkedBefore,countryWorkedBefore); // qDebug() << countryName; } @@ -64,12 +64,16 @@ void LogBook::_setAlreadyWorkedFromLog() } } -void LogBook::match(/*in*/const QString call, +void LogBook::match(/*in*/const QString call,QString grid, /*out*/ QString &countryName, bool &callWorkedBefore, bool &countryWorkedBefore, + bool &gridWorkedBefore, QString currentBand) const { + if(currentBand=="") qDebug() << "aa" << grid; + if(currentBand!="") qDebug() << "bb" << grid << currentBand; + if (call.length() > 0) { QString currentMode = "JT9"; // JT65 == JT9 == FT8 in ADIF::match() // QString currentBand = ""; // match any band diff --git a/logbook/logbook.h b/logbook/logbook.h index 215611f8e..c99b0a80e 100644 --- a/logbook/logbook.h +++ b/logbook/logbook.h @@ -20,11 +20,9 @@ class LogBook { public: void init(); - void match(/*in*/ const QString call, - /*out*/ QString &countryName, - bool &callWorkedBefore, - bool &countryWorkedBefore, - QString currentBand="") const; + void match(/*in*/ const QString call, QString grid, + /*out*/ QString &countryName, bool &callWorkedBefore, bool &countryWorkedBefore, + bool &gridWorkedBefore, QString currentBand="") const; void addAsWorked(const QString call, const QString band, const QString mode, const QString date); private: diff --git a/mainwindow.cpp b/mainwindow.cpp index 342f50421..3d6b14978 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -7799,9 +7799,9 @@ void MainWindow::houndCallers() if(m_loggedByFox[houndCall].contains(m_lastBand)) continue; //already logged on this band if(m_foxQSO.contains(houndCall)) continue; //still in the QSO map QString countryName,continent; - bool callWorkedBefore,countryWorkedBefore; - m_logBook.match(/*in*/houndCall,/*out*/countryName,callWorkedBefore,countryWorkedBefore, - /*in*/ m_currentBand); + bool callWorkedBefore,countryWorkedBefore,gridWorkedBefore; + m_logBook.match(/*in*/houndCall,"",/*out*/countryName,callWorkedBefore,countryWorkedBefore, + gridWorkedBefore,/*in*/ m_currentBand); int i1=countryName.lastIndexOf(";"); continent=countryName.mid(i1+2,-1);