Browse Source
Add support for different map types (street/satellite) and different map providers. Support finding real world addresses on the map. Add Maidenhead locator converter. Add Beacons. Allow data sources to be selected by a user. Add context menu to allow setting an object as a target, setting center frequency and adjusting display order.chirpmodem-v8.0.0
41 changed files with 2462 additions and 259 deletions
|
Before Width: | Height: | Size: 1.4 MiB After Width: | Height: | Size: 545 KiB |
|
After Width: | Height: | Size: 29 KiB |
|
After Width: | Height: | Size: 547 KiB |
@ -0,0 +1,238 @@
@@ -0,0 +1,238 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (C) 2021 Jon Beniston, M7RCE //
|
||||
// //
|
||||
// This program is free software; you can redistribute it and/or modify //
|
||||
// it under the terms of the GNU General Public License as published by //
|
||||
// the Free Software Foundation as version 3 of the License, or //
|
||||
// (at your option) any later version. //
|
||||
// //
|
||||
// This program is distributed in the hope that it will be useful, //
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
|
||||
// GNU General Public License V3 for more details. //
|
||||
// //
|
||||
// You should have received a copy of the GNU General Public License //
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef INCLUDE_BEACON_H |
||||
#define INCLUDE_BEACON_H |
||||
|
||||
#include <stdio.h> |
||||
#include <string.h> |
||||
|
||||
#include <QString> |
||||
#include <QList> |
||||
|
||||
#include "util/units.h" |
||||
#include "util/maidenhead.h" |
||||
#include "../../channelrx/demodadsb/csv.h" |
||||
|
||||
#define IARU_BEACONS_URL "https://iaru-r1-c5-beacons.org/wp-content/uploads/beacons.csv"
|
||||
|
||||
struct Beacon { |
||||
|
||||
QString m_callsign; |
||||
quint64 m_frequency; // In Hz
|
||||
QString m_locator; |
||||
float m_latitude; |
||||
float m_longitude; |
||||
float m_altitude; // In metres above sea-level
|
||||
QString m_power; // In Watts - sometimes a string with extra infos
|
||||
QString m_polarization; // H or V
|
||||
QString m_pattern; // Omni or 30deg etc
|
||||
QString m_key; // F1A, F1B
|
||||
QString m_mgm; // Machine mode
|
||||
|
||||
QString getText() |
||||
{ |
||||
QStringList list; |
||||
list.append("Beacon"); |
||||
list.append(QString("Callsign: %1").arg(m_callsign)); |
||||
list.append(QString("Frequency: %1").arg(getFrequencyText())); |
||||
if (!m_power.isEmpty()) |
||||
list.append(QString("Power: %1 Watts ERP").arg(m_power)); |
||||
if (!m_polarization.isEmpty()) |
||||
list.append(QString("Polarization: %1").arg(m_polarization)); |
||||
if (!m_pattern.isEmpty()) |
||||
list.append(QString("Pattern: %1").arg(m_pattern)); |
||||
if (!m_key.isEmpty()) |
||||
list.append(QString("Key: %1").arg(m_key)); |
||||
if (!m_mgm.isEmpty()) |
||||
list.append(QString("MGM: %1").arg(m_mgm)); |
||||
list.append(QString("Locator: %1").arg(m_locator)); |
||||
return list.join("\n"); |
||||
} |
||||
|
||||
QString getFrequencyText() |
||||
{ |
||||
if (m_frequency > 1000000000) |
||||
return QString("%1 GHz").arg(m_frequency/1000000000.0, 0, ',', 6); |
||||
else if (m_frequency > 1000000) |
||||
return QString("%1 MHz").arg(m_frequency/1000000.0, 0, ',', 3); |
||||
else |
||||
return QString("%1 kHz").arg(m_frequency/1000.0, 0, ',', 3); |
||||
} |
||||
|
||||
// Uses ; rather than ,
|
||||
static QList<Beacon *> *readIARUCSV(const QString &filename) |
||||
{ |
||||
int cnt = 0; |
||||
QList<Beacon *> *beacons = nullptr; |
||||
|
||||
// Column numbers used for the data as of 2021/1/20
|
||||
int callsignCol = 0; |
||||
int qrgCol = 1; |
||||
int locatorCol = 2; |
||||
int heightCol = 5; |
||||
int patternCol = 7; |
||||
int polarizationCol = 9; |
||||
int powerCol = 10; |
||||
int keyCol = 11; |
||||
int mgmCol = 12; |
||||
|
||||
FILE *file; |
||||
QByteArray utfFilename = filename.toUtf8(); |
||||
if ((file = fopen(utfFilename.constData(), "r")) != nullptr) |
||||
{ |
||||
char row[2048]; |
||||
|
||||
if (fgets(row, sizeof(row), file)) |
||||
{ |
||||
beacons = new QList<Beacon *>(); |
||||
|
||||
// Read header
|
||||
int idx = 0; |
||||
char *p = strtok(row, ";"); |
||||
while (p != nullptr) |
||||
{ |
||||
if (!strcmp(p, "Callsign")) |
||||
callsignCol = idx; |
||||
else if (!strcmp(p, "QRG")) |
||||
qrgCol = idx; |
||||
else if (!strcmp(p, "Locator")) |
||||
locatorCol = idx; |
||||
else if (!strcmp(p, "Hight ASL") || !strcmp(p, "Height ASL")) |
||||
heightCol = idx; |
||||
else if (!strcmp(p, "Pattern")) |
||||
patternCol = idx; |
||||
else if (!strcmp(p, "H/V")) |
||||
polarizationCol = idx; |
||||
else if (!strcmp(p, "Power")) |
||||
powerCol = idx; |
||||
else if (!strcmp(p, "Keying")) |
||||
keyCol = idx; |
||||
else if (!strcmp(p, "MGM")) |
||||
mgmCol = idx; |
||||
p = strtok(nullptr, ","); |
||||
idx++; |
||||
} |
||||
// Read data
|
||||
while (fgets(row, sizeof(row), file)) |
||||
{ |
||||
int id = 0; |
||||
char *callsign = nullptr; |
||||
size_t callsignLen = 0; |
||||
char *frequencyString = nullptr; |
||||
quint64 frequency; |
||||
char *locator = nullptr; |
||||
int height = 0; |
||||
char *heightString = nullptr; |
||||
char *pattern = nullptr; |
||||
char *polarization = nullptr; |
||||
char *power = nullptr; |
||||
char *key = nullptr; |
||||
char *mgm = nullptr; |
||||
|
||||
char *q = row; |
||||
idx = 0; |
||||
while ((p = csvNext(&q, ';')) != nullptr) |
||||
{ |
||||
// Read strings, stripping quotes
|
||||
if ((idx == callsignCol) && (p[0] == '\"')) |
||||
{ |
||||
callsign = p+1; |
||||
callsignLen = strlen(callsign)-1; |
||||
callsign[callsignLen] = '\0'; |
||||
} |
||||
else if ((idx == qrgCol) && (p[0] == '\"')) |
||||
{ |
||||
frequencyString = p+1; |
||||
frequencyString[strlen(frequencyString)-1] = '\0'; |
||||
frequency = QString(frequencyString).toLongLong(); |
||||
} |
||||
else if ((idx == locatorCol) && (p[0] == '\"')) |
||||
{ |
||||
locator = p+1; |
||||
locator[strlen(locator)-1] = '\0'; |
||||
} |
||||
else if ((idx == heightCol) && (p[0] == '\"')) |
||||
{ |
||||
heightString = p+1; |
||||
heightString[strlen(heightString)-1] = '\0'; |
||||
height = atoi(heightString); |
||||
} |
||||
else if ((idx == patternCol) && (p[0] == '\"')) |
||||
{ |
||||
pattern = p+1; |
||||
pattern[strlen(pattern)-1] = '\0'; |
||||
} |
||||
else if ((idx == polarizationCol) && (p[0] == '\"')) |
||||
{ |
||||
polarization = p+1; |
||||
polarization[strlen(polarization)-1] = '\0'; |
||||
} |
||||
else if ((idx == powerCol) && (p[0] == '\"')) |
||||
{ |
||||
power = p+1; |
||||
power[strlen(power)-1] = '\0'; |
||||
} |
||||
else if ((idx == keyCol) && (p[0] == '\"')) |
||||
{ |
||||
key = p+1; |
||||
key[strlen(key)-1] = '\0'; |
||||
} |
||||
else if ((idx == mgmCol) && (p[0] == '\"')) |
||||
{ |
||||
mgm = p+1; |
||||
mgm[strlen(mgm)-1] = '\0'; |
||||
} |
||||
idx++; |
||||
} |
||||
float latitude, longitude; |
||||
if (callsign && frequency && locator && Maidenhead::fromMaidenhead(locator, latitude, longitude)) |
||||
{ |
||||
Beacon *beacon = new Beacon(); |
||||
beacon->m_callsign = callsign; |
||||
beacon->m_frequency = frequency * 1000; // kHz to Hz
|
||||
beacon->m_locator = locator; |
||||
beacon->m_latitude = latitude; |
||||
beacon->m_longitude = longitude; |
||||
beacon->m_altitude = height; |
||||
if (!QString("omni").compare(pattern, Qt::CaseInsensitive)) |
||||
beacon->m_pattern = "Omni"; // Eliminate usage of mixed case
|
||||
else |
||||
beacon->m_pattern = pattern; |
||||
beacon->m_polarization = polarization; |
||||
beacon->m_power = power; |
||||
beacon->m_key = key; |
||||
beacon->m_mgm = mgm; |
||||
|
||||
beacons->append(beacon); |
||||
cnt++; |
||||
} |
||||
} |
||||
} |
||||
fclose(file); |
||||
} |
||||
else |
||||
qDebug() << "Beacon::readIARUCSV: Failed to open " << filename; |
||||
|
||||
qDebug() << "Beacon::readIARUCSV: Read " << cnt << " beacons"; |
||||
|
||||
return beacons; |
||||
} |
||||
|
||||
}; |
||||
|
||||
#endif // INCLUDE_BEACON_H
|
||||
@ -1,7 +1,6 @@
@@ -1,7 +1,6 @@
|
||||
<RCC> |
||||
<qresource prefix="/map/"> |
||||
<file>map/map.qml</file> |
||||
<file>map/MapStation.qml</file> |
||||
<file>map/antenna.png</file> |
||||
</qresource> |
||||
</RCC> |
||||
|
||||
@ -1,40 +0,0 @@
@@ -1,40 +0,0 @@
|
||||
import QtQuick 2.12 |
||||
import QtLocation 5.12 |
||||
import QtPositioning 5.12 |
||||
|
||||
MapQuickItem { |
||||
id: station |
||||
property string stationName // Name of the station, E.g. Home |
||||
|
||||
coordinate: QtPositioning.coordinate(51.5, 0.125) // Location of the antenna (QTH) - London |
||||
zoomLevel: 11 |
||||
|
||||
anchorPoint.x: image.width/2 |
||||
anchorPoint.y: image.height/2 |
||||
|
||||
sourceItem: Grid { |
||||
columns: 1 |
||||
Grid { |
||||
horizontalItemAlignment: Grid.AlignHCenter |
||||
layer.enabled: true |
||||
layer.smooth: true |
||||
Image { |
||||
id: image |
||||
source: "antenna.png" |
||||
} |
||||
Rectangle { |
||||
id: bubble |
||||
color: "lightblue" |
||||
border.width: 1 |
||||
width: text.width * 1.3 |
||||
height: text.height * 1.3 |
||||
radius: 5 |
||||
Text { |
||||
id: text |
||||
anchors.centerIn: parent |
||||
text: stationName |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,221 @@
@@ -0,0 +1,221 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (C) 2021 Jon Beniston, M7RCE //
|
||||
// //
|
||||
// This program is free software; you can redistribute it and/or modify //
|
||||
// it under the terms of the GNU General Public License as published by //
|
||||
// the Free Software Foundation as version 3 of the License, or //
|
||||
// (at your option) any later version. //
|
||||
// //
|
||||
// This program is distributed in the hope that it will be useful, //
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
|
||||
// GNU General Public License V3 for more details. //
|
||||
// //
|
||||
// You should have received a copy of the GNU General Public License //
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "mapbeacondialog.h" |
||||
|
||||
#include <QDebug> |
||||
#include <QUrl> |
||||
#include <QMessageBox> |
||||
|
||||
#include "channel/channelwebapiutils.h" |
||||
#include "mapgui.h" |
||||
|
||||
MapBeaconDialog::MapBeaconDialog(MapGUI *gui, QWidget* parent) : |
||||
QDialog(parent), |
||||
m_gui(gui), |
||||
ui(new Ui::MapBeaconDialog), |
||||
m_progressDialog(nullptr) |
||||
{ |
||||
ui->setupUi(this); |
||||
connect(&m_dlm, &HttpDownloadManager::downloadComplete, this, &MapBeaconDialog::downloadFinished); |
||||
} |
||||
|
||||
MapBeaconDialog::~MapBeaconDialog() |
||||
{ |
||||
delete ui; |
||||
} |
||||
|
||||
void MapBeaconDialog::updateTable() |
||||
{ |
||||
AzEl azEl = *m_gui->getAzEl(); |
||||
ui->beacons->setSortingEnabled(false); |
||||
ui->beacons->setRowCount(0); |
||||
QList<Beacon *> *beacons = m_gui->getBeacons(); |
||||
if (beacons != nullptr) |
||||
{ |
||||
ui->beacons->setRowCount(beacons->size()); |
||||
QListIterator<Beacon *> i(*beacons); |
||||
int row = 0; |
||||
while (i.hasNext()) |
||||
{ |
||||
Beacon *beacon = i.next(); |
||||
ui->beacons->setItem(row, BEACON_COL_CALLSIGN, new QTableWidgetItem(beacon->m_callsign)); |
||||
QTableWidgetItem *freq = new QTableWidgetItem(); |
||||
freq->setText(beacon->getFrequencyText()); |
||||
freq->setData(Qt::UserRole, beacon->m_frequency); |
||||
ui->beacons->setItem(row, BEACON_COL_FREQUENCY, freq); |
||||
ui->beacons->setItem(row, BEACON_COL_LOCATION, new QTableWidgetItem(beacon->m_locator)); |
||||
ui->beacons->setItem(row, BEACON_COL_POWER, new QTableWidgetItem(beacon->m_power)); |
||||
ui->beacons->setItem(row, BEACON_COL_POLARIZATION, new QTableWidgetItem(beacon->m_polarization)); |
||||
ui->beacons->setItem(row, BEACON_COL_PATTERN, new QTableWidgetItem(beacon->m_pattern)); |
||||
ui->beacons->setItem(row, BEACON_COL_KEY, new QTableWidgetItem(beacon->m_key)); |
||||
ui->beacons->setItem(row, BEACON_COL_MGM, new QTableWidgetItem(beacon->m_mgm)); |
||||
azEl.setTarget(beacon->m_latitude, beacon->m_longitude, beacon->m_altitude); |
||||
azEl.calculate(); |
||||
ui->beacons->setItem(row, BEACON_COL_AZIMUTH, new QTableWidgetItem(QString("%1").arg(round(azEl.getAzimuth())))); |
||||
ui->beacons->setItem(row, BEACON_COL_ELEVATION, new QTableWidgetItem(QString("%1").arg(round(azEl.getElevation())))); |
||||
int km = round(azEl.getDistance()/1000); |
||||
QTableWidgetItem *dist = new QTableWidgetItem(); |
||||
dist->setData(Qt::DisplayRole, km); |
||||
ui->beacons->setItem(row, BEACON_COL_DISTANCE, dist); |
||||
row++; |
||||
} |
||||
} |
||||
ui->beacons->setSortingEnabled(true); |
||||
ui->beacons->resizeColumnsToContents(); |
||||
} |
||||
|
||||
qint64 MapBeaconDialog::fileAgeInDays(QString filename) |
||||
{ |
||||
QFile file(filename); |
||||
if (file.exists()) |
||||
{ |
||||
QDateTime modified = file.fileTime(QFileDevice::FileModificationTime); |
||||
if (modified.isValid()) |
||||
return modified.daysTo(QDateTime::currentDateTime()); |
||||
else |
||||
return -1; |
||||
} |
||||
return -1; |
||||
} |
||||
|
||||
bool MapBeaconDialog::confirmDownload(QString filename) |
||||
{ |
||||
qint64 age = fileAgeInDays(filename); |
||||
if ((age == -1) || (age > 100)) |
||||
return true; |
||||
else |
||||
{ |
||||
QMessageBox::StandardButton reply; |
||||
if (age == 0) |
||||
reply = QMessageBox::question(this, "Confirm download", "This file was last downloaded today. Are you sure you wish to redownload it?", QMessageBox::Yes|QMessageBox::No); |
||||
else if (age == 1) |
||||
reply = QMessageBox::question(this, "Confirm download", "This file was last downloaded yesterday. Are you sure you wish to redownload it?", QMessageBox::Yes|QMessageBox::No); |
||||
else |
||||
reply = QMessageBox::question(this, "Confirm download", QString("This file was last downloaded %1 days ago. Are you sure you wish to redownload this file?").arg(age), QMessageBox::Yes|QMessageBox::No); |
||||
return reply == QMessageBox::Yes; |
||||
} |
||||
} |
||||
|
||||
void MapBeaconDialog::updateDownloadProgress(qint64 bytesRead, qint64 totalBytes) |
||||
{ |
||||
m_progressDialog->setMaximum(totalBytes); |
||||
m_progressDialog->setValue(bytesRead); |
||||
} |
||||
|
||||
void MapBeaconDialog::accept() |
||||
{ |
||||
QDialog::accept(); |
||||
} |
||||
|
||||
void MapBeaconDialog::on_downloadIARU_clicked() |
||||
{ |
||||
if (m_progressDialog == nullptr) |
||||
{ |
||||
QString beaconFile = MapGUI::getBeaconFilename(); |
||||
if (confirmDownload(beaconFile)) |
||||
{ |
||||
// Download IARU beacons database to disk
|
||||
QUrl dbURL(QString(IARU_BEACONS_URL)); |
||||
m_progressDialog = new QProgressDialog(this); |
||||
m_progressDialog->setAttribute(Qt::WA_DeleteOnClose); |
||||
m_progressDialog->setCancelButton(nullptr); |
||||
m_progressDialog->setMinimumDuration(500); |
||||
m_progressDialog->setLabelText(QString("Downloading %1.").arg(IARU_BEACONS_URL)); |
||||
QNetworkReply *reply = m_dlm.download(dbURL, beaconFile); |
||||
connect(reply, SIGNAL(downloadProgress(qint64,qint64)), this, SLOT(updateDownloadProgress(qint64,qint64))); |
||||
} |
||||
} |
||||
} |
||||
|
||||
void MapBeaconDialog::downloadFinished(const QString& filename, bool success) |
||||
{ |
||||
if (success) |
||||
{ |
||||
if (filename == MapGUI::getBeaconFilename()) |
||||
{ |
||||
QList<Beacon *> *beacons = Beacon::readIARUCSV(filename); |
||||
if (beacons != nullptr) |
||||
m_gui->setBeacons(beacons); |
||||
m_progressDialog->close(); |
||||
m_progressDialog = nullptr; |
||||
} |
||||
else |
||||
{ |
||||
qDebug() << "MapBeaconDialog::downloadFinished: Unexpected filename: " << filename; |
||||
m_progressDialog->close(); |
||||
m_progressDialog = nullptr; |
||||
} |
||||
} |
||||
else |
||||
{ |
||||
qDebug() << "MapBeaconDialog::downloadFinished: Failed: " << filename; |
||||
m_progressDialog->close(); |
||||
m_progressDialog = nullptr; |
||||
QMessageBox::warning(this, "Download failed", QString("Failed to download %1").arg(filename)); |
||||
} |
||||
} |
||||
|
||||
void MapBeaconDialog::on_beacons_cellDoubleClicked(int row, int column) |
||||
{ |
||||
if ((column == BEACON_COL_CALLSIGN) || (column == BEACON_COL_LOCATION)) |
||||
{ |
||||
// Find beacon on map
|
||||
QString location = ui->beacons->item(row, column)->text(); |
||||
m_gui->find(location); |
||||
} |
||||
else if (column == BEACON_COL_FREQUENCY) |
||||
{ |
||||
// Tune to beacon freq
|
||||
ChannelWebAPIUtils::setCenterFrequency(0, ui->beacons->item(row, column)->data(Qt::UserRole).toDouble()); |
||||
} |
||||
} |
||||
|
||||
void MapBeaconDialog::on_filter_currentIndexChanged(int index) |
||||
{ |
||||
for (int row = 0; row < ui->beacons->rowCount(); row++) |
||||
{ |
||||
bool hidden = false; |
||||
QTableWidgetItem *item = ui->beacons->item(row, BEACON_COL_FREQUENCY); |
||||
qint64 freq = item->data(Qt::UserRole).toLongLong(); |
||||
qint64 band = freq/1000000; |
||||
switch (index) |
||||
{ |
||||
case 0: // All
|
||||
break; |
||||
case 1: |
||||
hidden = band != 50; |
||||
break; |
||||
case 2: |
||||
hidden = band != 70; |
||||
break; |
||||
case 3: |
||||
hidden = band != 144; |
||||
break; |
||||
case 4: |
||||
hidden = band != 432; |
||||
break; |
||||
case 5: |
||||
hidden = band != 1296; |
||||
break; |
||||
case 6: |
||||
hidden = band <= 1296; |
||||
break; |
||||
} |
||||
ui->beacons->setRowHidden(row, hidden); |
||||
} |
||||
} |
||||
@ -0,0 +1,71 @@
@@ -0,0 +1,71 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (C) 2021 Jon Beniston, M7RCE //
|
||||
// //
|
||||
// This program is free software; you can redistribute it and/or modify //
|
||||
// it under the terms of the GNU General Public License as published by //
|
||||
// the Free Software Foundation as version 3 of the License, or //
|
||||
// (at your option) any later version. //
|
||||
// //
|
||||
// This program is distributed in the hope that it will be useful, //
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
|
||||
// GNU General Public License V3 for more details. //
|
||||
// //
|
||||
// You should have received a copy of the GNU General Public License //
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef INCLUDE_FEATURE_MAPBEACONDIALOG_H |
||||
#define INCLUDE_FEATURE_MAPBEACONDIALOG_H |
||||
|
||||
#include "ui_mapbeacondialog.h" |
||||
|
||||
#include <QProgressDialog> |
||||
|
||||
#include "util/httpdownloadmanager.h" |
||||
#include "beacon.h" |
||||
|
||||
class MapGUI; |
||||
|
||||
class MapBeaconDialog : public QDialog { |
||||
Q_OBJECT |
||||
|
||||
public: |
||||
explicit MapBeaconDialog(MapGUI *gui, QWidget* parent = 0); |
||||
~MapBeaconDialog(); |
||||
void updateTable(); |
||||
|
||||
private: |
||||
qint64 fileAgeInDays(QString filename); |
||||
bool confirmDownload(QString filename); |
||||
void downloadFinished(const QString& filename, bool success); |
||||
|
||||
private slots: |
||||
void accept(); |
||||
void on_downloadIARU_clicked(); |
||||
void updateDownloadProgress(qint64 bytesRead, qint64 totalBytes); |
||||
void on_beacons_cellDoubleClicked(int row, int column); |
||||
void on_filter_currentIndexChanged(int index); |
||||
|
||||
private: |
||||
MapGUI *m_gui; |
||||
Ui::MapBeaconDialog* ui; |
||||
HttpDownloadManager m_dlm; |
||||
QProgressDialog *m_progressDialog; |
||||
|
||||
enum BeaconCol { |
||||
BEACON_COL_CALLSIGN, |
||||
BEACON_COL_FREQUENCY, |
||||
BEACON_COL_LOCATION, |
||||
BEACON_COL_POWER, |
||||
BEACON_COL_POLARIZATION, |
||||
BEACON_COL_PATTERN, |
||||
BEACON_COL_KEY, |
||||
BEACON_COL_MGM, |
||||
BEACON_COL_AZIMUTH, |
||||
BEACON_COL_ELEVATION, |
||||
BEACON_COL_DISTANCE |
||||
}; |
||||
}; |
||||
|
||||
#endif // INCLUDE_FEATURE_MAPBEACONDIALOG_H
|
||||
@ -0,0 +1,226 @@
@@ -0,0 +1,226 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<ui version="4.0"> |
||||
<class>MapBeaconDialog</class> |
||||
<widget class="QDialog" name="MapBeaconDialog"> |
||||
<property name="geometry"> |
||||
<rect> |
||||
<x>0</x> |
||||
<y>0</y> |
||||
<width>1027</width> |
||||
<height>349</height> |
||||
</rect> |
||||
</property> |
||||
<property name="font"> |
||||
<font> |
||||
<family>Liberation Sans</family> |
||||
<pointsize>9</pointsize> |
||||
</font> |
||||
</property> |
||||
<property name="windowTitle"> |
||||
<string>Beacons</string> |
||||
</property> |
||||
<layout class="QVBoxLayout" name="verticalLayout"> |
||||
<item> |
||||
<widget class="QGroupBox" name="groupBox"> |
||||
<layout class="QVBoxLayout" name="verticalLayout_2"> |
||||
<property name="topMargin"> |
||||
<number>0</number> |
||||
</property> |
||||
<item> |
||||
<layout class="QHBoxLayout" name="horizontalLayout"> |
||||
<item> |
||||
<widget class="QLabel" name="filterLabel"> |
||||
<property name="text"> |
||||
<string>Show</string> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
<item> |
||||
<widget class="QComboBox" name="filter"> |
||||
<property name="minimumSize"> |
||||
<size> |
||||
<width>100</width> |
||||
<height>0</height> |
||||
</size> |
||||
</property> |
||||
<item> |
||||
<property name="text"> |
||||
<string>All</string> |
||||
</property> |
||||
</item> |
||||
<item> |
||||
<property name="text"> |
||||
<string>50MHz (6m)</string> |
||||
</property> |
||||
</item> |
||||
<item> |
||||
<property name="text"> |
||||
<string>70MHz (4m)</string> |
||||
</property> |
||||
</item> |
||||
<item> |
||||
<property name="text"> |
||||
<string>144MHz (2m)</string> |
||||
</property> |
||||
</item> |
||||
<item> |
||||
<property name="text"> |
||||
<string>432MHz (70cm)</string> |
||||
</property> |
||||
</item> |
||||
<item> |
||||
<property name="text"> |
||||
<string>1.296GHz (23cm)</string> |
||||
</property> |
||||
</item> |
||||
<item> |
||||
<property name="text"> |
||||
<string>>2.3GHz (<13cm)</string> |
||||
</property> |
||||
</item> |
||||
</widget> |
||||
</item> |
||||
<item> |
||||
<spacer name="horizontalSpacer"> |
||||
<property name="orientation"> |
||||
<enum>Qt::Horizontal</enum> |
||||
</property> |
||||
<property name="sizeHint" stdset="0"> |
||||
<size> |
||||
<width>40</width> |
||||
<height>20</height> |
||||
</size> |
||||
</property> |
||||
</spacer> |
||||
</item> |
||||
<item> |
||||
<widget class="QPushButton" name="downloadIARU"> |
||||
<property name="toolTip"> |
||||
<string>Download IARU Beacon list</string> |
||||
</property> |
||||
<property name="text"> |
||||
<string/> |
||||
</property> |
||||
<property name="icon"> |
||||
<iconset resource="../../../sdrgui/resources/res.qrc"> |
||||
<normaloff>:/antenna.png</normaloff>:/antenna.png</iconset> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
</layout> |
||||
</item> |
||||
<item> |
||||
<widget class="QTableWidget" name="beacons"> |
||||
<property name="toolTip"> |
||||
<string/> |
||||
</property> |
||||
<column> |
||||
<property name="text"> |
||||
<string>Callsign</string> |
||||
</property> |
||||
</column> |
||||
<column> |
||||
<property name="text"> |
||||
<string>Frequency</string> |
||||
</property> |
||||
</column> |
||||
<column> |
||||
<property name="text"> |
||||
<string>Location</string> |
||||
</property> |
||||
</column> |
||||
<column> |
||||
<property name="text"> |
||||
<string>Power</string> |
||||
</property> |
||||
</column> |
||||
<column> |
||||
<property name="text"> |
||||
<string>Polarization</string> |
||||
</property> |
||||
</column> |
||||
<column> |
||||
<property name="text"> |
||||
<string>Pattern</string> |
||||
</property> |
||||
</column> |
||||
<column> |
||||
<property name="text"> |
||||
<string>Key</string> |
||||
</property> |
||||
</column> |
||||
<column> |
||||
<property name="text"> |
||||
<string>MGM</string> |
||||
</property> |
||||
</column> |
||||
<column> |
||||
<property name="text"> |
||||
<string>Azimuth</string> |
||||
</property> |
||||
</column> |
||||
<column> |
||||
<property name="text"> |
||||
<string>Elevation</string> |
||||
</property> |
||||
</column> |
||||
<column> |
||||
<property name="text"> |
||||
<string>Distance (km)</string> |
||||
</property> |
||||
</column> |
||||
</widget> |
||||
</item> |
||||
</layout> |
||||
</widget> |
||||
</item> |
||||
<item> |
||||
<widget class="QDialogButtonBox" name="buttonBox"> |
||||
<property name="orientation"> |
||||
<enum>Qt::Horizontal</enum> |
||||
</property> |
||||
<property name="standardButtons"> |
||||
<set>QDialogButtonBox::Close</set> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
</layout> |
||||
</widget> |
||||
<resources> |
||||
<include location="../../../sdrgui/resources/res.qrc"/> |
||||
</resources> |
||||
<connections> |
||||
<connection> |
||||
<sender>buttonBox</sender> |
||||
<signal>accepted()</signal> |
||||
<receiver>MapBeaconDialog</receiver> |
||||
<slot>accept()</slot> |
||||
<hints> |
||||
<hint type="sourcelabel"> |
||||
<x>248</x> |
||||
<y>254</y> |
||||
</hint> |
||||
<hint type="destinationlabel"> |
||||
<x>157</x> |
||||
<y>274</y> |
||||
</hint> |
||||
</hints> |
||||
</connection> |
||||
<connection> |
||||
<sender>buttonBox</sender> |
||||
<signal>rejected()</signal> |
||||
<receiver>MapBeaconDialog</receiver> |
||||
<slot>reject()</slot> |
||||
<hints> |
||||
<hint type="sourcelabel"> |
||||
<x>316</x> |
||||
<y>260</y> |
||||
</hint> |
||||
<hint type="destinationlabel"> |
||||
<x>286</x> |
||||
<y>274</y> |
||||
</hint> |
||||
</hints> |
||||
</connection> |
||||
</connections> |
||||
</ui> |
||||
@ -0,0 +1,47 @@
@@ -0,0 +1,47 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (C) 2021 Jon Beniston, M7RCE //
|
||||
// //
|
||||
// This program is free software; you can redistribute it and/or modify //
|
||||
// it under the terms of the GNU General Public License as published by //
|
||||
// the Free Software Foundation as version 3 of the License, or //
|
||||
// (at your option) any later version. //
|
||||
// //
|
||||
// This program is distributed in the hope that it will be useful, //
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
|
||||
// GNU General Public License V3 for more details. //
|
||||
// //
|
||||
// You should have received a copy of the GNU General Public License //
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "maplocationdialog.h" |
||||
#include <QDebug> |
||||
#include <QGeoAddress> |
||||
|
||||
MapLocationDialog::MapLocationDialog(const QList<QGeoLocation>& locations, |
||||
QWidget* parent) : |
||||
QDialog(parent), |
||||
ui(new Ui::MapLocationDialog) |
||||
{ |
||||
ui->setupUi(this); |
||||
for (const QGeoLocation& location : locations) |
||||
{ |
||||
QGeoAddress address = location.address(); |
||||
ui->locations->addItem(address.text()); |
||||
} |
||||
ui->locations->setCurrentRow(0); |
||||
m_locations = &locations; |
||||
} |
||||
|
||||
MapLocationDialog::~MapLocationDialog() |
||||
{ |
||||
delete ui; |
||||
} |
||||
|
||||
void MapLocationDialog::accept() |
||||
{ |
||||
int row = ui->locations->currentRow(); |
||||
m_selectedLocation = m_locations->at(row); |
||||
QDialog::accept(); |
||||
} |
||||
@ -0,0 +1,43 @@
@@ -0,0 +1,43 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (C) 2021 Jon Beniston, M7RCE //
|
||||
// //
|
||||
// This program is free software; you can redistribute it and/or modify //
|
||||
// it under the terms of the GNU General Public License as published by //
|
||||
// the Free Software Foundation as version 3 of the License, or //
|
||||
// (at your option) any later version. //
|
||||
// //
|
||||
// This program is distributed in the hope that it will be useful, //
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
|
||||
// GNU General Public License V3 for more details. //
|
||||
// //
|
||||
// You should have received a copy of the GNU General Public License //
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef INCLUDE_FEATURE_MAPLOCATIONDIALOG_H |
||||
#define INCLUDE_FEATURE_MAPLOCATIONDIALOG_H |
||||
|
||||
#include "ui_maplocationdialog.h" |
||||
|
||||
#include <QList> |
||||
#include <QGeoLocation> |
||||
|
||||
class MapLocationDialog : public QDialog { |
||||
Q_OBJECT |
||||
|
||||
public: |
||||
explicit MapLocationDialog(const QList<QGeoLocation>& locations, QWidget* parent = 0); |
||||
~MapLocationDialog(); |
||||
|
||||
const QList<QGeoLocation> *m_locations; |
||||
QGeoLocation m_selectedLocation; |
||||
|
||||
private slots: |
||||
void accept(); |
||||
|
||||
private: |
||||
Ui::MapLocationDialog* ui; |
||||
}; |
||||
|
||||
#endif // INCLUDE_FEATURE_MAPLOCATIONDIALOG_H
|
||||
@ -0,0 +1,93 @@
@@ -0,0 +1,93 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<ui version="4.0"> |
||||
<class>MapLocationDialog</class> |
||||
<widget class="QDialog" name="MapLocationDialog"> |
||||
<property name="geometry"> |
||||
<rect> |
||||
<x>0</x> |
||||
<y>0</y> |
||||
<width>565</width> |
||||
<height>349</height> |
||||
</rect> |
||||
</property> |
||||
<property name="font"> |
||||
<font> |
||||
<family>Liberation Sans</family> |
||||
<pointsize>9</pointsize> |
||||
</font> |
||||
</property> |
||||
<property name="windowTitle"> |
||||
<string>Select a Location</string> |
||||
</property> |
||||
<layout class="QVBoxLayout" name="verticalLayout"> |
||||
<item> |
||||
<widget class="QGroupBox" name="groupBox"> |
||||
<layout class="QVBoxLayout" name="verticalLayout_2"> |
||||
<item> |
||||
<widget class="QLabel" name="locationsLabel"> |
||||
<property name="text"> |
||||
<string>Select a location:</string> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
<item> |
||||
<widget class="QListWidget" name="locations"> |
||||
<property name="toolTip"> |
||||
<string>Select a location</string> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
</layout> |
||||
</widget> |
||||
</item> |
||||
<item> |
||||
<widget class="QDialogButtonBox" name="buttonBox"> |
||||
<property name="orientation"> |
||||
<enum>Qt::Horizontal</enum> |
||||
</property> |
||||
<property name="standardButtons"> |
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
</layout> |
||||
</widget> |
||||
<tabstops> |
||||
<tabstop>locations</tabstop> |
||||
</tabstops> |
||||
<resources/> |
||||
<connections> |
||||
<connection> |
||||
<sender>buttonBox</sender> |
||||
<signal>accepted()</signal> |
||||
<receiver>MapLocationDialog</receiver> |
||||
<slot>accept()</slot> |
||||
<hints> |
||||
<hint type="sourcelabel"> |
||||
<x>248</x> |
||||
<y>254</y> |
||||
</hint> |
||||
<hint type="destinationlabel"> |
||||
<x>157</x> |
||||
<y>274</y> |
||||
</hint> |
||||
</hints> |
||||
</connection> |
||||
<connection> |
||||
<sender>buttonBox</sender> |
||||
<signal>rejected()</signal> |
||||
<receiver>MapLocationDialog</receiver> |
||||
<slot>reject()</slot> |
||||
<hints> |
||||
<hint type="sourcelabel"> |
||||
<x>316</x> |
||||
<y>260</y> |
||||
</hint> |
||||
<hint type="destinationlabel"> |
||||
<x>286</x> |
||||
<y>274</y> |
||||
</hint> |
||||
</hints> |
||||
</connection> |
||||
</connections> |
||||
</ui> |
||||
@ -0,0 +1,144 @@
@@ -0,0 +1,144 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (C) 2021 Jon Beniston, M7RCE //
|
||||
// //
|
||||
// This program is free software; you can redistribute it and/or modify //
|
||||
// it under the terms of the GNU General Public License as published by //
|
||||
// the Free Software Foundation as version 3 of the License, or //
|
||||
// (at your option) any later version. //
|
||||
// //
|
||||
// This program is distributed in the hope that it will be useful, //
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
|
||||
// GNU General Public License V3 for more details. //
|
||||
// //
|
||||
// You should have received a copy of the GNU General Public License //
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <QDebug> |
||||
#include <QGeoCoordinate> |
||||
#include <QGeoCodingManager> |
||||
#include <QGeoServiceProvider> |
||||
|
||||
#include "util/units.h" |
||||
#include "util/maidenhead.h" |
||||
|
||||
#include "mapmaidenheaddialog.h" |
||||
#include "maplocationdialog.h" |
||||
|
||||
MapMaidenheadDialog::MapMaidenheadDialog(QWidget* parent) : |
||||
QDialog(parent), |
||||
ui(new Ui::MapMaidenheadDialog) |
||||
{ |
||||
ui->setupUi(this); |
||||
} |
||||
|
||||
MapMaidenheadDialog::~MapMaidenheadDialog() |
||||
{ |
||||
delete ui; |
||||
} |
||||
|
||||
void MapMaidenheadDialog::on_address_returnPressed() |
||||
{ |
||||
QString address = ui->address->text().trimmed(); |
||||
if (!address.isEmpty()) |
||||
{ |
||||
ui->latAndLong->setText(""); |
||||
ui->error->setText(""); |
||||
QGeoServiceProvider* geoSrv = new QGeoServiceProvider("osm"); |
||||
if (geoSrv != nullptr) |
||||
{ |
||||
QLocale qLocaleC(QLocale::C, QLocale::AnyCountry); |
||||
geoSrv->setLocale(qLocaleC); |
||||
QGeoCodeReply *pQGeoCode = geoSrv->geocodingManager()->geocode(address); |
||||
if (pQGeoCode) |
||||
QObject::connect(pQGeoCode, &QGeoCodeReply::finished, this, &MapMaidenheadDialog::geoReply); |
||||
else |
||||
ui->error->setText("GeoCoding failed"); |
||||
} |
||||
else |
||||
ui->error->setText("OpenStreetMap Location services not available"); |
||||
} |
||||
} |
||||
|
||||
void MapMaidenheadDialog::on_latAndLong_returnPressed() |
||||
{ |
||||
float latitude, longitude; |
||||
QString coords = ui->latAndLong->text(); |
||||
|
||||
if (Units::stringToLatitudeAndLongitude(coords, latitude, longitude)) |
||||
{ |
||||
ui->error->setText(""); |
||||
ui->maidenhead->setText(Maidenhead::toMaidenhead(latitude, longitude)); |
||||
} |
||||
else |
||||
{ |
||||
ui->error->setText("Not a valid latitude and longitude"); |
||||
ui->maidenhead->setText(""); |
||||
QApplication::beep(); |
||||
} |
||||
ui->address->setText(""); |
||||
} |
||||
|
||||
void MapMaidenheadDialog::on_maidenhead_returnPressed() |
||||
{ |
||||
float latitude, longitude; |
||||
QString locator = ui->maidenhead->text(); |
||||
|
||||
if (Maidenhead::fromMaidenhead(locator, latitude, longitude)) |
||||
{ |
||||
ui->error->setText(""); |
||||
ui->latAndLong->setText(QString("%1,%2").arg(latitude).arg(longitude)); |
||||
} |
||||
else |
||||
{ |
||||
ui->error->setText("Not a valid Maidenhead locator"); |
||||
ui->latAndLong->setText(""); |
||||
QApplication::beep(); |
||||
} |
||||
ui->address->setText(""); |
||||
} |
||||
|
||||
void MapMaidenheadDialog::geoReply() |
||||
{ |
||||
QGeoCodeReply *pQGeoCode = dynamic_cast<QGeoCodeReply*>(sender()); |
||||
|
||||
if ((pQGeoCode != nullptr) && (pQGeoCode->error() == QGeoCodeReply::NoError)) |
||||
{ |
||||
QList<QGeoLocation> qGeoLocs = pQGeoCode->locations(); |
||||
if (qGeoLocs.size() == 0) |
||||
{ |
||||
ui->error->setText("No location found for address"); |
||||
QApplication::beep(); |
||||
} |
||||
else |
||||
{ |
||||
if (qGeoLocs.size() == 1) |
||||
{ |
||||
QGeoCoordinate c = qGeoLocs.at(0).coordinate(); |
||||
ui->latAndLong->setText(QString("%1,%2").arg(c.latitude()).arg(c.longitude())); |
||||
ui->maidenhead->setText(Maidenhead::toMaidenhead(c.latitude(), c.longitude())); |
||||
} |
||||
else |
||||
{ |
||||
// Show dialog allowing user to select from the results
|
||||
MapLocationDialog dialog(qGeoLocs, this); |
||||
if (dialog.exec() == QDialog::Accepted) |
||||
{ |
||||
QGeoCoordinate c = dialog.m_selectedLocation.coordinate(); |
||||
ui->latAndLong->setText(QString("%1,%2").arg(c.latitude()).arg(c.longitude())); |
||||
ui->maidenhead->setText(Maidenhead::toMaidenhead(c.latitude(), c.longitude())); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
else |
||||
ui->error->setText(QString("GeoCode error: %1").arg(pQGeoCode->error())); |
||||
pQGeoCode->deleteLater(); |
||||
} |
||||
|
||||
// Use a custom close button, so pressing enter doesn't close the dialog
|
||||
void MapMaidenheadDialog::on_close_clicked() |
||||
{ |
||||
QDialog::accept(); |
||||
} |
||||
@ -0,0 +1,42 @@
@@ -0,0 +1,42 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (C) 2021 Jon Beniston, M7RCE //
|
||||
// //
|
||||
// This program is free software; you can redistribute it and/or modify //
|
||||
// it under the terms of the GNU General Public License as published by //
|
||||
// the Free Software Foundation as version 3 of the License, or //
|
||||
// (at your option) any later version. //
|
||||
// //
|
||||
// This program is distributed in the hope that it will be useful, //
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
|
||||
// GNU General Public License V3 for more details. //
|
||||
// //
|
||||
// You should have received a copy of the GNU General Public License //
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef INCLUDE_FEATURE_MAPMAIDENHEADDIALOG_H |
||||
#define INCLUDE_FEATURE_MAPMAIDENHEADDIALOG_H |
||||
|
||||
#include "ui_mapmaidenheaddialog.h" |
||||
|
||||
class MapMaidenheadDialog : public QDialog { |
||||
Q_OBJECT |
||||
|
||||
public: |
||||
explicit MapMaidenheadDialog(QWidget* parent = 0); |
||||
~MapMaidenheadDialog(); |
||||
|
||||
void geoReply(); |
||||
|
||||
private slots: |
||||
void on_address_returnPressed(); |
||||
void on_latAndLong_returnPressed(); |
||||
void on_maidenhead_returnPressed(); |
||||
void on_close_clicked(); |
||||
|
||||
private: |
||||
Ui::MapMaidenheadDialog* ui; |
||||
}; |
||||
|
||||
#endif // INCLUDE_FEATURE_MAPMAIDENHEADDIALOG_H
|
||||
@ -0,0 +1,145 @@
@@ -0,0 +1,145 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<ui version="4.0"> |
||||
<class>MapMaidenheadDialog</class> |
||||
<widget class="QDialog" name="MapMaidenheadDialog"> |
||||
<property name="geometry"> |
||||
<rect> |
||||
<x>0</x> |
||||
<y>0</y> |
||||
<width>565</width> |
||||
<height>194</height> |
||||
</rect> |
||||
</property> |
||||
<property name="font"> |
||||
<font> |
||||
<family>Liberation Sans</family> |
||||
<pointsize>9</pointsize> |
||||
</font> |
||||
</property> |
||||
<property name="windowTitle"> |
||||
<string>Maidenhead Locator Converter</string> |
||||
</property> |
||||
<property name="toolTip"> |
||||
<string>Location conversion</string> |
||||
</property> |
||||
<layout class="QVBoxLayout" name="verticalLayout"> |
||||
<item> |
||||
<widget class="QGroupBox" name="groupBox"> |
||||
<layout class="QVBoxLayout" name="verticalLayout_2"> |
||||
<item> |
||||
<widget class="QLabel" name="infoLabel"> |
||||
<property name="text"> |
||||
<string>Enter a location to convert and press enter:</string> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
<item> |
||||
<layout class="QFormLayout" name="formLayout"> |
||||
<item row="0" column="0"> |
||||
<widget class="QLabel" name="addressLabel"> |
||||
<property name="text"> |
||||
<string>Address</string> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
<item row="0" column="1"> |
||||
<widget class="QLineEdit" name="address"> |
||||
<property name="toolTip"> |
||||
<string>Enter an address to convert to latitude/longitude and a Maidenhead locator</string> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
<item row="1" column="0"> |
||||
<widget class="QLabel" name="latAndLongLabel"> |
||||
<property name="text"> |
||||
<string>Latitude and longitude</string> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
<item row="2" column="0"> |
||||
<widget class="QLabel" name="maidenheadLabel"> |
||||
<property name="text"> |
||||
<string>Maidenhead locator</string> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
<item row="2" column="1"> |
||||
<widget class="QLineEdit" name="maidenhead"> |
||||
<property name="toolTip"> |
||||
<string>Enter a Maidenhead locator to convert to latitude and longitude</string> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
<item row="1" column="1"> |
||||
<widget class="QLineEdit" name="latAndLong"> |
||||
<property name="focusPolicy"> |
||||
<enum>Qt::StrongFocus</enum> |
||||
</property> |
||||
<property name="toolTip"> |
||||
<string>Enter latitude and longitude to convert to a Maidenhead locator</string> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
</layout> |
||||
</item> |
||||
<item> |
||||
<widget class="QLabel" name="error"> |
||||
<property name="text"> |
||||
<string/> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
<item> |
||||
<spacer name="verticalSpacer"> |
||||
<property name="orientation"> |
||||
<enum>Qt::Vertical</enum> |
||||
</property> |
||||
<property name="sizeHint" stdset="0"> |
||||
<size> |
||||
<width>20</width> |
||||
<height>40</height> |
||||
</size> |
||||
</property> |
||||
</spacer> |
||||
</item> |
||||
<item> |
||||
<layout class="QHBoxLayout" name="horizontalLayout"> |
||||
<item> |
||||
<spacer name="horizontalSpacer"> |
||||
<property name="orientation"> |
||||
<enum>Qt::Horizontal</enum> |
||||
</property> |
||||
<property name="sizeHint" stdset="0"> |
||||
<size> |
||||
<width>40</width> |
||||
<height>20</height> |
||||
</size> |
||||
</property> |
||||
</spacer> |
||||
</item> |
||||
<item> |
||||
<widget class="QPushButton" name="close"> |
||||
<property name="focusPolicy"> |
||||
<enum>Qt::NoFocus</enum> |
||||
</property> |
||||
<property name="text"> |
||||
<string>Close</string> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
</layout> |
||||
</item> |
||||
</layout> |
||||
</widget> |
||||
</item> |
||||
</layout> |
||||
</widget> |
||||
<tabstops> |
||||
<tabstop>address</tabstop> |
||||
<tabstop>latAndLong</tabstop> |
||||
<tabstop>maidenhead</tabstop> |
||||
<tabstop>close</tabstop> |
||||
</tabstops> |
||||
<resources/> |
||||
<connections/> |
||||
</ui> |
||||
@ -0,0 +1,66 @@
@@ -0,0 +1,66 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (C) 2021 Jon Beniston, M7RCE //
|
||||
// //
|
||||
// This program is free software; you can redistribute it and/or modify //
|
||||
// it under the terms of the GNU General Public License as published by //
|
||||
// the Free Software Foundation as version 3 of the License, or //
|
||||
// (at your option) any later version. //
|
||||
// //
|
||||
// This program is distributed in the hope that it will be useful, //
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
|
||||
// GNU General Public License V3 for more details. //
|
||||
// //
|
||||
// You should have received a copy of the GNU General Public License //
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <QDebug> |
||||
|
||||
#include "util/units.h" |
||||
|
||||
#include "mapsettingsdialog.h" |
||||
#include "maplocationdialog.h" |
||||
|
||||
MapSettingsDialog::MapSettingsDialog(MapSettings *settings, QWidget* parent) : |
||||
QDialog(parent), |
||||
m_settings(settings), |
||||
ui(new Ui::MapSettingsDialog) |
||||
{ |
||||
ui->setupUi(this); |
||||
ui->mapProvider->setCurrentIndex(MapSettings::m_mapProviders.indexOf(settings->m_mapProvider)); |
||||
ui->mapBoxApiKey->setText(settings->m_mapBoxApiKey); |
||||
ui->mapBoxStyles->setText(settings->m_mapBoxStyles); |
||||
for (int i = 0; i < ui->sourceList->count(); i++) |
||||
ui->sourceList->item(i)->setCheckState((m_settings->m_sources & (1 << i)) ? Qt::Checked : Qt::Unchecked); |
||||
} |
||||
|
||||
MapSettingsDialog::~MapSettingsDialog() |
||||
{ |
||||
delete ui; |
||||
} |
||||
|
||||
void MapSettingsDialog::accept() |
||||
{ |
||||
QString mapProvider = MapSettings::m_mapProviders[ui->mapProvider->currentIndex()]; |
||||
QString mapBoxApiKey = ui->mapBoxApiKey->text(); |
||||
QString mapBoxStyles = ui->mapBoxStyles->text(); |
||||
if ((mapProvider != m_settings->m_mapProvider) |
||||
|| (mapBoxApiKey != m_settings->m_mapBoxApiKey) |
||||
|| (mapBoxStyles != m_settings->m_mapBoxStyles)) |
||||
{ |
||||
m_settings->m_mapProvider = mapProvider; |
||||
m_settings->m_mapBoxApiKey = mapBoxApiKey; |
||||
m_settings->m_mapBoxStyles = mapBoxStyles; |
||||
m_mapSettingsChanged = true; |
||||
} |
||||
else |
||||
m_mapSettingsChanged = false; |
||||
m_settings->m_sources = 0; |
||||
quint32 sources = MapSettings::SOURCE_STATION; |
||||
for (int i = 0; i < ui->sourceList->count(); i++) |
||||
sources |= (ui->sourceList->item(i)->checkState() == Qt::Checked) << i; |
||||
m_sourcesChanged = sources != m_settings->m_sources; |
||||
m_settings->m_sources = sources; |
||||
QDialog::accept(); |
||||
} |
||||
@ -0,0 +1,42 @@
@@ -0,0 +1,42 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (C) 2021 Jon Beniston, M7RCE //
|
||||
// //
|
||||
// This program is free software; you can redistribute it and/or modify //
|
||||
// it under the terms of the GNU General Public License as published by //
|
||||
// the Free Software Foundation as version 3 of the License, or //
|
||||
// (at your option) any later version. //
|
||||
// //
|
||||
// This program is distributed in the hope that it will be useful, //
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
|
||||
// GNU General Public License V3 for more details. //
|
||||
// //
|
||||
// You should have received a copy of the GNU General Public License //
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef INCLUDE_FEATURE_MAPSETTINGSDIALOG_H |
||||
#define INCLUDE_FEATURE_MAPSETTINGSDIALOG_H |
||||
|
||||
#include "ui_mapsettingsdialog.h" |
||||
#include "mapsettings.h" |
||||
|
||||
class MapSettingsDialog : public QDialog { |
||||
Q_OBJECT |
||||
|
||||
public: |
||||
explicit MapSettingsDialog(MapSettings *settings, QWidget* parent = 0); |
||||
~MapSettingsDialog(); |
||||
|
||||
MapSettings *m_settings; |
||||
bool m_mapSettingsChanged; |
||||
bool m_sourcesChanged; |
||||
|
||||
private slots: |
||||
void accept(); |
||||
|
||||
private: |
||||
Ui::MapSettingsDialog* ui; |
||||
}; |
||||
|
||||
#endif // INCLUDE_FEATURE_MAPSETTINGSDIALOG_H
|
||||
@ -0,0 +1,199 @@
@@ -0,0 +1,199 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<ui version="4.0"> |
||||
<class>MapSettingsDialog</class> |
||||
<widget class="QDialog" name="MapSettingsDialog"> |
||||
<property name="geometry"> |
||||
<rect> |
||||
<x>0</x> |
||||
<y>0</y> |
||||
<width>436</width> |
||||
<height>491</height> |
||||
</rect> |
||||
</property> |
||||
<property name="font"> |
||||
<font> |
||||
<family>Liberation Sans</family> |
||||
<pointsize>9</pointsize> |
||||
</font> |
||||
</property> |
||||
<property name="windowTitle"> |
||||
<string>Select a Location</string> |
||||
</property> |
||||
<layout class="QVBoxLayout" name="verticalLayout"> |
||||
<item> |
||||
<widget class="QGroupBox" name="groupBox"> |
||||
<layout class="QVBoxLayout" name="verticalLayout_2"> |
||||
<property name="topMargin"> |
||||
<number>0</number> |
||||
</property> |
||||
<item> |
||||
<widget class="QLabel" name="locationsLabel"> |
||||
<property name="text"> |
||||
<string>Select data to display:</string> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
<item> |
||||
<widget class="QListWidget" name="sourceList"> |
||||
<property name="selectionMode"> |
||||
<enum>QAbstractItemView::MultiSelection</enum> |
||||
</property> |
||||
<property name="sortingEnabled"> |
||||
<bool>false</bool> |
||||
</property> |
||||
<item> |
||||
<property name="text"> |
||||
<string>ADS-B</string> |
||||
</property> |
||||
<property name="checkState"> |
||||
<enum>Checked</enum> |
||||
</property> |
||||
</item> |
||||
<item> |
||||
<property name="text"> |
||||
<string>APRS</string> |
||||
</property> |
||||
<property name="checkState"> |
||||
<enum>Checked</enum> |
||||
</property> |
||||
</item> |
||||
<item> |
||||
<property name="text"> |
||||
<string>Star Tracker</string> |
||||
</property> |
||||
<property name="checkState"> |
||||
<enum>Checked</enum> |
||||
</property> |
||||
</item> |
||||
<item> |
||||
<property name="text"> |
||||
<string>Beacons</string> |
||||
</property> |
||||
<property name="checkState"> |
||||
<enum>Checked</enum> |
||||
</property> |
||||
</item> |
||||
</widget> |
||||
</item> |
||||
<item> |
||||
<widget class="QGroupBox" name="groupBox_2"> |
||||
<property name="title"> |
||||
<string>Map Provider Settings</string> |
||||
</property> |
||||
<layout class="QFormLayout" name="formLayout_2"> |
||||
<item row="0" column="0"> |
||||
<widget class="QLabel" name="mapProviderLabel"> |
||||
<property name="text"> |
||||
<string>Map provider</string> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
<item row="0" column="1"> |
||||
<widget class="QComboBox" name="mapProvider"> |
||||
<property name="toolTip"> |
||||
<string>Select map provider</string> |
||||
</property> |
||||
<item> |
||||
<property name="text"> |
||||
<string>OpenStreetMap</string> |
||||
</property> |
||||
</item> |
||||
<item> |
||||
<property name="text"> |
||||
<string>ESRI</string> |
||||
</property> |
||||
</item> |
||||
<item> |
||||
<property name="text"> |
||||
<string>Mapbox</string> |
||||
</property> |
||||
</item> |
||||
<item> |
||||
<property name="text"> |
||||
<string>MapboxGL</string> |
||||
</property> |
||||
</item> |
||||
</widget> |
||||
</item> |
||||
<item row="1" column="0"> |
||||
<widget class="QLabel" name="mapBoxApiKeyLabel"> |
||||
<property name="text"> |
||||
<string>Mapbox API Key</string> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
<item row="1" column="1"> |
||||
<widget class="QLineEdit" name="mapBoxApiKey"> |
||||
<property name="toolTip"> |
||||
<string>Enter a Mapbox API key in order to use Mapbox maps</string> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
<item row="2" column="0"> |
||||
<widget class="QLabel" name="mapBoxStylesLabel"> |
||||
<property name="text"> |
||||
<string>MapboxGL Styles</string> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
<item row="2" column="1"> |
||||
<widget class="QLineEdit" name="mapBoxStyles"> |
||||
<property name="toolTip"> |
||||
<string>Comma separated list of MapBox styles</string> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
</layout> |
||||
</widget> |
||||
</item> |
||||
</layout> |
||||
</widget> |
||||
</item> |
||||
<item> |
||||
<widget class="QDialogButtonBox" name="buttonBox"> |
||||
<property name="orientation"> |
||||
<enum>Qt::Horizontal</enum> |
||||
</property> |
||||
<property name="standardButtons"> |
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
</layout> |
||||
</widget> |
||||
<resources/> |
||||
<connections> |
||||
<connection> |
||||
<sender>buttonBox</sender> |
||||
<signal>accepted()</signal> |
||||
<receiver>MapSettingsDialog</receiver> |
||||
<slot>accept()</slot> |
||||
<hints> |
||||
<hint type="sourcelabel"> |
||||
<x>248</x> |
||||
<y>254</y> |
||||
</hint> |
||||
<hint type="destinationlabel"> |
||||
<x>157</x> |
||||
<y>274</y> |
||||
</hint> |
||||
</hints> |
||||
</connection> |
||||
<connection> |
||||
<sender>buttonBox</sender> |
||||
<signal>rejected()</signal> |
||||
<receiver>MapSettingsDialog</receiver> |
||||
<slot>reject()</slot> |
||||
<hints> |
||||
<hint type="sourcelabel"> |
||||
<x>316</x> |
||||
<y>260</y> |
||||
</hint> |
||||
<hint type="destinationlabel"> |
||||
<x>286</x> |
||||
<y>274</y> |
||||
</hint> |
||||
</hints> |
||||
</connection> |
||||
</connections> |
||||
</ui> |
||||
Loading…
Reference in new issue