mirror of
https://github.com/saitohirga/WSJT-X.git
synced 2024-11-23 20:58:55 -05:00
1. Moved font width calc for DXCC enitity display from LogBook to DisplayText.
2. The available character count is now updated by catching resizeEvents git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/wsjtx@3545 ab8295b8-cf94-4d9e-aec4-7959e3be5d79
This commit is contained in:
parent
2946ad43c4
commit
e613c147b3
@ -2,9 +2,12 @@
|
||||
#include <QDebug>
|
||||
#include <QMouseEvent>
|
||||
|
||||
|
||||
DisplayText::DisplayText(QWidget *parent) :
|
||||
QTextBrowser(parent)
|
||||
{
|
||||
_fontWidth = 8; // typical
|
||||
_maxDisplayedCharacters = 48; // a nominal safe(?) value
|
||||
}
|
||||
|
||||
void DisplayText::mouseDoubleClickEvent(QMouseEvent *e)
|
||||
@ -14,3 +17,18 @@ void DisplayText::mouseDoubleClickEvent(QMouseEvent *e)
|
||||
emit(selectCallsign(shift,ctrl));
|
||||
QTextBrowser::mouseDoubleClickEvent(e);
|
||||
}
|
||||
|
||||
|
||||
void DisplayText::setFont(QFont font)
|
||||
{
|
||||
QFontMetrics qfm(font);
|
||||
_fontWidth = qfm.averageCharWidth()+1; // the plus one is emperical
|
||||
QTextBrowser::setFont(font);
|
||||
}
|
||||
|
||||
void DisplayText::resizeEvent(QResizeEvent * event)
|
||||
{
|
||||
if (_fontWidth > 0 && _fontWidth < 999)
|
||||
_maxDisplayedCharacters = width()/_fontWidth;
|
||||
QTextBrowser::resizeEvent(event);
|
||||
}
|
||||
|
@ -9,13 +9,23 @@ class DisplayText : public QTextBrowser
|
||||
public:
|
||||
explicit DisplayText(QWidget *parent = 0);
|
||||
|
||||
void setFont(QFont font);
|
||||
int getMaxDisplayedCharacters() { return _maxDisplayedCharacters; }
|
||||
|
||||
|
||||
signals:
|
||||
void selectCallsign(bool shift, bool ctrl);
|
||||
|
||||
public slots:
|
||||
|
||||
|
||||
protected:
|
||||
void mouseDoubleClickEvent(QMouseEvent *e);
|
||||
void resizeEvent(QResizeEvent * event);
|
||||
|
||||
private:
|
||||
int _fontWidth;
|
||||
int _maxDisplayedCharacters;
|
||||
|
||||
};
|
||||
|
||||
|
@ -74,10 +74,3 @@ void LogBook::addAsWorked(const QString call)
|
||||
|
||||
|
||||
|
||||
|
||||
void LogBook::setDisplayFont(QFont font)
|
||||
{
|
||||
QFontMetrics qfm(font);
|
||||
_fontWidth = qfm.averageCharWidth()+1; // the plus one is emperical
|
||||
}
|
||||
|
||||
|
@ -24,10 +24,6 @@ public:
|
||||
bool &countryWorkedBefore);
|
||||
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:
|
||||
CountryDat _countries;
|
||||
CountriesWorked _worked;
|
||||
@ -35,9 +31,6 @@ private:
|
||||
|
||||
void _setAlreadyWorkedFromLog();
|
||||
|
||||
int _fontWidth;
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif // LOGBOOK_H
|
||||
|
@ -137,6 +137,7 @@ MainWindow::MainWindow(QSettings * settings, QSharedMemory *shdmem, QString *the
|
||||
connect(ui->decodedTextBrowser,SIGNAL(selectCallsign(bool,bool)),this,
|
||||
SLOT(doubleClickOnCall2(bool,bool)));
|
||||
|
||||
|
||||
setWindowTitle(Program_Title_Version);
|
||||
connect(&m_detector, &Detector::framesWritten, this, &MainWindow::dataSink);
|
||||
connect(&m_soundInput, SIGNAL(error(QString)), this,
|
||||
@ -173,7 +174,6 @@ MainWindow::MainWindow(QSettings * settings, QSharedMemory *shdmem, QString *the
|
||||
font.setWeight(fontWeight2);
|
||||
ui->decodedTextBrowser->setFont(font);
|
||||
ui->decodedTextBrowser2->setFont(font);
|
||||
m_logBook.setDisplayFont(font);
|
||||
|
||||
font=ui->readFreq->font();
|
||||
font.setFamily("helvetica");
|
||||
@ -1441,13 +1441,13 @@ void MainWindow::readFromStdout() //readFromStdout
|
||||
bool countryWorkedBefore;
|
||||
m_logBook.match(/*in*/call,/*out*/countryName,callWorkedBefore,countryWorkedBefore);
|
||||
|
||||
//TODO this should happen on a resizeEvent
|
||||
int charsAvail = m_logBook.getMaxDisplayedCharacters(ui->decodedTextBrowser->width());
|
||||
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 += "!";
|
||||
@ -1470,6 +1470,7 @@ void MainWindow::readFromStdout() //readFromStdout
|
||||
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=\"" +
|
||||
|
Loading…
Reference in New Issue
Block a user