1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-12-17 23:28:50 -05:00

Multi device support: migrated channel registration objects to plugin API

This commit is contained in:
f4exb 2016-05-16 18:34:23 +02:00
parent a9cda881d6
commit 6840a20ab9
6 changed files with 33 additions and 16 deletions

View File

@ -199,6 +199,18 @@ void DeviceAPI::saveSourceSettings(Preset* preset)
}
}
void DeviceAPI::saveChannelSettings(Preset *preset)
{
qDebug("DeviceAPI::saveChannelSettings");
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());
}
}
// sort by increasing delta frequency and type (i.e. name)
bool DeviceAPI::ChannelInstanceRegistration::operator<(const ChannelInstanceRegistration& other) const
{

View File

@ -73,6 +73,7 @@ public:
void loadSourceSettings(const Preset* preset);
void saveSourceSettings(Preset* preset);
void saveChannelSettings(Preset* preset);
protected:
struct ChannelInstanceRegistration

View File

@ -316,7 +316,7 @@ void MainWindow::loadPresetSettings(const Preset* preset)
{
DeviceUISet *deviceUI = m_deviceUIs[currentSourceTabIndex];
deviceUI->m_spectrumGUI->deserialize(preset->getSpectrumConfig());
deviceUI->m_pluginManager->loadSettings(preset, deviceUI->m_deviceAPI);
deviceUI->m_pluginManager->loadChannelSettings(preset, deviceUI->m_deviceAPI);
deviceUI->m_deviceAPI->loadSourceSettings(preset);
}

View File

@ -2,6 +2,8 @@
#define INCLUDE_PLUGINAPI_H
#include <QObject>
#include <QList>
#include "util/export.h"
class QString;
@ -16,6 +18,18 @@ class SDRANGEL_API PluginAPI : public QObject {
Q_OBJECT
public:
struct ChannelRegistration
{
QString m_channelName;
PluginInterface* m_plugin;
ChannelRegistration(const QString& channelName, PluginInterface* plugin) :
m_channelName(channelName),
m_plugin(plugin)
{ }
};
typedef QList<ChannelRegistration> ChannelRegistrations;
// MainWindow access
MessageQueue* getMainWindowMessageQueue();

View File

@ -56,7 +56,7 @@ void PluginManager::loadPlugins()
void PluginManager::registerChannel(const QString& channelName, PluginInterface* plugin)
{
m_channelRegistrations.append(ChannelRegistration(channelName, plugin));
m_channelRegistrations.append(PluginAPI::ChannelRegistration(channelName, plugin));
}
void PluginManager::registerChannelInstance(const QString& channelName, PluginGUI* pluginGUI)
@ -85,7 +85,7 @@ void PluginManager::registerSampleSource(const QString& sourceName, PluginInterf
m_sampleSourceRegistrations.append(SampleSourceRegistration(sourceName, plugin));
}
void PluginManager::loadSettings(const Preset* preset, DeviceAPI *deviceAPI)
void PluginManager::loadChannelSettings(const Preset* preset, DeviceAPI *deviceAPI)
{
fprintf(stderr, "PluginManager::loadSettings: Loading preset [%s | %s]\n", qPrintable(preset->getGroup()), qPrintable(preset->getDescription()));
@ -507,7 +507,7 @@ void PluginManager::renameChannelInstances()
void PluginManager::populateChannelComboBox(QComboBox *channels)
{
for(ChannelRegistrations::iterator it = m_channelRegistrations.begin(); it != m_channelRegistrations.end(); ++it)
for(PluginAPI::ChannelRegistrations::iterator it = m_channelRegistrations.begin(); it != m_channelRegistrations.end(); ++it)
{
const PluginDescriptor& pluginDescipror = it->m_plugin->getPluginDescriptor();
channels->addItem(pluginDescipror.displayedName);

View File

@ -47,7 +47,7 @@ public:
void removeChannelInstance(PluginGUI* pluginGUI);
void registerSampleSource(const QString& sourceName, PluginInterface* plugin);
void loadSettings(const Preset* preset, DeviceAPI *deviceAPI);
void loadChannelSettings(const Preset* preset, DeviceAPI *deviceAPI);
// void loadSourceSettings(const Preset* preset);
void saveSettings(Preset* preset);
// void saveSourceSettings(Preset* preset);
@ -67,16 +67,6 @@ public:
void createChannelInstance(int channelPluginIndex, DeviceAPI *deviceAPI);
private:
struct ChannelRegistration {
QString m_channelName;
PluginInterface* m_plugin;
ChannelRegistration(const QString& channelName, PluginInterface* plugin) :
m_channelName(channelName),
m_plugin(plugin)
{ }
};
typedef QList<ChannelRegistration> ChannelRegistrations;
struct ChannelInstanceRegistration {
QString m_channelName;
PluginGUI* m_gui;
@ -129,7 +119,7 @@ private:
DSPDeviceEngine* m_dspDeviceEngine;
Plugins m_plugins;
ChannelRegistrations m_channelRegistrations; //!< Channel plugins register here
PluginAPI::ChannelRegistrations m_channelRegistrations; //!< Channel plugins register here
ChannelInstanceRegistrations m_channelInstanceRegistrations; // TODO: remove
SampleSourceRegistrations m_sampleSourceRegistrations; //!< Input source plugins (one per device kind) register here
SampleSourceDevices m_sampleSourceDevices; //!< Instances of input sources present in the system