1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-17 05:41:56 -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());
}
}
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);
void loadFeatureSetSettings(const FeatureSetPreset* preset, PluginAPI *pluginAPI, WebAPIAdapterInterface *apiAdapter);
void saveFeatureSetSettings(FeatureSetPreset* preset);
// slave mode
void addFeatureInstance(const QString& featureURI, Feature *feature);
void removeFeatureInstanceAt(int index);
void clearFeatures();
private:
struct FeatureInstanceRegistration

View File

@ -21,6 +21,7 @@
#include "loggerwithfile.h"
#include "dsp/dsptypes.h"
#include "feature/featureset.h"
#include "maincore.h"
@ -102,3 +103,23 @@ void MainCore::setLoggingOptions()
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<FeatureSet*>& getFeatureeSets() { return m_featureSets; }
void setLoggingOptions();
// slave mode
void appendFeatureSet();
void removeFeatureSet(int index);
void removeLastFeatureSet();
friend class MainServer;
friend class MainWindow;

View File

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

View File

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

View File

@ -36,6 +36,7 @@
#include "channel/channelapi.h"
#include "channel/channelgui.h"
#include "feature/featureuiset.h"
#include "feature/featureset.h"
#include "feature/feature.h"
#include "gui/commandkeyreceiver.h"
#include "gui/indicator.h"
@ -555,7 +556,8 @@ void MainWindow::removeLastDevice()
void MainWindow::addFeatureSet()
{
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));
}
@ -565,6 +567,7 @@ void MainWindow::removeFeatureSet(int tabIndex)
{
delete m_featureUIs[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];
deviceSet->deleteChannel(channelIndex);
m_mainCore->removeLastFeatureSet();
}
}

View File

@ -2921,7 +2921,7 @@ int WebAPIAdapterGUI::featuresetFeatureSettingsGet(
{
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];
Feature *feature = featureSet->getFeatureAt(featureIndex);