1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-22 16:08:39 -05:00

Handle the remove last device in main window with the new sampling device control

This commit is contained in:
f4exb 2017-11-02 14:29:49 +01:00
parent 10e92686fc
commit e77074ad60
5 changed files with 42 additions and 0 deletions

View File

@ -129,6 +129,26 @@ void DeviceEnumerator::changeTxSelection(int tabIndex, int deviceIndex)
}
}
void DeviceEnumerator::removeRxSelection(int tabIndex)
{
for (DevicesEnumeration::iterator it = m_rxEnumeration.begin(); it != m_rxEnumeration.end(); ++it)
{
if (it->m_samplingDevice.claimed == tabIndex) {
it->m_samplingDevice.claimed = -1;
}
}
}
void DeviceEnumerator::removeTxSelection(int tabIndex)
{
for (DevicesEnumeration::iterator it = m_txEnumeration.begin(); it != m_txEnumeration.end(); ++it)
{
if (it->m_samplingDevice.claimed == tabIndex) {
it->m_samplingDevice.claimed = -1;
}
}
}
int DeviceEnumerator::getFileSourceDeviceIndex() const
{
for (DevicesEnumeration::const_iterator it = m_rxEnumeration.begin(); it != m_rxEnumeration.end(); ++it)

View File

@ -37,6 +37,8 @@ public:
void listTxDeviceNames(QList<QString>& list, std::vector<int>& indexes) const;
void changeRxSelection(int tabIndex, int deviceIndex);
void changeTxSelection(int tabIndex, int deviceIndex);
void removeRxSelection(int tabIndex);
void removeTxSelection(int tabIndex);
PluginInterface::SamplingDevice getRxSamplingDevice(int deviceIndex) const { return m_rxEnumeration[deviceIndex].m_samplingDevice; }
PluginInterface::SamplingDevice getTxSamplingDevice(int deviceIndex) const { return m_txEnumeration[deviceIndex].m_samplingDevice; }
PluginInterface *getRxPluginInterface(int deviceIndex) { return m_rxEnumeration[deviceIndex].m_pluginInterface; }

View File

@ -30,6 +30,7 @@ SamplingDeviceControl::SamplingDeviceControl(int tabIndex, bool rxElseTx, QWidge
m_selectedDeviceIndex(-1)
{
ui->setupUi(this);
ui->deviceSelectedText->setText("None");
}
SamplingDeviceControl::~SamplingDeviceControl()
@ -75,6 +76,22 @@ void SamplingDeviceControl::setSelectedDeviceIndex(int index)
m_selectedDeviceIndex = index;
}
void SamplingDeviceControl::removeSelectedDeviceIndex()
{
if (m_rxElseTx)
{
DeviceEnumerator::instance()->removeRxSelection(m_deviceTabIndex);
ui->deviceSelectedText->setText("None");
}
else
{
DeviceEnumerator::instance()->removeTxSelection(m_deviceTabIndex);
ui->deviceSelectedText->setText("None");
}
m_selectedDeviceIndex = -1;
}
QComboBox *SamplingDeviceControl::getChannelSelector()
{
return ui->channelSelect;

View File

@ -42,6 +42,7 @@ public:
int getSelectedDeviceIndex() const { return m_selectedDeviceIndex; }
void setSelectedDeviceIndex(int index);
void removeSelectedDeviceIndex();
void setPluginManager(PluginManager *pluginManager) { m_pluginManager = pluginManager; }
QComboBox *getChannelSelector();

View File

@ -360,6 +360,7 @@ void MainWindow::removeLastDevice()
m_deviceUIs.back()->m_deviceSourceAPI->getPluginInterface()->deleteSampleSourcePluginInstanceInput(
m_deviceUIs.back()->m_deviceSourceAPI->getSampleSource());
m_deviceUIs.back()->m_deviceSourceAPI->clearBuddiesLists(); // clear old API buddies lists
m_deviceUIs.back()->m_samplingDeviceControl->removeSelectedDeviceIndex(); // This releases the device in the device list
ui->tabChannels->removeTab(ui->tabChannels->count() - 1);
@ -398,6 +399,7 @@ void MainWindow::removeLastDevice()
m_deviceUIs.back()->m_deviceSinkAPI->getPluginInterface()->deleteSampleSinkPluginInstanceOutput(
m_deviceUIs.back()->m_deviceSinkAPI->getSampleSink());
m_deviceUIs.back()->m_deviceSinkAPI->clearBuddiesLists(); // clear old API buddies lists
m_deviceUIs.back()->m_samplingDeviceControl->removeSelectedDeviceIndex(); // This releases the device in the device list
ui->tabChannels->removeTab(ui->tabChannels->count() - 1);