SDRAngel  4.11.5
Developer docs for <a href="https://github.com/f4exb/sdrangel">SDRangel<\a>, an Open Source Qt5 / OpenGL 3.0+ SDR and signal analyzer frontend to various hardware.
deviceuserargsdialog.cpp
Go to the documentation of this file.
1 // Copyright (C) 2019 Edouard Griffiths, F4EXB //
3 // //
4 // This program is free software; you can redistribute it and/or modify //
5 // it under the terms of the GNU General Public License as published by //
6 // the Free Software Foundation as version 3 of the License, or //
7 // (at your option) any later version. //
8 // //
9 // This program is distributed in the hope that it will be useful, //
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of //
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
12 // GNU General Public License V3 for more details. //
13 // //
14 // You should have received a copy of the GNU General Public License //
15 // along with this program. If not, see <http://www.gnu.org/licenses/>. //
17 
19 #include "ui_deviceuserargsdialog.h"
20 #include "deviceuserargsdialog.h"
21 
23  DeviceEnumerator* deviceEnumerator,
24  DeviceUserArgs& hardwareDeviceUserArgs,
25  QWidget* parent
26 ) :
27  QDialog(parent),
28  ui(new Ui::DeviceUserArgsDialog),
29  m_deviceEnumerator(deviceEnumerator),
30  m_hardwareDeviceUserArgs(hardwareDeviceUserArgs),
31  m_deviceUserArgsCopy(hardwareDeviceUserArgs)
32 {
33  ui->setupUi(this);
34 
35  for (int i = 0; i < m_deviceEnumerator->getNbRxSamplingDevices(); i++) {
37  }
38 
39  for (int i = 0; i < m_deviceEnumerator->getNbTxSamplingDevices(); i++) {
41  }
42 
43  for (int i = 0; i < m_deviceEnumerator->getNbMIMOSamplingDevices(); i++) {
45  }
46 
47  for (auto& hwItem : m_availableHWDevices)
48  {
49  QTreeWidgetItem *treeItem = new QTreeWidgetItem(ui->deviceTree);
50  treeItem->setText(0, hwItem.m_hardwareId);
51  treeItem->setText(1, tr("%1").arg(hwItem.m_sequence));
52  treeItem->setText(2, hwItem.m_description);
53  }
54 
55  ui->deviceTree->resizeColumnToContents(0);
56  ui->deviceTree->resizeColumnToContents(1);
57  ui->deviceTree->resizeColumnToContents(2);
58 
60 }
61 
63 {
64  delete ui;
65 }
66 
68 {
69  ui->argsTree->blockSignals(true);
70  ui->argsTree->clear();
71  ui->argStringEdit->clear();
72 
73  QList<DeviceUserArgs::Args>::const_iterator it = m_deviceUserArgsCopy.getArgsByDevice().begin();
74 
75  for (; it != m_deviceUserArgsCopy.getArgsByDevice().end(); ++it)
76  {
77  QTreeWidgetItem *treeItem = new QTreeWidgetItem(ui->argsTree);
78  treeItem->setText(0, it->m_id);
79  treeItem->setText(1, tr("%1").arg(it->m_sequence));
80  treeItem->setText(2, it->m_args);
81  }
82 
83  ui->argsTree->resizeColumnToContents(0);
84  ui->argsTree->resizeColumnToContents(1);
85  ui->argsTree->resizeColumnToContents(2);
86  ui->argsTree->blockSignals(false);
87 }
88 
90 {
92  hw.m_hardwareId = samplingDevice->hardwareId;
93  hw.m_sequence = samplingDevice->sequence;
94  hw.m_description = samplingDevice->displayedName;
95  bool found = false;
96 
97  for (auto& hwAvail : m_availableHWDevices)
98  {
99  if (hw == hwAvail)
100  {
101  found = true;
102  break;
103  }
104  }
105 
106  if (!found) {
107  m_availableHWDevices.push_back(hw);
108  }
109 }
110 
112 {
114  QDialog::accept();
115 }
116 
118 {
119  QDialog::reject();
120 }
121 
123 {
124  (void) checked;
125  QTreeWidgetItem *deviceItem = ui->deviceTree->currentItem();
126 
127  if (deviceItem)
128  {
129  bool ok;
130  int sequence = deviceItem->text(1).toInt(&ok);
131  m_deviceUserArgsCopy.addDeviceArgs(deviceItem->text(0), sequence, "");
133  }
134 }
135 
137 {
138  (void) checked;
139  QTreeWidgetItem *deviceItem = ui->argsTree->currentItem();
140 
141  if (deviceItem)
142  {
143  bool ok;
144  int sequence = deviceItem->text(1).toInt(&ok);
145  m_deviceUserArgsCopy.deleteDeviceArgs(deviceItem->text(0), sequence);
147  }
148 }
149 
150 void DeviceUserArgsDialog::on_argsTree_currentItemChanged(QTreeWidgetItem* currentItem, QTreeWidgetItem* previousItem)
151 {
152  (void) previousItem;
153  ui->argStringEdit->setText(currentItem->text(2));
154 }
155 
157 {
158  QTreeWidgetItem *deviceItem = ui->argsTree->currentItem();
159 
160  if (deviceItem)
161  {
162  bool ok;
163  int sequence = deviceItem->text(1).toInt(&ok);
164  m_deviceUserArgsCopy.updateDeviceArgs(deviceItem->text(0), sequence, ui->argStringEdit->text());
166  }
167 }
void deleteDeviceArgs(const QString &id, int sequence)
void pushHWDeviceReference(const PluginInterface::SamplingDevice *samplingDevice)
std::vector< HWDeviceReference > m_availableHWDevices
int sequence
The device sequence. >0 when more than one device of the same type is connected.
void on_argsTree_currentItemChanged(QTreeWidgetItem *currentItem, QTreeWidgetItem *previousItem)
QString displayedName
The human readable name.
QString hardwareId
The internal id that identifies the type of hardware (i.e. HackRF, BladeRF, ...)
void on_importDevice_clicked(bool checked)
DeviceEnumerator * m_deviceEnumerator
DeviceUserArgs & m_hardwareDeviceUserArgs
Fixed< IntType, IntBits > arg(const std::complex< Fixed< IntType, IntBits > > &val)
Definition: fixed.h:2401
const PluginInterface::SamplingDevice * getMIMOSamplingDevice(int deviceIndex) const
const QList< Args > & getArgsByDevice() const
void addDeviceArgs(const QString &id, int sequence, const QString &args)
Will not add if it exists for same reference.
int32_t i
Definition: decimators.h:244
Ui::DeviceUserArgsDialog * ui
int getNbRxSamplingDevices() const
const PluginInterface::SamplingDevice * getTxSamplingDevice(int deviceIndex) const
void updateDeviceArgs(const QString &id, int sequence, const QString &args)
Will not update if reference does not exist.
DeviceUserArgs m_deviceUserArgsCopy
void on_deleteArgs_clicked(bool checked)
const PluginInterface::SamplingDevice * getRxSamplingDevice(int deviceIndex) const
int getNbMIMOSamplingDevices() const
DeviceUserArgsDialog(DeviceEnumerator *deviceEnumerator, DeviceUserArgs &hardwareDeviceUserArgs, QWidget *parent=0)
int getNbTxSamplingDevices() const