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
This commit is contained in:
Bill Somerville 2017-08-30 02:27:57 +00:00
parent 683e35fdec
commit 363c469b55
14 changed files with 196 additions and 188 deletions

View File

@ -7,48 +7,79 @@ extern "C" {
bool stdmsg_(const char* msg, int len); 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(?<callsign>[A-Z0-9/]{2,})(\s[A-R]{2}[0-9]{2})?)"}; if (message_.length() >= 1)
return callsign_re.match (_string).captured ("callsign"); {
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(?<callsign>[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? 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; int i1=string_.indexOf(" ")+1;
return _string.mid(i1,3).toInt(); 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,19 +92,13 @@ float DecodedText::dt()
*/ */
// find and extract any report. Returns true if this is a standard message // 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 (message_.size () < 1) return false;
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
QStringList w=msg.split(" ",QString::SkipEmptyParts); QStringList const& w = message_.split(" ",QString::SkipEmptyParts);
if (w.size () if (w.size ()
&& b && (w[0] == myBaseCall && is_standard_ && (w[0] == myBaseCall
|| w[0].endsWith ("/" + myBaseCall) || w[0].endsWith ("/" + myBaseCall)
|| w[0].startsWith (myBaseCall + "/") || w[0].startsWith (myBaseCall + "/")
|| (w.size () > 1 && !dxBaseCall.isEmpty () || (w.size () > 1 && !dxBaseCall.isEmpty ()
@ -84,7 +109,7 @@ bool DecodedText::report(QString const& myBaseCall, QString const& dxBaseCall, /
QString tt=""; QString tt="";
if(w.size() > 2) tt=w[2]; if(w.size() > 2) tt=w[2];
bool ok; bool ok;
i1=tt.toInt(&ok); auto i1=tt.toInt(&ok);
if (ok and i1>=-50 and i1<50) if (ok and i1>=-50 and i1<50)
{ {
report = tt; report = tt;
@ -101,22 +126,22 @@ bool DecodedText::report(QString const& myBaseCall, QString const& dxBaseCall, /
} }
} }
} }
return b; return is_standard_;
} }
// get the first text word, usually the call // 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_); call = call.replace (QRegularExpression {" CQ ([A-Z]{2,2}|[0-9]{3,3}) "}, " CQ_\\1 ").mid (column_qsoText + padding_);
int i = call.indexOf(" "); int i = call.indexOf(" ");
return call.mid(0,i); return call.mid(0,i);
} }
// get the second word, most likely the de call and the third word, most likely grid // 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 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_); msg = msg.replace (QRegularExpression {" CQ ([A-Z]{2,2}|[0-9]{3,3}) "}, " CQ_\\1 ").mid (column_qsoText + padding_);
int i1 = msg.indexOf (" "); int i1 = msg.indexOf (" ");
@ -133,9 +158,9 @@ void DecodedText::deCallAndGrid(/*out*/QString& call, QString& grid)
call = call.left (i2).replace (">", ""); 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 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(); int sr = snr();
if (sr<-50) if (sr<-50)

View File

@ -27,54 +27,41 @@
class DecodedText class DecodedText
{ {
public: public:
void operator=(const QString &rhs) explicit DecodedText (QString const&);
{
_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
};
void operator+=(const QString &rhs) QString string() const { return string_; };
{ void removeAddedInfo ();
_string += rhs; 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); }; QString CQersCall() const;
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); };
void clear() { _string.clear(); }; bool isJT65() const;
bool isJT9() const;
QString CQersCall(); bool isTX() const;
bool isStandardMessage () const {return is_standard_;}
bool isJT65(); bool isLowConfidence () const;
bool isJT9(); int frequencyOffset() const; // hertz offset from the tuned dial or rx frequency, aka audio frequency
bool isTX(); int snr() const;
bool isLowConfidence (); float dt() const;
int frequencyOffset(); // hertz offset from the tuned dial or rx frequency, aka audio frequency
int snr();
float dt();
// find and extract any report. Returns true if this is a standard message // 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 // 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 // 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 // returns a string of the SNR field with a leading + or - followed by two digits
QString report(); QString report() const;
private: private:
// These define the columns in the decoded text where fields are to be found. // These define the columns in the decoded text where fields are to be found.
@ -86,8 +73,10 @@ private:
column_mode = 19, column_mode = 19,
column_qsoText = 22 }; column_qsoText = 22 };
QString _string; QString string_;
int padding_; int padding_;
QString message_;
bool is_standard_;
}; };
#endif // DECODEDTEXT_H #endif // DECODEDTEXT_H

View File

@ -81,7 +81,7 @@ void DisplayText::appendText(QString const& text, QColor bg)
QString DisplayText::appendDXCCWorkedB4(QString message, QString const& callsign, 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_DXCC,
QColor color_NewCall) QColor color_NewCall)
{ {
@ -158,8 +158,8 @@ QString DisplayText::appendDXCCWorkedB4(QString message, QString const& callsign
return message; return message;
} }
void DisplayText::displayDecodedText(DecodedText decodedText, QString myCall, void DisplayText::displayDecodedText(DecodedText const& decodedText, QString const& myCall,
bool displayDXCCEntity, LogBook logBook, bool displayDXCCEntity, LogBook const& logBook,
QColor color_CQ, QColor color_MyCall, QColor color_CQ, QColor color_MyCall,
QColor color_DXCC, QColor color_NewCall) QColor color_DXCC, QColor color_NewCall)
{ {

View File

@ -17,8 +17,8 @@ public:
void setContentFont (QFont const&); void setContentFont (QFont const&);
void insertLineSpacer(QString const&); void insertLineSpacer(QString const&);
void displayDecodedText(DecodedText decodedText, QString myCall, bool displayDXCCEntity, void displayDecodedText(DecodedText const& decodedText, QString const& myCall, bool displayDXCCEntity,
LogBook logBook, QColor color_CQ, QColor color_MyCall, LogBook const& logBook, QColor color_CQ, QColor color_MyCall,
QColor color_DXCC, QColor color_NewCall); QColor color_DXCC, QColor color_NewCall);
void displayTransmittedText(QString text, QString modeTx, qint32 txFreq, void displayTransmittedText(QString text, QString modeTx, qint32 txFreq,
QColor color_TxMsg, bool bFastMode); QColor color_TxMsg, bool bFastMode);
@ -32,7 +32,7 @@ protected:
void mouseDoubleClickEvent(QMouseEvent *e); void mouseDoubleClickEvent(QMouseEvent *e);
private: 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); QColor color_CQ, QColor color_DXCC, QColor color_NewCall);
QFont char_font_; QFont char_font_;

View File

@ -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); int fieldNameIndex = line.indexOf(fieldName,0,Qt::CaseInsensitive);
if (fieldNameIndex >=0) 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) // 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<QSO> qsos = _data.values(call); QList<QSO> qsos = _data.values(call);
if (qsos.size()>0) if (qsos.size()>0)
@ -120,7 +120,7 @@ bool ADIF::match(QString const& call, QString const& band, QString const& mode)
return false; return false;
} }
QList<QString> ADIF::getCallList() QList<QString> ADIF::getCallList() const
{ {
QList<QString> p; QList<QString> p;
QMultiHash<QString,QSO>::const_iterator i = _data.constBegin(); QMultiHash<QString,QSO>::const_iterator i = _data.constBegin();
@ -132,7 +132,7 @@ QList<QString> ADIF::getCallList()
return p; return p;
} }
int ADIF::getCount() int ADIF::getCount() const
{ {
return _data.size(); return _data.size();
} }

View File

@ -24,9 +24,9 @@ class ADIF
void init(QString const& filename); void init(QString const& filename);
void load(); void load();
void add(QString const& call, QString const& band, QString const& mode, QString const& date); 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); bool match(QString const& call, QString const& band, QString const& mode) const;
QList<QString> getCallList(); QList<QString> getCallList() const;
int getCount(); int getCount() const;
// open ADIF file and append the QSO details. Return true on success // 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, 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,
@ -43,7 +43,7 @@ class ADIF
QMultiHash<QString, QSO> _data; QMultiHash<QString, QSO> _data;
QString _filename; QString _filename;
QString _extractField(QString const& line, QString const& fieldName); QString _extractField(QString const& line, QString const& fieldName) const;
}; };

View File

@ -13,7 +13,7 @@ void CountriesWorked::setAsWorked(const QString countryName)
_data.insert(countryName,true); _data.insert(countryName,true);
} }
bool CountriesWorked::getHasWorked(const QString countryName) bool CountriesWorked::getHasWorked(const QString countryName) const
{ {
if (_data.contains(countryName)) if (_data.contains(countryName))
return _data.value(countryName); return _data.value(countryName);
@ -21,7 +21,7 @@ bool CountriesWorked::getHasWorked(const QString countryName)
return false; return false;
} }
int CountriesWorked::getWorkedCount() int CountriesWorked::getWorkedCount() const
{ {
int count = 0; int count = 0;
foreach (bool value,_data) foreach (bool value,_data)
@ -30,7 +30,7 @@ int CountriesWorked::getWorkedCount()
return count; return count;
} }
int CountriesWorked::getSize() int CountriesWorked::getSize() const
{ {
return _data.count(); return _data.count();
} }

View File

@ -17,9 +17,9 @@ class CountriesWorked
public: public:
void init(const QStringList countryNames); void init(const QStringList countryNames);
void setAsWorked(const QString countryName); void setAsWorked(const QString countryName);
bool getHasWorked(const QString countryName); bool getHasWorked(const QString countryName) const;
int getWorkedCount(); int getWorkedCount() const;
int getSize(); int getSize() const;
private: private:
QHash<QString, bool> _data; QHash<QString, bool> _data;

View File

@ -26,7 +26,7 @@ void CountryDat::init(const QString filename)
_data.clear(); _data.clear();
} }
QString CountryDat::_extractName(const QString line) QString CountryDat::_extractName(const QString line) const
{ {
int s1 = line.indexOf(':'); int s1 = line.indexOf(':');
if (s1>=0) if (s1>=0)
@ -37,7 +37,7 @@ QString CountryDat::_extractName(const QString line)
return ""; 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); int s1 = line.indexOf(a);
while (s1 >= 0) 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.remove(" \n");
line = line.replace("=",""); line = line.replace("=","");
@ -117,7 +117,7 @@ void CountryDat::load()
} }
// return country name else "" // return country name else ""
QString CountryDat::find(QString prefix) QString CountryDat::find(QString prefix) const
{ {
prefix = prefix.toUpper (); prefix = prefix.toUpper ();
auto pf = prefix; auto pf = prefix;
@ -143,6 +143,3 @@ QString CountryDat::find(QString prefix)
} }
return QString {}; return QString {};
} }

View File

@ -19,13 +19,13 @@ class CountryDat
public: public:
void init(const QString filename); void init(const QString filename);
void load(); void load();
QString find(QString prefix); // return country name or "" QString find(QString prefix) const; // return country name or ""
QStringList getCountryNames() { return _countryNames; }; QStringList getCountryNames() const { return _countryNames; };
private: private:
QString _extractName(const QString line); QString _extractName(const QString line) const;
void _removeBrackets(QString &line, const QString a, const QString b); void _removeBrackets(QString &line, const QString a, const QString b) const;
QStringList _extractPrefix(QString &line, bool &more); QStringList _extractPrefix(QString &line, bool &more) const;
QString _filename; QString _filename;
QStringList _countryNames; QStringList _countryNames;

View File

@ -67,7 +67,7 @@ void LogBook::_setAlreadyWorkedFromLog()
void LogBook::match(/*in*/const QString call, void LogBook::match(/*in*/const QString call,
/*out*/ QString &countryName, /*out*/ QString &countryName,
bool &callWorkedBefore, bool &callWorkedBefore,
bool &countryWorkedBefore) bool &countryWorkedBefore) const
{ {
if (call.length() > 0) if (call.length() > 0)
{ {

View File

@ -23,7 +23,7 @@ public:
void match(/*in*/ const QString call, void match(/*in*/ const QString call,
/*out*/ QString &countryName, /*out*/ QString &countryName,
bool &callWorkedBefore, bool &callWorkedBefore,
bool &countryWorkedBefore); bool &countryWorkedBefore) const;
void addAsWorked(const QString call, const QString band, const QString mode, const QString date); void addAsWorked(const QString call, const QString band, const QString mode, const QString date);
private: private:

View File

@ -42,6 +42,7 @@
#include "widegraph.h" #include "widegraph.h"
#include "sleep.h" #include "sleep.h"
#include "logqso.h" #include "logqso.h"
#include "decodedtext.h"
#include "Radio.hpp" #include "Radio.hpp"
#include "Bands.hpp" #include "Bands.hpp"
#include "TransceiverFactory.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, connect(m_wideGraph.data (), SIGNAL(setFreq3(int,int)),this,
SLOT(setFreq4(int,int))); SLOT(setFreq4(int,int)));
m_QSOText.clear();
decodeBusy(false); decodeBusy(false);
QString t1[28]={"1 uW","2 uW","5 uW","10 uW","20 uW","50 uW","100 uW","200 uW","500 uW", 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", "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 (); int ftol = ui->sbFtol->value ();
freqcal_(&dec_data.d2[0],&k,&nkhz,&RxFreq,&ftol,&line[0],80); freqcal_(&dec_data.d2[0],&k,&nkhz,&RxFreq,&ftol,&line[0],80);
QString t=QString::fromLatin1(line); QString t=QString::fromLatin1(line);
DecodedText decodedtext; DecodedText decodedtext {t};
decodedtext=t;
ui->decodedTextBrowser->displayDecodedText (decodedtext,m_baseCall,m_config.DXCC(), ui->decodedTextBrowser->displayDecodedText (decodedtext,m_baseCall,m_config.DXCC(),
m_logBook,m_config.color_CQ(),m_config.color_MyCall(),m_config.color_DXCC(), m_logBook,m_config.color_CQ(),m_config.color_MyCall(),m_config.color_DXCC(),
m_config.color_NewCall()); m_config.color_NewCall());
@ -1426,10 +1425,8 @@ void MainWindow::fastSink(qint64 frames)
m_fastGraph->plotSpec(m_diskData,m_UTCdisk); m_fastGraph->plotSpec(m_diskData,m_UTCdisk);
if(bmsk144 and (line[0]!=0)) { if(bmsk144 and (line[0]!=0)) {
DecodedText decodedtext; QString message {QString::fromLatin1 (line)};
QString message; DecodedText decodedtext {message.replace (QChar::LineFeed, "")};
message=QString::fromLatin1(line);
decodedtext=message.replace(QChar::LineFeed,"");
ui->decodedTextBrowser->displayDecodedText (decodedtext,m_baseCall,m_config.DXCC(), ui->decodedTextBrowser->displayDecodedText (decodedtext,m_baseCall,m_config.DXCC(),
m_logBook,m_config.color_CQ(),m_config.color_MyCall(),m_config.color_DXCC(), m_logBook,m_config.color_CQ(),m_config.color_MyCall(),m_config.color_DXCC(),
m_config.color_NewCall()); m_config.color_NewCall());
@ -1439,7 +1436,7 @@ void MainWindow::fastSink(qint64 frames)
writeAllTxt(message); writeAllTxt(message);
bool stdMsg = decodedtext.report(m_baseCall, bool stdMsg = decodedtext.report(m_baseCall,
Radio::base_callsign(ui->dxCallEntry->text()),m_rptRcvd); 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); 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); if(narg[13]/8==narg[12]) message=message.trimmed().replace("<...>",m_calls);
//Left (Band activity) window //Left (Band activity) window
DecodedText decodedtext; DecodedText decodedtext {message.replace (QChar::LineFeed, "")};
decodedtext=message.replace(QChar::LineFeed,"");
if(!m_bFastDone) { if(!m_bFastDone) {
ui->decodedTextBrowser->displayDecodedText (decodedtext,m_baseCall,m_config.DXCC(), ui->decodedTextBrowser->displayDecodedText (decodedtext,m_baseCall,m_config.DXCC(),
m_logBook,m_config.color_CQ(),m_config.color_MyCall(),m_config.color_DXCC(), m_logBook,m_config.color_CQ(),m_config.color_MyCall(),m_config.color_DXCC(),
@ -2590,7 +2586,7 @@ void::MainWindow::fast_decode_done()
if(m_mode=="JT9" or m_mode=="MSK144") { if(m_mode=="JT9" or m_mode=="MSK144") {
// find and extract any report for myCall // find and extract any report for myCall
QString msg=message.mid(0,4) + message.mid(6,-1); 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, bool stdMsg = decodedtext.report(m_baseCall,
Radio::base_callsign(ui->dxCallEntry->text()), m_rptRcvd); Radio::base_callsign(ui->dxCallEntry->text()), m_rptRcvd);
@ -2718,8 +2714,7 @@ void MainWindow::readFromStdout() //readFromStdout
m_blankLine = false; m_blankLine = false;
} }
DecodedText decodedtext; DecodedText decodedtext {QString::fromUtf8 (t.constData ()).remove (QRegularExpression {"\r|\n"})};
decodedtext = QString::fromUtf8 (t.constData ()).remove (QRegularExpression {"\r|\n"});
//Left (Band activity) window //Left (Band activity) window
if(!bAvgMsg) { if(!bAvgMsg) {
@ -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();
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); 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; 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 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 int i1=t1.lastIndexOf(QChar::LineFeed) + 1; //points to first char of line
DecodedText decodedtext;
QString t2 = messages.mid(i1,position-i1); //selected line QString t2 = messages.mid(i1,position-i1); //selected line
// basic mode sanity checks // basic mode sanity checks
@ -3687,15 +3681,8 @@ void MainWindow::processMessage(QString const& messages, int position, bool ctrl
} }
} }
} }
decodedtext = t2a; DecodedText decodedtext {t2a};
decodedtext.removeAddedInfo ();
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
}
auto t3 = decodedtext.string (); auto t3 = decodedtext.string ();
auto t4 = t3.replace (QRegularExpression {" CQ ([A-Z]{2,2}|[0-9]{3,3}) "}, " CQ_\\1 ").split (" ", QString::SkipEmptyParts); 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 hiscall;
QString hisgrid; QString hisgrid;
decodedtext.deCallAndGrid(/*out*/hiscall,hisgrid); decodedtext.deCallAndGrid(/*out*/hiscall,hisgrid);
auto acceptable_73 = m_QSOProgress >= ROGER_REPORT && message_is_73 (0, t4); bool is_73 = t4.filter (QRegularExpression {"73|RR73"}).size ();
if (!Radio::is_callsign (hiscall) // not interested if not from QSO partner 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.size () == 7 // unless it is of the form
&& (t4.at (5) == m_baseCall // "<our-call> 73" && (t4.at (5) == m_baseCall // "<our-call> 73"
|| t4.at (5).startsWith (m_baseCall + '/') || t4.at (5).startsWith (m_baseCall + '/')
|| t4.at (5).endsWith ('/' + m_baseCall)) || t4.at (5).endsWith ('/' + m_baseCall))
&& t4.at (6) == "73") && t4.at (6) == "73")))
&& !acceptable_73)
{ {
qDebug () << "Not processing message - hiscall:" << hiscall << "hisgrid:" << hisgrid; qDebug () << "Not processing message - hiscall:" << hiscall << "hisgrid:" << hisgrid;
return; 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 we get here then we are reacting to the message
if (m_bAutoReply) m_bCallingCQ = CALLING == m_QSOProgress; if (m_bAutoReply) m_bCallingCQ = CALLING == m_QSOProgress;
QString s1=m_QSOText.string().trimmed(); QString s1 = m_QSOText.trimmed ();
QString s2=t2.trimmed(); QString s2=t2.trimmed();
if (s1!=s2 and !decodedtext.isTX()) { if (s1!=s2 and !decodedtext.isTX()) {
decodedtext=t2; decodedtext = DecodedText {t2};
ui->decodedTextBrowser2->displayDecodedText(decodedtext, m_baseCall, ui->decodedTextBrowser2->displayDecodedText(decodedtext, m_baseCall,
false, m_logBook,m_config.color_CQ(), m_config.color_MyCall(), false, m_logBook,m_config.color_CQ(), m_config.color_MyCall(),
m_config.color_DXCC(),m_config.color_NewCall()); 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)) && (base_call != qso_partner_base_call || base_call != hiscall))
{ {
if (qso_partner_base_call != base_call) { if (qso_partner_base_call != base_call) {

View File

@ -33,7 +33,6 @@
#include "DisplayManual.hpp" #include "DisplayManual.hpp"
#include "psk_reporter.h" #include "psk_reporter.h"
#include "logbook/logbook.h" #include "logbook/logbook.h"
#include "decodedtext.h"
#include "commons.h" #include "commons.h"
#include "astro.h" #include "astro.h"
#include "MessageBox.hpp" #include "MessageBox.hpp"
@ -82,6 +81,7 @@ class Detector;
class SampleDownloader; class SampleDownloader;
class MultiSettings; class MultiSettings;
class EqualizationToolsDialog; class EqualizationToolsDialog;
class DecodedText;
class MainWindow : public QMainWindow class MainWindow : public QMainWindow
{ {
@ -541,7 +541,7 @@ private:
QSharedMemory *mem_jt9; QSharedMemory *mem_jt9;
LogBook m_logBook; LogBook m_logBook;
DecodedText m_QSOText; QString m_QSOText;
unsigned m_msAudioOutputBuffered; unsigned m_msAudioOutputBuffered;
unsigned m_framesAudioInputBuffered; unsigned m_framesAudioInputBuffered;
unsigned m_downSampleFactor; unsigned m_downSampleFactor;
@ -588,7 +588,7 @@ private:
void transmit (double snr = 99.); void transmit (double snr = 99.);
void rigFailure (QString const& reason); void rigFailure (QString const& reason);
void pskSetLocal (); void pskSetLocal ();
void pskPost(DecodedText decodedtext); void pskPost(DecodedText const& decodedtext);
void displayDialFrequency (); void displayDialFrequency ();
void transmitDisplay (bool); void transmitDisplay (bool);
void processMessage(QString const& messages, qint32 position, bool ctrl = false, bool alt = false); void processMessage(QString const& messages, qint32 position, bool ctrl = false, bool alt = false);