diff --git a/sdrbase/webapi/webapiadapter.cpp b/sdrbase/webapi/webapiadapter.cpp index 30278defa..7119764b9 100644 --- a/sdrbase/webapi/webapiadapter.cpp +++ b/sdrbase/webapi/webapiadapter.cpp @@ -1408,11 +1408,9 @@ int WebAPIAdapter::instanceDeviceSetDelete( SWGSDRangel::SWGSuccessResponse& response, SWGSDRangel::SWGErrorResponse& error) { -#ifdef SERVER_MODE - if (m_mainCore->m_deviceSets.size() != 0) -#else - if (m_mainCore->m_deviceSets.size() > 1) -#endif + unsigned int minFeatureSets = QCoreApplication::applicationName() == "SDRangelSrv" ? 0 : 1; + + if (m_mainCore->m_deviceSets.size() > minFeatureSets) { MainCore::MsgRemoveLastDeviceSet *msg = MainCore::MsgRemoveLastDeviceSet::create(); m_mainCore->m_mainMessageQueue->push(msg); @@ -1449,11 +1447,9 @@ int WebAPIAdapter::instanceFeatureSetDelete( SWGSDRangel::SWGSuccessResponse& response, SWGSDRangel::SWGErrorResponse& error) { -#ifdef SERVER_MODE - if (m_mainCore->m_featureSets.size() != 0) -#else - if (m_mainCore->m_featureSets.size() > 1) -#endif + unsigned int minFeatureSets = QCoreApplication::applicationName() == "SDRangelSrv" ? 0 : 1; + + if (m_mainCore->m_featureSets.size() > minFeatureSets) { MainCore::MsgRemoveLastFeatureSet *msg = MainCore::MsgRemoveLastFeatureSet::create(); m_mainCore->m_mainMessageQueue->push(msg); diff --git a/sdrgui/mainwindow.cpp b/sdrgui/mainwindow.cpp index 6e5c3d283..4dbce3af1 100644 --- a/sdrgui/mainwindow.cpp +++ b/sdrgui/mainwindow.cpp @@ -1086,6 +1086,19 @@ bool MainWindow::handleMessage(const Message& cmd) return true; } + else if (MainCore::MsgAddFeatureSet::match(cmd)) + { + addFeatureSet(); + return true; + } + else if (MainCore::MsgRemoveLastFeatureSet::match(cmd)) + { + if (m_mainCore->m_featureSets.size() != 0) { + removeFeatureSet(m_mainCore->m_featureSets.size() - 1); + } + + return true; + } else if (MainCore::MsgAddChannel::match(cmd)) { MainCore::MsgAddChannel& notif = (MainCore::MsgAddChannel&) cmd; diff --git a/sdrsrv/mainserver.cpp b/sdrsrv/mainserver.cpp index 24c7f04bb..023b8994d 100644 --- a/sdrsrv/mainserver.cpp +++ b/sdrsrv/mainserver.cpp @@ -190,6 +190,19 @@ bool MainServer::handleMessage(const Message& cmd) } return true; } + else if (MainCore::MsgAddFeatureSet::match(cmd)) + { + addFeatureSet(); + return true; + } + else if (MainCore::MsgRemoveLastFeatureSet::match(cmd)) + { + if (m_mainCore->m_featureSets.size() != 0) { + removeFeatureSet(m_mainCore->m_featureSets.size() - 1); + } + + return true; + } else if (MainCore::MsgAddChannel::match(cmd)) { MainCore::MsgAddChannel& notif = (MainCore::MsgAddChannel&) cmd; @@ -682,6 +695,18 @@ void MainServer::deleteChannel(int deviceSetIndex, int channelIndex) } } +void MainServer::addFeatureSet() +{ + m_mainCore->appendFeatureSet(); +} + +void MainServer::removeFeatureSet(unsigned int featureSetIndex) +{ + if (featureSetIndex < m_mainCore->m_featureSets.size()) { + m_mainCore->removeFeatureSet(featureSetIndex); + } +} + void MainServer::addFeature(int featureSetIndex, int selectedFeatureIndex) { if (featureSetIndex >= 0) diff --git a/sdrsrv/mainserver.h b/sdrsrv/mainserver.h index 6da13e499..69723fd65 100644 --- a/sdrsrv/mainserver.h +++ b/sdrsrv/mainserver.h @@ -66,6 +66,8 @@ public: void changeSampleMIMO(int deviceSetIndex, int selectedDeviceIndex); void addChannel(int deviceSetIndex, int selectedChannelIndex); void deleteChannel(int deviceSetIndex, int channelIndex); + void addFeatureSet(); + void removeFeatureSet(unsigned int featureSetIndex); void addFeature(int featureSetIndex, int selectedFeatureIndex); void deleteFeature(int featureSetIndex, int featureIndex);