mirror of
https://github.com/saitohirga/WSJT-X.git
synced 2024-09-09 06:46:39 -04:00
87ae336443
moves the Rx frequency to theirs, this facilitates calling a station who is busy and may have many callers on their frequency. Updated the corresponding mouse shortcuts help text. Allow for times with seconds when parsing fast mode and FT8 decodes. Exclude the RR73 grid square from and grid validation or matching, it is not a grid square any more as far as WSJT-X is concerned, it is an RRR substitute. Add a simple state machine for QSO progress such that replies and auto-sequencing can be better controlled. Get compound callsign edge cases working again and allow QSOs from and to compound callsign holders working in as many situations as possible including auto-sequencing and FT8 auto-reply mode. This does mean that a "DE W6/K1ABC DM93" type message close to a callers Tx or Rx frequency will be taken as a reply to a CQ call despite it not being explicitly addressed back to the CQ caller. Compound callsigns should work in MSK144 contest mode also as well as in short code modes with some minor restrictions (short codes will not be used where configuration demands that a message be used to send a full compound callsign). Auto sequencing has been made generic such that it can be used for more than one mode if desired. Allow the use of free text messages to sign off in auto sequenced QSOs without the message being overwritten by the sequencer. Double click actions have been added to the Tx5 radio and push buttons to revert back to the default standard 73 message. Make DisplayText class interface more idiomatic C++ and simplify a bit. Fixed some displayed widget arrangements for different modes and sub-modes so that they are consistent when starting up and when switching mode or sub-mode. This is a big change which has been extensively tested but no doubt there will also be some new defects introduced. git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/wsjtx@7939 ab8295b8-cf94-4d9e-aec4-7959e3be5d79
212 lines
7.0 KiB
C++
212 lines
7.0 KiB
C++
#include "displaytext.h"
|
|
|
|
#include <QMouseEvent>
|
|
#include <QDateTime>
|
|
#include <QTextCharFormat>
|
|
#include <QFont>
|
|
#include <QTextCursor>
|
|
|
|
#include "qt_helpers.hpp"
|
|
|
|
#include "moc_displaytext.cpp"
|
|
|
|
DisplayText::DisplayText(QWidget *parent) :
|
|
QTextEdit(parent)
|
|
{
|
|
setReadOnly (true);
|
|
viewport ()->setCursor (Qt::ArrowCursor);
|
|
setWordWrapMode (QTextOption::NoWrap);
|
|
setStyleSheet ("");
|
|
}
|
|
|
|
void DisplayText::setContentFont(QFont const& font)
|
|
{
|
|
setFont (font);
|
|
m_charFormat.setFont (font);
|
|
selectAll ();
|
|
auto cursor = textCursor ();
|
|
cursor.mergeCharFormat (m_charFormat);
|
|
cursor.clearSelection ();
|
|
cursor.movePosition (QTextCursor::End);
|
|
|
|
// position so viewport scrolled to left
|
|
cursor.movePosition (QTextCursor::Up);
|
|
cursor.movePosition (QTextCursor::StartOfLine);
|
|
|
|
setTextCursor (cursor);
|
|
ensureCursorVisible ();
|
|
}
|
|
|
|
void DisplayText::mouseDoubleClickEvent(QMouseEvent *e)
|
|
{
|
|
bool ctrl = (e->modifiers() & Qt::ControlModifier);
|
|
bool alt = (e->modifiers() & Qt::AltModifier);
|
|
emit(selectCallsign(alt,ctrl));
|
|
QTextEdit::mouseDoubleClickEvent(e);
|
|
}
|
|
|
|
void DisplayText::insertLineSpacer(QString const& line)
|
|
{
|
|
appendText (line, "#d3d3d3");
|
|
}
|
|
|
|
void DisplayText::appendText(QString const& text, QString const& bg)
|
|
{
|
|
QString escaped {text.trimmed().replace('<',"<").replace('>',">").replace(' ', " ")};
|
|
QString s = "<table border=0 cellspacing=0 width=100%><tr><td bgcolor=\"" +
|
|
bg + "\">" + escaped + "</td></tr></table>";
|
|
auto cursor = textCursor ();
|
|
cursor.movePosition (QTextCursor::End);
|
|
auto pos = cursor.position ();
|
|
cursor.insertHtml (s);
|
|
cursor.setPosition (pos, QTextCursor::MoveAnchor);
|
|
cursor.movePosition (QTextCursor::End, QTextCursor::KeepAnchor);
|
|
cursor.mergeCharFormat (m_charFormat);
|
|
cursor.clearSelection ();
|
|
|
|
// position so viewport scrolled to left
|
|
cursor.movePosition (QTextCursor::Up);
|
|
cursor.movePosition (QTextCursor::StartOfLine);
|
|
setTextCursor (cursor);
|
|
ensureCursorVisible ();
|
|
}
|
|
|
|
|
|
QString DisplayText::_appendDXCCWorkedB4(QString message, QString const& callsign, QString * bg,
|
|
LogBook logBook, QColor color_CQ,
|
|
QColor color_DXCC,
|
|
QColor color_NewCall)
|
|
{
|
|
QString call = callsign;
|
|
QString countryName;
|
|
bool callWorkedBefore;
|
|
bool countryWorkedBefore;
|
|
|
|
if(call.length()==2) {
|
|
int i0=message.indexOf("CQ "+call);
|
|
call=message.mid(i0+6,-1);
|
|
i0=call.indexOf(" ");
|
|
call=call.mid(0,i0);
|
|
}
|
|
if(call.length()<3) return message;
|
|
if(!call.contains(QRegExp("[0-9]")) or !call.contains(QRegExp("[A-Z]"))) return message;
|
|
|
|
logBook.match(/*in*/call,/*out*/countryName,callWorkedBefore,countryWorkedBefore);
|
|
int charsAvail = 48;
|
|
|
|
// the decoder (seems) to always generate 41 chars. For a normal CQ call, the last five are spaces
|
|
// TODO this magic 37 characters is also referenced in MainWindow::doubleClickOnCall()
|
|
int nmin=37;
|
|
int i=message.indexOf(" CQ ");
|
|
int k=message.mid(i+4,3).toInt();
|
|
if(k>0 and k<999) nmin += 4;
|
|
int s3 = message.indexOf(" ",nmin);
|
|
if (s3 < nmin) s3 = nmin; // always want at least the characters to position 35
|
|
s3 += 1; // convert the index into a character count
|
|
message = message.left(s3); // reduce trailing white space
|
|
charsAvail -= s3;
|
|
if (charsAvail > 4)
|
|
{
|
|
if (!countryWorkedBefore) // therefore not worked call either
|
|
{
|
|
message += "!";
|
|
*bg = color_DXCC.name();
|
|
}
|
|
else
|
|
if (!callWorkedBefore) // but have worked the country
|
|
{
|
|
message += "~";
|
|
*bg = color_NewCall.name();
|
|
}
|
|
else
|
|
{
|
|
message += " "; // have worked this call before
|
|
*bg = color_CQ.name();
|
|
}
|
|
charsAvail -= 1;
|
|
|
|
// do some obvious abbreviations
|
|
countryName.replace ("Islands", "Is.");
|
|
countryName.replace ("Island", "Is.");
|
|
countryName.replace ("North ", "N. ");
|
|
countryName.replace ("Northern ", "N. ");
|
|
countryName.replace ("South ", "S. ");
|
|
countryName.replace ("East ", "E. ");
|
|
countryName.replace ("Eastern ", "E. ");
|
|
countryName.replace ("West ", "W. ");
|
|
countryName.replace ("Western ", "W. ");
|
|
countryName.replace ("Central ", "C. ");
|
|
countryName.replace (" and ", " & ");
|
|
countryName.replace ("Republic", "Rep.");
|
|
countryName.replace ("United States", "U.S.A.");
|
|
countryName.replace ("Fed. Rep. of ", "");
|
|
countryName.replace ("French ", "Fr.");
|
|
countryName.replace ("Asiatic", "AS");
|
|
countryName.replace ("European", "EU");
|
|
countryName.replace ("African", "AF");
|
|
message += countryName;
|
|
}
|
|
return message;
|
|
}
|
|
|
|
void DisplayText::displayDecodedText(DecodedText decodedText, QString myCall,
|
|
bool displayDXCCEntity, LogBook logBook,
|
|
QColor color_CQ, QColor color_MyCall,
|
|
QColor color_DXCC, QColor color_NewCall)
|
|
{
|
|
QString bg="white";
|
|
bool CQcall = false;
|
|
if (decodedText.string ().contains (" CQ ")
|
|
|| decodedText.string ().contains (" CQDX ")
|
|
|| decodedText.string ().contains (" QRZ "))
|
|
{
|
|
CQcall = true;
|
|
bg=color_CQ.name();
|
|
}
|
|
if (myCall != "" and (
|
|
decodedText.indexOf (" " + myCall + " ") >= 0
|
|
or decodedText.indexOf (" " + myCall + "/") >= 0
|
|
or decodedText.indexOf ("/" + myCall + " ") >= 0
|
|
or decodedText.indexOf ("<" + myCall + " ") >= 0
|
|
or decodedText.indexOf (" " + myCall + ">") >= 0)) {
|
|
bg=color_MyCall.name();
|
|
}
|
|
// if enabled add the DXCC entity and B4 status to the end of the
|
|
// preformated text line t1
|
|
auto message = decodedText.string ();
|
|
if (displayDXCCEntity && CQcall)
|
|
_appendDXCCWorkedB4 (message, decodedText.CQersCall (), &bg, logBook, color_CQ,
|
|
color_DXCC, color_NewCall);
|
|
appendText (message, bg);
|
|
}
|
|
|
|
|
|
void DisplayText::displayTransmittedText(QString text, QString modeTx, qint32 txFreq,
|
|
QColor color_TxMsg, bool bFastMode)
|
|
{
|
|
QString bg=color_TxMsg.name();
|
|
QString t1=" @ ";
|
|
if(modeTx=="FT8") t1=" ~ ";
|
|
if(modeTx=="JT4") t1=" $ ";
|
|
if(modeTx=="JT65") t1=" # ";
|
|
if(modeTx=="MSK144") t1=" & ";
|
|
QString t2;
|
|
t2.sprintf("%4d",txFreq);
|
|
QString t;
|
|
if(bFastMode or modeTx=="FT8") {
|
|
t = QDateTime::currentDateTimeUtc().toString("hhmmss") + \
|
|
" Tx " + t2 + t1 + text;
|
|
} else {
|
|
t = QDateTime::currentDateTimeUtc().toString("hhmm") + \
|
|
" Tx " + t2 + t1 + text;
|
|
}
|
|
appendText(t,bg);
|
|
}
|
|
|
|
void DisplayText::displayQSY(QString text)
|
|
{
|
|
QString t = QDateTime::currentDateTimeUtc().toString("hhmmss") + " " + text;
|
|
QString bg="hot pink";
|
|
appendText(t,bg);
|
|
}
|