mirror of
https://github.com/saitohirga/WSJT-X.git
synced 2026-06-08 08:54:41 -04:00
1. Only the left 'band activity' display has DXCC and worked B4 status
2. Moved some of the text handling code from MainWindow to Displaytext git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/wsjtx@3550 ab8295b8-cf94-4d9e-aec4-7959e3be5d79
This commit is contained in:
@@ -32,3 +32,92 @@ void DisplayText::resizeEvent(QResizeEvent * event)
|
||||
_maxDisplayedCharacters = width()/_fontWidth;
|
||||
QTextBrowser::resizeEvent(event);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void DisplayText::insertLineSpacer()
|
||||
{
|
||||
QTextCursor cursor;
|
||||
QTextBlockFormat bf;
|
||||
QString bg="#d3d3d3";
|
||||
bf.setBackground(QBrush(QColor(bg)));
|
||||
QString tt="----------------------------------------";
|
||||
QString s = "<table border=0 cellspacing=0 width=100%><tr><td bgcolor=\"" +
|
||||
bg + "\"><pre>" + tt + "</pre></td></tr></table>";
|
||||
cursor = this->textCursor();
|
||||
cursor.movePosition(QTextCursor::End);
|
||||
bf = cursor.blockFormat();
|
||||
bf.setBackground(QBrush(QColor(bg)));
|
||||
cursor.insertHtml(s);
|
||||
}
|
||||
|
||||
|
||||
void DisplayText::_appendDXCCWorkedB4(/*mod*/QString& t1, QString& bg, /*uses*/LogBook logBook)
|
||||
{
|
||||
// extract the CQer's call TODO: does this work with all call formats? What about 'CQ DX'?
|
||||
int s1 = 4 + t1.indexOf(" CQ ");
|
||||
int s2 = t1.indexOf(" ",s1);
|
||||
QString call = t1.mid(s1,s2-s1);
|
||||
QString countryName;
|
||||
bool callWorkedBefore;
|
||||
bool countryWorkedBefore;
|
||||
logBook.match(/*in*/call,/*out*/countryName,callWorkedBefore,countryWorkedBefore);
|
||||
|
||||
int charsAvail = _maxDisplayedCharacters;
|
||||
|
||||
// the decoder (seems) to always generate 40 chars. For a normal CQ call, the last five are spaces
|
||||
t1 = t1.left(36); // reduce trailing white space TODO this magic 36 is also referenced in MainWindow::doubleClickOnCall()
|
||||
charsAvail -= 36;
|
||||
if (charsAvail > 4)
|
||||
{
|
||||
if (!countryWorkedBefore) // therefore not worked call either
|
||||
{
|
||||
t1 += "!";
|
||||
bg = "#66ff66"; // strong green
|
||||
}
|
||||
else
|
||||
if (!callWorkedBefore) // but have worked the country
|
||||
{
|
||||
t1 += "~";
|
||||
bg = "#76cd76"; // mid green
|
||||
}
|
||||
else
|
||||
{
|
||||
t1 += " "; // have worked this call before
|
||||
bg="#9cc79c"; // pale green
|
||||
}
|
||||
charsAvail -= 1;
|
||||
|
||||
if (countryName.length()>charsAvail)
|
||||
countryName = countryName.left(1)+"."+countryName.right(charsAvail-2); //abreviate the first word to the first letter, show remaining right most chars
|
||||
t1 += countryName;
|
||||
}
|
||||
}
|
||||
|
||||
void DisplayText::displayDecodedText(QString decodedText, QString myCall, bool displayDXCCEntity, LogBook logBook)
|
||||
{
|
||||
QString bg="white";
|
||||
bool CQcall = false;
|
||||
if (decodedText.indexOf(" CQ ") > 0)
|
||||
{
|
||||
CQcall = true;
|
||||
bg="#66ff66"; //green
|
||||
}
|
||||
if (myCall != "" and decodedText.indexOf(" " + myCall + " ") > 0)
|
||||
bg="#ff6666"; //red
|
||||
|
||||
// if enabled add the DXCC entity and B4 status to the end of the preformated text line t1
|
||||
if (displayDXCCEntity && CQcall)
|
||||
_appendDXCCWorkedB4(/*mod*/decodedText,bg,logBook);
|
||||
|
||||
|
||||
QString s = "<table border=0 cellspacing=0 width=100%><tr><td bgcolor=\"" +
|
||||
bg + "\"><pre>" + decodedText + "</pre></td></tr></table>";
|
||||
|
||||
QTextCursor cursor = textCursor();
|
||||
cursor.movePosition(QTextCursor::End);
|
||||
QTextBlockFormat bf = cursor.blockFormat();
|
||||
bf.setBackground(QBrush(QColor(bg)));
|
||||
cursor.insertHtml(s);
|
||||
this->setTextCursor(cursor);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user