From c01bd18b5f570772850569462215530b8aba02a8 2017-07-13 08:18:09 From: Alexandre Leroux Date: 2017-07-13 08:18:09 Subject: [PATCH] Amda provider cleaning Removes unnecessary private impl --- diff --git a/plugins/amda/include/AmdaProvider.h b/plugins/amda/include/AmdaProvider.h index 7999f62..3b72488 100644 --- a/plugins/amda/include/AmdaProvider.h +++ b/plugins/amda/include/AmdaProvider.h @@ -3,8 +3,6 @@ #include "AmdaGlobal.h" -#include - #include #include @@ -25,14 +23,6 @@ public: private: void retrieveData(QUuid token, const SqpDateTime &dateTime); - - class AmdaProviderPrivate; - spimpl::unique_impl_ptr impl; - - // private slots: - // void httpFinished(QNetworkReply *reply, QUuid dataId) noexcept; - // void httpDownloadFinished(QNetworkReply *reply, QUuid dataId) noexcept; - // void httpDownloadReadyRead(QNetworkReply *reply, QUuid dataId) noexcept; }; #endif // SCIQLOP_AMDAPROVIDER_H diff --git a/plugins/amda/src/AmdaProvider.cpp b/plugins/amda/src/AmdaProvider.cpp index 415df87..d555550 100644 --- a/plugins/amda/src/AmdaProvider.cpp +++ b/plugins/amda/src/AmdaProvider.cpp @@ -34,18 +34,9 @@ QString dateFormat(double sqpDateTime) noexcept return dateTime.toString(AMDA_TIME_FORMAT); } - } // namespace -struct AmdaProvider::AmdaProviderPrivate { - SqpDateTime m_DateTime{}; - std::unique_ptr m_AccessManager{nullptr}; - QNetworkReply *m_Reply{nullptr}; - // std::unique_ptr m_File{nullptr}; - QUuid m_Token; -}; - -AmdaProvider::AmdaProvider() : impl{spimpl::make_unique_impl()} +AmdaProvider::AmdaProvider() { qCDebug(LOG_NetworkController()) << tr("AmdaProvider::AmdaProvider") << QThread::currentThread(); @@ -79,30 +70,31 @@ void AmdaProvider::retrieveData(QUuid token, const SqpDateTime &dateTime) auto tempFile = std::make_shared(); - // LAMBDA - auto httpDownloadFinished = [this, tempFile](QNetworkReply *reply, QUuid dataId) noexcept { - - if (tempFile) { - auto replyReadAll = reply->readAll(); - if (!replyReadAll.isEmpty()) { - tempFile->write(replyReadAll); - } - tempFile->close(); - - // Parse results file - if (auto dataSeries = AmdaResultParser::readTxt(tempFile->fileName())) { - emit dataProvided(impl->m_Token, dataSeries, impl->m_DateTime); - } - else { - /// @todo ALX : debug - } - } - - // Deletes reply - reply->deleteLater(); - reply = nullptr; - }; + auto httpDownloadFinished + = [this, dateTime, tempFile, token](QNetworkReply *reply, QUuid dataId) noexcept { + Q_UNUSED(dataId); + + if (tempFile) { + auto replyReadAll = reply->readAll(); + if (!replyReadAll.isEmpty()) { + tempFile->write(replyReadAll); + } + tempFile->close(); + + // Parse results file + if (auto dataSeries = AmdaResultParser::readTxt(tempFile->fileName())) { + emit dataProvided(token, dataSeries, dateTime); + } + else { + /// @todo ALX : debug + } + } + + // Deletes reply + reply->deleteLater(); + reply = nullptr; + }; auto httpFinishedLambda = [this, httpDownloadFinished, tempFile](QNetworkReply *reply, QUuid dataId) noexcept { @@ -122,8 +114,5 @@ void AmdaProvider::retrieveData(QUuid token, const SqpDateTime &dateTime) // //////////////// // // Executes request // // //////////////// // - - impl->m_Token = token; - impl->m_DateTime = dateTime; emit requestConstructed(QNetworkRequest{url}, token, httpFinishedLambda); }