mirror of
https://github.com/f4exb/sdrangel.git
synced 2025-07-03 09:25:23 -04:00
On DeviceUISet load channels delete all channels before adding new channels. This ensures channels are placed in the same order (sorted) as in the preset
This commit is contained in:
parent
6e5e912c74
commit
904bcf2dc1
@ -166,7 +166,7 @@ void DeviceUISet::loadRxChannelSettings(const Preset *preset, PluginAPI *pluginA
|
|||||||
{
|
{
|
||||||
if (preset->isSourcePreset())
|
if (preset->isSourcePreset())
|
||||||
{
|
{
|
||||||
qDebug("DeviceUISet::loadChannelSettings: Loading preset [%s | %s]", qPrintable(preset->getGroup()), qPrintable(preset->getDescription()));
|
qDebug("DeviceUISet::loadRxChannelSettings: Loading preset [%s | %s]", qPrintable(preset->getGroup()), qPrintable(preset->getDescription()));
|
||||||
|
|
||||||
// Available channel plugins
|
// Available channel plugins
|
||||||
PluginAPI::ChannelRegistrations *channelRegistrations = pluginAPI->getRxChannelRegistrations();
|
PluginAPI::ChannelRegistrations *channelRegistrations = pluginAPI->getRxChannelRegistrations();
|
||||||
@ -175,66 +175,47 @@ void DeviceUISet::loadRxChannelSettings(const Preset *preset, PluginAPI *pluginA
|
|||||||
ChannelInstanceRegistrations openChannels = m_rxChannelInstanceRegistrations;
|
ChannelInstanceRegistrations openChannels = m_rxChannelInstanceRegistrations;
|
||||||
m_rxChannelInstanceRegistrations.clear();
|
m_rxChannelInstanceRegistrations.clear();
|
||||||
|
|
||||||
qDebug("DeviceUISet::loadChannelSettings: %d channel(s) in preset", preset->getChannelCount());
|
for(int i = 0; i < openChannels.count(); i++)
|
||||||
|
{
|
||||||
|
qDebug("DeviceUISet::loadRxChannelSettings: destroying old channel [%s]", qPrintable(openChannels[i].m_channelName));
|
||||||
|
openChannels[i].m_gui->destroy(); // FIXME: stop channel before
|
||||||
|
}
|
||||||
|
|
||||||
for(int i = 0; i < preset->getChannelCount(); i++)
|
qDebug("DeviceUISet::loadRxChannelSettings: %d channel(s) in preset", preset->getChannelCount());
|
||||||
|
|
||||||
|
for (int i = 0; i < preset->getChannelCount(); i++)
|
||||||
{
|
{
|
||||||
const Preset::ChannelConfig& channelConfig = preset->getChannelConfig(i);
|
const Preset::ChannelConfig& channelConfig = preset->getChannelConfig(i);
|
||||||
ChannelInstanceRegistration reg;
|
ChannelInstanceRegistration reg;
|
||||||
|
|
||||||
// if we have one instance available already, use it
|
// create channel instance
|
||||||
|
|
||||||
for(int i = 0; i < openChannels.count(); i++)
|
for(int i = 0; i < channelRegistrations->count(); i++)
|
||||||
{
|
{
|
||||||
qDebug("DeviceUISet::loadChannelSettings: channels compare [%s] vs [%s]", qPrintable(openChannels[i].m_channelName), qPrintable(channelConfig.m_channelIdURI));
|
if((*channelRegistrations)[i].m_channelIdURI == channelConfig.m_channelIdURI)
|
||||||
|
|
||||||
if(openChannels[i].m_channelName == channelConfig.m_channelIdURI)
|
|
||||||
{
|
{
|
||||||
qDebug("DeviceSourceAPI::loadChannelSettings: channel [%s] found", qPrintable(openChannels[i].m_channelName));
|
qDebug("DeviceUISet::loadRxChannelSettings: creating new channel [%s]", qPrintable(channelConfig.m_channelIdURI));
|
||||||
reg = openChannels.takeAt(i);
|
BasebandSampleSink *rxChannel =
|
||||||
m_rxChannelInstanceRegistrations.append(reg);
|
(*channelRegistrations)[i].m_plugin->createRxChannelBS(m_deviceSourceAPI);
|
||||||
|
PluginInstanceGUI *rxChannelGUI =
|
||||||
|
(*channelRegistrations)[i].m_plugin->createRxChannelGUI(this, rxChannel);
|
||||||
|
reg = ChannelInstanceRegistration(channelConfig.m_channelIdURI, rxChannelGUI);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// if we haven't one already, create one
|
if (reg.m_gui != 0)
|
||||||
|
|
||||||
if(reg.m_gui == NULL)
|
|
||||||
{
|
{
|
||||||
for(int i = 0; i < channelRegistrations->count(); i++)
|
qDebug("DeviceUISet::loadRxChannelSettings: deserializing channel [%s]", qPrintable(channelConfig.m_channelIdURI));
|
||||||
{
|
|
||||||
if((*channelRegistrations)[i].m_channelIdURI == channelConfig.m_channelIdURI)
|
|
||||||
{
|
|
||||||
qDebug("DeviceUISet::loadChannelSettings: creating new channel [%s]", qPrintable(channelConfig.m_channelIdURI));
|
|
||||||
BasebandSampleSink *rxChannel =
|
|
||||||
(*channelRegistrations)[i].m_plugin->createRxChannelBS(m_deviceSourceAPI);
|
|
||||||
PluginInstanceGUI *rxChannelGUI =
|
|
||||||
(*channelRegistrations)[i].m_plugin->createRxChannelGUI(this, rxChannel);
|
|
||||||
reg = ChannelInstanceRegistration(channelConfig.m_channelIdURI, rxChannelGUI);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(reg.m_gui != NULL)
|
|
||||||
{
|
|
||||||
qDebug("DeviceUISet::loadChannelSettings: deserializing channel [%s]", qPrintable(channelConfig.m_channelIdURI));
|
|
||||||
reg.m_gui->deserialize(channelConfig.m_config);
|
reg.m_gui->deserialize(channelConfig.m_config);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// everything, that is still "available" is not needed anymore
|
|
||||||
for(int i = 0; i < openChannels.count(); i++)
|
|
||||||
{
|
|
||||||
qDebug("DeviceUISet::loadChannelSettings: destroying spare channel [%s]", qPrintable(openChannels[i].m_channelName));
|
|
||||||
openChannels[i].m_gui->destroy();
|
|
||||||
}
|
|
||||||
|
|
||||||
renameRxChannelInstances();
|
renameRxChannelInstances();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
qDebug("DeviceUISet::loadChannelSettings: Loading preset [%s | %s] not a source preset", qPrintable(preset->getGroup()), qPrintable(preset->getDescription()));
|
qDebug("DeviceUISet::loadRxChannelSettings: Loading preset [%s | %s] not a source preset", qPrintable(preset->getGroup()), qPrintable(preset->getDescription()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -246,13 +227,13 @@ void DeviceUISet::saveRxChannelSettings(Preset *preset)
|
|||||||
|
|
||||||
for(int i = 0; i < m_rxChannelInstanceRegistrations.count(); i++)
|
for(int i = 0; i < m_rxChannelInstanceRegistrations.count(); i++)
|
||||||
{
|
{
|
||||||
qDebug("DeviceUISet::saveChannelSettings: channel [%s] saved", qPrintable(m_rxChannelInstanceRegistrations[i].m_channelName));
|
qDebug("DeviceUISet::saveRxChannelSettings: channel [%s] saved", qPrintable(m_rxChannelInstanceRegistrations[i].m_channelName));
|
||||||
preset->addChannel(m_rxChannelInstanceRegistrations[i].m_channelName, m_rxChannelInstanceRegistrations[i].m_gui->serialize());
|
preset->addChannel(m_rxChannelInstanceRegistrations[i].m_channelName, m_rxChannelInstanceRegistrations[i].m_gui->serialize());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
qDebug("DeviceUISet::saveChannelSettings: not a source preset");
|
qDebug("DeviceUISet::saveRxChannelSettings: not a source preset");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -260,11 +241,11 @@ void DeviceUISet::loadTxChannelSettings(const Preset *preset, PluginAPI *pluginA
|
|||||||
{
|
{
|
||||||
if (preset->isSourcePreset())
|
if (preset->isSourcePreset())
|
||||||
{
|
{
|
||||||
qDebug("DeviceUISet::loadChannelSettings: Loading preset [%s | %s] not a sink preset", qPrintable(preset->getGroup()), qPrintable(preset->getDescription()));
|
qDebug("DeviceUISet::loadTxChannelSettings: Loading preset [%s | %s] not a sink preset", qPrintable(preset->getGroup()), qPrintable(preset->getDescription()));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
qDebug("DeviceUISet::loadChannelSettings: Loading preset [%s | %s]", qPrintable(preset->getGroup()), qPrintable(preset->getDescription()));
|
qDebug("DeviceUISet::loadTxChannelSettings: Loading preset [%s | %s]", qPrintable(preset->getGroup()), qPrintable(preset->getDescription()));
|
||||||
|
|
||||||
// Available channel plugins
|
// Available channel plugins
|
||||||
PluginAPI::ChannelRegistrations *channelRegistrations = pluginAPI->getTxChannelRegistrations();
|
PluginAPI::ChannelRegistrations *channelRegistrations = pluginAPI->getTxChannelRegistrations();
|
||||||
@ -273,61 +254,42 @@ void DeviceUISet::loadTxChannelSettings(const Preset *preset, PluginAPI *pluginA
|
|||||||
ChannelInstanceRegistrations openChannels = m_txChannelInstanceRegistrations;
|
ChannelInstanceRegistrations openChannels = m_txChannelInstanceRegistrations;
|
||||||
m_txChannelInstanceRegistrations.clear();
|
m_txChannelInstanceRegistrations.clear();
|
||||||
|
|
||||||
qDebug("DeviceUISet::loadChannelSettings: %d channel(s) in preset", preset->getChannelCount());
|
for(int i = 0; i < openChannels.count(); i++)
|
||||||
|
{
|
||||||
|
qDebug("DeviceUISet::loadTxChannelSettings: destroying old channel [%s]", qPrintable(openChannels[i].m_channelName));
|
||||||
|
openChannels[i].m_gui->destroy();
|
||||||
|
}
|
||||||
|
|
||||||
|
qDebug("DeviceUISet::loadTxChannelSettings: %d channel(s) in preset", preset->getChannelCount());
|
||||||
|
|
||||||
for(int i = 0; i < preset->getChannelCount(); i++)
|
for(int i = 0; i < preset->getChannelCount(); i++)
|
||||||
{
|
{
|
||||||
const Preset::ChannelConfig& channelConfig = preset->getChannelConfig(i);
|
const Preset::ChannelConfig& channelConfig = preset->getChannelConfig(i);
|
||||||
ChannelInstanceRegistration reg;
|
ChannelInstanceRegistration reg;
|
||||||
|
|
||||||
// if we have one instance available already, use it
|
// create channel instance
|
||||||
|
|
||||||
for(int i = 0; i < openChannels.count(); i++)
|
for(int i = 0; i < channelRegistrations->count(); i++)
|
||||||
{
|
{
|
||||||
qDebug("DeviceUISet::loadChannelSettings: channels compare [%s] vs [%s]", qPrintable(openChannels[i].m_channelName), qPrintable(channelConfig.m_channelIdURI));
|
if((*channelRegistrations)[i].m_channelIdURI == channelConfig.m_channelIdURI)
|
||||||
|
|
||||||
if(openChannels[i].m_channelName == channelConfig.m_channelIdURI)
|
|
||||||
{
|
{
|
||||||
qDebug("DeviceUISet::loadChannelSettings: channel [%s] found", qPrintable(openChannels[i].m_channelName));
|
qDebug("DeviceUISet::loadTxChannelSettings: creating new channel [%s]", qPrintable(channelConfig.m_channelIdURI));
|
||||||
reg = openChannels.takeAt(i);
|
BasebandSampleSource *txChannel =
|
||||||
m_txChannelInstanceRegistrations.append(reg);
|
(*channelRegistrations)[i].m_plugin->createTxChannelBS(m_deviceSinkAPI);
|
||||||
|
PluginInstanceGUI *txChannelGUI =
|
||||||
|
(*channelRegistrations)[i].m_plugin->createTxChannelGUI(this, txChannel);
|
||||||
|
reg = ChannelInstanceRegistration(channelConfig.m_channelIdURI, txChannelGUI);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// if we haven't one already, create one
|
|
||||||
|
|
||||||
if(reg.m_gui == 0)
|
|
||||||
{
|
|
||||||
for(int i = 0; i < channelRegistrations->count(); i++)
|
|
||||||
{
|
|
||||||
if((*channelRegistrations)[i].m_channelIdURI == channelConfig.m_channelIdURI)
|
|
||||||
{
|
|
||||||
qDebug("DeviceUISet::loadChannelSettings: creating new channel [%s]", qPrintable(channelConfig.m_channelIdURI));
|
|
||||||
BasebandSampleSource *txChannel =
|
|
||||||
(*channelRegistrations)[i].m_plugin->createTxChannelBS(m_deviceSinkAPI);
|
|
||||||
PluginInstanceGUI *txChannelGUI =
|
|
||||||
(*channelRegistrations)[i].m_plugin->createTxChannelGUI(this, txChannel);
|
|
||||||
reg = ChannelInstanceRegistration(channelConfig.m_channelIdURI, txChannelGUI);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(reg.m_gui != 0)
|
if(reg.m_gui != 0)
|
||||||
{
|
{
|
||||||
qDebug("DeviceUISet::loadChannelSettings: deserializing channel [%s]", qPrintable(channelConfig.m_channelIdURI));
|
qDebug("DeviceUISet::loadTxChannelSettings: deserializing channel [%s]", qPrintable(channelConfig.m_channelIdURI));
|
||||||
reg.m_gui->deserialize(channelConfig.m_config);
|
reg.m_gui->deserialize(channelConfig.m_config);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// everything, that is still "available" is not needed anymore
|
|
||||||
for(int i = 0; i < openChannels.count(); i++)
|
|
||||||
{
|
|
||||||
qDebug("DeviceUISet::loadChannelSettings: destroying spare channel [%s]", qPrintable(openChannels[i].m_channelName));
|
|
||||||
openChannels[i].m_gui->destroy();
|
|
||||||
}
|
|
||||||
|
|
||||||
renameTxChannelInstances();
|
renameTxChannelInstances();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -336,7 +298,7 @@ void DeviceUISet::saveTxChannelSettings(Preset *preset)
|
|||||||
{
|
{
|
||||||
if (preset->isSourcePreset())
|
if (preset->isSourcePreset())
|
||||||
{
|
{
|
||||||
qDebug("DeviceUISet::saveChannelSettings: not a sink preset");
|
qDebug("DeviceUISet::saveTxChannelSettings: not a sink preset");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -344,7 +306,7 @@ void DeviceUISet::saveTxChannelSettings(Preset *preset)
|
|||||||
|
|
||||||
for(int i = 0; i < m_txChannelInstanceRegistrations.count(); i++)
|
for(int i = 0; i < m_txChannelInstanceRegistrations.count(); i++)
|
||||||
{
|
{
|
||||||
qDebug("DeviceUISet::saveChannelSettings: channel [%s] saved", qPrintable(m_txChannelInstanceRegistrations[i].m_channelName));
|
qDebug("DeviceUISet::saveTxChannelSettings: channel [%s] saved", qPrintable(m_txChannelInstanceRegistrations[i].m_channelName));
|
||||||
preset->addChannel(m_txChannelInstanceRegistrations[i].m_channelName, m_txChannelInstanceRegistrations[i].m_gui->serialize());
|
preset->addChannel(m_txChannelInstanceRegistrations[i].m_channelName, m_txChannelInstanceRegistrations[i].m_gui->serialize());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user