From 363c469b55ec0cf16a35326d9c2a3e50441668be Mon Sep 17 00:00:00 2001 From: Bill Somerville Date: Wed, 30 Aug 2017 02:27:57 +0000 Subject: [PATCH] Fix some signoff issues with auto-sequencing 73 messages from other QSOs on frequency should now be ignored rather than being processed. Also some long overdue refactoring and tidying of non-idiomatic C++ code in the logbook directory. git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/wsjtx@8047 ab8295b8-cf94-4d9e-aec4-7959e3be5d79 --- decodedtext.cpp | 133 +++++++++++++++++++++--------------- decodedtext.h | 61 +++++++---------- displaytext.cpp | 6 +- displaytext.h | 6 +- logbook/adif.cpp | 8 +-- logbook/adif.h | 20 +++--- logbook/countriesworked.cpp | 6 +- logbook/countriesworked.h | 16 ++--- logbook/countrydat.cpp | 11 ++- logbook/countrydat.h | 10 +-- logbook/logbook.cpp | 2 +- logbook/logbook.h | 2 +- mainwindow.cpp | 97 +++++++++++++------------- mainwindow.h | 6 +- 14 files changed, 196 insertions(+), 188 deletions(-) diff --git a/decodedtext.cpp b/decodedtext.cpp index 841f6ef53..1527d4354 100644 --- a/decodedtext.cpp +++ b/decodedtext.cpp @@ -7,48 +7,79 @@ extern "C" { bool stdmsg_(const char* msg, int len); } -QString DecodedText::CQersCall() +DecodedText::DecodedText (QString const& the_string) + : string_ {the_string} + , padding_ {the_string.indexOf (" ") > 4 ? 2 : 0} // allow for + // seconds + , message_ {string_.mid (column_qsoText + padding_).trimmed ()} + , is_standard_ {false} { - QRegularExpression callsign_re {R"(\s(CQ|DE|QRZ)(\s?DX|\s([A-Z]{2}|\d{3}))?\s(?[A-Z0-9/]{2,})(\s[A-R]{2}[0-9]{2})?)"}; - return callsign_re.match (_string).captured ("callsign"); + if (message_.length() >= 1) + { + message_ = message_.left (22).remove (QRegularExpression {"[<>]"}); + int i1 = message_.indexOf ('\r'); + if (i1 > 0) + { + message_ = message_.left (i1 - 1); + } + // stdmsg is a fortran routine that packs the text, unpacks it and compares the result + is_standard_ = stdmsg_ ((message_ + " ").toLatin1 ().constData (),22); + } +}; + +void DecodedText::removeAddedInfo () +{ + if (string_.indexOf (" CQ ") > 0) { + // TODO this magic 37 characters is also referenced in DisplayText::_appendDXCCWorkedB4() + auto eom_pos = string_.indexOf (' ', 37); + if (eom_pos < 37) eom_pos = string_.size () - 1; // we always want at least the characters + // to position 37 + string_ = string_.left (eom_pos + 1); // remove DXCC entity and worked B4 status. TODO need a better way to do this + } +} + +QString DecodedText::CQersCall() const +{ + QRegularExpression callsign_re {R"(^(CQ|DE|QRZ)(\s?DX|\s([A-Z]{2}|\d{3}))?\s(?[A-Z0-9/]{2,})(\s[A-R]{2}[0-9]{2})?)"}; + return callsign_re.match (message_).captured ("callsign"); } -bool DecodedText::isJT65() +bool DecodedText::isJT65() const { - return _string.indexOf("#") == column_mode + padding_; + return string_.indexOf("#") == column_mode + padding_; } -bool DecodedText::isJT9() +bool DecodedText::isJT9() const { - return _string.indexOf("@") == column_mode + padding_; + return string_.indexOf("@") == column_mode + padding_; } -bool DecodedText::isTX() +bool DecodedText::isTX() const { - int i = _string.indexOf("Tx"); + int i = string_.indexOf("Tx"); return (i >= 0 && i < 15); // TODO guessing those numbers. Does Tx ever move? } -bool DecodedText::isLowConfidence () +bool DecodedText::isLowConfidence () const { - return QChar {'?'} == _string.mid (padding_ + column_qsoText + 21, 1); + return QChar {'?'} == string_.mid (padding_ + column_qsoText + 21, 1); } -int DecodedText::frequencyOffset() +int DecodedText::frequencyOffset() const { - return _string.mid(column_freq + padding_,4).toInt(); + return string_.mid(column_freq + padding_,4).toInt(); } -int DecodedText::snr() +int DecodedText::snr() const { - int i1=_string.indexOf(" ")+1; - return _string.mid(i1,3).toInt(); + int i1=string_.indexOf(" ")+1; + return string_.mid(i1,3).toInt(); } -float DecodedText::dt() +float DecodedText::dt() const { - return _string.mid(column_dt + padding_,5).toFloat(); + return string_.mid(column_dt + padding_,5).toFloat(); } /* @@ -61,62 +92,56 @@ float DecodedText::dt() */ // find and extract any report. Returns true if this is a standard message -bool DecodedText::report(QString const& myBaseCall, QString const& dxBaseCall, /*mod*/QString& report) +bool DecodedText::report(QString const& myBaseCall, QString const& dxBaseCall, /*mod*/QString& report) const { - QString msg=_string.mid(column_qsoText + padding_).trimmed(); - if(msg.length() < 1) return false; - msg = msg.left (22).remove (QRegularExpression {"[<>]"}); - int i1=msg.indexOf('\r'); - if (i1>0) - msg=msg.left (i1-1); - bool b = stdmsg_ ((msg + " ").toLatin1().constData(),22); // stdmsg is a fortran routine that packs the text, unpacks it and compares the result + if (message_.size () < 1) return false; - QStringList w=msg.split(" ",QString::SkipEmptyParts); - if(w.size () - && b && (w[0] == myBaseCall - || w[0].endsWith ("/" + myBaseCall) - || w[0].startsWith (myBaseCall + "/") - || (w.size () > 1 && !dxBaseCall.isEmpty () - && (w[1] == dxBaseCall - || w[1].endsWith ("/" + dxBaseCall) - || w[1].startsWith (dxBaseCall + "/"))))) + QStringList const& w = message_.split(" ",QString::SkipEmptyParts); + if (w.size () + && is_standard_ && (w[0] == myBaseCall + || w[0].endsWith ("/" + myBaseCall) + || w[0].startsWith (myBaseCall + "/") + || (w.size () > 1 && !dxBaseCall.isEmpty () + && (w[1] == dxBaseCall + || w[1].endsWith ("/" + dxBaseCall) + || w[1].startsWith (dxBaseCall + "/"))))) { - QString tt=""; - if(w.size() > 2) tt=w[2]; - bool ok; - i1=tt.toInt(&ok); - if (ok and i1>=-50 and i1<50) + QString tt=""; + if(w.size() > 2) tt=w[2]; + bool ok; + auto i1=tt.toInt(&ok); + if (ok and i1>=-50 and i1<50) { - report = tt; + report = tt; } - else + else { - if (tt.mid(0,1)=="R") + if (tt.mid(0,1)=="R") { - i1=tt.mid(1).toInt(&ok); - if(ok and i1>=-50 and i1<50) + i1=tt.mid(1).toInt(&ok); + if(ok and i1>=-50 and i1<50) { - report = tt.mid(1); + report = tt.mid(1); } } } } - return b; + return is_standard_; } // get the first text word, usually the call -QString DecodedText::call() +QString DecodedText::call() const { - auto call = _string; + auto call = string_; call = call.replace (QRegularExpression {" CQ ([A-Z]{2,2}|[0-9]{3,3}) "}, " CQ_\\1 ").mid (column_qsoText + padding_); int i = call.indexOf(" "); return call.mid(0,i); } // get the second word, most likely the de call and the third word, most likely grid -void DecodedText::deCallAndGrid(/*out*/QString& call, QString& grid) +void DecodedText::deCallAndGrid(/*out*/QString& call, QString& grid) const { - auto msg = _string; + auto msg = string_; if(msg.mid(4,1)!=" ") msg=msg.mid(0,4)+msg.mid(6,-1); //Remove seconds from UTC msg = msg.replace (QRegularExpression {" CQ ([A-Z]{2,2}|[0-9]{3,3}) "}, " CQ_\\1 ").mid (column_qsoText + padding_); int i1 = msg.indexOf (" "); @@ -133,9 +158,9 @@ void DecodedText::deCallAndGrid(/*out*/QString& call, QString& grid) call = call.left (i2).replace (">", ""); } -int DecodedText::timeInSeconds() +int DecodedText::timeInSeconds() const { - return 60*_string.mid(column_time,2).toInt() + _string.mid(2,2).toInt(); + return 60*string_.mid(column_time,2).toInt() + string_.mid(2,2).toInt(); } /* @@ -147,7 +172,7 @@ int DecodedText::timeInSeconds() 0605 Tx 1259 # CQ VK3ACF QF22 */ -QString DecodedText::report() // returns a string of the SNR field with a leading + or - followed by two digits +QString DecodedText::report() const // returns a string of the SNR field with a leading + or - followed by two digits { int sr = snr(); if (sr<-50) diff --git a/decodedtext.h b/decodedtext.h index 952120932..49b054c71 100644 --- a/decodedtext.h +++ b/decodedtext.h @@ -27,54 +27,41 @@ class DecodedText { public: - void operator=(const QString &rhs) - { - _string = rhs; - padding_ = _string.indexOf (" ") > 4 ? 2 : 0; // allow for seconds - }; - void operator=(const QByteArray &rhs) - { - _string = rhs; - padding_ = _string.indexOf (" ") > 4 ? 2 : 0; // allow for seconds - }; + explicit DecodedText (QString const&); - void operator+=(const QString &rhs) - { - _string += rhs; - }; + QString string() const { return string_; }; + void removeAddedInfo (); + int indexOf(QString s) const { return string_.indexOf(s); }; + int indexOf(QString s, int i) const { return string_.indexOf(s,i); }; + QString mid(int f, int t) const { return string_.mid(f,t); }; + QString left(int i) const { return string_.left(i); }; - QString string() { return _string; }; + void clear() { string_.clear(); }; - int indexOf(QString s) { return _string.indexOf(s); }; - int indexOf(QString s, int i) { return _string.indexOf(s,i); }; - QString mid(int f, int t) { return _string.mid(f,t); }; - QString left(int i) { return _string.left(i); }; + QString CQersCall() const; - void clear() { _string.clear(); }; - - QString CQersCall(); - - bool isJT65(); - bool isJT9(); - bool isTX(); - bool isLowConfidence (); - int frequencyOffset(); // hertz offset from the tuned dial or rx frequency, aka audio frequency - int snr(); - float dt(); + bool isJT65() const; + bool isJT9() const; + bool isTX() const; + bool isStandardMessage () const {return is_standard_;} + bool isLowConfidence () const; + int frequencyOffset() const; // hertz offset from the tuned dial or rx frequency, aka audio frequency + int snr() const; + float dt() const; // find and extract any report. Returns true if this is a standard message - bool report(QString const& myBaseCall, QString const& dxBaseCall, /*mod*/QString& report); + bool report(QString const& myBaseCall, QString const& dxBaseCall, /*mod*/QString& report) const; // get the first message text word, usually the call - QString call(); + QString call() const; // get the second word, most likely the de call and the third word, most likely grid - void deCallAndGrid(/*out*/QString& call, QString& grid); + void deCallAndGrid(/*out*/QString& call, QString& grid) const; - int timeInSeconds(); + int timeInSeconds() const; // returns a string of the SNR field with a leading + or - followed by two digits - QString report(); + QString report() const; private: // These define the columns in the decoded text where fields are to be found. @@ -86,8 +73,10 @@ private: column_mode = 19, column_qsoText = 22 }; - QString _string; + QString string_; int padding_; + QString message_; + bool is_standard_; }; #endif // DECODEDTEXT_H diff --git a/displaytext.cpp b/displaytext.cpp index 8d28ac879..fa62940d6 100644 --- a/displaytext.cpp +++ b/displaytext.cpp @@ -81,7 +81,7 @@ void DisplayText::appendText(QString const& text, QColor bg) QString DisplayText::appendDXCCWorkedB4(QString message, QString const& callsign, QColor * bg, - LogBook logBook, QColor color_CQ, + LogBook const& logBook, QColor color_CQ, QColor color_DXCC, QColor color_NewCall) { @@ -158,8 +158,8 @@ QString DisplayText::appendDXCCWorkedB4(QString message, QString const& callsign return message; } -void DisplayText::displayDecodedText(DecodedText decodedText, QString myCall, - bool displayDXCCEntity, LogBook logBook, +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) { diff --git a/displaytext.h b/displaytext.h index b6c0dd01c..f0c72a7bb 100644 --- a/displaytext.h +++ b/displaytext.h @@ -17,8 +17,8 @@ public: void setContentFont (QFont const&); void insertLineSpacer(QString const&); - void displayDecodedText(DecodedText decodedText, QString myCall, bool displayDXCCEntity, - LogBook logBook, QColor color_CQ, QColor color_MyCall, + 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); void displayTransmittedText(QString text, QString modeTx, qint32 txFreq, QColor color_TxMsg, bool bFastMode); @@ -32,7 +32,7 @@ protected: void mouseDoubleClickEvent(QMouseEvent *e); private: - QString appendDXCCWorkedB4(QString message, QString const& callsign, QColor * bg, LogBook logBook, + QString appendDXCCWorkedB4(QString message, QString const& callsign, QColor * bg, LogBook const& logBook, QColor color_CQ, QColor color_DXCC, QColor color_NewCall); QFont char_font_; diff --git a/logbook/adif.cpp b/logbook/adif.cpp index 7077b5659..30f450a0b 100644 --- a/logbook/adif.cpp +++ b/logbook/adif.cpp @@ -18,7 +18,7 @@ void ADIF::init(QString const& filename) } -QString ADIF::_extractField(QString const& line, QString const& fieldName) +QString ADIF::_extractField(QString const& line, QString const& fieldName) const { int fieldNameIndex = line.indexOf(fieldName,0,Qt::CaseInsensitive); if (fieldNameIndex >=0) @@ -87,7 +87,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) -bool ADIF::match(QString const& call, QString const& band, QString const& mode) +bool ADIF::match(QString const& call, QString const& band, QString const& mode) const { QList qsos = _data.values(call); if (qsos.size()>0) @@ -120,7 +120,7 @@ bool ADIF::match(QString const& call, QString const& band, QString const& mode) return false; } -QList ADIF::getCallList() +QList ADIF::getCallList() const { QList p; QMultiHash::const_iterator i = _data.constBegin(); @@ -132,7 +132,7 @@ QList ADIF::getCallList() return p; } -int ADIF::getCount() +int ADIF::getCount() const { return _data.size(); } diff --git a/logbook/adif.h b/logbook/adif.h index 00e0c74c8..604a448ec 100644 --- a/logbook/adif.h +++ b/logbook/adif.h @@ -21,18 +21,18 @@ class QDateTime; class ADIF { public: - void init(QString const& filename); - void load(); - void add(QString const& call, QString const& band, QString const& mode, QString const& date); - bool match(QString const& call, QString const& band, QString const& mode); - QList getCallList(); - int getCount(); + void init(QString const& filename); + void load(); + void add(QString const& call, QString const& band, QString const& mode, QString const& date); + bool match(QString const& call, QString const& band, QString const& mode) const; + QList getCallList() const; + int getCount() const; // open ADIF file and append the QSO details. Return true on success - bool addQSOToFile(QString const& hisCall, QString const& hisGrid, QString const& mode, QString const& rptSent, QString const& rptRcvd, QDateTime const& dateTimeOn, QDateTime const& dateTimeOff, QString const& band, - QString const& comments, QString const& name, QString const& strDialFreq, QString const& m_myCall, QString const& m_myGrid, QString const& m_txPower); + bool addQSOToFile(QString const& hisCall, QString const& hisGrid, QString const& mode, QString const& rptSent, QString const& rptRcvd, QDateTime const& dateTimeOn, QDateTime const& dateTimeOff, QString const& band, + QString const& comments, QString const& name, QString const& strDialFreq, QString const& m_myCall, QString const& m_myGrid, QString const& m_txPower); - static QString bandFromFrequency(double dialFreq); + static QString bandFromFrequency(double dialFreq); private: struct QSO @@ -43,7 +43,7 @@ class ADIF QMultiHash _data; QString _filename; - QString _extractField(QString const& line, QString const& fieldName); + QString _extractField(QString const& line, QString const& fieldName) const; }; diff --git a/logbook/countriesworked.cpp b/logbook/countriesworked.cpp index a70a4e1af..6a991f8a4 100644 --- a/logbook/countriesworked.cpp +++ b/logbook/countriesworked.cpp @@ -13,7 +13,7 @@ void CountriesWorked::setAsWorked(const QString countryName) _data.insert(countryName,true); } -bool CountriesWorked::getHasWorked(const QString countryName) +bool CountriesWorked::getHasWorked(const QString countryName) const { if (_data.contains(countryName)) return _data.value(countryName); @@ -21,7 +21,7 @@ bool CountriesWorked::getHasWorked(const QString countryName) return false; } -int CountriesWorked::getWorkedCount() +int CountriesWorked::getWorkedCount() const { int count = 0; foreach (bool value,_data) @@ -30,7 +30,7 @@ int CountriesWorked::getWorkedCount() return count; } -int CountriesWorked::getSize() +int CountriesWorked::getSize() const { return _data.count(); } diff --git a/logbook/countriesworked.h b/logbook/countriesworked.h index 34fcc0c0b..fedfa7524 100644 --- a/logbook/countriesworked.h +++ b/logbook/countriesworked.h @@ -14,15 +14,15 @@ class CountriesWorked { - public: - void init(const QStringList countryNames); - void setAsWorked(const QString countryName); - bool getHasWorked(const QString countryName); - int getWorkedCount(); - int getSize(); + public: + void init(const QStringList countryNames); + void setAsWorked(const QString countryName); + bool getHasWorked(const QString countryName) const; + int getWorkedCount() const; + int getSize() const; - private: - QHash _data; + private: + QHash _data; }; #endif diff --git a/logbook/countrydat.cpp b/logbook/countrydat.cpp index 613d4aeeb..d0d976d69 100644 --- a/logbook/countrydat.cpp +++ b/logbook/countrydat.cpp @@ -26,7 +26,7 @@ void CountryDat::init(const QString filename) _data.clear(); } -QString CountryDat::_extractName(const QString line) +QString CountryDat::_extractName(const QString line) const { int s1 = line.indexOf(':'); if (s1>=0) @@ -37,7 +37,7 @@ QString CountryDat::_extractName(const QString line) return ""; } -void CountryDat::_removeBrackets(QString &line, const QString a, const QString b) +void CountryDat::_removeBrackets(QString &line, const QString a, const QString b) const { int s1 = line.indexOf(a); while (s1 >= 0) @@ -48,7 +48,7 @@ void CountryDat::_removeBrackets(QString &line, const QString a, const QString b } } -QStringList CountryDat::_extractPrefix(QString &line, bool &more) +QStringList CountryDat::_extractPrefix(QString &line, bool &more) const { line = line.remove(" \n"); line = line.replace("=",""); @@ -117,7 +117,7 @@ void CountryDat::load() } // return country name else "" -QString CountryDat::find(QString prefix) +QString CountryDat::find(QString prefix) const { prefix = prefix.toUpper (); auto pf = prefix; @@ -143,6 +143,3 @@ QString CountryDat::find(QString prefix) } return QString {}; } - - - diff --git a/logbook/countrydat.h b/logbook/countrydat.h index ce5d70e3b..383e783f1 100644 --- a/logbook/countrydat.h +++ b/logbook/countrydat.h @@ -19,13 +19,13 @@ class CountryDat public: void init(const QString filename); void load(); - QString find(QString prefix); // return country name or "" - QStringList getCountryNames() { return _countryNames; }; + QString find(QString prefix) const; // return country name or "" + QStringList getCountryNames() const { return _countryNames; }; private: - QString _extractName(const QString line); - void _removeBrackets(QString &line, const QString a, const QString b); - QStringList _extractPrefix(QString &line, bool &more); + QString _extractName(const QString line) const; + void _removeBrackets(QString &line, const QString a, const QString b) const; + QStringList _extractPrefix(QString &line, bool &more) const; QString _filename; QStringList _countryNames; diff --git a/logbook/logbook.cpp b/logbook/logbook.cpp index 9fb8a79d0..48d6a2a6f 100644 --- a/logbook/logbook.cpp +++ b/logbook/logbook.cpp @@ -67,7 +67,7 @@ void LogBook::_setAlreadyWorkedFromLog() void LogBook::match(/*in*/const QString call, /*out*/ QString &countryName, bool &callWorkedBefore, - bool &countryWorkedBefore) + bool &countryWorkedBefore) const { if (call.length() > 0) { diff --git a/logbook/logbook.h b/logbook/logbook.h index 38ea9d188..4b80974db 100644 --- a/logbook/logbook.h +++ b/logbook/logbook.h @@ -23,7 +23,7 @@ public: void match(/*in*/ const QString call, /*out*/ QString &countryName, bool &callWorkedBefore, - bool &countryWorkedBefore); + bool &countryWorkedBefore) 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 17ae01828..82f3816f4 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -42,6 +42,7 @@ #include "widegraph.h" #include "sleep.h" #include "logqso.h" +#include "decodedtext.h" #include "Radio.hpp" #include "Bands.hpp" #include "TransceiverFactory.hpp" @@ -690,7 +691,6 @@ MainWindow::MainWindow(QDir const& temp_directory, bool multiple, connect(m_wideGraph.data (), SIGNAL(setFreq3(int,int)),this, SLOT(setFreq4(int,int))); - m_QSOText.clear(); decodeBusy(false); QString t1[28]={"1 uW","2 uW","5 uW","10 uW","20 uW","50 uW","100 uW","200 uW","500 uW", "1 mW","2 mW","5 mW","10 mW","20 mW","50 mW","100 mW","200 mW","500 mW", @@ -1191,8 +1191,7 @@ void MainWindow::dataSink(qint64 frames) int ftol = ui->sbFtol->value (); freqcal_(&dec_data.d2[0],&k,&nkhz,&RxFreq,&ftol,&line[0],80); QString t=QString::fromLatin1(line); - DecodedText decodedtext; - decodedtext=t; + 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()); @@ -1426,10 +1425,8 @@ void MainWindow::fastSink(qint64 frames) m_fastGraph->plotSpec(m_diskData,m_UTCdisk); if(bmsk144 and (line[0]!=0)) { - DecodedText decodedtext; - QString message; - message=QString::fromLatin1(line); - decodedtext=message.replace(QChar::LineFeed,""); + QString message {QString::fromLatin1 (line)}; + 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()); @@ -1439,7 +1436,7 @@ void MainWindow::fastSink(qint64 frames) writeAllTxt(message); bool stdMsg = decodedtext.report(m_baseCall, Radio::base_callsign(ui->dxCallEntry->text()),m_rptRcvd); - decodedtext=message.mid(0,4) + message.mid(6,-1); + decodedtext = DecodedText {message.left (4) + message.mid (6, -1)}; if (stdMsg) pskPost (decodedtext); } @@ -2570,8 +2567,7 @@ void::MainWindow::fast_decode_done() if(narg[13]/8==narg[12]) message=message.trimmed().replace("<...>",m_calls); //Left (Band activity) window - DecodedText decodedtext; - decodedtext=message.replace(QChar::LineFeed,""); + DecodedText decodedtext {message.replace (QChar::LineFeed, "")}; 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(), @@ -2590,12 +2586,12 @@ void::MainWindow::fast_decode_done() if(m_mode=="JT9" or m_mode=="MSK144") { // find and extract any report for myCall QString msg=message.mid(0,4) + message.mid(6,-1); - decodedtext=msg.replace(QChar::LineFeed,""); + decodedtext = DecodedText {msg.replace (QChar::LineFeed, "")}; bool stdMsg = decodedtext.report(m_baseCall, - Radio::base_callsign(ui->dxCallEntry->text()), m_rptRcvd); + Radio::base_callsign(ui->dxCallEntry->text()), m_rptRcvd); // extract details and send to PSKreporter - if (stdMsg) pskPost(decodedtext); + if (stdMsg) pskPost (decodedtext); } } m_startAnother=m_loopall; @@ -2707,21 +2703,20 @@ void MainWindow::readFromStdout() //readFromStdout .arg (f.fileName ()).arg (f.errorString ())); } - if (m_config.insert_blank () && m_blankLine) - { - QString band; - if (QDateTime::currentMSecsSinceEpoch() / 1000 - m_secBandChanged > 50) - { - band = ' ' + m_config.bands ()->find (m_freqNominal); - } - ui->decodedTextBrowser->insertLineSpacer (band.rightJustified (40, '-')); - m_blankLine = false; - } + if (m_config.insert_blank () && m_blankLine) + { + QString band; + if (QDateTime::currentMSecsSinceEpoch() / 1000 - m_secBandChanged > 50) + { + band = ' ' + m_config.bands ()->find (m_freqNominal); + } + ui->decodedTextBrowser->insertLineSpacer (band.rightJustified (40, '-')); + m_blankLine = false; + } - DecodedText decodedtext; - decodedtext = QString::fromUtf8 (t.constData ()).remove (QRegularExpression {"\r|\n"}); + DecodedText decodedtext {QString::fromUtf8 (t.constData ()).remove (QRegularExpression {"\r|\n"})}; - //Left (Band activity) window + //Left (Band activity) window if(!bAvgMsg) { ui->decodedTextBrowser->displayDecodedText(decodedtext,m_baseCall,m_config.DXCC(), m_logBook,m_config.color_CQ(),m_config.color_MyCall(), @@ -2762,7 +2757,7 @@ void MainWindow::readFromStdout() //readFromStdout if(b65 and m_modeTx!="JT65") on_pbTxMode_clicked(); if(!b65 and m_modeTx=="JT65") on_pbTxMode_clicked(); } - m_QSOText=decodedtext; + m_QSOText = decodedtext.string (); } if(m_mode=="FT8" or m_mode=="QRA64") auto_sequence (decodedtext.string(), 25, 50); @@ -2836,7 +2831,7 @@ void MainWindow::auto_sequence (QString const& message, unsigned start_tolerance } } -void MainWindow::pskPost (DecodedText decodedtext) +void MainWindow::pskPost (DecodedText const& decodedtext) { if (m_diskData || !m_config.spot_to_psk_reporter() || decodedtext.isLowConfidence ()) return; @@ -3648,7 +3643,6 @@ void MainWindow::processMessage(QString const& messages, int position, bool ctrl { QString t1 = messages.left(position); //contents up to \n on selected line int i1=t1.lastIndexOf(QChar::LineFeed) + 1; //points to first char of line - DecodedText decodedtext; QString t2 = messages.mid(i1,position-i1); //selected line // basic mode sanity checks @@ -3687,15 +3681,8 @@ void MainWindow::processMessage(QString const& messages, int position, bool ctrl } } } - decodedtext = t2a; - - if (decodedtext.indexOf(" CQ ") > 0) { -// TODO this magic 37 characters is also referenced in DisplayText::_appendDXCCWorkedB4() - auto eom_pos = decodedtext.string ().indexOf (' ', 37); - if (eom_pos < 37) eom_pos = decodedtext.string ().size () - 1; // we always want at least the characters - // to position 37 - decodedtext = decodedtext.string ().left (eom_pos + 1); // remove DXCC entity and worked B4 status. TODO need a better way to do this - } + DecodedText decodedtext {t2a}; + decodedtext.removeAddedInfo (); auto t3 = decodedtext.string (); auto t4 = t3.replace (QRegularExpression {" CQ ([A-Z]{2,2}|[0-9]{3,3}) "}, " CQ_\\1 ").split (" ", QString::SkipEmptyParts); @@ -3720,14 +3707,24 @@ void MainWindow::processMessage(QString const& messages, int position, bool ctrl QString hiscall; QString hisgrid; decodedtext.deCallAndGrid(/*out*/hiscall,hisgrid); - auto acceptable_73 = m_QSOProgress >= ROGER_REPORT && message_is_73 (0, t4); - if (!Radio::is_callsign (hiscall) // not interested if not from QSO partner - && !(t4.size () == 7 // unless it is of the form - && (t4.at (5) == m_baseCall // " 73" - || t4.at (5).startsWith (m_baseCall + '/') - || t4.at (5).endsWith ('/' + m_baseCall)) - && t4.at (6) == "73") - && !acceptable_73) + bool is_73 = t4.filter (QRegularExpression {"73|RR73"}).size (); + auto acceptable_73 = + m_QSOProgress >= ROGER_REPORT + && is_73 + && ((decodedtext.isStandardMessage () + && (t4.contains (m_baseCall) + || t4.contains (m_config.my_callsign ()) + || t4.contains (ui->dxCallEntry->text ()) + || t4.contains (Radio::base_callsign (ui->dxCallEntry->text ())) + || t4.contains ("DE"))) + || !decodedtext.isStandardMessage ()); + if ((is_73 && !acceptable_73) + || (!Radio::is_callsign (hiscall) // not interested if not from QSO partner + && !(t4.size () == 7 // unless it is of the form + && (t4.at (5) == m_baseCall // " 73" + || t4.at (5).startsWith (m_baseCall + '/') + || t4.at (5).endsWith ('/' + m_baseCall)) + && t4.at (6) == "73"))) { qDebug () << "Not processing message - hiscall:" << hiscall << "hisgrid:" << hisgrid; return; @@ -3934,17 +3931,17 @@ void MainWindow::processMessage(QString const& messages, int position, bool ctrl // if we get here then we are reacting to the message if (m_bAutoReply) m_bCallingCQ = CALLING == m_QSOProgress; - QString s1=m_QSOText.string().trimmed(); + QString s1 = m_QSOText.trimmed (); QString s2=t2.trimmed(); if (s1!=s2 and !decodedtext.isTX()) { - decodedtext=t2; + decodedtext = DecodedText {t2}; 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_QSOText=decodedtext; + m_QSOText = decodedtext.string (); } - if (hiscall != "73" && !acceptable_73 + if (hiscall != "73" && (base_call != qso_partner_base_call || base_call != hiscall)) { if (qso_partner_base_call != base_call) { diff --git a/mainwindow.h b/mainwindow.h index 5a0e925d0..b3a87431c 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -33,7 +33,6 @@ #include "DisplayManual.hpp" #include "psk_reporter.h" #include "logbook/logbook.h" -#include "decodedtext.h" #include "commons.h" #include "astro.h" #include "MessageBox.hpp" @@ -82,6 +81,7 @@ class Detector; class SampleDownloader; class MultiSettings; class EqualizationToolsDialog; +class DecodedText; class MainWindow : public QMainWindow { @@ -541,7 +541,7 @@ private: QSharedMemory *mem_jt9; LogBook m_logBook; - DecodedText m_QSOText; + QString m_QSOText; unsigned m_msAudioOutputBuffered; unsigned m_framesAudioInputBuffered; unsigned m_downSampleFactor; @@ -588,7 +588,7 @@ private: void transmit (double snr = 99.); void rigFailure (QString const& reason); void pskSetLocal (); - void pskPost(DecodedText decodedtext); + void pskPost(DecodedText const& decodedtext); void displayDialFrequency (); void transmitDisplay (bool); void processMessage(QString const& messages, qint32 position, bool ctrl = false, bool alt = false);