mirror of
https://github.com/saitohirga/WSJT-X.git
synced 2024-11-27 06:38:44 -05:00
Calc chars available when adding DXCC entity to decoded text line
git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/wsjtx@3539 ab8295b8-cf94-4d9e-aec4-7959e3be5d79
This commit is contained in:
parent
7d198f3d50
commit
db4d5f0141
@ -1,5 +1,7 @@
|
|||||||
#include "logbook.h"
|
#include "logbook.h"
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
#include <QFontMetrics>
|
||||||
|
|
||||||
|
|
||||||
void LogBook::init()
|
void LogBook::init()
|
||||||
{
|
{
|
||||||
@ -69,3 +71,13 @@ void LogBook::addAsWorked(const QString call)
|
|||||||
if (countryName.length() > 0)
|
if (countryName.length() > 0)
|
||||||
_worked.setAsWorked(countryName);
|
_worked.setAsWorked(countryName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void LogBook::setDisplayFont(QFont font)
|
||||||
|
{
|
||||||
|
QFontMetrics qfm(font);
|
||||||
|
_fontWidth = qfm.averageCharWidth()+1; // the plus one is emperical
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
|
|
||||||
|
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
#include <QFont>
|
||||||
|
|
||||||
#include "countrydat.h"
|
#include "countrydat.h"
|
||||||
#include "countriesworked.h"
|
#include "countriesworked.h"
|
||||||
@ -23,6 +24,10 @@ public:
|
|||||||
bool &countryWorkedBefore);
|
bool &countryWorkedBefore);
|
||||||
void addAsWorked(const QString call);
|
void addAsWorked(const QString call);
|
||||||
|
|
||||||
|
// TODO these are just to avoid more globals in mainwindow
|
||||||
|
void setDisplayFont(QFont font);
|
||||||
|
int getMaxDisplayedCharacters(int displayWidth) { return displayWidth/_fontWidth; } // TODO catch /0
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CountryDat _countries;
|
CountryDat _countries;
|
||||||
CountriesWorked _worked;
|
CountriesWorked _worked;
|
||||||
@ -30,6 +35,10 @@ private:
|
|||||||
|
|
||||||
void _setAlreadyWorkedFromLog();
|
void _setAlreadyWorkedFromLog();
|
||||||
|
|
||||||
|
int _fontWidth;
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // LOGBOOK_H
|
#endif // LOGBOOK_H
|
||||||
|
|
||||||
|
@ -152,6 +152,8 @@ MainWindow::MainWindow(QSharedMemory *shdmem, QString *thekey, \
|
|||||||
font.setWeight(fontWeight2);
|
font.setWeight(fontWeight2);
|
||||||
ui->decodedTextBrowser->setFont(font);
|
ui->decodedTextBrowser->setFont(font);
|
||||||
ui->decodedTextBrowser2->setFont(font);
|
ui->decodedTextBrowser2->setFont(font);
|
||||||
|
m_logBook.setDisplayFont(font);
|
||||||
|
|
||||||
font=ui->readFreq->font();
|
font=ui->readFreq->font();
|
||||||
font.setFamily("helvetica");
|
font.setFamily("helvetica");
|
||||||
font.setPointSize(9);
|
font.setPointSize(9);
|
||||||
@ -1437,7 +1439,12 @@ void MainWindow::readFromStdout() //readFromStdout
|
|||||||
bool countryWorkedBefore;
|
bool countryWorkedBefore;
|
||||||
m_logBook.match(/*in*/call,/*out*/countryName,callWorkedBefore,countryWorkedBefore);
|
m_logBook.match(/*in*/call,/*out*/countryName,callWorkedBefore,countryWorkedBefore);
|
||||||
|
|
||||||
t1 = t1.left(36); // reduce trailing white space TODO: hardcoded char count
|
//TODO this should happen on a resizeEvent
|
||||||
|
int charsAvail = m_logBook.getMaxDisplayedCharacters(ui->decodedTextBrowser->width());
|
||||||
|
|
||||||
|
// 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 (!countryWorkedBefore) // therefore not worked call either
|
if (!countryWorkedBefore) // therefore not worked call either
|
||||||
{
|
{
|
||||||
@ -1455,14 +1462,16 @@ void MainWindow::readFromStdout() //readFromStdout
|
|||||||
t1 += " "; // have worked this call before
|
t1 += " "; // have worked this call before
|
||||||
bg="#9cc79c"; // pale green
|
bg="#9cc79c"; // pale green
|
||||||
}
|
}
|
||||||
if (countryName.length()>10) //TODO: hardcoded width. Depends on font and window size/layout
|
charsAvail -= 1;
|
||||||
countryName = countryName.left(1)+"."+countryName.right(8); //abreviate the first word to the first letter, show remaining right most chars
|
|
||||||
|
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;
|
t1 += countryName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QString s = "<table border=0 cellspacing=0 width=100%><tr><td bgcolor=\"" +
|
QString s = "<table border=0 cellspacing=0 width=100%><tr><td bgcolor=\"" +
|
||||||
bg + "\"><pre>" + t1 + "</pre></td></tr></table>";
|
bg + "\"><pre>" + t1 + "</pre></td></tr></table>";
|
||||||
bool b65=t1.indexOf("#")==19;
|
bool b65=t1.indexOf("#")==19;
|
||||||
if(bQSO) {
|
if(bQSO) {
|
||||||
cursor = ui->decodedTextBrowser2->textCursor();
|
cursor = ui->decodedTextBrowser2->textCursor();
|
||||||
@ -1479,7 +1488,7 @@ void MainWindow::readFromStdout() //readFromStdout
|
|||||||
if(jt9com_.nagain==0) {
|
if(jt9com_.nagain==0) {
|
||||||
if(m_myCall!="" and t.indexOf(" "+m_myCall+" ")>0) bg="#ff6666"; //red
|
if(m_myCall!="" and t.indexOf(" "+m_myCall+" ")>0) bg="#ff6666"; //red
|
||||||
QString s = "<table border=0 cellspacing=0 width=100%><tr><td bgcolor=\"" +
|
QString s = "<table border=0 cellspacing=0 width=100%><tr><td bgcolor=\"" +
|
||||||
bg + "\"><pre>" + t1 + "</pre></td></tr></table>";
|
bg + "\"><pre>" + t1 + "</pre></td></tr></table>";
|
||||||
cursor = ui->decodedTextBrowser->textCursor();
|
cursor = ui->decodedTextBrowser->textCursor();
|
||||||
cursor.movePosition(QTextCursor::End);
|
cursor.movePosition(QTextCursor::End);
|
||||||
bf = cursor.blockFormat();
|
bf = cursor.blockFormat();
|
||||||
|
Loading…
Reference in New Issue
Block a user