1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
|
#include "qsymonitor.h"
#include "ui_qsymonitor.h"
#include "SettingsGroup.hpp"
#include "Configuration.hpp"
#include "widgets/QSYMessageParser.h"
#include "qt_helpers.hpp"
#include "commons.h"
#include <QSettings>
#include <QObject>
#include <QCloseEvent>
#include <QThread>
#include <QLabel>
#include <QWidget>
#include <QMessageBox>
#include <QStringList>
QSYMonitor::QSYMonitor(QSettings * settings, QFont const& font, Configuration const * configuration, QWidget *parent)
: QWidget(parent),
settings_ {settings},
configuration_ {configuration},
ui(new Ui::QSYMonitor)
{
ui->setupUi(this);
setWindowTitle (QApplication::applicationName () + " - " + tr ("QSY Monitor"));
ui->QSYMonitorTextBrowser->setReadOnly (true);
changeFont (font);
read_settings ();
ui->qsyMonitorLabel->setText(" UTC Call Freq Mode");
}
QSYMonitor::~QSYMonitor()
{
delete ui;
}
void QSYMonitor::getQSYData(QString value)
{
createQSYLine(value);
}
void QSYMonitor::read_settings ()
{
SettingsGroup g (settings_, "QSYMonitor");
move (settings_->value ("window/pos", pos ()).toPoint ());
restoreGeometry(settings_->value("geometry").toByteArray());
}
void QSYMonitor::write_settings ()
{
SettingsGroup g (settings_, "QSYMonitor");
settings_->setValue ("window/pos", pos ());
settings_->setValue ("geometry", saveGeometry());
}
void QSYMonitor::changeFont (QFont const& font)
{
ui->qsyMonitorLabel->setStyleSheet (font_as_stylesheet (font));
ui->QSYMonitorTextBrowser->setStyleSheet (font_as_stylesheet (font));
updateGeometry ();
}
void QSYMonitor::closeEvent (QCloseEvent * e)
{
write_settings();
e->accept(); // was ignore
}
void QSYMonitor::on_clearButton_clicked()
{
ui->QSYMonitorTextBrowser->clear();
}
void QSYMonitor::createQSYLine(QString value)
{
QStringList qsySpot = value.split(' ', SkipEmptyParts);
if(qsySpot.length() == 3) {
QString theTime = qsySpot[0];
QString theCall = qsySpot[1];
getBandModeFreq(theTime, theCall, qsySpot[2]);
}
}
void QSYMonitor::getBandModeFreq(QString theTime, QString theCall, QString value)
{
QSYMessageParser::Message const message =
QSYMessageParser::decode (value, configuration_->region ());
if (message.type != QSYMessageParser::Type::Frequency) return;
int numSpaces1 = 2;
int numSpaces2 = 10 - theCall.length();
int numSpaces3 = 11 - message.frequency_mhz.length();
QString spaces1_theCall = QString(numSpaces1, ' ').append(theCall);
QString spaces2_theFreq = QString(numSpaces2, ' ').append(message.frequency_mhz);
QString spaces3_theMode = QString(numSpaces3, ' ').append(message.mode);
QString qsyMessageString = theTime + spaces1_theCall + spaces2_theFreq + spaces3_theMode;
ui->QSYMonitorTextBrowser->append(qsyMessageString);
}
|