Skip to content

Commit

Permalink
Merge branch 'qt-progress-info' of https://github.com/Jazzco/openapi-…
Browse files Browse the repository at this point in the history
…generator into Jazzco-qt-progress-info30
  • Loading branch information
wing328 committed Aug 4, 2024
2 parents 49c9bec + 96c9b9c commit 2a37bb9
Show file tree
Hide file tree
Showing 15 changed files with 36 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/samples-cpp-qt-client.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ jobs:
target: "desktop"
- name: Build
working-directory: "samples/client/petstore/cpp-qt"
run: cmake . && cmake --build .
run: cmake . && cmake --build . --verbose
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,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::finished, [this, reply] {
on_reply_finished(reply);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ public:

Q_SIGNALS:
void on_execution_finished({{prefix}}HttpRequestWorker *worker);
void downloadProgress(qint64 bytesReceived, qint64 bytesTotal);

private:
enum {{prefix}}CompressionType{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -660,6 +660,8 @@ void {{classname}}::{{nickname}}({{#allParams}}{{#required}}const {{{dataType}}}
input.headers.insert(keyValueIt->first, keyValueIt->second);
}

{{#addDownloadProgress}}
connect(worker, &{{prefix}}HttpRequestWorker::downloadProgress, this, &{{classname}}::{{nickname}}Progress);{{/addDownloadProgress}}
connect(worker, &{{prefix}}HttpRequestWorker::on_execution_finished, this, &{{classname}}::{{nickname}}Callback);
connect(this, &{{classname}}::abortRequestsSignal, worker, &QObject::deleteLater);
connect(worker, &QObject::destroyed, this, [this]() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ private:
Q_SIGNALS:
{{#operations}}{{#operation}}
void {{nickname}}Signal({{#returnType}}{{{.}}} summary{{/returnType}});{{/operation}}{{/operations}}
{{#operations}}{{#operation}}{{#addDownloadProgress}}
void {{nickname}}Progress(qint64 bytesReceived, qint64 bytesTotal);{{/addDownloadProgress}}{{/operation}}{{/operations}}
{{#operations}}{{#operation}}
void {{nickname}}SignalFull({{prefix}}HttpRequestWorker *worker{{#returnType}}, {{{.}}} summary{{/returnType}});{{/operation}}{{/operations}}
{{#operations}}{{#operation}}
Expand Down
1 change: 1 addition & 0 deletions samples/client/petstore/cpp-qt/client/PFXHttpRequest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,7 @@ void PFXHttpRequestWorker::execute(PFXHttpRequestInput *input) {
}
if (reply != nullptr) {
reply->setParent(this);
connect(reply, &QNetworkReply::downloadProgress, this, &PFXHttpRequestWorker::downloadProgress);
connect(reply, &QNetworkReply::finished, [this, reply] {
on_reply_finished(reply);
});
Expand Down
1 change: 1 addition & 0 deletions samples/client/petstore/cpp-qt/client/PFXHttpRequest.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ class PFXHttpRequestWorker : public QObject {

Q_SIGNALS:
void on_execution_finished(PFXHttpRequestWorker *worker);
void downloadProgress(qint64 bytesReceived, qint64 bytesTotal);

private:
enum PFXCompressionType{
Expand Down
9 changes: 9 additions & 0 deletions samples/client/petstore/cpp-qt/client/PFXPetApi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@ void PFXPetApi::addPet(const PFXPet &pfx_pet) {
input.headers.insert(keyValueIt->first, keyValueIt->second);
}


connect(worker, &PFXHttpRequestWorker::on_execution_finished, this, &PFXPetApi::addPetCallback);
connect(this, &PFXPetApi::abortRequestsSignal, worker, &QObject::deleteLater);
connect(worker, &QObject::destroyed, this, [this]() {
Expand Down Expand Up @@ -348,6 +349,7 @@ void PFXPetApi::allPets() {
input.headers.insert(keyValueIt->first, keyValueIt->second);
}


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


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


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


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


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


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


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


connect(worker, &PFXHttpRequestWorker::on_execution_finished, this, &PFXPetApi::uploadFileCallback);
connect(this, &PFXPetApi::abortRequestsSignal, worker, &QObject::deleteLater);
connect(worker, &QObject::destroyed, this, [this]() {
Expand Down
1 change: 1 addition & 0 deletions samples/client/petstore/cpp-qt/client/PFXPetApi.h
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ class PFXPetApi : public QObject {
void updatePetWithFormSignal();
void uploadFileSignal(PFXApiResponse summary);


void addPetSignalFull(PFXHttpRequestWorker *worker);
void allPetsSignalFull(PFXHttpRequestWorker *worker, QSet<PFXPet> summary);
void deletePetSignalFull(PFXHttpRequestWorker *worker);
Expand Down
2 changes: 2 additions & 0 deletions samples/client/petstore/cpp-qt/client/PFXPrimitivesApi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ void PFXPrimitivesApi::primitivesIntegerPost(const ::test_namespace::OptionalPar
input.headers.insert(keyValueIt->first, keyValueIt->second);
}


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


connect(worker, &PFXHttpRequestWorker::on_execution_finished, this, &PFXPrimitivesApi::primitivesNumberPutCallback);
connect(this, &PFXPrimitivesApi::abortRequestsSignal, worker, &QObject::deleteLater);
connect(worker, &QObject::destroyed, this, [this]() {
Expand Down
1 change: 1 addition & 0 deletions samples/client/petstore/cpp-qt/client/PFXPrimitivesApi.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ class PFXPrimitivesApi : public QObject {
void primitivesIntegerPostSignal();
void primitivesNumberPutSignal();


void primitivesIntegerPostSignalFull(PFXHttpRequestWorker *worker);
void primitivesNumberPutSignalFull(PFXHttpRequestWorker *worker);

Expand Down
4 changes: 4 additions & 0 deletions samples/client/petstore/cpp-qt/client/PFXStoreApi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@ void PFXStoreApi::deleteOrder(const QString &order_id) {
input.headers.insert(keyValueIt->first, keyValueIt->second);
}


connect(worker, &PFXHttpRequestWorker::on_execution_finished, this, &PFXStoreApi::deleteOrderCallback);
connect(this, &PFXStoreApi::abortRequestsSignal, worker, &QObject::deleteLater);
connect(worker, &QObject::destroyed, this, [this]() {
Expand Down Expand Up @@ -311,6 +312,7 @@ void PFXStoreApi::getInventory() {
input.headers.insert(keyValueIt->first, keyValueIt->second);
}


connect(worker, &PFXHttpRequestWorker::on_execution_finished, this, &PFXStoreApi::getInventoryCallback);
connect(this, &PFXStoreApi::abortRequestsSignal, worker, &QObject::deleteLater);
connect(worker, &QObject::destroyed, this, [this]() {
Expand Down Expand Up @@ -403,6 +405,7 @@ void PFXStoreApi::getOrderById(const qint64 &order_id) {
input.headers.insert(keyValueIt->first, keyValueIt->second);
}


connect(worker, &PFXHttpRequestWorker::on_execution_finished, this, &PFXStoreApi::getOrderByIdCallback);
connect(this, &PFXStoreApi::abortRequestsSignal, worker, &QObject::deleteLater);
connect(worker, &QObject::destroyed, this, [this]() {
Expand Down Expand Up @@ -477,6 +480,7 @@ void PFXStoreApi::placeOrder(const PFXOrder &pfx_order) {
input.headers.insert(keyValueIt->first, keyValueIt->second);
}


connect(worker, &PFXHttpRequestWorker::on_execution_finished, this, &PFXStoreApi::placeOrderCallback);
connect(this, &PFXStoreApi::abortRequestsSignal, worker, &QObject::deleteLater);
connect(worker, &QObject::destroyed, this, [this]() {
Expand Down
1 change: 1 addition & 0 deletions samples/client/petstore/cpp-qt/client/PFXStoreApi.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ class PFXStoreApi : public QObject {
void getOrderByIdSignal(PFXOrder summary);
void placeOrderSignal(PFXOrder summary);


void deleteOrderSignalFull(PFXHttpRequestWorker *worker);
void getInventorySignalFull(PFXHttpRequestWorker *worker, QMap<QString, qint32> summary);
void getOrderByIdSignalFull(PFXHttpRequestWorker *worker, PFXOrder summary);
Expand Down
8 changes: 8 additions & 0 deletions samples/client/petstore/cpp-qt/client/PFXUserApi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@ void PFXUserApi::createUser(const PFXUser &pfx_user) {
input.headers.insert(keyValueIt->first, keyValueIt->second);
}


connect(worker, &PFXHttpRequestWorker::on_execution_finished, this, &PFXUserApi::createUserCallback);
connect(this, &PFXUserApi::abortRequestsSignal, worker, &QObject::deleteLater);
connect(worker, &QObject::destroyed, this, [this]() {
Expand Down Expand Up @@ -310,6 +311,7 @@ void PFXUserApi::createUsersWithArrayInput(const QList<PFXUser> &pfx_user) {
input.headers.insert(keyValueIt->first, keyValueIt->second);
}


connect(worker, &PFXHttpRequestWorker::on_execution_finished, this, &PFXUserApi::createUsersWithArrayInputCallback);
connect(this, &PFXUserApi::abortRequestsSignal, worker, &QObject::deleteLater);
connect(worker, &QObject::destroyed, this, [this]() {
Expand Down Expand Up @@ -382,6 +384,7 @@ void PFXUserApi::createUsersWithListInput(const QList<PFXUser> &pfx_user) {
input.headers.insert(keyValueIt->first, keyValueIt->second);
}


connect(worker, &PFXHttpRequestWorker::on_execution_finished, this, &PFXUserApi::createUsersWithListInputCallback);
connect(this, &PFXUserApi::abortRequestsSignal, worker, &QObject::deleteLater);
connect(worker, &QObject::destroyed, this, [this]() {
Expand Down Expand Up @@ -464,6 +467,7 @@ void PFXUserApi::deleteUser(const QString &username) {
input.headers.insert(keyValueIt->first, keyValueIt->second);
}


connect(worker, &PFXHttpRequestWorker::on_execution_finished, this, &PFXUserApi::deleteUserCallback);
connect(this, &PFXUserApi::abortRequestsSignal, worker, &QObject::deleteLater);
connect(worker, &QObject::destroyed, this, [this]() {
Expand Down Expand Up @@ -546,6 +550,7 @@ void PFXUserApi::getUserByName(const QString &username) {
input.headers.insert(keyValueIt->first, keyValueIt->second);
}


connect(worker, &PFXHttpRequestWorker::on_execution_finished, this, &PFXUserApi::getUserByNameCallback);
connect(this, &PFXUserApi::abortRequestsSignal, worker, &QObject::deleteLater);
connect(worker, &QObject::destroyed, this, [this]() {
Expand Down Expand Up @@ -646,6 +651,7 @@ void PFXUserApi::loginUser(const QString &username, const QString &password) {
input.headers.insert(keyValueIt->first, keyValueIt->second);
}


connect(worker, &PFXHttpRequestWorker::on_execution_finished, this, &PFXUserApi::loginUserCallback);
connect(this, &PFXUserApi::abortRequestsSignal, worker, &QObject::deleteLater);
connect(worker, &QObject::destroyed, this, [this]() {
Expand Down Expand Up @@ -716,6 +722,7 @@ void PFXUserApi::logoutUser() {
input.headers.insert(keyValueIt->first, keyValueIt->second);
}


connect(worker, &PFXHttpRequestWorker::on_execution_finished, this, &PFXUserApi::logoutUserCallback);
connect(this, &PFXUserApi::abortRequestsSignal, worker, &QObject::deleteLater);
connect(worker, &QObject::destroyed, this, [this]() {
Expand Down Expand Up @@ -803,6 +810,7 @@ void PFXUserApi::updateUser(const QString &username, const PFXUser &pfx_user) {
input.headers.insert(keyValueIt->first, keyValueIt->second);
}


connect(worker, &PFXHttpRequestWorker::on_execution_finished, this, &PFXUserApi::updateUserCallback);
connect(this, &PFXUserApi::abortRequestsSignal, worker, &QObject::deleteLater);
connect(worker, &QObject::destroyed, this, [this]() {
Expand Down
1 change: 1 addition & 0 deletions samples/client/petstore/cpp-qt/client/PFXUserApi.h
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ class PFXUserApi : public QObject {
void logoutUserSignal();
void updateUserSignal();


void createUserSignalFull(PFXHttpRequestWorker *worker);
void createUsersWithArrayInputSignalFull(PFXHttpRequestWorker *worker);
void createUsersWithListInputSignalFull(PFXHttpRequestWorker *worker);
Expand Down

0 comments on commit 2a37bb9

Please sign in to comment.