10 changed files with 357 additions and 18 deletions
|
After Width: | Height: | Size: 19 KiB |
|
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 16 KiB |
@ -0,0 +1,147 @@
@@ -0,0 +1,147 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (C) 2024 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 <QTableWidgetItem> |
||||
#include <QDebug> |
||||
|
||||
#include "util/vlftransmitters.h" |
||||
#include "channel/channelwebapiutils.h" |
||||
#include "device/deviceapi.h" |
||||
#include "device/deviceset.h" |
||||
#include "dsp/dspdevicesourceengine.h" |
||||
#include "maincore.h" |
||||
|
||||
#include "sidaddchannelsdialog.h" |
||||
|
||||
SIDAddChannelsDialog::SIDAddChannelsDialog(SIDSettings *settings, QWidget* parent) : |
||||
QDialog(parent), |
||||
ui(new Ui::SIDAddChannelsDialog), |
||||
m_settings(settings) |
||||
{ |
||||
ui->setupUi(this); |
||||
|
||||
MainCore *mainCore = MainCore::instance(); |
||||
std::vector<DeviceSet*>& deviceSets = mainCore->getDeviceSets(); |
||||
|
||||
ui->channels->setColumnCount(deviceSets.size() + 2); |
||||
|
||||
// Create column header
|
||||
ui->channels->setHorizontalHeaderItem(COL_TX_NAME, new QTableWidgetItem("Callsign")); |
||||
ui->channels->setHorizontalHeaderItem(COL_TX_FREQUENCY, new QTableWidgetItem("Frequency (Hz)")); |
||||
for (int i = 0; i < deviceSets.size(); i++) |
||||
{ |
||||
if (deviceSets[i]->m_deviceSourceEngine || deviceSets[i]->m_deviceMIMOEngine) |
||||
{ |
||||
QTableWidgetItem *item = new QTableWidgetItem(mainCore->getDeviceSetId(deviceSets[i])); |
||||
|
||||
ui->channels->setHorizontalHeaderItem(COL_DEVICE + i, item); |
||||
} |
||||
} |
||||
|
||||
// Add row for each transmitter, with checkbox for each device
|
||||
for (int j = 0; j < VLFTransmitters::m_transmitters.size(); j++) |
||||
{ |
||||
int row = ui->channels->rowCount(); |
||||
ui->channels->setRowCount(row+1); |
||||
|
||||
ui->channels->setItem(row, COL_TX_NAME, new QTableWidgetItem(VLFTransmitters::m_transmitters[j].m_callsign)); |
||||
ui->channels->setItem(row, COL_TX_FREQUENCY, new QTableWidgetItem(QString::number(VLFTransmitters::m_transmitters[j].m_frequency))); |
||||
|
||||
for (int i = 0; i < deviceSets.size(); i++) |
||||
{ |
||||
if (deviceSets[i]->m_deviceSourceEngine || deviceSets[i]->m_deviceMIMOEngine) |
||||
{ |
||||
QTableWidgetItem *enableItem = new QTableWidgetItem(); |
||||
enableItem->setFlags(Qt::ItemIsSelectable | Qt::ItemIsUserCheckable | Qt::ItemIsEnabled); |
||||
enableItem->setCheckState(Qt::Unchecked); |
||||
ui->channels->setItem(row, COL_DEVICE + i, enableItem); |
||||
} |
||||
} |
||||
} |
||||
|
||||
ui->channels->resizeColumnsToContents(); |
||||
} |
||||
|
||||
SIDAddChannelsDialog::~SIDAddChannelsDialog() |
||||
{ |
||||
delete ui; |
||||
} |
||||
|
||||
void SIDAddChannelsDialog::accept() |
||||
{ |
||||
MainCore *mainCore = MainCore::instance(); |
||||
connect(mainCore, &MainCore::channelAdded, this, &SIDAddChannelsDialog::channelAdded); |
||||
|
||||
m_count = m_settings->m_channelSettings.size(); |
||||
m_row = 0; |
||||
m_col = COL_DEVICE; |
||||
addNextChannel(); |
||||
} |
||||
|
||||
void SIDAddChannelsDialog::addNextChannel() |
||||
{ |
||||
if (m_row < ui->channels->rowCount()) |
||||
{ |
||||
QString id = ui->channels->horizontalHeaderItem(m_col)->text(); |
||||
unsigned int deviceSetIndex; |
||||
|
||||
if (ui->channels->item(m_row, m_col)->checkState() == Qt::Checked) |
||||
{ |
||||
MainCore::getDeviceSetIndexFromId(id, deviceSetIndex); |
||||
ChannelWebAPIUtils::addChannel(deviceSetIndex, "sdrangel.channel.channelpower", 0); |
||||
} |
||||
else |
||||
{ |
||||
nextChannel(); // can recursively call this method
|
||||
} |
||||
} |
||||
else |
||||
{ |
||||
QDialog::accept(); |
||||
} |
||||
} |
||||
|
||||
void SIDAddChannelsDialog::nextChannel() |
||||
{ |
||||
m_col++; |
||||
if (m_col >= ui->channels->columnCount()) |
||||
{ |
||||
m_col = COL_DEVICE; |
||||
m_row++; |
||||
} |
||||
|
||||
addNextChannel(); |
||||
} |
||||
|
||||
void SIDAddChannelsDialog::channelAdded(int deviceSetIndex, ChannelAPI *channel) |
||||
{ |
||||
const VLFTransmitters::Transmitter *transmitter = VLFTransmitters::m_callsignHash.value(ui->channels->item(m_row, COL_TX_NAME)->text()); |
||||
|
||||
ChannelWebAPIUtils::patchChannelSetting(channel, "title", transmitter->m_callsign); |
||||
ChannelWebAPIUtils::patchChannelSetting(channel, "frequency", transmitter->m_frequency); |
||||
ChannelWebAPIUtils::patchChannelSetting(channel, "frequencyMode", 1); |
||||
ChannelWebAPIUtils::patchChannelSetting(channel, "rfBandwidth", 300); |
||||
ChannelWebAPIUtils::patchChannelSetting(channel, "averagePeriodUS", 10000000); |
||||
|
||||
// Update setings if they are created by SIDGUI before this slot is called
|
||||
if (m_count < m_settings->m_channelSettings.size()) { |
||||
m_settings->m_channelSettings[m_count].m_label = transmitter->m_callsign; |
||||
} |
||||
|
||||
m_count++; |
||||
nextChannel(); |
||||
} |
||||
@ -0,0 +1,58 @@
@@ -0,0 +1,58 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (C) 2024 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_SIDADDCHANNELSDIALOG_H |
||||
#define INCLUDE_SIDADDCHANNELSDIALOG_H |
||||
|
||||
#include "ui_sidaddchannelsdialog.h" |
||||
|
||||
#include "sidsettings.h" |
||||
|
||||
class SIDAddChannelsDialog : public QDialog { |
||||
Q_OBJECT |
||||
|
||||
public: |
||||
explicit SIDAddChannelsDialog(SIDSettings *settings, QWidget* parent = 0); |
||||
~SIDAddChannelsDialog(); |
||||
|
||||
private: |
||||
|
||||
private slots: |
||||
void accept(); |
||||
|
||||
void channelAdded(int deviceSetIndex, ChannelAPI *channel); |
||||
|
||||
private: |
||||
Ui::SIDAddChannelsDialog* ui; |
||||
|
||||
enum Column { |
||||
COL_TX_NAME, |
||||
COL_TX_FREQUENCY, |
||||
COL_DEVICE |
||||
}; |
||||
|
||||
SIDSettings *m_settings; |
||||
|
||||
int m_row; // Row and column in table, when adding channels
|
||||
int m_col; |
||||
int m_count; // How many channels we've added
|
||||
|
||||
void addNextChannel(); |
||||
void nextChannel(); |
||||
}; |
||||
|
||||
#endif // INCLUDE_SIDADDCHANNELSDIALOG_H
|
||||
@ -0,0 +1,92 @@
@@ -0,0 +1,92 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<ui version="4.0"> |
||||
<class>SIDAddChannelsDialog</class> |
||||
<widget class="QDialog" name="SIDAddChannelsDialog"> |
||||
<property name="geometry"> |
||||
<rect> |
||||
<x>0</x> |
||||
<y>0</y> |
||||
<width>441</width> |
||||
<height>463</height> |
||||
</rect> |
||||
</property> |
||||
<property name="font"> |
||||
<font> |
||||
<family>Liberation Sans</family> |
||||
<pointsize>9</pointsize> |
||||
</font> |
||||
</property> |
||||
<property name="windowTitle"> |
||||
<string>Add channels</string> |
||||
</property> |
||||
<layout class="QVBoxLayout" name="verticalLayout"> |
||||
<item> |
||||
<widget class="QGroupBox" name="groupBox"> |
||||
<property name="title"> |
||||
<string>Select devices and VLF transmitters to add channels for</string> |
||||
</property> |
||||
<layout class="QFormLayout" name="formLayout_2"> |
||||
<item row="0" column="0" colspan="2"> |
||||
<widget class="QTableWidget" name="channels"> |
||||
<property name="selectionMode"> |
||||
<enum>QAbstractItemView::NoSelection</enum> |
||||
</property> |
||||
<property name="selectionBehavior"> |
||||
<enum>QAbstractItemView::SelectRows</enum> |
||||
</property> |
||||
<attribute name="verticalHeaderStretchLastSection"> |
||||
<bool>true</bool> |
||||
</attribute> |
||||
</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>SIDAddChannelsDialog</receiver> |
||||
<slot>accept()</slot> |
||||
<hints> |
||||
<hint type="sourcelabel"> |
||||
<x>257</x> |
||||
<y>31</y> |
||||
</hint> |
||||
<hint type="destinationlabel"> |
||||
<x>157</x> |
||||
<y>274</y> |
||||
</hint> |
||||
</hints> |
||||
</connection> |
||||
<connection> |
||||
<sender>buttonBox</sender> |
||||
<signal>rejected()</signal> |
||||
<receiver>SIDAddChannelsDialog</receiver> |
||||
<slot>reject()</slot> |
||||
<hints> |
||||
<hint type="sourcelabel"> |
||||
<x>325</x> |
||||
<y>31</y> |
||||
</hint> |
||||
<hint type="destinationlabel"> |
||||
<x>286</x> |
||||
<y>274</y> |
||||
</hint> |
||||
</hints> |
||||
</connection> |
||||
</connections> |
||||
</ui> |
||||
Loading…
Reference in new issue