mirror of
https://github.com/saitohirga/WSJT-X.git
synced 2024-11-27 06:38:44 -05: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:
parent
5a30407bd7
commit
d4242734f4
@ -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);
|
||||
}
|
||||
|
@ -2,30 +2,33 @@
|
||||
#define DISPLAYTEXT_H
|
||||
|
||||
#include <QTextBrowser>
|
||||
#include "logbook/logbook.h"
|
||||
|
||||
class DisplayText : public QTextBrowser
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit DisplayText(QWidget *parent = 0);
|
||||
explicit DisplayText(QWidget *parent = 0);
|
||||
|
||||
void setFont(QFont font);
|
||||
int getMaxDisplayedCharacters() { return _maxDisplayedCharacters; }
|
||||
void setFont(QFont font);
|
||||
|
||||
void insertLineSpacer();
|
||||
void displayDecodedText(QString decodedText, QString myCall, bool displayDXCCEntity, LogBook logBook);
|
||||
|
||||
signals:
|
||||
void selectCallsign(bool shift, bool ctrl);
|
||||
void selectCallsign(bool shift, bool ctrl);
|
||||
|
||||
public slots:
|
||||
|
||||
|
||||
protected:
|
||||
void mouseDoubleClickEvent(QMouseEvent *e);
|
||||
void resizeEvent(QResizeEvent * event);
|
||||
void mouseDoubleClickEvent(QMouseEvent *e);
|
||||
void resizeEvent(QResizeEvent * event);
|
||||
|
||||
private:
|
||||
int _fontWidth;
|
||||
int _maxDisplayedCharacters;
|
||||
int _fontWidth;
|
||||
int _maxDisplayedCharacters;
|
||||
void _appendDXCCWorkedB4(/*mod*/QString& t1, QString &bg, LogBook logBook);
|
||||
|
||||
};
|
||||
|
||||
|
@ -117,16 +117,17 @@ void CountryDat::load()
|
||||
}
|
||||
|
||||
// return country name else ""
|
||||
QString CountryDat::find(QString prefix)
|
||||
QString CountryDat::find(const QString prefix)
|
||||
{
|
||||
while(prefix.length() >= 1)
|
||||
QString pf = prefix.toUpper();
|
||||
while(pf.length() >= 1)
|
||||
{
|
||||
if (_data.contains(prefix))
|
||||
if (_data.contains(pf))
|
||||
{
|
||||
QString country = _data.value(prefix);
|
||||
QString country = _data.value(pf);
|
||||
return country;
|
||||
}
|
||||
prefix = prefix.left(prefix.length()-1);
|
||||
pf = pf.left(pf.length()-1);
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ class CountryDat
|
||||
public:
|
||||
void init(const QString filename);
|
||||
void load();
|
||||
QString find(QString prefix); // return country name or ""
|
||||
QString find(const QString prefix); // return country name or ""
|
||||
QStringList getCountryNames() { return _countryNames; };
|
||||
|
||||
private:
|
||||
|
@ -23,6 +23,13 @@ void LogBook::init()
|
||||
int count = _worked.getWorkedCount();
|
||||
qDebug() << QSOcount << "QSOs and" << count << "countries worked in file" << logFilename;
|
||||
*/
|
||||
|
||||
// QString call = "ok1ct";
|
||||
// QString countryName;
|
||||
// bool callWorkedBefore,countryWorkedBefore;
|
||||
// match(/*in*/call, /*out*/ countryName,callWorkedBefore,countryWorkedBefore);
|
||||
// qDebug() << countryName;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
108
mainwindow.cpp
108
mainwindow.cpp
@ -1406,100 +1406,30 @@ void MainWindow::readFromStdout() //readFromStdout
|
||||
out << t.mid(0,n-2) << endl;
|
||||
f.close();
|
||||
|
||||
QTextCursor cursor;
|
||||
QTextBlockFormat bf;
|
||||
if(m_insertBlank and m_blankLine and jt9com_.nagain==0) {
|
||||
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 = ui->decodedTextBrowser->textCursor();
|
||||
cursor.movePosition(QTextCursor::End);
|
||||
bf = cursor.blockFormat();
|
||||
bf.setBackground(QBrush(QColor(bg)));
|
||||
cursor.insertHtml(s);
|
||||
m_blankLine=false;
|
||||
|
||||
if(m_insertBlank and m_blankLine and jt9com_.nagain==0)
|
||||
{
|
||||
ui->decodedTextBrowser->insertLineSpacer();
|
||||
m_blankLine=false;
|
||||
}
|
||||
|
||||
QString bg="white";
|
||||
if(t.indexOf(" CQ ")>0) bg="#66ff66"; //green
|
||||
if(m_myCall!="" and t.indexOf(" "+m_myCall+" ")>0) bg="#ff6666"; //red
|
||||
bool bQSO=abs(t.mid(14,4).toInt() - m_wideGraph->rxFreq()) <= 10;
|
||||
QString t1=t.replace("\n","").mid(0,t.length()-4);
|
||||
|
||||
// if enabled add the DXCC entity and B4 status to the end of the preformated text line t1
|
||||
int cqi = t.indexOf(" CQ ");
|
||||
if (m_displayDXCCEntity && (cqi >= 0))
|
||||
// the left band display
|
||||
ui->decodedTextBrowser->displayDecodedText(t1,m_myCall,m_displayDXCCEntity,m_logBook);
|
||||
|
||||
if (abs(t1.mid(14,4).toInt() - m_wideGraph->rxFreq()) <= 10) // this msg is within 10 hertz of our tuned frequency
|
||||
{
|
||||
// extract the CQer's call TODO: does this work with all call formats? What about 'CQ DX'?
|
||||
int s1 = 4 + t.indexOf(" CQ ");
|
||||
int s2 = t.indexOf(" ",s1);
|
||||
QString call = t.mid(s1,s2-s1);
|
||||
QString countryName;
|
||||
bool callWorkedBefore;
|
||||
bool countryWorkedBefore;
|
||||
m_logBook.match(/*in*/call,/*out*/countryName,callWorkedBefore,countryWorkedBefore);
|
||||
// the right QSO window
|
||||
ui->decodedTextBrowser2->displayDecodedText(t1,m_myCall,false,m_logBook);
|
||||
|
||||
int charsAvail = ui->decodedTextBrowser->getMaxDisplayedCharacters();
|
||||
|
||||
// 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
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
QString s = "<table border=0 cellspacing=0 width=100%><tr><td bgcolor=\"" +
|
||||
bg + "\"><pre>" + t1 + "</pre></td></tr></table>";
|
||||
bool b65=t1.indexOf("#")==19;
|
||||
if(bQSO) {
|
||||
cursor = ui->decodedTextBrowser2->textCursor();
|
||||
cursor.movePosition(QTextCursor::End);
|
||||
bf = cursor.blockFormat();
|
||||
bf.setBackground(QBrush(QColor(bg)));
|
||||
cursor.insertHtml(s);
|
||||
ui->decodedTextBrowser2->setTextCursor(cursor);
|
||||
m_QSOmsg=t1;
|
||||
if(b65 and m_modeTx!="JT65") on_pbTxMode_clicked();
|
||||
if(!b65 and m_modeTx=="JT65") on_pbTxMode_clicked();
|
||||
}
|
||||
|
||||
if(jt9com_.nagain==0) {
|
||||
if(m_myCall!="" and t.indexOf(" "+m_myCall+" ")>0) bg="#ff6666"; //red
|
||||
QString s = "<table border=0 cellspacing=0 width=100%><tr><td bgcolor=\"" +
|
||||
bg + "\"><pre>" + t1 + "</pre></td></tr></table>";
|
||||
cursor = ui->decodedTextBrowser->textCursor();
|
||||
cursor.movePosition(QTextCursor::End);
|
||||
bf = cursor.blockFormat();
|
||||
bf.setBackground(QBrush(QColor(bg)));
|
||||
cursor.insertHtml(s);
|
||||
ui->decodedTextBrowser->setTextCursor(cursor);
|
||||
bool b65=t1.indexOf("#")==19;
|
||||
if(b65 and m_modeTx!="JT65") on_pbTxMode_clicked();
|
||||
if(!b65 and m_modeTx=="JT65") on_pbTxMode_clicked();
|
||||
m_QSOmsg=t1;
|
||||
}
|
||||
|
||||
// find and extract any report
|
||||
QString msg=t.mid(21);
|
||||
int i1=msg.indexOf("\r");
|
||||
if(i1>0) msg=msg.mid(0,i1-1) + " ";
|
||||
@ -1522,9 +1452,11 @@ void MainWindow::readFromStdout() //readFromStdout
|
||||
}
|
||||
}
|
||||
|
||||
// extract details and send to PSKreporter
|
||||
int nsec=QDateTime::currentMSecsSinceEpoch()/1000-m_secBandChanged;
|
||||
bool okToPost=(nsec>50);
|
||||
QString msgmode="JT9";
|
||||
bool b65=t1.indexOf("#")==19;
|
||||
if(b65) msgmode="JT65";
|
||||
i1=msg.indexOf(" ");
|
||||
QString c2=msg.mid(i1+1);
|
||||
@ -2021,6 +1953,10 @@ void MainWindow::doubleClickOnCall(bool shift, bool ctrl)
|
||||
QString t1 = t.mid(0,i2); //contents up to \n on selected line
|
||||
int i1=t1.lastIndexOf("\n") + 1; //points to first char of line
|
||||
QString t2 = t1.mid(i1,i2-i1); //selected line
|
||||
|
||||
if (t2.indexOf(" CQ ") > 0)
|
||||
t2 = t2.left(36); // to remove DXCC entity and worked B4 status. TODO need a better way to do this
|
||||
|
||||
// if(t2.indexOf("Tx")==6) return; //Ignore Tx line
|
||||
int i4=t.mid(i1).length();
|
||||
if(i4>55) i4=55;
|
||||
|
Loading…
Reference in New Issue
Block a user