2012-05-22 13:09:48 -04:00
|
|
|
#include "displaytext.h"
|
|
|
|
#include <QDebug>
|
|
|
|
#include <QMouseEvent>
|
|
|
|
|
2013-08-11 07:45:17 -04:00
|
|
|
|
2012-05-22 13:09:48 -04:00
|
|
|
DisplayText::DisplayText(QWidget *parent) :
|
|
|
|
QTextBrowser(parent)
|
|
|
|
{
|
2013-08-11 07:45:17 -04:00
|
|
|
_fontWidth = 8; // typical
|
|
|
|
_maxDisplayedCharacters = 48; // a nominal safe(?) value
|
2012-05-22 13:09:48 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void DisplayText::mouseDoubleClickEvent(QMouseEvent *e)
|
|
|
|
{
|
2012-11-23 11:44:40 -05:00
|
|
|
bool ctrl = (e->modifiers() & Qt::ControlModifier);
|
2013-03-01 16:25:33 -05:00
|
|
|
bool shift = (e->modifiers() & Qt::ShiftModifier);
|
|
|
|
emit(selectCallsign(shift,ctrl));
|
2012-05-22 13:09:48 -04:00
|
|
|
QTextBrowser::mouseDoubleClickEvent(e);
|
|
|
|
}
|
2013-08-11 07:45:17 -04:00
|
|
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
}
|