From e8ed80167ceed911c93484df48a1debad1d4f3a8 Mon Sep 17 00:00:00 2001 From: f4exb Date: Thu, 16 Sep 2021 21:20:03 +0200 Subject: [PATCH] API: added index in FeatureSet structure --- sdrbase/resources/webapi/doc/html2/index.html | 8 +++++-- .../resources/webapi/doc/swagger/swagger.yaml | 4 ++++ sdrbase/webapi/webapiadapter.cpp | 1 + swagger/sdrangel/api/swagger/swagger.yaml | 4 ++++ swagger/sdrangel/code/html2/index.html | 8 +++++-- .../code/qt5/client/SWGFeatureSet.cpp | 23 +++++++++++++++++++ .../sdrangel/code/qt5/client/SWGFeatureSet.h | 6 +++++ 7 files changed, 50 insertions(+), 4 deletions(-) diff --git a/sdrbase/resources/webapi/doc/html2/index.html b/sdrbase/resources/webapi/doc/html2/index.html index ad92d4307..ffdaa0625 100644 --- a/sdrbase/resources/webapi/doc/html2/index.html +++ b/sdrbase/resources/webapi/doc/html2/index.html @@ -4913,8 +4913,12 @@ margin-bottom: 20px; "description" : "Base feature report. Only the feature report corresponding to the feature specified in the featureType field is or should be present." }; defs.FeatureSet = { - "required" : [ "featurecount" ], + "required" : [ "featurecount", "index" ], "properties" : { + "index" : { + "type" : "integer", + "description" : "Index in the list of feature sets opened in this instance" + }, "featurecount" : { "type" : "integer", "description" : "Number of features in the set" @@ -50576,7 +50580,7 @@ except ApiException as e:
- Generated 2021-09-05T21:54:27.642+02:00 + Generated 2021-09-12T20:10:39.058+02:00
diff --git a/sdrbase/resources/webapi/doc/swagger/swagger.yaml b/sdrbase/resources/webapi/doc/swagger/swagger.yaml index 383200ea9..884157346 100644 --- a/sdrbase/resources/webapi/doc/swagger/swagger.yaml +++ b/sdrbase/resources/webapi/doc/swagger/swagger.yaml @@ -2759,8 +2759,12 @@ definitions: FeatureSet: description: "Grouping of features" required: + - index - featurecount properties: + index: + description: "Index in the list of feature sets opened in this instance" + type: integer featurecount: description: "Number of features in the set" type: integer diff --git a/sdrbase/webapi/webapiadapter.cpp b/sdrbase/webapi/webapiadapter.cpp index 9201ae0f3..accd68783 100644 --- a/sdrbase/webapi/webapiadapter.cpp +++ b/sdrbase/webapi/webapiadapter.cpp @@ -3767,6 +3767,7 @@ void WebAPIAdapter::getFeatureSet(SWGSDRangel::SWGFeatureSet *swgFeatureSet, con (void) featureSetIndex; // FIXME: the index should be present in the API FeatureSet structure swgFeatureSet->init(); swgFeatureSet->setFeaturecount(featureSet->getNumberOfFeatures()); + swgFeatureSet->setIndex(featureSetIndex); QList *features = swgFeatureSet->getFeatures(); for (int i = 0; i < featureSet->getNumberOfFeatures(); i++) diff --git a/swagger/sdrangel/api/swagger/swagger.yaml b/swagger/sdrangel/api/swagger/swagger.yaml index a840800a3..e25826e8f 100644 --- a/swagger/sdrangel/api/swagger/swagger.yaml +++ b/swagger/sdrangel/api/swagger/swagger.yaml @@ -2759,8 +2759,12 @@ definitions: FeatureSet: description: "Grouping of features" required: + - index - featurecount properties: + index: + description: "Index in the list of feature sets opened in this instance" + type: integer featurecount: description: "Number of features in the set" type: integer diff --git a/swagger/sdrangel/code/html2/index.html b/swagger/sdrangel/code/html2/index.html index ad92d4307..ffdaa0625 100644 --- a/swagger/sdrangel/code/html2/index.html +++ b/swagger/sdrangel/code/html2/index.html @@ -4913,8 +4913,12 @@ margin-bottom: 20px; "description" : "Base feature report. Only the feature report corresponding to the feature specified in the featureType field is or should be present." }; defs.FeatureSet = { - "required" : [ "featurecount" ], + "required" : [ "featurecount", "index" ], "properties" : { + "index" : { + "type" : "integer", + "description" : "Index in the list of feature sets opened in this instance" + }, "featurecount" : { "type" : "integer", "description" : "Number of features in the set" @@ -50576,7 +50580,7 @@ except ApiException as e:
- Generated 2021-09-05T21:54:27.642+02:00 + Generated 2021-09-12T20:10:39.058+02:00
diff --git a/swagger/sdrangel/code/qt5/client/SWGFeatureSet.cpp b/swagger/sdrangel/code/qt5/client/SWGFeatureSet.cpp index df6db3ed7..810adcef9 100644 --- a/swagger/sdrangel/code/qt5/client/SWGFeatureSet.cpp +++ b/swagger/sdrangel/code/qt5/client/SWGFeatureSet.cpp @@ -28,6 +28,8 @@ SWGFeatureSet::SWGFeatureSet(QString* json) { } SWGFeatureSet::SWGFeatureSet() { + index = 0; + m_index_isSet = false; featurecount = 0; m_featurecount_isSet = false; features = nullptr; @@ -40,6 +42,8 @@ SWGFeatureSet::~SWGFeatureSet() { void SWGFeatureSet::init() { + index = 0; + m_index_isSet = false; featurecount = 0; m_featurecount_isSet = false; features = new QList(); @@ -49,6 +53,7 @@ SWGFeatureSet::init() { void SWGFeatureSet::cleanup() { + if(features != nullptr) { auto arr = features; for(auto o: *arr) { @@ -69,6 +74,8 @@ SWGFeatureSet::fromJson(QString &json) { void SWGFeatureSet::fromJsonObject(QJsonObject &pJson) { + ::SWGSDRangel::setValue(&index, pJson["index"], "qint32", ""); + ::SWGSDRangel::setValue(&featurecount, pJson["featurecount"], "qint32", ""); @@ -89,6 +96,9 @@ SWGFeatureSet::asJson () QJsonObject* SWGFeatureSet::asJsonObject() { QJsonObject* obj = new QJsonObject(); + if(m_index_isSet){ + obj->insert("index", QJsonValue(index)); + } if(m_featurecount_isSet){ obj->insert("featurecount", QJsonValue(featurecount)); } @@ -99,6 +109,16 @@ SWGFeatureSet::asJsonObject() { return obj; } +qint32 +SWGFeatureSet::getIndex() { + return index; +} +void +SWGFeatureSet::setIndex(qint32 index) { + this->index = index; + this->m_index_isSet = true; +} + qint32 SWGFeatureSet::getFeaturecount() { return featurecount; @@ -124,6 +144,9 @@ bool SWGFeatureSet::isSet(){ bool isObjectUpdated = false; do{ + if(m_index_isSet){ + isObjectUpdated = true; break; + } if(m_featurecount_isSet){ isObjectUpdated = true; break; } diff --git a/swagger/sdrangel/code/qt5/client/SWGFeatureSet.h b/swagger/sdrangel/code/qt5/client/SWGFeatureSet.h index fa4688572..e6232dedd 100644 --- a/swagger/sdrangel/code/qt5/client/SWGFeatureSet.h +++ b/swagger/sdrangel/code/qt5/client/SWGFeatureSet.h @@ -43,6 +43,9 @@ public: virtual void fromJsonObject(QJsonObject &json) override; virtual SWGFeatureSet* fromJson(QString &jsonString) override; + qint32 getIndex(); + void setIndex(qint32 index); + qint32 getFeaturecount(); void setFeaturecount(qint32 featurecount); @@ -53,6 +56,9 @@ public: virtual bool isSet() override; private: + qint32 index; + bool m_index_isSet; + qint32 featurecount; bool m_featurecount_isSet;