@@ -34,6 +34,11 public: | |||||
34 | */ |
|
34 | */ | |
35 | virtual void requestDataLoading(QUuid identifier, const DataProviderParameters ¶meters) = 0; |
|
35 | virtual void requestDataLoading(QUuid identifier, const DataProviderParameters ¶meters) = 0; | |
36 |
|
36 | |||
|
37 | /** | |||
|
38 | * @brief requestDataAborting stop data loading of the data identified by identifier | |||
|
39 | */ | |||
|
40 | virtual void requestDataAborting(QUuid identifier) = 0; | |||
|
41 | ||||
37 | signals: |
|
42 | signals: | |
38 | /** |
|
43 | /** | |
39 | * @brief dataProvided send dataSeries under dateTime and that corresponds of the data |
|
44 | * @brief dataProvided send dataSeries under dateTime and that corresponds of the data |
@@ -50,6 +50,11 public: | |||||
50 | */ |
|
50 | */ | |
51 | void deleteVariables(const QVector<std::shared_ptr<Variable> > &variables) noexcept; |
|
51 | void deleteVariables(const QVector<std::shared_ptr<Variable> > &variables) noexcept; | |
52 |
|
52 | |||
|
53 | /** | |||
|
54 | * @brief abort the variable retrieve data progression | |||
|
55 | */ | |||
|
56 | void abortProgress(std::shared_ptr<Variable> variable); | |||
|
57 | ||||
53 | signals: |
|
58 | signals: | |
54 | /// Signal emitted when a variable is about to be deleted from the controller |
|
59 | /// Signal emitted when a variable is about to be deleted from the controller | |
55 | void variableAboutToBeDeleted(std::shared_ptr<Variable> variable); |
|
60 | void variableAboutToBeDeleted(std::shared_ptr<Variable> variable); | |
@@ -72,6 +77,8 public slots: | |||||
72 |
|
77 | |||
73 | void onVariableRetrieveDataInProgress(QUuid identifier, double progress); |
|
78 | void onVariableRetrieveDataInProgress(QUuid identifier, double progress); | |
74 |
|
79 | |||
|
80 | void onAbortProgressRequested(std::shared_ptr<Variable> variable); | |||
|
81 | ||||
75 | void initialize(); |
|
82 | void initialize(); | |
76 | void finalize(); |
|
83 | void finalize(); | |
77 |
|
84 |
@@ -22,6 +22,7 class Variable; | |||||
22 | * @brief The VariableModel class aims to hold the variables that have been created in SciQlop |
|
22 | * @brief The VariableModel class aims to hold the variables that have been created in SciQlop | |
23 | */ |
|
23 | */ | |
24 | class VariableModel : public QAbstractTableModel { |
|
24 | class VariableModel : public QAbstractTableModel { | |
|
25 | Q_OBJECT | |||
25 | public: |
|
26 | public: | |
26 | explicit VariableModel(QObject *parent = nullptr); |
|
27 | explicit VariableModel(QObject *parent = nullptr); | |
27 |
|
28 | |||
@@ -46,6 +47,7 public: | |||||
46 |
|
47 | |||
47 | void setDataProgress(std::shared_ptr<Variable> variable, double progress); |
|
48 | void setDataProgress(std::shared_ptr<Variable> variable, double progress); | |
48 |
|
49 | |||
|
50 | ||||
49 | // /////////////////////////// // |
|
51 | // /////////////////////////// // | |
50 | // QAbstractTableModel methods // |
|
52 | // QAbstractTableModel methods // | |
51 | // /////////////////////////// // |
|
53 | // /////////////////////////// // | |
@@ -56,6 +58,12 public: | |||||
56 | virtual QVariant headerData(int section, Qt::Orientation orientation, |
|
58 | virtual QVariant headerData(int section, Qt::Orientation orientation, | |
57 | int role = Qt::DisplayRole) const override; |
|
59 | int role = Qt::DisplayRole) const override; | |
58 |
|
60 | |||
|
61 | ||||
|
62 | void abortProgress(const QModelIndex &index); | |||
|
63 | ||||
|
64 | signals: | |||
|
65 | void abortProgessRequested(std::shared_ptr<Variable> variable); | |||
|
66 | ||||
59 | private: |
|
67 | private: | |
60 | class VariableModelPrivate; |
|
68 | class VariableModelPrivate; | |
61 | spimpl::unique_impl_ptr<VariableModelPrivate> impl; |
|
69 | spimpl::unique_impl_ptr<VariableModelPrivate> impl; |
@@ -46,6 +46,9 VariableController::VariableController(QObject *parent) | |||||
46 | { |
|
46 | { | |
47 | qCDebug(LOG_VariableController()) << tr("VariableController construction") |
|
47 | qCDebug(LOG_VariableController()) << tr("VariableController construction") | |
48 | << QThread::currentThread(); |
|
48 | << QThread::currentThread(); | |
|
49 | ||||
|
50 | connect(impl->m_VariableModel, &VariableModel::abortProgessRequested, this, | |||
|
51 | &VariableController::onAbortProgressRequested); | |||
49 | } |
|
52 | } | |
50 |
|
53 | |||
51 | VariableController::~VariableController() |
|
54 | VariableController::~VariableController() | |
@@ -105,6 +108,10 void VariableController::deleteVariables( | |||||
105 | } |
|
108 | } | |
106 | } |
|
109 | } | |
107 |
|
110 | |||
|
111 | void VariableController::abortProgress(std::shared_ptr<Variable> variable) | |||
|
112 | { | |||
|
113 | } | |||
|
114 | ||||
108 | void VariableController::createVariable(const QString &name, const QVariantHash &metadata, |
|
115 | void VariableController::createVariable(const QString &name, const QVariantHash &metadata, | |
109 | std::shared_ptr<IDataProvider> provider) noexcept |
|
116 | std::shared_ptr<IDataProvider> provider) noexcept | |
110 | { |
|
117 | { | |
@@ -166,6 +173,22 void VariableController::onVariableRetrieveDataInProgress(QUuid identifier, doub | |||||
166 | } |
|
173 | } | |
167 | } |
|
174 | } | |
168 |
|
175 | |||
|
176 | void VariableController::onAbortProgressRequested(std::shared_ptr<Variable> variable) | |||
|
177 | { | |||
|
178 | qCDebug(LOG_VariableController()) << "TORM: VariableController::onAbortProgressRequested" | |||
|
179 | << QThread::currentThread()->objectName(); | |||
|
180 | ||||
|
181 | auto it = impl->m_VariableToIdentifier.find(variable); | |||
|
182 | if (it != impl->m_VariableToIdentifier.cend()) { | |||
|
183 | impl->m_VariableToProviderMap.at(variable)->requestDataAborting(it->second); | |||
|
184 | } | |||
|
185 | else { | |||
|
186 | qCWarning(LOG_VariableController()) | |||
|
187 | << tr("Aborting progression of inexistant variable detected !!!") | |||
|
188 | << QThread::currentThread()->objectName(); | |||
|
189 | } | |||
|
190 | } | |||
|
191 | ||||
169 |
|
192 | |||
170 | void VariableController::onRequestDataLoading(std::shared_ptr<Variable> variable, |
|
193 | void VariableController::onRequestDataLoading(std::shared_ptr<Variable> variable, | |
171 | const SqpDateTime &dateTime) |
|
194 | const SqpDateTime &dateTime) |
@@ -205,6 +205,13 QVariant VariableModel::headerData(int section, Qt::Orientation orientation, int | |||||
205 | return QVariant{}; |
|
205 | return QVariant{}; | |
206 | } |
|
206 | } | |
207 |
|
207 | |||
|
208 | void VariableModel::abortProgress(const QModelIndex &index) | |||
|
209 | { | |||
|
210 | if (auto variable = impl->m_Variables.at(index.row())) { | |||
|
211 | emit abortProgessRequested(variable); | |||
|
212 | } | |||
|
213 | } | |||
|
214 | ||||
208 | void VariableModel::onVariableUpdated() noexcept |
|
215 | void VariableModel::onVariableUpdated() noexcept | |
209 | { |
|
216 | { | |
210 | // Finds variable that has been updated in the model |
|
217 | // Finds variable that has been updated in the model |
@@ -5,6 +5,7 | |||||
5 |
|
5 | |||
6 | #include <ui_VariableInspectorWidget.h> |
|
6 | #include <ui_VariableInspectorWidget.h> | |
7 |
|
7 | |||
|
8 | #include <QMouseEvent> | |||
8 | #include <QSortFilterProxyModel> |
|
9 | #include <QSortFilterProxyModel> | |
9 | #include <QStyledItemDelegate> |
|
10 | #include <QStyledItemDelegate> | |
10 | #include <QWidgetAction> |
|
11 | #include <QWidgetAction> | |
@@ -27,9 +28,12 public: | |||||
27 | if (data.isValid() && progressData.isValid()) { |
|
28 | if (data.isValid() && progressData.isValid()) { | |
28 | auto name = data.value<QString>(); |
|
29 | auto name = data.value<QString>(); | |
29 | auto progress = progressData.value<double>(); |
|
30 | auto progress = progressData.value<double>(); | |
30 |
if (progress > |
|
31 | if (progress > 0) { | |
|
32 | auto cancelButtonWidth = 20; | |||
31 | auto progressBarOption = QStyleOptionProgressBar{}; |
|
33 | auto progressBarOption = QStyleOptionProgressBar{}; | |
32 |
progress |
|
34 | auto progressRect = option.rect; | |
|
35 | progressRect.setWidth(progressRect.width() - cancelButtonWidth); | |||
|
36 | progressBarOption.rect = progressRect; | |||
33 | progressBarOption.minimum = 0; |
|
37 | progressBarOption.minimum = 0; | |
34 | progressBarOption.maximum = 100; |
|
38 | progressBarOption.maximum = 100; | |
35 | progressBarOption.progress = progress; |
|
39 | progressBarOption.progress = progress; | |
@@ -38,14 +42,70 public: | |||||
38 | progressBarOption.textVisible = true; |
|
42 | progressBarOption.textVisible = true; | |
39 | progressBarOption.textAlignment = Qt::AlignCenter; |
|
43 | progressBarOption.textAlignment = Qt::AlignCenter; | |
40 |
|
44 | |||
|
45 | ||||
41 | QApplication::style()->drawControl(QStyle::CE_ProgressBar, &progressBarOption, |
|
46 | QApplication::style()->drawControl(QStyle::CE_ProgressBar, &progressBarOption, | |
42 | painter); |
|
47 | painter); | |
|
48 | ||||
|
49 | // Cancel button | |||
|
50 | auto buttonRect = QRect(progressRect.right(), option.rect.top(), cancelButtonWidth, | |||
|
51 | option.rect.height()); | |||
|
52 | auto buttonOption = QStyleOptionButton{}; | |||
|
53 | buttonOption.rect = buttonRect; | |||
|
54 | buttonOption.text = "X"; | |||
|
55 | ||||
|
56 | QApplication::style()->drawControl(QStyle::CE_PushButton, &buttonOption, painter); | |||
|
57 | } | |||
|
58 | else { | |||
|
59 | QStyledItemDelegate::paint(painter, option, index); | |||
43 | } |
|
60 | } | |
44 | } |
|
61 | } | |
45 | else { |
|
62 | else { | |
46 | QStyledItemDelegate::paint(painter, option, index); |
|
63 | QStyledItemDelegate::paint(painter, option, index); | |
47 | } |
|
64 | } | |
48 | } |
|
65 | } | |
|
66 | ||||
|
67 | bool editorEvent(QEvent *event, QAbstractItemModel *model, const QStyleOptionViewItem &option, | |||
|
68 | const QModelIndex &index) | |||
|
69 | { | |||
|
70 | if (event->type() == QEvent::MouseButtonRelease) { | |||
|
71 | auto data = index.data(Qt::DisplayRole); | |||
|
72 | auto progressData = index.data(VariableRoles::ProgressRole); | |||
|
73 | if (data.isValid() && progressData.isValid()) { | |||
|
74 | auto cancelButtonWidth = 20; | |||
|
75 | auto progressRect = option.rect; | |||
|
76 | progressRect.setWidth(progressRect.width() - cancelButtonWidth); | |||
|
77 | // Cancel button | |||
|
78 | auto buttonRect = QRect(progressRect.right(), option.rect.top(), cancelButtonWidth, | |||
|
79 | option.rect.height()); | |||
|
80 | ||||
|
81 | QMouseEvent *e = (QMouseEvent *)event; | |||
|
82 | int clickX = e->x(); | |||
|
83 | int clickY = e->y(); | |||
|
84 | ||||
|
85 | auto x = buttonRect.left(); // the X coordinate | |||
|
86 | auto y = buttonRect.top(); // the Y coordinate | |||
|
87 | auto w = buttonRect.width(); // button width | |||
|
88 | auto h = buttonRect.height(); // button height | |||
|
89 | ||||
|
90 | if (clickX > x && clickX < x + w) { | |||
|
91 | if (clickY > y && clickY < y + h) { | |||
|
92 | qCritical(LOG_VariableInspectorWidget()) << tr("editorEvent CLIC"); | |||
|
93 | auto variableModel = sqpApp->variableController().variableModel(); | |||
|
94 | variableModel->abortProgress(index); | |||
|
95 | } | |||
|
96 | } | |||
|
97 | else { | |||
|
98 | QStyledItemDelegate::editorEvent(event, model, option, index); | |||
|
99 | } | |||
|
100 | } | |||
|
101 | else { | |||
|
102 | QStyledItemDelegate::editorEvent(event, model, option, index); | |||
|
103 | } | |||
|
104 | } | |||
|
105 | else { | |||
|
106 | QStyledItemDelegate::editorEvent(event, model, option, index); | |||
|
107 | } | |||
|
108 | } | |||
49 | }; |
|
109 | }; | |
50 |
|
110 | |||
51 | VariableInspectorWidget::VariableInspectorWidget(QWidget *parent) |
|
111 | VariableInspectorWidget::VariableInspectorWidget(QWidget *parent) |
@@ -21,6 +21,8 public: | |||||
21 |
|
21 | |||
22 | void requestDataLoading(QUuid token, const DataProviderParameters ¶meters) override; |
|
22 | void requestDataLoading(QUuid token, const DataProviderParameters ¶meters) override; | |
23 |
|
23 | |||
|
24 | void requestDataAborting(QUuid identifier) override; | |||
|
25 | ||||
24 | private: |
|
26 | private: | |
25 | void retrieveData(QUuid token, const SqpDateTime &dateTime, const QVariantHash &data); |
|
27 | void retrieveData(QUuid token, const SqpDateTime &dateTime, const QVariantHash &data); | |
26 | }; |
|
28 | }; |
@@ -61,6 +61,14 void AmdaProvider::requestDataLoading(QUuid token, const DataProviderParameters | |||||
61 | } |
|
61 | } | |
62 | } |
|
62 | } | |
63 |
|
63 | |||
|
64 | void AmdaProvider::requestDataAborting(QUuid identifier) | |||
|
65 | { | |||
|
66 | if (auto app = sqpApp) { | |||
|
67 | auto &networkController = app->networkController(); | |||
|
68 | networkController.onReplyCanceled(identifier); | |||
|
69 | } | |||
|
70 | } | |||
|
71 | ||||
64 | void AmdaProvider::retrieveData(QUuid token, const SqpDateTime &dateTime, const QVariantHash &data) |
|
72 | void AmdaProvider::retrieveData(QUuid token, const SqpDateTime &dateTime, const QVariantHash &data) | |
65 | { |
|
73 | { | |
66 | // Retrieves product ID from data: if the value is invalid, no request is made |
|
74 | // Retrieves product ID from data: if the value is invalid, no request is made | |
@@ -102,16 +110,13 void AmdaProvider::retrieveData(QUuid token, const SqpDateTime &dateTime, const | |||||
102 | } |
|
110 | } | |
103 | } |
|
111 | } | |
104 |
|
112 | |||
105 | // Deletes reply |
|
113 | ||
106 | reply->deleteLater(); |
|
|||
107 | reply = nullptr; |
|
|||
108 | }; |
|
114 | }; | |
109 | auto httpFinishedLambda = [this, httpDownloadFinished, tempFile](QNetworkReply *reply, |
|
115 | auto httpFinishedLambda = [this, httpDownloadFinished, tempFile](QNetworkReply *reply, | |
110 | QUuid dataId) noexcept { |
|
116 | QUuid dataId) noexcept { | |
111 |
|
117 | |||
112 | auto downloadFileUrl = QUrl{QString{reply->readAll()}}; |
|
118 | auto downloadFileUrl = QUrl{QString{reply->readAll()}}; | |
113 | // Deletes old reply |
|
119 | ||
114 | reply->deleteLater(); |
|
|||
115 |
|
120 | |||
116 | // Executes request for downloading file // |
|
121 | // Executes request for downloading file // | |
117 |
|
122 |
@@ -17,6 +17,9 public: | |||||
17 | void requestDataLoading(QUuid token, const DataProviderParameters ¶meters) override; |
|
17 | void requestDataLoading(QUuid token, const DataProviderParameters ¶meters) override; | |
18 |
|
18 | |||
19 |
|
19 | |||
|
20 | void requestDataAborting(QUuid identifier) override; | |||
|
21 | ||||
|
22 | ||||
20 | private: |
|
23 | private: | |
21 | /// @sa IDataProvider::retrieveData() |
|
24 | /// @sa IDataProvider::retrieveData() | |
22 | std::shared_ptr<IDataSeries> retrieveData(const SqpDateTime &dateTime) const; |
|
25 | std::shared_ptr<IDataSeries> retrieveData(const SqpDateTime &dateTime) const; |
@@ -46,3 +46,8 void CosinusProvider::requestDataLoading(QUuid token, const DataProviderParamete | |||||
46 | emit dataProvided(token, scalarSeries, dateTime); |
|
46 | emit dataProvided(token, scalarSeries, dateTime); | |
47 | } |
|
47 | } | |
48 | } |
|
48 | } | |
|
49 | ||||
|
50 | void CosinusProvider::requestDataAborting(QUuid identifier) | |||
|
51 | { | |||
|
52 | // TODO | |||
|
53 | } |
General Comments 0
You need to be logged in to leave comments.
Login now