32 #include <QMessageBox> 33 #include <QXmlStreamWriter> 34 #include <QXmlStreamReader> 41 horizontalHeader()->setStretchLastSection(
true);
44 headers <<
"Date" <<
"Time" <<
"From Call" <<
"From Grid" <<
"To Call" <<
"To Grid" 45 <<
"Mode" <<
"RX Freq" <<
"TX Freq" <<
"Comment";
46 setColumnCount(headers.size());
53 connect(
this, &GUISoDa::LogTable::cellChanged,
54 [
this](
int row,
int col) {
57 this->item(row, col)->text()); });
59 connect(
this, SIGNAL(cellChanged(
int,
int)),
66 QDateTime utc_time(QDateTime::currentDateTime().toUTC());
68 QString logfname = QString(
"SoDa_%1_%2.soda_log").arg(utc_time.toString(
"ddMMyy")).arg(utc_time.toString(
"hhmmss"));
76 setHorizontalHeaderLabels(headers);
95 for(
int i = 0; i < columnCount(); i++) {
96 if(item(r, i))
return false;
103 int rows = rowCount();
104 int cols = columnCount();
110 for(
int i = 0; i < rows; i++) {
114 for(
int j = 0; j < cols; j++) {
115 QTableWidgetItem * itm(item(i,j));
117 out << QString(
"%1:%2:%3").arg(i).arg(j).arg(itm->text()) << endl;
128 QTableWidgetItem * itm(item(r,c));
130 out << QString(
"%1:%2:%3").arg(r).arg(c).arg(item(r,c)->text()) << endl;
133 out << QString(
"%1:%2: ").arg(r).arg(c) << endl;
143 qDebug() << QString(
"Reading log file [%1]").arg(fname);
146 if(!infile.open(QFile::ReadOnly)) {
147 QMessageBox::information(
this, tr(
"Unable to open file for reading"),
148 infile.errorString());
153 QTextStream instr(&infile);
156 while(!(lbuf = instr.readLine()).isNull()) {
157 int co0 = lbuf.indexOf(
':');
158 int co1 = lbuf.indexOf(
':',co0+1);
161 int row = lbuf.mid(0,co0).toInt() + row_start;
162 int col = lbuf.mid(co0+1,co1 - (co0+1)).toInt();
163 QString val = lbuf.mid(co1+1);
164 if((row + 10) > rowCount()) setRowCount(rowCount() + 20);
165 setItem(row, col,
new QTableWidgetItem(val));
166 if(row > max_row) max_row = row;
174 QString fname = QFileDialog::getOpenFileName(
this,
175 tr(
"Read Log Report from File"),
177 tr(
"*.soda_log (*.soda_log);;All Files(*)"));
183 QString fname = QFileDialog::getSaveFileName(
this,
184 tr(
"Write Log Report to File"),
186 tr(
"*.soda_log (*.soda_log);;All Files(*)"));
192 const QString & from_grid,
193 const QString & to_call,
194 const QString & to_grid,
195 const QString & mode,
196 const QString & comment,
200 QDateTime utc_time(QDateTime::currentDateTime().toUTC());
219 setRowCount(rowCount() + 20);
231 QMessageBox::information(
this, tr(
"Unable to open file for writing"),
void recordChange(int r, int c)
QStringList current_headers
void writeLogReport(const QString &fname)
void setLogFile(const QString &fname)
void readLogReport(const QString &fname)
void logContact(const QString &from_call, const QString &from_grid, const QString &to_call, const QString &to_grid, const QString &mode, const QString &comment, double rx_freq, double tx_freq)
void entryUpdated(int row, const QString &key, const QString &val)
LogTable(QWidget *parent=Q_NULLPTR)
void setKeys(QStringList headers)
void setField(int row, const QString &key_st, const QString &st)