SoDaRadio-5.0.3-master:8901fb5
soda_logtable.hpp
Go to the documentation of this file.
1 /*
2 Copyright (c) 2017 Matthew H. Reilly (kb1vc)
3 All rights reserved.
4 
5 Redistribution and use in source and binary forms, with or without
6 modification, are permitted provided that the following conditions are
7 met:
8 
9  Redistributions of source code must retain the above copyright
10  notice, this list of conditions and the following disclaimer.
11  Redistributions in binary form must reproduce the above copyright
12  notice, this list of conditions and the following disclaimer in
13  the documentation and/or other materials provided with the
14  distribution.
15 
16 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28 
29 #ifndef SODA_LOGTABLE_HDR
30 #define SODA_LOGTABLE_HDR
31 
32 #include <Qt>
33 #include <QDesktopWidget>
34 #include <QHeaderView>
35 #include <QTableWidget>
36 #include <QFileDialog>
37 #include <QDebug>
38 #include <iostream>
39 
40 namespace Ui {
41  class LogTable;
42 }
43 
44 namespace GUISoDa {
45  class LogTable : public QTableWidget
46  {
47  Q_OBJECT
48 
49  public:
50  explicit LogTable(QWidget *parent = Q_NULLPTR);
51 
52  ~LogTable();
53 
54  signals:
55  void entryUpdated(int row, const QString & key, const QString & val);
56 
57  public slots:
58  void logContact(const QString & from_call,
59  const QString & from_grid,
60  const QString & to_call,
61  const QString & to_grid,
62  const QString & mode,
63  const QString & comment,
64  double rx_freq,
65  double tx_freq);
66 
67 
68  void setKeys(QStringList headers);
69  void setLogFile(const QString & fname);
70 
71  void writeLogReport(const QString & fname);
72  void readLogReport(const QString & fname);
73 
74  void writeLogReportDlg();
75  void readLogReportDlg();
76 
77  protected slots:
78  void recordChange(int r, int c);
79 
80  protected:
81  void openLogFile();
82  void readLogFile(const QString & fname);
83  void recordEdit(int row, int col);
84 
85  bool emptyRow(int r);
86 
87  void setField(int row, const QString & key_st, const QString & st) {
88  int ncol = current_headers.indexOf(key_st);
89  if(ncol < 0) {
90  qDebug() << QString("Could not find column key [%1] in log table column headers").arg(key_st);
91  return;
92  }
93  setItem(row, ncol, new QTableWidgetItem(st));
94  }
95 
96  void setField(int row, const QString & key_st, double val) {
97  int ncol = current_headers.indexOf(key_st);
98  if(ncol < 0) {
99  qDebug() << QString("Could not find column key [%1] in log table column headers").arg(key_st);
100  return;
101  }
102  setItem(row, ncol, new QTableWidgetItem(QString("%1").arg(val, 15, 'f')));
103  }
104 
105 
107  QStringList current_headers;
108 
109  QFile * log_file_out;
110  };
111 }
112 
113 #endif // SODA_LOGTABLE_HDR
QStringList current_headers
void setField(int row, const QString &key_st, double val)
void setField(int row, const QString &key_st, const QString &st)