diff --git a/displaytext.cpp b/displaytext.cpp index a31cf9bc4..1ef685a07 100644 --- a/displaytext.cpp +++ b/displaytext.cpp @@ -151,18 +151,18 @@ 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, QColor color_CQ, - QColor color_DXCC, - QColor color_NewCall) + LogBook const& logBook, QColor color_CQ, QColor color_DXCC, QColor color_NewCall, + QColor color_NewCallBand, QString currentBand) { // allow for seconds int padding {message.indexOf (" ") > 4 ? 2 : 0}; QString call = callsign; QString countryName; bool callWorkedBefore; + bool callB4onBand; bool countryWorkedBefore; + bool countryB4onBand; if(call.length()==2) { int i0=message.indexOf("CQ "+call); @@ -174,26 +174,31 @@ QString DisplayText::appendDXCCWorkedB4(QString message, QString const& callsign 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, + /*in*/ currentBand); + message = message.trimmed (); - QString appendage; - if (!countryWorkedBefore) // therefore not worked call either - { - appendage += "!"; - *bg = color_DXCC; - } - else - { - if (!callWorkedBefore) // but have worked the country - { - appendage += "~"; - *bg = color_NewCall; - } - else - { - appendage += " "; // have worked this call before - *bg = color_CQ; - } + QString appendage{""}; + + if (!countryWorkedBefore) { + // therefore not worked call either + appendage += "!"; + *bg = color_DXCC; + } else { + if (!callWorkedBefore) { + // but have worked the country + appendage += "~"; + *bg = color_NewCall; + } else { + if(!callB4onBand) { + appendage += "~"; + *bg = color_NewCallBand; + } else { + appendage += " "; // have worked this call before + *bg = color_CQ; + } } + } int i1=countryName.indexOf(";"); if(m_bPrincipalPrefix) { @@ -240,8 +245,9 @@ QString DisplayText::appendDXCCWorkedB4(QString message, QString const& callsign void DisplayText::displayDecodedText(DecodedText const& decodedText, QString const& myCall, bool displayDXCCEntity, LogBook const& logBook, QColor color_CQ, QColor color_MyCall, - QColor color_DXCC, QColor color_NewCall, bool ppfx, - bool bCQonly) + QColor color_DXCC, QColor color_NewCall, + QColor color_NewCallBand, + QString currentBand, bool ppfx, bool bCQonly) { m_bPrincipalPrefix=ppfx; QColor bg {Qt::transparent}; @@ -262,7 +268,7 @@ void DisplayText::displayDecodedText(DecodedText const& decodedText, QString con or decodedText.indexOf (" " + myCall + ">") >= 0)) { bg = color_MyCall; } - auto message = decodedText.string (); + auto message = decodedText.string(); QString dxCall; QString dxGrid; decodedText.deCallAndGrid (dxCall, dxGrid); @@ -271,7 +277,7 @@ void DisplayText::displayDecodedText(DecodedText const& decodedText, QString con // 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, color_CQ, - color_DXCC, color_NewCall); + color_DXCC, color_NewCall, color_NewCallBand, currentBand); appendText (message.trimmed (), bg, decodedText.call (), dxCall); } diff --git a/displaytext.h b/displaytext.h index 0f1ef01b3..a479a2bb5 100644 --- a/displaytext.h +++ b/displaytext.h @@ -22,9 +22,10 @@ public: void setContentFont (QFont const&); void insertLineSpacer(QString const&); - void displayDecodedText(DecodedText const& decodedText, QString const& myCall, bool displayDXCCEntity, - LogBook const& logBook, QColor color_CQ, QColor color_MyCall, - QColor color_DXCC, QColor color_NewCall, bool ppfx, bool bCQonly=false); + void displayDecodedText(DecodedText const& decodedText, QString const& myCall, + bool displayDXCCEntity, LogBook const& logBook, QColor color_CQ, QColor color_MyCall, + QColor color_DXCC, QColor color_NewCall, QColor color_NewCallBand, + QString currentBand="", bool ppfx=false, bool bCQonly=false); void displayTransmittedText(QString text, QString modeTx, qint32 txFreq, QColor color_TxMsg, bool bFastMode); void displayQSY(QString text); @@ -43,8 +44,9 @@ protected: private: bool m_bPrincipalPrefix; - QString appendDXCCWorkedB4(QString message, QString const& callsign, QColor * bg, LogBook const& logBook, - QColor color_CQ, QColor color_DXCC, QColor color_NewCall); + QString appendDXCCWorkedB4(QString message, QString const& callsign, QColor * bg, + LogBook const& logBook, QColor color_CQ, QColor color_DXCC, + QColor color_NewCall, QColor color_NewCallBand, QString currentBand); QFont char_font_; QAction * erase_action_; diff --git a/logbook/adif.cpp b/logbook/adif.cpp index a1be7de51..4e69a54b8 100644 --- a/logbook/adif.cpp +++ b/logbook/adif.cpp @@ -121,7 +121,7 @@ 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) +// 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); diff --git a/logbook/logbook.cpp b/logbook/logbook.cpp index e938910d7..41da0b393 100644 --- a/logbook/logbook.cpp +++ b/logbook/logbook.cpp @@ -67,25 +67,23 @@ void LogBook::_setAlreadyWorkedFromLog() void LogBook::match(/*in*/const QString call, /*out*/ QString &countryName, bool &callWorkedBefore, - bool &countryWorkedBefore) const + bool &countryWorkedBefore, + QString currentBand) const { - if (call.length() > 0) - { - QString currentMode = "JT9"; // JT65 == JT9 in ADIF::match() - QString currentBand = ""; // match any band - callWorkedBefore = _log.match(call,currentBand,currentMode); - countryName = _countries.find(call); -// qDebug() << "B" << countryName; + if (call.length() > 0) { + QString currentMode = "JT9"; // JT65 == JT9 == FT8 in ADIF::match() +// QString currentBand = ""; // match any band + callWorkedBefore = _log.match(call,currentBand,currentMode); + countryName = _countries.find(call); - if (countryName.length() > 0) // country was found - countryWorkedBefore = _worked.getHasWorked(countryName); - else - { - countryName = "where?"; //error: prefix not found - countryWorkedBefore = false; - } + if (countryName.length() > 0) { // country was found + countryWorkedBefore = _worked.getHasWorked(countryName); + } else { + countryName = "where?"; //error: prefix not found + countryWorkedBefore = false; } - //qDebug() << "Logbook:" << call << ":" << countryName << "Cty B4:" << countryWorkedBefore << "call B4:" << callWorkedBefore; +// qDebug() << "Logbook:" << call << currentBand << callWorkedBefore << countryName << countryWorkedBefore; + } } void LogBook::addAsWorked(const QString call, const QString band, const QString mode, const QString date) diff --git a/logbook/logbook.h b/logbook/logbook.h index 4b80974db..215611f8e 100644 --- a/logbook/logbook.h +++ b/logbook/logbook.h @@ -23,7 +23,8 @@ public: void match(/*in*/ const QString call, /*out*/ QString &countryName, bool &callWorkedBefore, - bool &countryWorkedBefore) const; + bool &countryWorkedBefore, + 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 8c27dad3c..7416495df 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -906,8 +906,6 @@ MainWindow::MainWindow(QDir const& temp_directory, bool multiple, splashTimer.setSingleShot (true); splashTimer.start (20 * 1000); - readLog(); //Read wsjtx.log - /* if(m_config.my_callsign()=="K1JT" or m_config.my_callsign()=="K9AN" or m_config.my_callsign()=="G4WJS" or @@ -984,87 +982,6 @@ void MainWindow::on_the_minute () } } -int MainWindow::iband(float fMHz) -{ - float f[]={0.1375,0.4755,1.9,3.75,5.3585,7.150,10.125,14.175,18.128,21.225, - 24.940,28.850,52.0,70.25,146.0,435.0,915.0,1270.0,2375.,3400.,5787., - 10250.,24125.,47100.,78500.,122500.,137500.,246000.}; - float x,xmin=1.0e30; - int ibest=-1; - for(int i=0; i<28; i++) { - x=qAbs(fMHz/f[i] - 1.0); - if(x < xmin) { - xmin=x; - ibest=i; - } - } -// qDebug() << "AA" << fMHz << ibest << xmin << hamBand(ibest); - return ibest; -} - -QString MainWindow::hamBand(int iband) -{ - QString b[]={"2200m","630m","160m","80m","60m","40m","30m","20m","17m","15m", - "12m","10m","6m","4m","2m","1.25m","70cm","33cm","23cm","13cm", - "6cm","3cm","1.25cm"}; - if(iband<=23) { - return b[iband]; - } else { - return ""; - } -} - -void MainWindow::readLog() -{ - QFile f(m_config.writeable_data_dir ().absoluteFilePath ("wsjtx.log")); - if(f.open(QIODevice::ReadOnly | QIODevice::Text)) { - QTextStream s(&f); - QString t0,t,callsign,grid,mode; - int nQSO=0; //Total number of QSOs - int i0,i1,i2,len; - float fMHz; - // Read the log - while(!s.atEnd()) { - t0=s.readLine().mid(40); - i0=t0.indexOf(","); - callsign=t0.left(i0); - t=t0.mid(i0+1); - i0=t.indexOf(","); - grid=t.left(i0); - t=t.mid(i0+1); - i0=t.indexOf(","); - fMHz=t.left(i0).toFloat(); - t=t.mid(i0+1); - i0=t.indexOf(","); - mode=t.left(i0); - nQSO++; - i1 = m_callWorked[callsign]; - i2 = 1 << iband(fMHz); - m_callWorked[callsign]=i1 | i2; - if(MaidenheadLocatorValidator::Acceptable == MaidenheadLocatorValidator().validate(grid,len)) { - m_gridWorked[grid]=i1 | i2; - } -// qDebug() << nQSO << callsign << grid << fMHz << mode; - } - } -} - -bool MainWindow::isWorked(int itype, QString key, float fMHz, QString mode) -{ - bool worked; - int i=0; - if(itype==CALL) i = m_callWorked[key]; - if(itype==GRID) i = m_gridWorked[key]; - if(fMHz==0.0) { - worked=(i!=0); - } else { - int ib=iband(fMHz); - worked=((i>>ib) & 1)!=0; - } -// Check mode here... - return worked; -} - //--------------------------------------------------- MainWindow destructor MainWindow::~MainWindow() { @@ -1376,8 +1293,8 @@ void MainWindow::dataSink(qint64 frames) QString t=QString::fromLatin1(line); DecodedText decodedtext {t}; ui->decodedTextBrowser->displayDecodedText (decodedtext,m_baseCall,m_config.DXCC(), - m_logBook,m_config.color_CQ(),m_config.color_MyCall(),m_config.color_DXCC(), - m_config.color_NewCall(),m_config.ppfx()); + m_logBook,m_config.color_CQ(),m_config.color_MyCall(),m_config.color_DXCC(), + m_config.color_NewCall(),m_config.color_NewCallBand(),m_currentBand, m_config.ppfx()); if (ui->measure_check_box->isChecked ()) { // Append results text to file "fmt.all". QFile f {m_config.writeable_data_dir ().absoluteFilePath ("fmt.all")}; @@ -1618,7 +1535,7 @@ void MainWindow::fastSink(qint64 frames) DecodedText decodedtext {message.replace (QChar::LineFeed, "")}; ui->decodedTextBrowser->displayDecodedText (decodedtext,m_baseCall,m_config.DXCC(), m_logBook,m_config.color_CQ(),m_config.color_MyCall(),m_config.color_DXCC(), - m_config.color_NewCall(),m_config.ppfx()); + m_config.color_NewCall(),m_config.color_NewCallBand(),m_currentBand,m_config.ppfx()); m_bDecoded=true; auto_sequence (decodedtext, ui->sbFtol->value (), std::numeric_limits::max ()); if (m_mode != "ISCAT") postDecode (true, decodedtext.string ()); @@ -2862,7 +2779,7 @@ void::MainWindow::fast_decode_done() if(!m_bFastDone) { ui->decodedTextBrowser->displayDecodedText (decodedtext,m_baseCall,m_config.DXCC(), m_logBook,m_config.color_CQ(),m_config.color_MyCall(),m_config.color_DXCC(), - m_config.color_NewCall(),m_config.ppfx()); + m_config.color_NewCall(),m_config.color_NewCallBand(),m_currentBand,m_config.ppfx()); } t=message.mid(10,5).toFloat(); @@ -3004,14 +2921,16 @@ void MainWindow::readFromStdout() //readFromStdout DecodedText dt{"."}; ui->decodedTextBrowser->displayDecodedText(dt,m_baseCall,m_config.DXCC(), m_logBook,m_config.color_CQ(),m_config.color_MyCall(), - m_config.color_DXCC(), m_config.color_NewCall(),m_config.ppfx()); + m_config.color_DXCC(), m_config.color_NewCall(),m_config.color_NewCallBand(), + m_currentBand,m_config.ppfx()); m_bDisplayedOnce=true; } } else { ui->decodedTextBrowser->displayDecodedText(decodedtext,m_baseCall,m_config.DXCC(), m_logBook,m_config.color_CQ(),m_config.color_MyCall(), - m_config.color_DXCC(), m_config.color_NewCall(), - m_config.ppfx(),(ui->cbCQonly->isVisible() and ui->cbCQonly->isChecked())); + m_config.color_DXCC(), m_config.color_NewCall(),m_config.color_NewCallBand(), + m_currentBand,m_config.ppfx(), + (ui->cbCQonly->isVisible() and ui->cbCQonly->isChecked())); } } @@ -3046,7 +2965,8 @@ void MainWindow::readFromStdout() //readFromStdout // or contains MyCall ui->decodedTextBrowser2->displayDecodedText(decodedtext,m_baseCall,false, m_logBook,m_config.color_CQ(),m_config.color_MyCall(), - m_config.color_DXCC(),m_config.color_NewCall(),m_config.ppfx()); + m_config.color_DXCC(),m_config.color_NewCall(),m_config.color_NewCallBand(), + m_currentBand,m_config.ppfx()); if(m_mode!="JT4") { bool b65=decodedtext.isJT65(); @@ -3800,12 +3720,14 @@ void MainWindow::guiUpdate() //Once per second: if(nsec != m_sec0) { -// qDebug() << "OneSec:" << ui->tx1->isEnabled(); +// qDebug() << "OneSec:" << m_config.ppfx(); if(m_freqNominal!=0 and m_freqNominal<50000000 and m_config.enable_VHF_features()) { if(!m_bVHFwarned) vhfWarning(); } else { m_bVHFwarned=false; } + m_currentBand=m_config.bands()->find(m_freqNominal); + // if(m_config.bFox()) { // if(m_config.my_callsign()=="K1JT" or m_config.my_callsign()=="K9AN" or // m_config.my_callsign()=="G4WJS" or m_config.my_callsign().contains("KH7Z")) { @@ -4549,9 +4471,9 @@ void MainWindow::processMessage (DecodedText const& message, Qt::KeyboardModifie QString s2 = message.string ().trimmed(); if (s1!=s2 and !message.isTX()) { if (!s2.contains(m_baseCall) or m_mode=="MSK144") { // Taken care of elsewhere if for_us and slow mode - ui->decodedTextBrowser2->displayDecodedText(message, m_baseCall, - false, m_logBook,m_config.color_CQ(), m_config.color_MyCall(), - m_config.color_DXCC(),m_config.color_NewCall(),m_config.ppfx()); + ui->decodedTextBrowser2->displayDecodedText(message, m_baseCall,false, + m_logBook,m_config.color_CQ(), m_config.color_MyCall(), m_config.color_DXCC(), + m_config.color_NewCall(),m_config.color_NewCallBand(),m_currentBand,m_config.ppfx()); } m_QSOText = s2; } @@ -7874,7 +7796,8 @@ void MainWindow::houndCallers() 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); + m_logBook.match(/*in*/houndCall,/*out*/countryName,callWorkedBefore,countryWorkedBefore, + /*in*/ m_currentBand); int i1=countryName.lastIndexOf(";"); continent=countryName.mid(i1+2,-1); diff --git a/mainwindow.h b/mainwindow.h index 4e12daa12..28c5c36db 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -596,6 +596,7 @@ private: QString m_fm1; QString m_xSent; //Contest exchange sent QString m_xRcvd; //Contest exchange received + QString m_currentBand; QSet m_pfx; QSet m_sfx; @@ -614,11 +615,6 @@ private: QMap m_foxQSO; //Key = HoundCall, value = parameters for QSO in progress QMap m_loggedByFox; //Key = HoundCall, value = logged band - QHash m_callWorked; - QHash m_gridWorked; -// QHash m_dxccWorked; -// QHash m_multWorked; - QQueue m_houndQueue; //Selected Hounds available for starting a QSO QQueue m_foxQSOinProgress; //QSOs in progress: Fox has sent a report QQueue m_foxRateQueue; @@ -696,10 +692,7 @@ private: void fast_config(bool b); void CQTxFreq(); void cabLog(); - void readLog(); bool isWorked(int itype, QString key, float fMHz=0, QString=""); - int iband(float fMHz); - QString hamBand(int iband); QString save_wave_file (QString const& name , short const * data @@ -744,6 +737,5 @@ extern void getDev(int* numDevices,char hostAPI_DeviceName[][50], int minChan[], int maxChan[], int minSpeed[], int maxSpeed[]); extern int next_tx_state(int pctx); -//extern void readLog(); #endif // MAINWINDOW_H