##// END OF EJS Templates
Temporal parameters of the selected variables can be updated using the...
perrinel -
r304:08349e12a7ef
parent child
Show More
@@ -29,6 +29,7
29 29 #include <Time/TimeController.h>
30 30 #include <TimeWidget/TimeWidget.h>
31 31 #include <Variable/Variable.h>
32 #include <Variable/VariableController.h>
32 33 #include <Visualization/VisualizationController.h>
33 34
34 35 #include <QAction>
@@ -182,6 +183,10 MainWindow::MainWindow(QWidget *parent)
182 183 connect(timeWidget, SIGNAL(timeUpdated(SqpDateTime)), &sqpApp->timeController(),
183 184 SLOT(onTimeToUpdate(SqpDateTime)));
184 185
186 qRegisterMetaType<SqpDateTime>();
187 connect(&sqpApp->timeController(), SIGNAL(timeUpdated(SqpDateTime)),
188 &sqpApp->variableController(), SLOT(onDateTimeOnSelection(SqpDateTime)));
189
185 190 // Widgets / widgets connections
186 191 qRegisterMetaType<std::shared_ptr<Variable> >();
187 192
@@ -44,7 +44,6 public slots:
44 44 signals:
45 45 void updated();
46 46
47
48 47 private:
49 48 class VariablePrivate;
50 49 spimpl::unique_impl_ptr<VariablePrivate> impl;
@@ -8,8 +8,8
8 8
9 9 #include <Common/spimpl.h>
10 10
11
12 11 class IDataProvider;
12 class QItemSelectionModel;
13 13 class TimeController;
14 14 class Variable;
15 15 class VariableModel;
@@ -26,6 +26,7 public:
26 26 virtual ~VariableController();
27 27
28 28 VariableModel *variableModel() noexcept;
29 QItemSelectionModel *variableSelectionModel() noexcept;
29 30
30 31 void setTimeController(TimeController *timeController) noexcept;
31 32
@@ -44,6 +45,9 public slots:
44 45 */
45 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 51 void initialize();
48 52 void finalize();
49 53
@@ -11,6 +11,7
11 11 #include <QDateTime>
12 12 #include <QMutex>
13 13 #include <QThread>
14 #include <QtCore/QItemSelectionModel>
14 15
15 16 #include <unordered_map>
16 17
@@ -34,6 +35,7 struct VariableController::VariableControllerPrivate {
34 35 explicit VariableControllerPrivate(VariableController *parent)
35 36 : m_WorkingMutex{},
36 37 m_VariableModel{new VariableModel{parent}},
38 m_VariableSelectionModel{new QItemSelectionModel{m_VariableModel, parent}},
37 39 m_VariableCacheController{std::make_unique<VariableCacheController>()}
38 40 {
39 41 }
@@ -41,6 +43,7 struct VariableController::VariableControllerPrivate {
41 43 QMutex m_WorkingMutex;
42 44 /// Variable model. The VariableController has the ownership
43 45 VariableModel *m_VariableModel;
46 QItemSelectionModel *m_VariableSelectionModel;
44 47
45 48
46 49 TimeController *m_TimeController{nullptr};
@@ -69,6 +72,11 VariableModel *VariableController::variableModel() noexcept
69 72 return impl->m_VariableModel;
70 73 }
71 74
75 QItemSelectionModel *VariableController::variableSelectionModel() noexcept
76 {
77 return impl->m_VariableSelectionModel;
78 }
79
72 80 void VariableController::setTimeController(TimeController *timeController) noexcept
73 81 {
74 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 133 void VariableController::onRequestDataLoading(std::shared_ptr<Variable> variable,
115 134 const SqpDateTime &dateTime)
@@ -20,6 +20,16 TimeWidget::TimeWidget(QWidget *parent) : QWidget{parent}, ui{new Ui::TimeWidget
20 20
21 21 connect(ui->applyToolButton, &QToolButton::clicked, &sqpApp->timeController(),
22 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 18 ui->setupUi(this);
19 19
20 20 // Sets model for table
21 auto sortFilterModel = new QSortFilterProxyModel{this};
22 sortFilterModel->setSourceModel(sqpApp->variableController().variableModel());
21 // auto sortFilterModel = new QSortFilterProxyModel{this};
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 27 // Fixes column sizes
27 28 auto model = ui->tableView->model();
General Comments 0
You need to be logged in to leave comments. Login now