From 493912cd8f95c5a41e02e9c8e15c9fde23dd0577 Mon Sep 17 00:00:00 2001 From: William Cheng Date: Tue, 18 Jun 2024 12:09:22 +0800 Subject: [PATCH] fix tabs, update samples --- .../resources/cpp-qt-client/HttpRequest.cpp.mustache | 2 +- .../main/resources/cpp-qt-client/HttpRequest.h.mustache | 2 +- .../src/main/resources/cpp-qt-client/api-header.mustache | 2 +- samples/client/petstore/cpp-qt/client/PFXHttpRequest.cpp | 5 +++-- samples/client/petstore/cpp-qt/client/PFXHttpRequest.h | 1 + samples/client/petstore/cpp-qt/client/PFXPetApi.cpp | 9 +++++++++ samples/client/petstore/cpp-qt/client/PFXPetApi.h | 1 + .../client/petstore/cpp-qt/client/PFXPrimitivesApi.cpp | 2 ++ samples/client/petstore/cpp-qt/client/PFXPrimitivesApi.h | 1 + samples/client/petstore/cpp-qt/client/PFXStoreApi.cpp | 4 ++++ samples/client/petstore/cpp-qt/client/PFXStoreApi.h | 1 + samples/client/petstore/cpp-qt/client/PFXUserApi.cpp | 8 ++++++++ samples/client/petstore/cpp-qt/client/PFXUserApi.h | 1 + 13 files changed, 34 insertions(+), 5 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/cpp-qt-client/HttpRequest.cpp.mustache b/modules/openapi-generator/src/main/resources/cpp-qt-client/HttpRequest.cpp.mustache index adba1ac6eb0b..f1b4a455c59f 100644 --- a/modules/openapi-generator/src/main/resources/cpp-qt-client/HttpRequest.cpp.mustache +++ b/modules/openapi-generator/src/main/resources/cpp-qt-client/HttpRequest.cpp.mustache @@ -376,7 +376,7 @@ void {{prefix}}HttpRequestWorker::execute({{prefix}}HttpRequestInput *input) { } if (reply != nullptr) { reply->setParent(this); - connect(reply, &QNetworkReply::downloadProgress, this, &{{prefix}}HttpRequestWorker::downloadProgress); + connect(reply, &QNetworkReply::downloadProgress, this, &{{prefix}}HttpRequestWorker::downloadProgress); connect(reply, &QNetworkReply::finished, this, [this, reply] { on_reply_finished(reply); }); diff --git a/modules/openapi-generator/src/main/resources/cpp-qt-client/HttpRequest.h.mustache b/modules/openapi-generator/src/main/resources/cpp-qt-client/HttpRequest.h.mustache index 222b358960f2..2ac1b9f13d07 100644 --- a/modules/openapi-generator/src/main/resources/cpp-qt-client/HttpRequest.h.mustache +++ b/modules/openapi-generator/src/main/resources/cpp-qt-client/HttpRequest.h.mustache @@ -74,7 +74,7 @@ public: Q_SIGNALS: void on_execution_finished({{prefix}}HttpRequestWorker *worker); - void downloadProgress(qint64 bytesReceived, qint64 bytesTotal); + void downloadProgress(qint64 bytesReceived, qint64 bytesTotal); private: enum {{prefix}}CompressionType{ diff --git a/modules/openapi-generator/src/main/resources/cpp-qt-client/api-header.mustache b/modules/openapi-generator/src/main/resources/cpp-qt-client/api-header.mustache index 3b09fbf03448..824c0b6ed653 100644 --- a/modules/openapi-generator/src/main/resources/cpp-qt-client/api-header.mustache +++ b/modules/openapi-generator/src/main/resources/cpp-qt-client/api-header.mustache @@ -99,7 +99,7 @@ Q_SIGNALS: void {{nickname}}SignalEFull({{prefix}}HttpRequestWorker *worker, QNetworkReply::NetworkError error_type, QString error_str); void {{nickname}}SignalErrorFull({{prefix}}HttpRequestWorker *worker, QNetworkReply::NetworkError error_type, const QString &error_str);{{/operation}}{{/operations}} - void downloadProgress(qint64 bytesReceived, qint64 bytesTotal); + void downloadProgress(qint64 bytesReceived, qint64 bytesTotal); void abortRequestsSignal(); void allPendingRequestsCompleted(); diff --git a/samples/client/petstore/cpp-qt/client/PFXHttpRequest.cpp b/samples/client/petstore/cpp-qt/client/PFXHttpRequest.cpp index 4664b9a399b6..2d1f84ffb777 100644 --- a/samples/client/petstore/cpp-qt/client/PFXHttpRequest.cpp +++ b/samples/client/petstore/cpp-qt/client/PFXHttpRequest.cpp @@ -383,12 +383,13 @@ void PFXHttpRequestWorker::execute(PFXHttpRequestInput *input) { } if (reply != nullptr) { reply->setParent(this); - connect(reply, &QNetworkReply::finished, [this, reply] { + connect(reply, &QNetworkReply::downloadProgress, this, &PFXHttpRequestWorker::downloadProgress); + connect(reply, &QNetworkReply::finished, this, [this, reply] { on_reply_finished(reply); }); } if (timeOutTimer.interval() > 0) { - QObject::connect(&timeOutTimer, &QTimer::timeout, [this, reply] { + QObject::connect(&timeOutTimer, &QTimer::timeout, this, [this, reply] { on_reply_timeout(reply); }); timeOutTimer.start(); diff --git a/samples/client/petstore/cpp-qt/client/PFXHttpRequest.h b/samples/client/petstore/cpp-qt/client/PFXHttpRequest.h index 31e2ec823af2..c788482fba0b 100644 --- a/samples/client/petstore/cpp-qt/client/PFXHttpRequest.h +++ b/samples/client/petstore/cpp-qt/client/PFXHttpRequest.h @@ -82,6 +82,7 @@ class PFXHttpRequestWorker : public QObject { Q_SIGNALS: void on_execution_finished(PFXHttpRequestWorker *worker); + void downloadProgress(qint64 bytesReceived, qint64 bytesTotal); private: enum PFXCompressionType{ diff --git a/samples/client/petstore/cpp-qt/client/PFXPetApi.cpp b/samples/client/petstore/cpp-qt/client/PFXPetApi.cpp index 3aad8a2e9e3f..8c4d799e666c 100644 --- a/samples/client/petstore/cpp-qt/client/PFXPetApi.cpp +++ b/samples/client/petstore/cpp-qt/client/PFXPetApi.cpp @@ -252,6 +252,7 @@ void PFXPetApi::addPet(const PFXPet &pfx_pet) { } #endif + connect(worker, &PFXHttpRequestWorker::downloadProgress, this, &PFXPetApi::downloadProgress); connect(worker, &PFXHttpRequestWorker::on_execution_finished, this, &PFXPetApi::addPetCallback); connect(this, &PFXPetApi::abortRequestsSignal, worker, &QObject::deleteLater); connect(worker, &QObject::destroyed, this, [this]() { @@ -366,6 +367,7 @@ void PFXPetApi::allPets() { } #endif + connect(worker, &PFXHttpRequestWorker::downloadProgress, this, &PFXPetApi::downloadProgress); connect(worker, &PFXHttpRequestWorker::on_execution_finished, this, &PFXPetApi::allPetsCallback); connect(this, &PFXPetApi::abortRequestsSignal, worker, &QObject::deleteLater); connect(worker, &QObject::destroyed, this, [this]() { @@ -470,6 +472,7 @@ void PFXPetApi::deletePet(const qint64 &pet_id, const ::test_namespace::Optional } #endif + connect(worker, &PFXHttpRequestWorker::downloadProgress, this, &PFXPetApi::downloadProgress); connect(worker, &PFXHttpRequestWorker::on_execution_finished, this, &PFXPetApi::deletePetCallback); connect(this, &PFXPetApi::abortRequestsSignal, worker, &QObject::deleteLater); connect(worker, &QObject::destroyed, this, [this]() { @@ -670,6 +673,7 @@ void PFXPetApi::findPetsByStatus(const QList &status) { } #endif + connect(worker, &PFXHttpRequestWorker::downloadProgress, this, &PFXPetApi::downloadProgress); connect(worker, &PFXHttpRequestWorker::on_execution_finished, this, &PFXPetApi::findPetsByStatusCallback); connect(this, &PFXPetApi::abortRequestsSignal, worker, &QObject::deleteLater); connect(worker, &QObject::destroyed, this, [this]() { @@ -880,6 +884,7 @@ void PFXPetApi::findPetsByTags(const QList &tags) { } #endif + connect(worker, &PFXHttpRequestWorker::downloadProgress, this, &PFXPetApi::downloadProgress); connect(worker, &PFXHttpRequestWorker::on_execution_finished, this, &PFXPetApi::findPetsByTagsCallback); connect(this, &PFXPetApi::abortRequestsSignal, worker, &QObject::deleteLater); connect(worker, &QObject::destroyed, this, [this]() { @@ -1022,6 +1027,7 @@ void PFXPetApi::getPetById(const qint64 &pet_id) { } #endif + connect(worker, &PFXHttpRequestWorker::downloadProgress, this, &PFXPetApi::downloadProgress); connect(worker, &PFXHttpRequestWorker::on_execution_finished, this, &PFXPetApi::getPetByIdCallback); connect(this, &PFXPetApi::abortRequestsSignal, worker, &QObject::deleteLater); connect(worker, &QObject::destroyed, this, [this]() { @@ -1102,6 +1108,7 @@ void PFXPetApi::updatePet(const PFXPet &pfx_pet) { } #endif + connect(worker, &PFXHttpRequestWorker::downloadProgress, this, &PFXPetApi::downloadProgress); connect(worker, &PFXHttpRequestWorker::on_execution_finished, this, &PFXPetApi::updatePetCallback); connect(this, &PFXPetApi::abortRequestsSignal, worker, &QObject::deleteLater); connect(worker, &QObject::destroyed, this, [this]() { @@ -1238,6 +1245,7 @@ void PFXPetApi::updatePetWithForm(const qint64 &pet_id, const ::test_namespace:: } #endif + connect(worker, &PFXHttpRequestWorker::downloadProgress, this, &PFXPetApi::downloadProgress); connect(worker, &PFXHttpRequestWorker::on_execution_finished, this, &PFXPetApi::updatePetWithFormCallback); connect(this, &PFXPetApi::abortRequestsSignal, worker, &QObject::deleteLater); connect(worker, &QObject::destroyed, this, [this]() { @@ -1374,6 +1382,7 @@ void PFXPetApi::uploadFile(const qint64 &pet_id, const ::test_namespace::Optiona } #endif + connect(worker, &PFXHttpRequestWorker::downloadProgress, this, &PFXPetApi::downloadProgress); connect(worker, &PFXHttpRequestWorker::on_execution_finished, this, &PFXPetApi::uploadFileCallback); connect(this, &PFXPetApi::abortRequestsSignal, worker, &QObject::deleteLater); connect(worker, &QObject::destroyed, this, [this]() { diff --git a/samples/client/petstore/cpp-qt/client/PFXPetApi.h b/samples/client/petstore/cpp-qt/client/PFXPetApi.h index ba85ac3b95e9..5a6e8de50c0e 100644 --- a/samples/client/petstore/cpp-qt/client/PFXPetApi.h +++ b/samples/client/petstore/cpp-qt/client/PFXPetApi.h @@ -218,6 +218,7 @@ class PFXPetApi : public QObject { void uploadFileSignalEFull(PFXHttpRequestWorker *worker, QNetworkReply::NetworkError error_type, QString error_str); void uploadFileSignalErrorFull(PFXHttpRequestWorker *worker, QNetworkReply::NetworkError error_type, const QString &error_str); + void downloadProgress(qint64 bytesReceived, qint64 bytesTotal); void abortRequestsSignal(); void allPendingRequestsCompleted(); diff --git a/samples/client/petstore/cpp-qt/client/PFXPrimitivesApi.cpp b/samples/client/petstore/cpp-qt/client/PFXPrimitivesApi.cpp index 6badeb2c05f7..4fb79257ef9f 100644 --- a/samples/client/petstore/cpp-qt/client/PFXPrimitivesApi.cpp +++ b/samples/client/petstore/cpp-qt/client/PFXPrimitivesApi.cpp @@ -237,6 +237,7 @@ void PFXPrimitivesApi::primitivesIntegerPost(const ::test_namespace::OptionalPar } #endif + connect(worker, &PFXHttpRequestWorker::downloadProgress, this, &PFXPrimitivesApi::downloadProgress); connect(worker, &PFXHttpRequestWorker::on_execution_finished, this, &PFXPrimitivesApi::primitivesIntegerPostCallback); connect(this, &PFXPrimitivesApi::abortRequestsSignal, worker, &QObject::deleteLater); connect(worker, &QObject::destroyed, this, [this]() { @@ -315,6 +316,7 @@ void PFXPrimitivesApi::primitivesNumberPut(const ::test_namespace::OptionalParam } #endif + connect(worker, &PFXHttpRequestWorker::downloadProgress, this, &PFXPrimitivesApi::downloadProgress); connect(worker, &PFXHttpRequestWorker::on_execution_finished, this, &PFXPrimitivesApi::primitivesNumberPutCallback); connect(this, &PFXPrimitivesApi::abortRequestsSignal, worker, &QObject::deleteLater); connect(worker, &QObject::destroyed, this, [this]() { diff --git a/samples/client/petstore/cpp-qt/client/PFXPrimitivesApi.h b/samples/client/petstore/cpp-qt/client/PFXPrimitivesApi.h index 7ecebdef01d9..32f75b913ba2 100644 --- a/samples/client/petstore/cpp-qt/client/PFXPrimitivesApi.h +++ b/samples/client/petstore/cpp-qt/client/PFXPrimitivesApi.h @@ -113,6 +113,7 @@ class PFXPrimitivesApi : public QObject { void primitivesNumberPutSignalEFull(PFXHttpRequestWorker *worker, QNetworkReply::NetworkError error_type, QString error_str); void primitivesNumberPutSignalErrorFull(PFXHttpRequestWorker *worker, QNetworkReply::NetworkError error_type, const QString &error_str); + void downloadProgress(qint64 bytesReceived, qint64 bytesTotal); void abortRequestsSignal(); void allPendingRequestsCompleted(); diff --git a/samples/client/petstore/cpp-qt/client/PFXStoreApi.cpp b/samples/client/petstore/cpp-qt/client/PFXStoreApi.cpp index af5cdb421e01..91eddc821eaf 100644 --- a/samples/client/petstore/cpp-qt/client/PFXStoreApi.cpp +++ b/samples/client/petstore/cpp-qt/client/PFXStoreApi.cpp @@ -251,6 +251,7 @@ void PFXStoreApi::deleteOrder(const QString &order_id) { } #endif + connect(worker, &PFXHttpRequestWorker::downloadProgress, this, &PFXStoreApi::downloadProgress); connect(worker, &PFXHttpRequestWorker::on_execution_finished, this, &PFXStoreApi::deleteOrderCallback); connect(this, &PFXStoreApi::abortRequestsSignal, worker, &QObject::deleteLater); connect(worker, &QObject::destroyed, this, [this]() { @@ -329,6 +330,7 @@ void PFXStoreApi::getInventory() { } #endif + connect(worker, &PFXHttpRequestWorker::downloadProgress, this, &PFXStoreApi::downloadProgress); connect(worker, &PFXHttpRequestWorker::on_execution_finished, this, &PFXStoreApi::getInventoryCallback); connect(this, &PFXStoreApi::abortRequestsSignal, worker, &QObject::deleteLater); connect(worker, &QObject::destroyed, this, [this]() { @@ -427,6 +429,7 @@ void PFXStoreApi::getOrderById(const qint64 &order_id) { } #endif + connect(worker, &PFXHttpRequestWorker::downloadProgress, this, &PFXStoreApi::downloadProgress); connect(worker, &PFXHttpRequestWorker::on_execution_finished, this, &PFXStoreApi::getOrderByIdCallback); connect(this, &PFXStoreApi::abortRequestsSignal, worker, &QObject::deleteLater); connect(worker, &QObject::destroyed, this, [this]() { @@ -507,6 +510,7 @@ void PFXStoreApi::placeOrder(const PFXOrder &pfx_order) { } #endif + connect(worker, &PFXHttpRequestWorker::downloadProgress, this, &PFXStoreApi::downloadProgress); connect(worker, &PFXHttpRequestWorker::on_execution_finished, this, &PFXStoreApi::placeOrderCallback); connect(this, &PFXStoreApi::abortRequestsSignal, worker, &QObject::deleteLater); connect(worker, &QObject::destroyed, this, [this]() { diff --git a/samples/client/petstore/cpp-qt/client/PFXStoreApi.h b/samples/client/petstore/cpp-qt/client/PFXStoreApi.h index a9ac689d36d0..806265d8e9ce 100644 --- a/samples/client/petstore/cpp-qt/client/PFXStoreApi.h +++ b/samples/client/petstore/cpp-qt/client/PFXStoreApi.h @@ -141,6 +141,7 @@ class PFXStoreApi : public QObject { void placeOrderSignalEFull(PFXHttpRequestWorker *worker, QNetworkReply::NetworkError error_type, QString error_str); void placeOrderSignalErrorFull(PFXHttpRequestWorker *worker, QNetworkReply::NetworkError error_type, const QString &error_str); + void downloadProgress(qint64 bytesReceived, qint64 bytesTotal); void abortRequestsSignal(); void allPendingRequestsCompleted(); diff --git a/samples/client/petstore/cpp-qt/client/PFXUserApi.cpp b/samples/client/petstore/cpp-qt/client/PFXUserApi.cpp index 7949f0afa3a4..c18b894eb9b1 100644 --- a/samples/client/petstore/cpp-qt/client/PFXUserApi.cpp +++ b/samples/client/petstore/cpp-qt/client/PFXUserApi.cpp @@ -250,6 +250,7 @@ void PFXUserApi::createUser(const PFXUser &pfx_user) { } #endif + connect(worker, &PFXHttpRequestWorker::downloadProgress, this, &PFXUserApi::downloadProgress); connect(worker, &PFXHttpRequestWorker::on_execution_finished, this, &PFXUserApi::createUserCallback); connect(this, &PFXUserApi::abortRequestsSignal, worker, &QObject::deleteLater); connect(worker, &QObject::destroyed, this, [this]() { @@ -328,6 +329,7 @@ void PFXUserApi::createUsersWithArrayInput(const QList &pfx_user) { } #endif + connect(worker, &PFXHttpRequestWorker::downloadProgress, this, &PFXUserApi::downloadProgress); connect(worker, &PFXHttpRequestWorker::on_execution_finished, this, &PFXUserApi::createUsersWithArrayInputCallback); connect(this, &PFXUserApi::abortRequestsSignal, worker, &QObject::deleteLater); connect(worker, &QObject::destroyed, this, [this]() { @@ -406,6 +408,7 @@ void PFXUserApi::createUsersWithListInput(const QList &pfx_user) { } #endif + connect(worker, &PFXHttpRequestWorker::downloadProgress, this, &PFXUserApi::downloadProgress); connect(worker, &PFXHttpRequestWorker::on_execution_finished, this, &PFXUserApi::createUsersWithListInputCallback); connect(this, &PFXUserApi::abortRequestsSignal, worker, &QObject::deleteLater); connect(worker, &QObject::destroyed, this, [this]() { @@ -494,6 +497,7 @@ void PFXUserApi::deleteUser(const QString &username) { } #endif + connect(worker, &PFXHttpRequestWorker::downloadProgress, this, &PFXUserApi::downloadProgress); connect(worker, &PFXHttpRequestWorker::on_execution_finished, this, &PFXUserApi::deleteUserCallback); connect(this, &PFXUserApi::abortRequestsSignal, worker, &QObject::deleteLater); connect(worker, &QObject::destroyed, this, [this]() { @@ -582,6 +586,7 @@ void PFXUserApi::getUserByName(const QString &username) { } #endif + connect(worker, &PFXHttpRequestWorker::downloadProgress, this, &PFXUserApi::downloadProgress); connect(worker, &PFXHttpRequestWorker::on_execution_finished, this, &PFXUserApi::getUserByNameCallback); connect(this, &PFXUserApi::abortRequestsSignal, worker, &QObject::deleteLater); connect(worker, &QObject::destroyed, this, [this]() { @@ -688,6 +693,7 @@ void PFXUserApi::loginUser(const QString &username, const QString &password) { } #endif + connect(worker, &PFXHttpRequestWorker::downloadProgress, this, &PFXUserApi::downloadProgress); connect(worker, &PFXHttpRequestWorker::on_execution_finished, this, &PFXUserApi::loginUserCallback); connect(this, &PFXUserApi::abortRequestsSignal, worker, &QObject::deleteLater); connect(worker, &QObject::destroyed, this, [this]() { @@ -764,6 +770,7 @@ void PFXUserApi::logoutUser() { } #endif + connect(worker, &PFXHttpRequestWorker::downloadProgress, this, &PFXUserApi::downloadProgress); connect(worker, &PFXHttpRequestWorker::on_execution_finished, this, &PFXUserApi::logoutUserCallback); connect(this, &PFXUserApi::abortRequestsSignal, worker, &QObject::deleteLater); connect(worker, &QObject::destroyed, this, [this]() { @@ -857,6 +864,7 @@ void PFXUserApi::updateUser(const QString &username, const PFXUser &pfx_user) { } #endif + connect(worker, &PFXHttpRequestWorker::downloadProgress, this, &PFXUserApi::downloadProgress); connect(worker, &PFXHttpRequestWorker::on_execution_finished, this, &PFXUserApi::updateUserCallback); connect(this, &PFXUserApi::abortRequestsSignal, worker, &QObject::deleteLater); connect(worker, &QObject::destroyed, this, [this]() { diff --git a/samples/client/petstore/cpp-qt/client/PFXUserApi.h b/samples/client/petstore/cpp-qt/client/PFXUserApi.h index 552a683e142e..46b244592641 100644 --- a/samples/client/petstore/cpp-qt/client/PFXUserApi.h +++ b/samples/client/petstore/cpp-qt/client/PFXUserApi.h @@ -198,6 +198,7 @@ class PFXUserApi : public QObject { void updateUserSignalEFull(PFXHttpRequestWorker *worker, QNetworkReply::NetworkError error_type, QString error_str); void updateUserSignalErrorFull(PFXHttpRequestWorker *worker, QNetworkReply::NetworkError error_type, const QString &error_str); + void downloadProgress(qint64 bytesReceived, qint64 bytesTotal); void abortRequestsSignal(); void allPendingRequestsCompleted();