From e0737c56c1e384e05064a0c6e1ac46979371041b Mon Sep 17 00:00:00 2001 From: Christoph Berg Date: Wed, 19 Dec 2018 22:58:32 +0100 Subject: New upstream version 2.0.0+repack --- decodedtext.cpp | 35 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 18 deletions(-) (limited to 'decodedtext.cpp') diff --git a/decodedtext.cpp b/decodedtext.cpp index 3523266f..f466bb8d 100644 --- a/decodedtext.cpp +++ b/decodedtext.cpp @@ -5,7 +5,7 @@ #include extern "C" { - bool stdmsg_(char const * msg, bool contest_mode, char const * mygrid, fortran_charlen_t, fortran_charlen_t); + bool stdmsg_(char const * msg, fortran_charlen_t); } namespace @@ -13,17 +13,18 @@ namespace QRegularExpression words_re {R"(^(?:(?(?:CQ|DE|QRZ)(?:\s?DX|\s(?:[A-Z]{2}|\d{3}))|[A-Z0-9/]+)\s)(?:(?[A-Z0-9/]+)(?:\s(?[-+A-Z0-9]+)(?:\s(?(?:OOO|(?!RR73)[A-R]{2}[0-9]{2})))?)?)?)"}; } -DecodedText::DecodedText (QString const& the_string, bool contest_mode, QString const& my_grid) +DecodedText::DecodedText (QString const& the_string) : string_ {the_string.left (the_string.indexOf (QChar::Nbsp))} // discard appended info , padding_ {string_.indexOf (" ") > 4 ? 2 : 0} // allow for // seconds - , contest_mode_ {contest_mode} , message_ {string_.mid (column_qsoText + padding_).trimmed ()} , is_standard_ {false} { +// qDebug () << "DecodedText: the_string:" << the_string << "Nbsp pos:" << the_string.indexOf (QChar::Nbsp); if (message_.length() >= 1) { - message_ = message_.left (21).remove (QRegularExpression {"[<>]"}); + message0_ = message_.left(36); + message_ = message_.left(36).remove (QRegularExpression {"[<>]"}); int i1 = message_.indexOf ('\r'); if (i1 > 0) { @@ -40,16 +41,11 @@ DecodedText::DecodedText (QString const& the_string, bool contest_mode, QString // remove DXCC entity and worked B4 status. TODO need a better way to do this message_ = message_.left (eom_pos + 1); } - // stdmsg is a fortran routine that packs the text, unpacks it + // stdmsg is a Fortran routine that packs the text, unpacks it // and compares the result - auto message_c_string = message_.toLocal8Bit (); - message_c_string += QByteArray {22 - message_c_string.size (), ' '}; - auto grid_c_string = my_grid.toLocal8Bit (); - grid_c_string += QByteArray {6 - grid_c_string.size (), ' '}; - is_standard_ = stdmsg_ (message_c_string.constData () - , contest_mode_ - , grid_c_string.constData () - , 22, 6); + auto message_c_string = message0_.toLocal8Bit (); + message_c_string += QByteArray {37 - message_c_string.size (), ' '}; + is_standard_ = stdmsg_(message_c_string.constData(),37); } }; @@ -69,7 +65,7 @@ QStringList DecodedText::messageWords () const 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})?)"}; + QRegularExpression callsign_re {R"(^(CQ|DE|QRZ)(\s?DX|\s([A-Z]{2,4}|\d{3}))?\s(?[A-Z0-9/]{2,})(\s[A-R]{2}[0-9]{2})?)"}; return callsign_re.match (message_).captured ("callsign"); } @@ -170,10 +166,13 @@ void DecodedText::deCallAndGrid(/*out*/QString& call, QString& grid) const auto const& match = words_re.match (message_); call = match.captured ("word2"); grid = match.captured ("word3"); - if (contest_mode_ && "R" == grid) - { - grid = match.captured ("word4"); - } + if ("R" == grid) grid = match.captured ("word4"); + if(match.captured("word1")=="CQ" and call.length()>=3 and call.length()<=4 + and !call.contains(QRegExp("[0-9]"))) { + //Second word has length 3 or 4 and contains no digits + call = match.captured ("word3"); + grid = match.captured ("word4"); + } } unsigned DecodedText::timeInSeconds() const -- cgit v1.2.3