##// END OF EJS Templates
Temporal parameters of the selected variables can be updated using the...
perrinel -
r281:08349e12a7ef
parent child
Show More
@@ -29,6 +29,7
29 #include <Time/TimeController.h>
29 #include <Time/TimeController.h>
30 #include <TimeWidget/TimeWidget.h>
30 #include <TimeWidget/TimeWidget.h>
31 #include <Variable/Variable.h>
31 #include <Variable/Variable.h>
32 #include <Variable/VariableController.h>
32 #include <Visualization/VisualizationController.h>
33 #include <Visualization/VisualizationController.h>
33
34
34 #include <QAction>
35 #include <QAction>
@@ -182,6 +183,10 MainWindow::MainWindow(QWidget *parent)
182 connect(timeWidget, SIGNAL(timeUpdated(SqpDateTime)), &sqpApp->timeController(),
183 connect(timeWidget, SIGNAL(timeUpdated(SqpDateTime)), &sqpApp->timeController(),
183 SLOT(onTimeToUpdate(SqpDateTime)));
184 SLOT(onTimeToUpdate(SqpDateTime)));
184
185
186 qRegisterMetaType<SqpDateTime>();
187 connect(&sqpApp->timeController(), SIGNAL(timeUpdated(SqpDateTime)),
188 &sqpApp->variableController(), SLOT(onDateTimeOnSelection(SqpDateTime)));
189
185 // Widgets / widgets connections
190 // Widgets / widgets connections
186 qRegisterMetaType<std::shared_ptr<Variable> >();
191 qRegisterMetaType<std::shared_ptr<Variable> >();
187
192
@@ -44,7 +44,6 public slots:
44 signals:
44 signals:
45 void updated();
45 void updated();
46
46
47
48 private:
47 private:
49 class VariablePrivate;
48 class VariablePrivate;
50 spimpl::unique_impl_ptr<VariablePrivate> impl;
49 spimpl::unique_impl_ptr<VariablePrivate> impl;
@@ -8,8 +8,8
8
8
9 #include <Common/spimpl.h>
9 #include <Common/spimpl.h>
10
10
11
12 class IDataProvider;
11 class IDataProvider;
12 class QItemSelectionModel;
13 class TimeController;
13 class TimeController;
14 class Variable;
14 class Variable;
15 class VariableModel;
15 class VariableModel;
@@ -26,6 +26,7 public:
26 virtual ~VariableController();
26 virtual ~VariableController();
27
27
28 VariableModel *variableModel() noexcept;
28 VariableModel *variableModel() noexcept;
29 QItemSelectionModel *variableSelectionModel() noexcept;
29
30
30 void setTimeController(TimeController *timeController) noexcept;
31 void setTimeController(TimeController *timeController) noexcept;
31
32
@@ -44,6 +45,9 public slots:
44 */
45 */
45 void createVariable(const QString &name, std::shared_ptr<IDataProvider> provider) noexcept;
46 void createVariable(const QString &name, std::shared_ptr<IDataProvider> provider) noexcept;
46
47
48 /// Update the temporal parameters of every selected variable to dateTime
49 void onDateTimeOnSelection(const SqpDateTime &dateTime);
50
47 void initialize();
51 void initialize();
48 void finalize();
52 void finalize();
49
53
@@ -11,6 +11,7
11 #include <QDateTime>
11 #include <QDateTime>
12 #include <QMutex>
12 #include <QMutex>
13 #include <QThread>
13 #include <QThread>
14 #include <QtCore/QItemSelectionModel>
14
15
15 #include <unordered_map>
16 #include <unordered_map>
16
17
@@ -34,6 +35,7 struct VariableController::VariableControllerPrivate {
34 explicit VariableControllerPrivate(VariableController *parent)
35 explicit VariableControllerPrivate(VariableController *parent)
35 : m_WorkingMutex{},
36 : m_WorkingMutex{},
36 m_VariableModel{new VariableModel{parent}},
37 m_VariableModel{new VariableModel{parent}},
38 m_VariableSelectionModel{new QItemSelectionModel{m_VariableModel, parent}},
37 m_VariableCacheController{std::make_unique<VariableCacheController>()}
39 m_VariableCacheController{std::make_unique<VariableCacheController>()}
38 {
40 {
39 }
41 }
@@ -41,6 +43,7 struct VariableController::VariableControllerPrivate {
41 QMutex m_WorkingMutex;
43 QMutex m_WorkingMutex;
42 /// Variable model. The VariableController has the ownership
44 /// Variable model. The VariableController has the ownership
43 VariableModel *m_VariableModel;
45 VariableModel *m_VariableModel;
46 QItemSelectionModel *m_VariableSelectionModel;
44
47
45
48
46 TimeController *m_TimeController{nullptr};
49 TimeController *m_TimeController{nullptr};
@@ -69,6 +72,11 VariableModel *VariableController::variableModel() noexcept
69 return impl->m_VariableModel;
72 return impl->m_VariableModel;
70 }
73 }
71
74
75 QItemSelectionModel *VariableController::variableSelectionModel() noexcept
76 {
77 return impl->m_VariableSelectionModel;
78 }
79
72 void VariableController::setTimeController(TimeController *timeController) noexcept
80 void VariableController::setTimeController(TimeController *timeController) noexcept
73 {
81 {
74 impl->m_TimeController = timeController;
82 impl->m_TimeController = timeController;
@@ -110,6 +118,17 void VariableController::createVariable(const QString &name,
110 }
118 }
111 }
119 }
112
120
121 void VariableController::onDateTimeOnSelection(const SqpDateTime &dateTime)
122 {
123 auto selectedRows = impl->m_VariableSelectionModel->selectedRows();
124
125 for (const auto &selectedRow : qAsConst(selectedRows)) {
126 if (auto selectedVariable = impl->m_VariableModel->variable(selectedRow.row())) {
127 selectedVariable->setDateTime(dateTime);
128 }
129 }
130 }
131
113
132
114 void VariableController::onRequestDataLoading(std::shared_ptr<Variable> variable,
133 void VariableController::onRequestDataLoading(std::shared_ptr<Variable> variable,
115 const SqpDateTime &dateTime)
134 const SqpDateTime &dateTime)
@@ -20,6 +20,16 TimeWidget::TimeWidget(QWidget *parent) : QWidget{parent}, ui{new Ui::TimeWidget
20
20
21 connect(ui->applyToolButton, &QToolButton::clicked, &sqpApp->timeController(),
21 connect(ui->applyToolButton, &QToolButton::clicked, &sqpApp->timeController(),
22 &TimeController::onTimeNotify);
22 &TimeController::onTimeNotify);
23
24 // Initialisation
25 ui->startDateTimeEdit->setDateTime(
26 QDateTime::currentDateTime().addSecs(-3600)); // one hour berefore
27 ui->endDateTimeEdit->setDateTime(QDateTime::currentDateTime());
28
29 auto dateTime
30 = SqpDateTime{QDateTime::currentDateTime().addSecs(-3600).toMSecsSinceEpoch() / 1000.0,
31 QDateTime::currentDateTime().toMSecsSinceEpoch() / 1000.0};
32 sqpApp->timeController().onTimeToUpdate(dateTime);
23 }
33 }
24
34
25
35
@@ -18,10 +18,11 VariableInspectorWidget::VariableInspectorWidget(QWidget *parent)
18 ui->setupUi(this);
18 ui->setupUi(this);
19
19
20 // Sets model for table
20 // Sets model for table
21 auto sortFilterModel = new QSortFilterProxyModel{this};
21 // auto sortFilterModel = new QSortFilterProxyModel{this};
22 sortFilterModel->setSourceModel(sqpApp->variableController().variableModel());
22 // sortFilterModel->setSourceModel(sqpApp->variableController().variableModel());
23
23
24 ui->tableView->setModel(sortFilterModel);
24 ui->tableView->setModel(sqpApp->variableController().variableModel());
25 ui->tableView->setSelectionModel(sqpApp->variableController().variableSelectionModel());
25
26
26 // Fixes column sizes
27 // Fixes column sizes
27 auto model = ui->tableView->model();
28 auto model = ui->tableView->model();
General Comments 1
Under Review
author

Auto status change to "Under Review"

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