-
Notifications
You must be signed in to change notification settings - Fork 0
/
logdialog.cpp
111 lines (94 loc) · 3.5 KB
/
logdialog.cpp
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
#include "logdialog.h"
#include "ui_logdialog.h"
#include <QDateTime>
#include <QDir>
#include <QMessageBox>
#include <QSettings>
LogDialog::LogDialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::LogDialog)
{
ui->setupUi(this);
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
QDir d;
d.mkdir("logs"); // just in case
logfile.setFileName("logs/RPiKeyerTerm.log");
ui->logCommentLineEdit->setFocus();
}
LogDialog::~LogDialog()
{
delete ui;
}
void LogDialog::setCurrentValues()
{
const QDateTime now = QDateTime::currentDateTimeUtc();
ui->dtOffDateTimeEdit->setDateTime(now);
ui->dtOnDateTimeEdit->setDateTime(now);
}
void LogDialog::setFrequency(const QString freq)
{
ui->logFrequencyLineEdit->setText(freq);
}
void LogDialog::setPower(const int power)
{
ui->logPowerSpinBox->setValue(power);
}
void LogDialog::setRemoteLoc(const QString remote)
{
ui->logMHLineEdit->setText(remote);
}
void LogDialog::setSentReport(const QString sent)
{
ui->logSentReportLineEdit->setText(sent);
}
void LogDialog::setRecdReport(const QString recd)
{
ui->logReceivedReportLineEdit->setText(recd);
}
void LogDialog::setMode(const QString mode)
{
ui->logModeComboBox->setCurrentText(mode.trimmed().toUpper());
}
void LogDialog::setOtherCall(const QString call)
{
ui->logCallLineEdit->setText(call.trimmed().toUpper());
}
void LogDialog::setOpName(const QString op)
{
ui->logOpNameLineEdit->setText(op.trimmed());
}
void LogDialog::on_logSaveButton_clicked()
{
// wsjt style CSV log line
// date on, time on, date off, time off, CALL, MHG, freq, mode, Sent rpt, Recd rpt, pwr,comments,opname
//2022-11-07,16:23:30,2022-11-07,16:29:44,WF1T,FN43,14.074404,FT8,+18,-16,5,comment, Larry,
QString out = ui->dtOnDateTimeEdit->dateTime().toString("yyyy-MM-dd").append(DELIM).append(ui->dtOnDateTimeEdit->dateTime().toString("hh:mm:ss")).append(DELIM);
out.append(ui->dtOffDateTimeEdit->dateTime().toString("yyyy-MM-dd")).append(DELIM).append(ui->dtOffDateTimeEdit->dateTime().toString("hh:mm:ss")).append(DELIM);
out.append(ui->logCallLineEdit->text().trimmed().toUpper().replace(","," ")).append(DELIM).append(ui->logMHLineEdit->text().trimmed().replace(","," ")).append(DELIM);
out.append(ui->logFrequencyLineEdit->text()).append(DELIM).append(ui->logModeComboBox->currentText().trimmed().toUpper().replace(","," ")).append(DELIM);
out.append(ui->logSentReportLineEdit->text().trimmed().replace(","," ")).append(DELIM).append(ui->logReceivedReportLineEdit->text().trimmed().replace(","," ")).append(DELIM);
out.append(ui->logPowerSpinBox->text()).append(DELIM).append(ui->logCommentLineEdit->text().trimmed().replace(","," ")).append(DELIM);
out.append(ui->logOpNameLineEdit->text().trimmed().replace(","," "));
if(logfile.open(QFile::WriteOnly | QFile::Append)) {
logfile.write(out.toLatin1());
logfile.write("\r\n");
logfile.close();
}
// close();
emit logSaved(out);
}
void LogDialog::on_logClearButton_clicked()
{
ui->logCallLineEdit->clear();
ui->logCommentLineEdit->clear();
ui->logMHLineEdit->clear();
ui->logReceivedReportLineEdit->clear();
ui->logSentReportLineEdit->clear();
ui->logOpNameLineEdit->clear();
setCurrentValues();
}
void LogDialog::on_closeButton_clicked()
{
emit logSaved(""); // just to reset the LOG action button in the main UI
close();
}