mirror of
https://github.com/f4exb/sdrangel.git
synced 2026-06-01 13:47:01 -04:00
Multi device support: use device API for channel load and save
This commit is contained in:
@@ -85,67 +85,67 @@ void PluginManager::registerSampleSource(const QString& sourceName, PluginInterf
|
||||
m_sampleSourceRegistrations.append(SampleSourceRegistration(sourceName, plugin));
|
||||
}
|
||||
|
||||
void PluginManager::loadChannelSettings(const Preset* preset, DeviceAPI *deviceAPI)
|
||||
{
|
||||
fprintf(stderr, "PluginManager::loadSettings: Loading preset [%s | %s]\n", qPrintable(preset->getGroup()), qPrintable(preset->getDescription()));
|
||||
|
||||
// copy currently open channels and clear list
|
||||
ChannelInstanceRegistrations openChannels = m_channelInstanceRegistrations;
|
||||
m_channelInstanceRegistrations.clear();
|
||||
|
||||
for(int i = 0; i < preset->getChannelCount(); i++)
|
||||
{
|
||||
const Preset::ChannelConfig& channelConfig = preset->getChannelConfig(i);
|
||||
ChannelInstanceRegistration reg;
|
||||
|
||||
// if we have one instance available already, use it
|
||||
|
||||
for(int i = 0; i < openChannels.count(); i++)
|
||||
{
|
||||
qDebug("PluginManager::loadSettings: channels compare [%s] vs [%s]", qPrintable(openChannels[i].m_channelName), qPrintable(channelConfig.m_channel));
|
||||
|
||||
if(openChannels[i].m_channelName == channelConfig.m_channel)
|
||||
{
|
||||
qDebug("PluginManager::loadSettings: channel [%s] found", qPrintable(openChannels[i].m_channelName));
|
||||
reg = openChannels.takeAt(i);
|
||||
m_channelInstanceRegistrations.append(reg);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// if we haven't one already, create one
|
||||
|
||||
if(reg.m_gui == NULL)
|
||||
{
|
||||
for(int i = 0; i < m_channelRegistrations.count(); i++)
|
||||
{
|
||||
if(m_channelRegistrations[i].m_channelName == channelConfig.m_channel)
|
||||
{
|
||||
qDebug("PluginManager::loadSettings: creating new channel [%s]", qPrintable(channelConfig.m_channel));
|
||||
reg = ChannelInstanceRegistration(channelConfig.m_channel, m_channelRegistrations[i].m_plugin->createChannel(channelConfig.m_channel, deviceAPI));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(reg.m_gui != NULL)
|
||||
{
|
||||
qDebug("PluginManager::loadSettings: deserializing channel [%s]", qPrintable(channelConfig.m_channel));
|
||||
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("PluginManager::loadSettings: destroying spare channel [%s]", qPrintable(openChannels[i].m_channelName));
|
||||
openChannels[i].m_gui->destroy();
|
||||
}
|
||||
|
||||
renameChannelInstances();
|
||||
|
||||
// loadSourceSettings(preset); // FIXME
|
||||
}
|
||||
//void PluginManager::loadChannelSettings(const Preset* preset, DeviceAPI *deviceAPI)
|
||||
//{
|
||||
// fprintf(stderr, "PluginManager::loadSettings: Loading preset [%s | %s]\n", qPrintable(preset->getGroup()), qPrintable(preset->getDescription()));
|
||||
//
|
||||
// // copy currently open channels and clear list
|
||||
// ChannelInstanceRegistrations openChannels = m_channelInstanceRegistrations;
|
||||
// m_channelInstanceRegistrations.clear();
|
||||
//
|
||||
// for(int i = 0; i < preset->getChannelCount(); i++)
|
||||
// {
|
||||
// const Preset::ChannelConfig& channelConfig = preset->getChannelConfig(i);
|
||||
// ChannelInstanceRegistration reg;
|
||||
//
|
||||
// // if we have one instance available already, use it
|
||||
//
|
||||
// for(int i = 0; i < openChannels.count(); i++)
|
||||
// {
|
||||
// qDebug("PluginManager::loadSettings: channels compare [%s] vs [%s]", qPrintable(openChannels[i].m_channelName), qPrintable(channelConfig.m_channel));
|
||||
//
|
||||
// if(openChannels[i].m_channelName == channelConfig.m_channel)
|
||||
// {
|
||||
// qDebug("PluginManager::loadSettings: channel [%s] found", qPrintable(openChannels[i].m_channelName));
|
||||
// reg = openChannels.takeAt(i);
|
||||
// m_channelInstanceRegistrations.append(reg);
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// // if we haven't one already, create one
|
||||
//
|
||||
// if(reg.m_gui == NULL)
|
||||
// {
|
||||
// for(int i = 0; i < m_channelRegistrations.count(); i++)
|
||||
// {
|
||||
// if(m_channelRegistrations[i].m_channelName == channelConfig.m_channel)
|
||||
// {
|
||||
// qDebug("PluginManager::loadSettings: creating new channel [%s]", qPrintable(channelConfig.m_channel));
|
||||
// reg = ChannelInstanceRegistration(channelConfig.m_channel, m_channelRegistrations[i].m_plugin->createChannel(channelConfig.m_channel, deviceAPI));
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// if(reg.m_gui != NULL)
|
||||
// {
|
||||
// qDebug("PluginManager::loadSettings: deserializing channel [%s]", qPrintable(channelConfig.m_channel));
|
||||
// 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("PluginManager::loadSettings: destroying spare channel [%s]", qPrintable(openChannels[i].m_channelName));
|
||||
// openChannels[i].m_gui->destroy();
|
||||
// }
|
||||
//
|
||||
// renameChannelInstances();
|
||||
//
|
||||
//// loadSourceSettings(preset); // FIXME
|
||||
//}
|
||||
|
||||
//void PluginManager::loadSourceSettings(const Preset* preset)
|
||||
//{
|
||||
@@ -179,18 +179,18 @@ bool PluginManager::ChannelInstanceRegistration::operator<(const ChannelInstance
|
||||
}
|
||||
}
|
||||
|
||||
void PluginManager::saveSettings(Preset* preset)
|
||||
{
|
||||
qDebug("PluginManager::saveSettings");
|
||||
// saveSourceSettings(preset); // FIXME
|
||||
|
||||
qSort(m_channelInstanceRegistrations.begin(), m_channelInstanceRegistrations.end()); // sort by increasing delta frequency and type
|
||||
|
||||
for(int i = 0; i < m_channelInstanceRegistrations.count(); i++)
|
||||
{
|
||||
preset->addChannel(m_channelInstanceRegistrations[i].m_channelName, m_channelInstanceRegistrations[i].m_gui->serialize());
|
||||
}
|
||||
}
|
||||
//void PluginManager::saveSettings(Preset* preset)
|
||||
//{
|
||||
// qDebug("PluginManager::saveSettings");
|
||||
//// saveSourceSettings(preset); // FIXME
|
||||
//
|
||||
// qSort(m_channelInstanceRegistrations.begin(), m_channelInstanceRegistrations.end()); // sort by increasing delta frequency and type
|
||||
//
|
||||
// for(int i = 0; i < m_channelInstanceRegistrations.count(); i++)
|
||||
// {
|
||||
// preset->addChannel(m_channelInstanceRegistrations[i].m_channelName, m_channelInstanceRegistrations[i].m_gui->serialize());
|
||||
// }
|
||||
//}
|
||||
|
||||
//void PluginManager::saveSourceSettings(Preset* preset)
|
||||
//{
|
||||
|
||||
Reference in New Issue
Block a user