SoDaRadio-5.0.3-master:8901fb5
main_setup_loggps.cpp
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 #include "mainwindow.hpp"
30 #include "ui_mainwindow.h"
31 #include <iostream>
32 #include <boost/format.hpp>
33 #include "soda_comboboxes.hpp"
34 #include "soda_listener.hpp"
35 #include "../common/Navigation.hxx"
36 
38 {
39  // connect the log contact button to something that will do us some good.
40  connect(ui->LogContact_btn, SIGNAL(clicked(bool)),
41  this, SLOT(logContact(bool)));
42 
43  connect(ui->FromGrid_le, SIGNAL(textChanged(const QString &)),
44  this, SLOT(evalNav(const QString &)));
45  connect(ui->ToGrid_le, SIGNAL(textChanged(const QString &)),
46  this, SLOT(evalNav(const QString &)));
47 
48  connect(listener, SIGNAL(repGPSTime(int, int, int)),
49  this, SLOT(updateTime(int, int, int)));
50  connect(listener, SIGNAL(repGPSLatLon(double, double)),
51  this, SLOT(updatePosition(double, double)));
52 }
53 
54 void MainWindow::evalNav(const QString & dummy)
55 {
56  (void) dummy;
57  QString from_grid = ui->FromGrid_le->text();
58  QString to_grid = ui->ToGrid_le->text();
59 
60  float bearing, rbearing, distance;
61  int stat = GetBearingDistance(from_grid.toStdString(), to_grid.toStdString(), bearing, rbearing, distance);
62 
63  if(stat == 0) {
64  ui->Bearing_lab->setText(QString("%1").arg(bearing, 3, 'f', 0));
65  ui->RevBearing_lab->setText(QString("%1").arg(rbearing, 3, 'f', 0));
66  ui->Range_lab->setText(QString("%1").arg(distance, 4, 'f', 0));
67  }
68 }
73 void MainWindow::logContact(bool dummy)
74 {
75  (void) dummy;
76  ui->LogView->logContact(ui->FromCall_le->text(),
77  ui->FromGrid_le->text(),
78  ui->ToCall_le->text(),
79  ui->ToGrid_le->text(),
80  ui->Mode_cb->currentText(),
81  ui->LogComment_txt->text(),
82  ui->RXFreq_lab->getFreq(),
83  ui->TXFreq_lab->getFreq());
84 }
85 
86 void MainWindow::updateTime(int h, int m, int s)
87 {
88  QChar fc('0');
89  ui->UTC_lab->setText(QString("%1:%2:%3").arg(h,2,10,fc).arg(m,2,10,fc).arg(s,2,10,fc));
90 }
91 
92 void MainWindow::updatePosition(double lat, double lon)
93 {
94  QString grid = QString::fromStdString(GetGridSquare(lat, lon));
95 
96  ui->GRID_lab->setText(grid);
97 
98  ui->LAT_lab->setText(QString("%1").arg(lat, 5, 'f', 2));
99  ui->LON_lab->setText(QString("%1").arg(lon, 6, 'f', 2));
100 
101  if(ui->useGPS_ck->isChecked()) {
102  ui->FromGrid_lab->setText(grid);
103  ui->FromGrid_le->setText(grid);
104  }
105 }
GUISoDa::Listener * listener
Definition: mainwindow.hpp:151
Ui::MainWindow * ui
Definition: mainwindow.hpp:149
void updateTime(int h, int m, int s)
void evalNav(const QString &dummy)
void updatePosition(double lat, double lon)
void logContact(bool)
log the current contact by storing the grid, call, date, time, frequency, mode, and other stuff into ...