##// END OF EJS Templates
Implement of the abort download process
perrinel -
r388:ff0aebb946e3
parent child
Show More
@@ -34,6 +34,11 public:
34 34 */
35 35 virtual void requestDataLoading(QUuid identifier, const DataProviderParameters &parameters) = 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 42 signals:
38 43 /**
39 44 * @brief dataProvided send dataSeries under dateTime and that corresponds of the data
@@ -50,6 +50,11 public:
50 50 */
51 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 58 signals:
54 59 /// Signal emitted when a variable is about to be deleted from the controller
55 60 void variableAboutToBeDeleted(std::shared_ptr<Variable> variable);
@@ -72,6 +77,8 public slots:
72 77
73 78 void onVariableRetrieveDataInProgress(QUuid identifier, double progress);
74 79
80 void onAbortProgressRequested(std::shared_ptr<Variable> variable);
81
75 82 void initialize();
76 83 void finalize();
77 84
@@ -22,6 +22,7 class Variable;
22 22 * @brief The VariableModel class aims to hold the variables that have been created in SciQlop
23 23 */
24 24 class VariableModel : public QAbstractTableModel {
25 Q_OBJECT
25 26 public:
26 27 explicit VariableModel(QObject *parent = nullptr);
27 28
@@ -46,6 +47,7 public:
46 47
47 48 void setDataProgress(std::shared_ptr<Variable> variable, double progress);
48 49
50
49 51 // /////////////////////////// //
50 52 // QAbstractTableModel methods //
51 53 // /////////////////////////// //
@@ -56,6 +58,12 public:
56 58 virtual QVariant headerData(int section, Qt::Orientation orientation,
57 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 67 private:
60 68 class VariableModelPrivate;
61 69 spimpl::unique_impl_ptr<VariableModelPrivate> impl;
@@ -46,6 +46,9 VariableController::VariableController(QObject *parent)
46 46 {
47 47 qCDebug(LOG_VariableController()) << tr("VariableController construction")
48 48 << QThread::currentThread();
49
50 connect(impl->m_VariableModel, &VariableModel::abortProgessRequested, this,
51 &VariableController::onAbortProgressRequested);
49 52 }
50 53
51 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 115 void VariableController::createVariable(const QString &name, const QVariantHash &metadata,
109 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 193 void VariableController::onRequestDataLoading(std::shared_ptr<Variable> variable,
171 194 const SqpDateTime &dateTime)
@@ -205,6 +205,13 QVariant VariableModel::headerData(int section, Qt::Orientation orientation, int
205 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 215 void VariableModel::onVariableUpdated() noexcept
209 216 {
210 217 // Finds variable that has been updated in the model
@@ -5,6 +5,7
5 5
6 6 #include <ui_VariableInspectorWidget.h>
7 7
8 #include <QMouseEvent>
8 9 #include <QSortFilterProxyModel>
9 10 #include <QStyledItemDelegate>
10 11 #include <QWidgetAction>
@@ -27,9 +28,12 public:
27 28 if (data.isValid() && progressData.isValid()) {
28 29 auto name = data.value<QString>();
29 30 auto progress = progressData.value<double>();
30 if (progress >= 0) {
31 if (progress > 0) {
32 auto cancelButtonWidth = 20;
31 33 auto progressBarOption = QStyleOptionProgressBar{};
32 progressBarOption.rect = option.rect;
34 auto progressRect = option.rect;
35 progressRect.setWidth(progressRect.width() - cancelButtonWidth);
36 progressBarOption.rect = progressRect;
33 37 progressBarOption.minimum = 0;
34 38 progressBarOption.maximum = 100;
35 39 progressBarOption.progress = progress;
@@ -38,14 +42,70 public:
38 42 progressBarOption.textVisible = true;
39 43 progressBarOption.textAlignment = Qt::AlignCenter;
40 44
45
41 46 QApplication::style()->drawControl(QStyle::CE_ProgressBar, &progressBarOption,
42 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 62 else {
46 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();
note

ok

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");
note

remove

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 111 VariableInspectorWidget::VariableInspectorWidget(QWidget *parent)
@@ -21,6 +21,8 public:
21 21
22 22 void requestDataLoading(QUuid token, const DataProviderParameters &parameters) override;
23 23
24 void requestDataAborting(QUuid identifier) override;
25
24 26 private:
25 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 72 void AmdaProvider::retrieveData(QUuid token, const SqpDateTime &dateTime, const QVariantHash &data)
65 73 {
66 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
106 reply->deleteLater();
107 reply = nullptr;
113
108 114 };
109 115 auto httpFinishedLambda = [this, httpDownloadFinished, tempFile](QNetworkReply *reply,
110 116 QUuid dataId) noexcept {
111 117
112 118 auto downloadFileUrl = QUrl{QString{reply->readAll()}};
113 // Deletes old reply
114 reply->deleteLater();
119
115 120
116 121 // Executes request for downloading file //
117 122
@@ -17,6 +17,9 public:
17 17 void requestDataLoading(QUuid token, const DataProviderParameters &parameters) override;
18 18
19 19
20 void requestDataAborting(QUuid identifier) override;
21
22
20 23 private:
21 24 /// @sa IDataProvider::retrieveData()
22 25 std::shared_ptr<IDataSeries> retrieveData(const SqpDateTime &dateTime) const;
@@ -46,3 +46,8 void CosinusProvider::requestDataLoading(QUuid token, const DataProviderParamete
46 46 emit dataProvided(token, scalarSeries, dateTime);
47 47 }
48 48 }
49
50 void CosinusProvider::requestDataAborting(QUuid identifier)
51 {
52 // TODO
53 }
General Comments 3
Under Review
author

Pull request updated. Auto status change to "Under Review"

Changed commits:
  * 3 added
  * 0 removed

Changed files:
  * A plugins/amda/tests-resources/TestAmdaResultParser/FileNotFound.txt
  * M gui/src/Visualization/operations/RescaleAxeOperation.cpp
  * M app/src/MainWindow.cpp
  * M core/include/Data/IDataProvider.h
  * M core/include/DataSource/DataSourceItemAction.h
  * M core/include/Variable/VariableController.h
  * M core/include/Variable/VariableModel.h
  * M core/include/Visualization/VisualizationController.h
  * M core/src/Network/NetworkController.cpp
  * M core/src/Variable/Variable.cpp
  * M core/src/Variable/VariableController.cpp
  * M core/src/Variable/VariableModel.cpp
  * M gui/include/Visualization/VisualizationGraphWidget.h
  * M gui/include/Visualization/VisualizationWidget.h
  * M gui/src/SqpApplication.cpp
  * M gui/src/Variable/VariableInspectorWidget.cpp
  * M gui/src/Visualization/VisualizationGraphHelper.cpp
  * M gui/src/Visualization/VisualizationGraphWidget.cpp
  * M gui/src/Visualization/VisualizationWidget.cpp
  * M gui/src/Visualization/VisualizationZoneWidget.cpp
  * M plugins/amda/include/AmdaProvider.h
  * M plugins/amda/src/AmdaProvider.cpp
  * M plugins/amda/src/AmdaResultParser.cpp
  * M plugins/amda/tests/TestAmdaResultParser.cpp
  * M plugins/mockplugin/include/CosinusProvider.h
  * M plugins/mockplugin/src/CosinusProvider.cpp
  * R COPYING
  * R app/ui/MainWindow.ui
  * R cmake/sciqlop_package_qt.cmake
  * R core/include/Common/MetaTypes.h
  * R core/include/Data/ArrayData.h
  * R core/include/Data/DataProviderParameters.h
  * R core/include/Data/DataSeries.h
  * R core/include/Data/IDataSeries.h
  * R core/include/Data/ScalarSeries.h
  * R core/include/Data/SqpDateTime.h
  * R core/include/Network/NetworkController.h
  * R core/include/Plugin/PluginManager.h
  * R core/include/Time/TimeController.h
  * R core/include/Variable/Variable.h
  * R core/include/Variable/VariableCacheController.h
  * R core/src/Data/ScalarSeries.cpp
  * R core/src/DataSource/DataSourceItemAction.cpp
  * R core/src/Plugin/PluginManager.cpp
  * R core/src/Time/TimeController.cpp
  * R core/src/Variable/VariableCacheController.cpp
  * R core/src/Visualization/VisualizationController.cpp
  * R core/tests/Variable/TestVariableCacheController.cpp
  * R gui/include/DataSource/DataSourceTreeWidgetItem.h
  * R gui/include/DataSource/DataSourceWidget.h
  * R gui/include/SidePane/SqpSidePane.h
  * R gui/include/TimeWidget/TimeWidget.h
  * R gui/include/Variable/VariableInspectorWidget.h
  * R gui/include/Variable/VariableMenuHeaderWidget.h
  * R gui/include/Visualization/IVariableContainer.h
  * R gui/include/Visualization/IVisualizationWidget.h
  * R gui/include/Visualization/IVisualizationWidgetVisitor.h
  * R gui/include/Visualization/VisualizationGraphHelper.h
  * R gui/include/Visualization/VisualizationTabWidget.h
  * R gui/include/Visualization/VisualizationZoneWidget.h
  * R gui/include/Visualization/operations/GenerateVariableMenuOperation.h
  * R gui/include/Visualization/operations/MenuBuilder.h
  * R gui/include/Visualization/operations/RemoveVariableOperation.h
  * R gui/include/Visualization/qcustomplot.h
  * R gui/resources/icones/dataSourceComponent.png
  * R gui/resources/icones/dataSourceNode.png
  * R gui/resources/icones/dataSourceProduct.png
  * R gui/resources/icones/dataSourceRoot.png
  * R gui/resources/icones/delete.png
  * R gui/resources/icones/next.png
  * R gui/resources/icones/openInspector.png
  * R gui/resources/icones/plot.png
  * R gui/resources/icones/previous.png
  * R gui/resources/icones/sciqlop2PNG_1024.png
  * R gui/resources/icones/unplot.png
  * R gui/resources/sqpguiresources.qrc
  * R gui/src/DataSource/DataSourceTreeWidgetItem.cpp
  * R gui/src/DataSource/DataSourceWidget.cpp
  * R gui/src/SidePane/SqpSidePane.cpp
  * R gui/src/TimeWidget/TimeWidget.cpp
  * R gui/src/Variable/VariableMenuHeaderWidget.cpp
  * R gui/src/Visualization/VisualizationTabWidget.cpp
  * R gui/src/Visualization/operations/GenerateVariableMenuOperation.cpp
  * R gui/src/Visualization/operations/MenuBuilder.cpp
  * R gui/src/Visualization/operations/RemoveVariableOperation.cpp
  * R gui/src/Visualization/qcustomplot.cpp
  * R gui/ui/DataSource/DataSourceWidget.ui
  * R gui/ui/SidePane/SqpSidePane.ui
  * R gui/ui/TimeWidget/TimeWidget.ui
  * R gui/ui/Variable/VariableInspectorWidget.ui
  * R gui/ui/Variable/VariableMenuHeaderWidget.ui
  * R gui/ui/Visualization/VisualizationGraphWidget.ui
  * R gui/ui/Visualization/VisualizationTabWidget.ui
  * R gui/ui/Visualization/VisualizationWidget.ui
  * R gui/ui/Visualization/VisualizationZoneWidget.ui
  * R gui/vera-exclusions/exclusions.txt
  * R plugin/CMakeLists.txt
  * R plugin/cmake/Findsciqlop-plugin.cmake
  * R plugin/include/Plugin/IPlugin.h
  * R plugins/amda/CMakeLists.txt
  * R plugins/amda/cmake/Findsciqlop-amda.cmake
  * R plugins/amda/include/AmdaDefs.h
  * R plugins/amda/include/AmdaGlobal.h
  * R plugins/amda/include/AmdaParser.h
  * R plugins/amda/include/AmdaPlugin.h
  * R plugins/amda/include/AmdaResultParser.h
  * R plugins/amda/resources/amda.json
  * R plugins/amda/resources/amdaresources.qrc
  * R plugins/amda/resources/samples/AmdaSample.json
  * R plugins/amda/src/AmdaDefs.cpp
  * R plugins/amda/src/AmdaParser.cpp
  * R plugins/amda/src/AmdaPlugin.cpp
  * R plugins/amda/tests-resources/TestAmdaParser/TwoRootsFile.json
  * R plugins/amda/tests-resources/TestAmdaParser/ValidFile1.json
  * R plugins/amda/tests-resources/TestAmdaParser/WrongRootKey.json
  * R plugins/amda/tests-resources/TestAmdaParser/WrongRootType.json
  * R plugins/amda/tests-resources/TestAmdaResultParser/NaNValue.txt
  * R plugins/amda/tests-resources/TestAmdaResultParser/NoUnit.txt
  * R plugins/amda/tests-resources/TestAmdaResultParser/TooManyValues.txt
  * R plugins/amda/tests-resources/TestAmdaResultParser/ValidScalar1.txt
  * R plugins/amda/tests-resources/TestAmdaResultParser/WrongDate.txt
  * R plugins/amda/tests-resources/TestAmdaResultParser/WrongUnit.txt
  * R plugins/amda/tests-resources/TestAmdaResultParser/WrongValue.txt
  * R plugins/amda/tests/TestAmdaParser.cpp
  * R plugins/mockplugin/CMakeLists.txt
  * R plugins/mockplugin/cmake/Findsciqlop-mockplugin.cmake
  * R plugins/mockplugin/include/MockPlugin.h
  * R plugins/mockplugin/include/MockPluginGlobal.h
  * R plugins/mockplugin/resources/mockplugin.json
  * R plugins/mockplugin/src/MockPlugin.cpp
  * R README.md
  * R app/CMakeLists.txt
  * R app/include/MainWindow.h
  * R app/src/Main.cpp
  * R app/vera-exclusions/exclusions.txt
  * R cmake/sciqlop.cmake
  * R cmake/sciqlop_applications.cmake
  * R cmake/sciqlop_package.cmake
  * R cmake/sciqlop_params.cmake
  * R core/CMakeLists.txt
  * R core/include/Common/spimpl.h
  * R core/include/DataSource/DataSourceController.h
  * R core/include/DataSource/DataSourceItem.h
  * R core/src/DataSource/DataSourceController.cpp
  * R core/src/DataSource/DataSourceItem.cpp
  * R core/tests/DataSource/TestDataSourceController.cpp
  * R core/vera-exclusions/exclusions.txt
  * R formatting/cmake/use_clangformat.cmake
  * R formatting/vera-exclusions/exclusions.txt
  * R gui/CMakeLists.txt
  * R gui/include/SqpApplication.h
  * R LICENSE
  * R app/src/mainwindow.cpp
  * R app/src/mainwindow.ui
Approved
author

Status change > Approved

You need to be logged in to leave comments. Login now