1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-14 20:31:53 -05:00

Implement MainCore in MainWindow step2: feature sets

This commit is contained in:
f4exb 2020-10-11 00:22:42 +02:00
parent bb8e54451b
commit 96329326b4
8 changed files with 65 additions and 4 deletions

View File

@ -174,3 +174,21 @@ void FeatureSet::saveFeatureSetSettings(FeatureSetPreset *preset)
preset->addFeature(m_featureInstanceRegistrations[i].m_featureName, m_featureInstanceRegistrations[i].m_feature->serialize()); preset->addFeature(m_featureInstanceRegistrations[i].m_featureName, m_featureInstanceRegistrations[i].m_feature->serialize());
} }
} }
void FeatureSet::addFeatureInstance(const QString& featureURI, Feature *feature)
{
qDebug("FeatureSet::addFeatureInstance");
m_featureInstanceRegistrations.push_back(FeatureInstanceRegistration(featureURI, feature));
}
void FeatureSet::removeFeatureInstanceAt(int index)
{
if (index < m_featureInstanceRegistrations.size()) {
m_featureInstanceRegistrations.removeAt(index);
}
}
void FeatureSet::clearFeatures()
{
m_featureInstanceRegistrations.clear();
}

View File

@ -43,6 +43,10 @@ public:
Feature *getFeatureAt(int featureIndex); Feature *getFeatureAt(int featureIndex);
void loadFeatureSetSettings(const FeatureSetPreset* preset, PluginAPI *pluginAPI, WebAPIAdapterInterface *apiAdapter); void loadFeatureSetSettings(const FeatureSetPreset* preset, PluginAPI *pluginAPI, WebAPIAdapterInterface *apiAdapter);
void saveFeatureSetSettings(FeatureSetPreset* preset); void saveFeatureSetSettings(FeatureSetPreset* preset);
// slave mode
void addFeatureInstance(const QString& featureURI, Feature *feature);
void removeFeatureInstanceAt(int index);
void clearFeatures();
private: private:
struct FeatureInstanceRegistration struct FeatureInstanceRegistration

View File

@ -21,6 +21,7 @@
#include "loggerwithfile.h" #include "loggerwithfile.h"
#include "dsp/dsptypes.h" #include "dsp/dsptypes.h"
#include "feature/featureset.h"
#include "maincore.h" #include "maincore.h"
@ -102,3 +103,23 @@ void MainCore::setLoggingOptions()
m_logger->logToFile(QtInfoMsg, appInfoStr); m_logger->logToFile(QtInfoMsg, appInfoStr);
} }
} }
void MainCore::appendFeatureSet()
{
int newIndex = m_featureSets.size();
m_featureSets.push_back(new FeatureSet(newIndex));
}
void MainCore::removeFeatureSet(int index)
{
if (index < m_featureSets.size()) {
m_featureSets.erase(m_featureSets.begin() + index);
}
}
void MainCore::removeLastFeatureSet()
{
if (m_featureSets.size() != 0) {
m_featureSets.pop_back();
}
}

View File

@ -410,6 +410,10 @@ public:
std::vector<DeviceSet*>& getDeviceSets() { return m_deviceSets; } std::vector<DeviceSet*>& getDeviceSets() { return m_deviceSets; }
std::vector<FeatureSet*>& getFeatureeSets() { return m_featureSets; } std::vector<FeatureSet*>& getFeatureeSets() { return m_featureSets; }
void setLoggingOptions(); void setLoggingOptions();
// slave mode
void appendFeatureSet();
void removeFeatureSet(int index);
void removeLastFeatureSet();
friend class MainServer; friend class MainServer;
friend class MainWindow; friend class MainWindow;

View File

@ -19,15 +19,17 @@
#include "plugin/pluginapi.h" #include "plugin/pluginapi.h"
#include "settings/featuresetpreset.h" #include "settings/featuresetpreset.h"
#include "feature/featureutils.h" #include "feature/featureutils.h"
#include "feature/featureset.h"
#include "feature/feature.h" #include "feature/feature.h"
#include "feature/featuregui.h" #include "feature/featuregui.h"
#include "featureuiset.h" #include "featureuiset.h"
FeatureUISet::FeatureUISet(int tabIndex) FeatureUISet::FeatureUISet(int tabIndex, FeatureSet *featureSet)
{ {
m_featureWindow = new FeatureWindow; m_featureWindow = new FeatureWindow;
m_featureTabIndex = tabIndex; m_featureTabIndex = tabIndex;
m_featureSet = featureSet;
} }
FeatureUISet::~FeatureUISet() FeatureUISet::~FeatureUISet()
@ -44,6 +46,7 @@ void FeatureUISet::addRollupWidget(QWidget *widget)
void FeatureUISet::registerFeatureInstance(const QString& featureURI, FeatureGUI* featureGUI, Feature *feature) void FeatureUISet::registerFeatureInstance(const QString& featureURI, FeatureGUI* featureGUI, Feature *feature)
{ {
m_featureInstanceRegistrations.append(FeatureInstanceRegistration(featureURI, featureGUI, feature)); m_featureInstanceRegistrations.append(FeatureInstanceRegistration(featureURI, featureGUI, feature));
m_featureSet->addFeatureInstance(featureURI, feature);
QObject::connect( QObject::connect(
featureGUI, featureGUI,
&FeatureGUI::closing, &FeatureGUI::closing,
@ -71,6 +74,8 @@ void FeatureUISet::freeFeatures()
m_featureInstanceRegistrations[i].m_gui->destroy(); m_featureInstanceRegistrations[i].m_gui->destroy();
m_featureInstanceRegistrations[i].m_feature->destroy(); m_featureInstanceRegistrations[i].m_feature->destroy();
} }
m_featureSet->clearFeatures();
} }
void FeatureUISet::deleteFeature(int featureIndex) void FeatureUISet::deleteFeature(int featureIndex)
@ -82,6 +87,7 @@ void FeatureUISet::deleteFeature(int featureIndex)
featureIndex); featureIndex);
m_featureInstanceRegistrations[featureIndex].m_gui->destroy(); m_featureInstanceRegistrations[featureIndex].m_gui->destroy();
m_featureInstanceRegistrations[featureIndex].m_feature->destroy(); m_featureInstanceRegistrations[featureIndex].m_feature->destroy();
m_featureSet->removeFeatureInstanceAt(featureIndex);
} }
} }
@ -113,6 +119,7 @@ void FeatureUISet::loadFeatureSetSettings(const FeatureSetPreset *preset, Plugin
// copy currently open features and clear list // copy currently open features and clear list
FeatureInstanceRegistrations openFeatures = m_featureInstanceRegistrations; FeatureInstanceRegistrations openFeatures = m_featureInstanceRegistrations;
m_featureInstanceRegistrations.clear(); m_featureInstanceRegistrations.clear();
m_featureSet->clearFeatures();
for (int i = 0; i < openFeatures.count(); i++) for (int i = 0; i < openFeatures.count(); i++)
{ {
@ -172,6 +179,7 @@ void FeatureUISet::handleClosingFeatureGUI(FeatureGUI *featureGUI)
{ {
if (it->m_gui == featureGUI) if (it->m_gui == featureGUI)
{ {
m_featureSet->removeFeatureInstance(it->m_feature);
it->m_feature->destroy(); it->m_feature->destroy();
m_featureInstanceRegistrations.erase(it); m_featureInstanceRegistrations.erase(it);
break; break;

View File

@ -28,6 +28,7 @@ class QWidget;
class FeatureWindow; class FeatureWindow;
class FeatureGUI; class FeatureGUI;
class PluginAPI; class PluginAPI;
class FeatureSet;
class Feature; class Feature;
class FeatureSetPreset; class FeatureSetPreset;
class WebAPIAdapterInterface; class WebAPIAdapterInterface;
@ -36,7 +37,7 @@ class SDRGUI_API FeatureUISet : public QObject
{ {
Q_OBJECT Q_OBJECT
public: public:
FeatureUISet(int tabIndex); FeatureUISet(int tabIndex, FeatureSet *featureSet);
~FeatureUISet(); ~FeatureUISet();
void addRollupWidget(QWidget *widget); //!< Add feature rollup widget to feature window void addRollupWidget(QWidget *widget); //!< Add feature rollup widget to feature window
@ -76,6 +77,7 @@ private:
FeatureInstanceRegistrations m_featureInstanceRegistrations; FeatureInstanceRegistrations m_featureInstanceRegistrations;
int m_featureTabIndex; int m_featureTabIndex;
FeatureSet *m_featureSet;
void freeFeatures(); void freeFeatures();

View File

@ -36,6 +36,7 @@
#include "channel/channelapi.h" #include "channel/channelapi.h"
#include "channel/channelgui.h" #include "channel/channelgui.h"
#include "feature/featureuiset.h" #include "feature/featureuiset.h"
#include "feature/featureset.h"
#include "feature/feature.h" #include "feature/feature.h"
#include "gui/commandkeyreceiver.h" #include "gui/commandkeyreceiver.h"
#include "gui/indicator.h" #include "gui/indicator.h"
@ -555,7 +556,8 @@ void MainWindow::removeLastDevice()
void MainWindow::addFeatureSet() void MainWindow::addFeatureSet()
{ {
int tabIndex = m_featureUIs.size(); int tabIndex = m_featureUIs.size();
m_featureUIs.push_back(new FeatureUISet(tabIndex)); m_mainCore->appendFeatureSet();
m_featureUIs.push_back(new FeatureUISet(tabIndex, m_mainCore->m_featureSets[tabIndex]));
ui->tabFeatures->addTab(m_featureUIs.back()->m_featureWindow, QString("F%1").arg(tabIndex)); ui->tabFeatures->addTab(m_featureUIs.back()->m_featureWindow, QString("F%1").arg(tabIndex));
} }
@ -565,6 +567,7 @@ void MainWindow::removeFeatureSet(int tabIndex)
{ {
delete m_featureUIs[tabIndex]; delete m_featureUIs[tabIndex];
m_featureUIs.erase(m_featureUIs.begin() + tabIndex); m_featureUIs.erase(m_featureUIs.begin() + tabIndex);
m_mainCore->removeFeatureSet(tabIndex);
} }
} }
@ -583,6 +586,7 @@ void MainWindow::deleteChannel(int deviceSetIndex, int channelIndex)
{ {
DeviceUISet *deviceSet = m_deviceUIs[deviceSetIndex]; DeviceUISet *deviceSet = m_deviceUIs[deviceSetIndex];
deviceSet->deleteChannel(channelIndex); deviceSet->deleteChannel(channelIndex);
m_mainCore->removeLastFeatureSet();
} }
} }

View File

@ -2921,7 +2921,7 @@ int WebAPIAdapterGUI::featuresetFeatureSettingsGet(
{ {
error.init(); error.init();
if ((featureSetIndex >= 0) && (featureSetIndex < (int) m_mainCore->m_deviceSets.size())) if ((featureSetIndex >= 0) && (featureSetIndex < (int) m_mainCore->m_featureSets.size()))
{ {
FeatureSet *featureSet = m_mainCore->m_featureSets[featureSetIndex]; FeatureSet *featureSet = m_mainCore->m_featureSets[featureSetIndex];
Feature *feature = featureSet->getFeatureAt(featureIndex); Feature *feature = featureSet->getFeatureAt(featureIndex);