Merged master 8748
This commit is contained in:
@@ -1,222 +0,0 @@
|
||||
#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]|[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");
|
||||
|
||||
//
|
||||
// deal with special rules that cty.dat does not cope with
|
||||
//
|
||||
|
||||
// KG4 2x1 and 2x3 calls that map to Gitmo are mainland US not Gitmo
|
||||
if (call.startsWith ("KG4") && call.size () != 5)
|
||||
{
|
||||
countryName.replace ("Guantanamo Bay", "U.S.A.");
|
||||
}
|
||||
|
||||
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)
|
||||
message = _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);
|
||||
}
|
||||
@@ -1,51 +0,0 @@
|
||||
128
|
||||
48
|
||||
9
|
||||
1 17 34 51 66 81 99 111 124
|
||||
2 18 35 50 67 82 100 112 125
|
||||
3 19 36 52 68 82 101 111 126
|
||||
2 20 36 51 69 83 102 113 127
|
||||
4 19 37 53 66 84 103 114 128
|
||||
5 21 38 54 70 85 92 114 0
|
||||
6 22 39 55 66 85 96 110 0
|
||||
7 23 32 56 71 86 103 115 0
|
||||
8 20 40 55 72 86 104 116 0
|
||||
9 19 41 57 73 87 105 116 0
|
||||
10 24 36 56 74 88 105 117 125
|
||||
10 17 33 47 75 89 106 118 128
|
||||
11 21 42 51 76 87 107 119 0
|
||||
1 25 40 58 74 84 107 113 0
|
||||
12 22 42 49 77 90 108 118 125
|
||||
13 26 43 59 68 89 104 120 124
|
||||
13 22 44 57 75 91 109 113 0
|
||||
12 23 37 46 78 88 107 112 0
|
||||
3 27 34 60 65 87 109 118 0
|
||||
6 27 45 61 79 89 98 112 0
|
||||
14 28 34 62 72 92 106 112 127
|
||||
8 27 42 59 71 92 110 121 126
|
||||
15 20 46 57 79 93 101 115 124
|
||||
9 29 45 62 74 94 108 121 0
|
||||
8 30 38 63 73 95 109 111 128
|
||||
16 29 47 64 69 96 109 117 126
|
||||
16 23 48 63 76 94 110 116 125
|
||||
7 25 39 52 70 97 106 117 124
|
||||
4 26 45 63 67 83 90 119 123
|
||||
15 28 39 50 76 88 103 121 123
|
||||
15 26 33 58 65 97 102 122 0
|
||||
14 31 47 52 77 81 93 116 0
|
||||
14 24 37 61 71 82 99 122 0
|
||||
4 31 40 54 80 91 106 115 122
|
||||
5 32 41 58 77 98 104 117 0
|
||||
9 18 49 65 79 85 104 119 128
|
||||
10 30 43 60 69 84 108 115 123
|
||||
1 18 43 48 73 91 98 114 127
|
||||
3 21 46 64 67 86 108 113 0
|
||||
5 24 48 55 75 93 107 120 126
|
||||
2 32 44 62 80 95 99 114 0
|
||||
16 28 41 59 80 83 100 118 0
|
||||
11 33 35 53 72 96 105 111 0
|
||||
11 25 44 60 78 90 100 120 122
|
||||
6 31 35 56 70 95 102 121 0
|
||||
12 17 50 54 68 94 105 119 0
|
||||
13 29 38 53 78 97 110 123 0
|
||||
7 30 49 61 64 81 101 120 127
|
||||
@@ -1,50 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Example of a (2000,1000) LDPC code with 3 checks per bit and 6 bits per
|
||||
# check, tested on Additive White Gaussian Noise channels with noise standard
|
||||
# deviations varying from 0.80 to 0.95.
|
||||
#
|
||||
# Testing is done by transmitting random messages, which is safer (though
|
||||
# slower) than using only zero messages. Decoding is done using a maximum
|
||||
# of 250 iterations of probability propagation.
|
||||
|
||||
set -e # Stop if an error occurs
|
||||
set -v # Echo commands as they are read
|
||||
|
||||
make-ldpc ex-ldpc36-1000a.pchk 1000 2000 1 evenboth 3 no4cycle
|
||||
make-gen ex-ldpc36-1000a.pchk ex-ldpc36-1000a.gen dense
|
||||
rand-src ex-ldpc36-1000a.src 1 1000x100
|
||||
encode ex-ldpc36-1000a.pchk ex-ldpc36-1000a.gen ex-ldpc36-1000a.src \
|
||||
ex-ldpc36-1000a.enc
|
||||
|
||||
# NOISE STANDARD DEVIATION 0.80, Eb/N0 = 1.94 dB
|
||||
|
||||
transmit ex-ldpc36-1000a.enc ex-ldpc36-1000a.rec 1 awgn 0.80
|
||||
decode ex-ldpc36-1000a.pchk ex-ldpc36-1000a.rec ex-ldpc36-1000a.dec awgn 0.80\
|
||||
prprp 250
|
||||
verify ex-ldpc36-1000a.pchk ex-ldpc36-1000a.dec ex-ldpc36-1000a.gen \
|
||||
ex-ldpc36-1000a.src
|
||||
|
||||
# NOISE STANDARD DEVIATION 0.85, Eb/N0 = 1.41 dB
|
||||
|
||||
transmit ex-ldpc36-1000a.enc ex-ldpc36-1000a.rec 1 awgn 0.85
|
||||
decode ex-ldpc36-1000a.pchk ex-ldpc36-1000a.rec ex-ldpc36-1000a.dec awgn 0.85\
|
||||
prprp 250
|
||||
verify ex-ldpc36-1000a.pchk ex-ldpc36-1000a.dec ex-ldpc36-1000a.gen \
|
||||
ex-ldpc36-1000a.src
|
||||
|
||||
# NOISE STANDARD DEVIATION 0.90, Eb/N0 = 0.92 dB
|
||||
|
||||
transmit ex-ldpc36-1000a.enc ex-ldpc36-1000a.rec 1 awgn 0.90
|
||||
decode ex-ldpc36-1000a.pchk ex-ldpc36-1000a.rec ex-ldpc36-1000a.dec awgn 0.90\
|
||||
prprp 250
|
||||
verify ex-ldpc36-1000a.pchk ex-ldpc36-1000a.dec ex-ldpc36-1000a.gen \
|
||||
ex-ldpc36-1000a.src
|
||||
|
||||
# NOISE STANDARD DEVIATION 0.95, Eb/N0 = 0.45 dB
|
||||
|
||||
transmit ex-ldpc36-1000a.enc ex-ldpc36-1000a.rec 1 awgn 0.95
|
||||
decode ex-ldpc36-1000a.pchk ex-ldpc36-1000a.rec ex-ldpc36-1000a.dec awgn 0.95\
|
||||
prprp 250
|
||||
verify ex-ldpc36-1000a.pchk ex-ldpc36-1000a.dec ex-ldpc36-1000a.gen \
|
||||
ex-ldpc36-1000a.src
|
||||
Reference in New Issue
Block a user