Skip to content

Commit ffd03b7

Browse files
authored
[cpp-qt-client] Qt progress info (#18950)
* Update HttpRequest.cpp.mustache Use stable 4-parameter connect * add generated files * Revert "add generated files" This reverts commit 1d4e78a. * catch download progress in HttpRequest and pass it to api * Update HttpRequest.cpp.mustache - clean mixed in changes Removed additional changes from other PullRequest * Update HttpRequest.cpp.mustache - replaced tabs by spaces * Update api-header.mustache - replaced tabs by spaces * Update HttpRequest.h.mustache - replaced tab by spaces * ran step 3 from Linux * changed downloadProgress to -nickname-DownloadProgress and added it to all regions where execution finish is connected * ran step 3 * replaced tab by spaces * ran step 3 * activate tracing to detect link issue * removed redundant connects and encapsulated changes in {{addDownloadProgress}} * added generated files from step 3 * remove cli-option for httprequest - this should be always there * added files from step 3 * improved name * Update samples-cpp-qt-client.yaml - fix parameter order * Update samples-cpp-qt-client.yaml
1 parent 25936b4 commit ffd03b7

15 files changed

Lines changed: 36 additions & 1 deletion

File tree

.github/workflows/samples-cpp-qt-client.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,4 @@ jobs:
3030
target: "desktop"
3131
- name: Build
3232
working-directory: "samples/client/petstore/cpp-qt"
33-
run: cmake . && cmake --build .
33+
run: cmake . && cmake --build . --verbose

modules/openapi-generator/src/main/resources/cpp-qt-client/HttpRequest.cpp.mustache

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,7 @@ void {{prefix}}HttpRequestWorker::execute({{prefix}}HttpRequestInput *input) {
372372
}
373373
if (reply != nullptr) {
374374
reply->setParent(this);
375+
connect(reply, &QNetworkReply::downloadProgress, this, &{{prefix}}HttpRequestWorker::downloadProgress);
375376
connect(reply, &QNetworkReply::finished, [this, reply] {
376377
on_reply_finished(reply);
377378
});

modules/openapi-generator/src/main/resources/cpp-qt-client/HttpRequest.h.mustache

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ public:
7272

7373
Q_SIGNALS:
7474
void on_execution_finished({{prefix}}HttpRequestWorker *worker);
75+
void downloadProgress(qint64 bytesReceived, qint64 bytesTotal);
7576

7677
private:
7778
enum {{prefix}}CompressionType{

modules/openapi-generator/src/main/resources/cpp-qt-client/api-body.mustache

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -660,6 +660,8 @@ void {{classname}}::{{nickname}}({{#allParams}}{{#required}}const {{{dataType}}}
660660
input.headers.insert(keyValueIt->first, keyValueIt->second);
661661
}
662662

663+
{{#addDownloadProgress}}
664+
connect(worker, &{{prefix}}HttpRequestWorker::downloadProgress, this, &{{classname}}::{{nickname}}Progress);{{/addDownloadProgress}}
663665
connect(worker, &{{prefix}}HttpRequestWorker::on_execution_finished, this, &{{classname}}::{{nickname}}Callback);
664666
connect(this, &{{classname}}::abortRequestsSignal, worker, &QObject::deleteLater);
665667
connect(worker, &QObject::destroyed, this, [this]() {

modules/openapi-generator/src/main/resources/cpp-qt-client/api-header.mustache

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,8 @@ private:
8888
Q_SIGNALS:
8989
{{#operations}}{{#operation}}
9090
void {{nickname}}Signal({{#returnType}}{{{.}}} summary{{/returnType}});{{/operation}}{{/operations}}
91+
{{#operations}}{{#operation}}{{#addDownloadProgress}}
92+
void {{nickname}}Progress(qint64 bytesReceived, qint64 bytesTotal);{{/addDownloadProgress}}{{/operation}}{{/operations}}
9193
{{#operations}}{{#operation}}
9294
void {{nickname}}SignalFull({{prefix}}HttpRequestWorker *worker{{#returnType}}, {{{.}}} summary{{/returnType}});{{/operation}}{{/operations}}
9395
{{#operations}}{{#operation}}

samples/client/petstore/cpp-qt/client/PFXHttpRequest.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,7 @@ void PFXHttpRequestWorker::execute(PFXHttpRequestInput *input) {
379379
}
380380
if (reply != nullptr) {
381381
reply->setParent(this);
382+
connect(reply, &QNetworkReply::downloadProgress, this, &PFXHttpRequestWorker::downloadProgress);
382383
connect(reply, &QNetworkReply::finished, [this, reply] {
383384
on_reply_finished(reply);
384385
});

samples/client/petstore/cpp-qt/client/PFXHttpRequest.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ class PFXHttpRequestWorker : public QObject {
8080

8181
Q_SIGNALS:
8282
void on_execution_finished(PFXHttpRequestWorker *worker);
83+
void downloadProgress(qint64 bytesReceived, qint64 bytesTotal);
8384

8485
private:
8586
enum PFXCompressionType{

samples/client/petstore/cpp-qt/client/PFXPetApi.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,7 @@ void PFXPetApi::addPet(const PFXPet &pfx_pet) {
240240
input.headers.insert(keyValueIt->first, keyValueIt->second);
241241
}
242242

243+
243244
connect(worker, &PFXHttpRequestWorker::on_execution_finished, this, &PFXPetApi::addPetCallback);
244245
connect(this, &PFXPetApi::abortRequestsSignal, worker, &QObject::deleteLater);
245246
connect(worker, &QObject::destroyed, this, [this]() {
@@ -348,6 +349,7 @@ void PFXPetApi::allPets() {
348349
input.headers.insert(keyValueIt->first, keyValueIt->second);
349350
}
350351

352+
351353
connect(worker, &PFXHttpRequestWorker::on_execution_finished, this, &PFXPetApi::allPetsCallback);
352354
connect(this, &PFXPetApi::abortRequestsSignal, worker, &QObject::deleteLater);
353355
connect(worker, &QObject::destroyed, this, [this]() {
@@ -446,6 +448,7 @@ void PFXPetApi::deletePet(const qint64 &pet_id, const ::test_namespace::Optional
446448
input.headers.insert(keyValueIt->first, keyValueIt->second);
447449
}
448450

451+
449452
connect(worker, &PFXHttpRequestWorker::on_execution_finished, this, &PFXPetApi::deletePetCallback);
450453
connect(this, &PFXPetApi::abortRequestsSignal, worker, &QObject::deleteLater);
451454
connect(worker, &QObject::destroyed, this, [this]() {
@@ -640,6 +643,7 @@ void PFXPetApi::findPetsByStatus(const QList<QString> &status) {
640643
input.headers.insert(keyValueIt->first, keyValueIt->second);
641644
}
642645

646+
643647
connect(worker, &PFXHttpRequestWorker::on_execution_finished, this, &PFXPetApi::findPetsByStatusCallback);
644648
connect(this, &PFXPetApi::abortRequestsSignal, worker, &QObject::deleteLater);
645649
connect(worker, &QObject::destroyed, this, [this]() {
@@ -844,6 +848,7 @@ void PFXPetApi::findPetsByTags(const QList<QString> &tags) {
844848
input.headers.insert(keyValueIt->first, keyValueIt->second);
845849
}
846850

851+
847852
connect(worker, &PFXHttpRequestWorker::on_execution_finished, this, &PFXPetApi::findPetsByTagsCallback);
848853
connect(this, &PFXPetApi::abortRequestsSignal, worker, &QObject::deleteLater);
849854
connect(worker, &QObject::destroyed, this, [this]() {
@@ -980,6 +985,7 @@ void PFXPetApi::getPetById(const qint64 &pet_id) {
980985
input.headers.insert(keyValueIt->first, keyValueIt->second);
981986
}
982987

988+
983989
connect(worker, &PFXHttpRequestWorker::on_execution_finished, this, &PFXPetApi::getPetByIdCallback);
984990
connect(this, &PFXPetApi::abortRequestsSignal, worker, &QObject::deleteLater);
985991
connect(worker, &QObject::destroyed, this, [this]() {
@@ -1054,6 +1060,7 @@ void PFXPetApi::updatePet(const PFXPet &pfx_pet) {
10541060
input.headers.insert(keyValueIt->first, keyValueIt->second);
10551061
}
10561062

1063+
10571064
connect(worker, &PFXHttpRequestWorker::on_execution_finished, this, &PFXPetApi::updatePetCallback);
10581065
connect(this, &PFXPetApi::abortRequestsSignal, worker, &QObject::deleteLater);
10591066
connect(worker, &QObject::destroyed, this, [this]() {
@@ -1184,6 +1191,7 @@ void PFXPetApi::updatePetWithForm(const qint64 &pet_id, const ::test_namespace::
11841191
input.headers.insert(keyValueIt->first, keyValueIt->second);
11851192
}
11861193

1194+
11871195
connect(worker, &PFXHttpRequestWorker::on_execution_finished, this, &PFXPetApi::updatePetWithFormCallback);
11881196
connect(this, &PFXPetApi::abortRequestsSignal, worker, &QObject::deleteLater);
11891197
connect(worker, &QObject::destroyed, this, [this]() {
@@ -1314,6 +1322,7 @@ void PFXPetApi::uploadFile(const qint64 &pet_id, const ::test_namespace::Optiona
13141322
input.headers.insert(keyValueIt->first, keyValueIt->second);
13151323
}
13161324

1325+
13171326
connect(worker, &PFXHttpRequestWorker::on_execution_finished, this, &PFXPetApi::uploadFileCallback);
13181327
connect(this, &PFXPetApi::abortRequestsSignal, worker, &QObject::deleteLater);
13191328
connect(worker, &QObject::destroyed, this, [this]() {

samples/client/petstore/cpp-qt/client/PFXPetApi.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ class PFXPetApi : public QObject {
152152
void updatePetWithFormSignal();
153153
void uploadFileSignal(PFXApiResponse summary);
154154

155+
155156
void addPetSignalFull(PFXHttpRequestWorker *worker);
156157
void allPetsSignalFull(PFXHttpRequestWorker *worker, QSet<PFXPet> summary);
157158
void deletePetSignalFull(PFXHttpRequestWorker *worker);

samples/client/petstore/cpp-qt/client/PFXPrimitivesApi.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,7 @@ void PFXPrimitivesApi::primitivesIntegerPost(const ::test_namespace::OptionalPar
225225
input.headers.insert(keyValueIt->first, keyValueIt->second);
226226
}
227227

228+
228229
connect(worker, &PFXHttpRequestWorker::on_execution_finished, this, &PFXPrimitivesApi::primitivesIntegerPostCallback);
229230
connect(this, &PFXPrimitivesApi::abortRequestsSignal, worker, &QObject::deleteLater);
230231
connect(worker, &QObject::destroyed, this, [this]() {
@@ -297,6 +298,7 @@ void PFXPrimitivesApi::primitivesNumberPut(const ::test_namespace::OptionalParam
297298
input.headers.insert(keyValueIt->first, keyValueIt->second);
298299
}
299300

301+
300302
connect(worker, &PFXHttpRequestWorker::on_execution_finished, this, &PFXPrimitivesApi::primitivesNumberPutCallback);
301303
connect(this, &PFXPrimitivesApi::abortRequestsSignal, worker, &QObject::deleteLater);
302304
connect(worker, &QObject::destroyed, this, [this]() {

0 commit comments

Comments
 (0)