##// END OF EJS Templates
Amda provider cleaning...
Alexandre Leroux -
r409:c01bd18b5f57
parent child
Show More
@@ -3,8 +3,6
3
3
4 #include "AmdaGlobal.h"
4 #include "AmdaGlobal.h"
5
5
6 #include <Common/spimpl.h>
7
8 #include <Data/IDataProvider.h>
6 #include <Data/IDataProvider.h>
9
7
10 #include <QLoggingCategory>
8 #include <QLoggingCategory>
@@ -25,14 +23,6 public:
25
23
26 private:
24 private:
27 void retrieveData(QUuid token, const SqpDateTime &dateTime);
25 void retrieveData(QUuid token, const SqpDateTime &dateTime);
28
29 class AmdaProviderPrivate;
30 spimpl::unique_impl_ptr<AmdaProviderPrivate> impl;
31
32 // private slots:
33 // void httpFinished(QNetworkReply *reply, QUuid dataId) noexcept;
34 // void httpDownloadFinished(QNetworkReply *reply, QUuid dataId) noexcept;
35 // void httpDownloadReadyRead(QNetworkReply *reply, QUuid dataId) noexcept;
36 };
26 };
37
27
38 #endif // SCIQLOP_AMDAPROVIDER_H
28 #endif // SCIQLOP_AMDAPROVIDER_H
@@ -34,18 +34,9 QString dateFormat(double sqpDateTime) noexcept
34 return dateTime.toString(AMDA_TIME_FORMAT);
34 return dateTime.toString(AMDA_TIME_FORMAT);
35 }
35 }
36
36
37
38 } // namespace
37 } // namespace
39
38
40 struct AmdaProvider::AmdaProviderPrivate {
39 AmdaProvider::AmdaProvider()
41 SqpDateTime m_DateTime{};
42 std::unique_ptr<QNetworkAccessManager> m_AccessManager{nullptr};
43 QNetworkReply *m_Reply{nullptr};
44 // std::unique_ptr<QTemporaryFile> m_File{nullptr};
45 QUuid m_Token;
46 };
47
48 AmdaProvider::AmdaProvider() : impl{spimpl::make_unique_impl<AmdaProviderPrivate>()}
49 {
40 {
50 qCDebug(LOG_NetworkController()) << tr("AmdaProvider::AmdaProvider")
41 qCDebug(LOG_NetworkController()) << tr("AmdaProvider::AmdaProvider")
51 << QThread::currentThread();
42 << QThread::currentThread();
@@ -79,9 +70,10 void AmdaProvider::retrieveData(QUuid token, const SqpDateTime &dateTime)
79
70
80 auto tempFile = std::make_shared<QTemporaryFile>();
71 auto tempFile = std::make_shared<QTemporaryFile>();
81
72
82
83 // LAMBDA
73 // LAMBDA
84 auto httpDownloadFinished = [this, tempFile](QNetworkReply *reply, QUuid dataId) noexcept {
74 auto httpDownloadFinished
75 = [this, dateTime, tempFile, token](QNetworkReply *reply, QUuid dataId) noexcept {
76 Q_UNUSED(dataId);
85
77
86 if (tempFile) {
78 if (tempFile) {
87 auto replyReadAll = reply->readAll();
79 auto replyReadAll = reply->readAll();
@@ -92,7 +84,7 void AmdaProvider::retrieveData(QUuid token, const SqpDateTime &dateTime)
92
84
93 // Parse results file
85 // Parse results file
94 if (auto dataSeries = AmdaResultParser::readTxt(tempFile->fileName())) {
86 if (auto dataSeries = AmdaResultParser::readTxt(tempFile->fileName())) {
95 emit dataProvided(impl->m_Token, dataSeries, impl->m_DateTime);
87 emit dataProvided(token, dataSeries, dateTime);
96 }
88 }
97 else {
89 else {
98 /// @todo ALX : debug
90 /// @todo ALX : debug
@@ -122,8 +114,5 void AmdaProvider::retrieveData(QUuid token, const SqpDateTime &dateTime)
122 // //////////////// //
114 // //////////////// //
123 // Executes request //
115 // Executes request //
124 // //////////////// //
116 // //////////////// //
125
126 impl->m_Token = token;
127 impl->m_DateTime = dateTime;
128 emit requestConstructed(QNetworkRequest{url}, token, httpFinishedLambda);
117 emit requestConstructed(QNetworkRequest{url}, token, httpFinishedLambda);
129 }
118 }
General Comments 0
You need to be logged in to leave comments. Login now