@@ -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 |
@@ -26,9 +26,12 signals: | |||||
26 | void timeUpdated(SqpDateTime time); |
|
26 | void timeUpdated(SqpDateTime time); | |
27 |
|
27 | |||
28 | public slots: |
|
28 | public slots: | |
29 |
/// Slot called when a new dateTime has been defined. |
|
29 | /// Slot called when a new dateTime has been defined. | |
30 | void onTimeToUpdate(SqpDateTime dateTime); |
|
30 | void onTimeToUpdate(SqpDateTime dateTime); | |
31 |
|
31 | |||
|
32 | /// Slot called when the dateTime has to be notified. Call timeUpdated signal | |||
|
33 | void onTimeNotify(); | |||
|
34 | ||||
32 | private: |
|
35 | private: | |
33 | class TimeControllerPrivate; |
|
36 | class TimeControllerPrivate; | |
34 | spimpl::unique_impl_ptr<TimeControllerPrivate> impl; |
|
37 | spimpl::unique_impl_ptr<TimeControllerPrivate> impl; |
@@ -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 |
@@ -21,6 +21,9 SqpDateTime TimeController::dateTime() const noexcept | |||||
21 | void TimeController::onTimeToUpdate(SqpDateTime dateTime) |
|
21 | void TimeController::onTimeToUpdate(SqpDateTime dateTime) | |
22 | { |
|
22 | { | |
23 | impl->m_DateTime = dateTime; |
|
23 | impl->m_DateTime = dateTime; | |
|
24 | } | |||
24 |
|
25 | |||
25 | emit timeUpdated(dateTime); |
|
26 | void TimeController::onTimeNotify() | |
|
27 | { | |||
|
28 | emit timeUpdated(impl->m_DateTime); | |||
26 | } |
|
29 | } |
@@ -55,7 +55,7 void VariableCacheController::addDateTime(std::shared_ptr<Variable> variable, | |||||
55 | impl->m_VariableToSqpDateTimeListMap.at(variable), 0); |
|
55 | impl->m_VariableToSqpDateTimeListMap.at(variable), 0); | |
56 | } |
|
56 | } | |
57 | catch (const std::out_of_range &e) { |
|
57 | catch (const std::out_of_range &e) { | |
58 |
qC |
|
58 | qCWarning(LOG_VariableCacheController()) << e.what(); | |
59 | } |
|
59 | } | |
60 | } |
|
60 | } | |
61 | } |
|
61 | } | |
@@ -77,7 +77,7 VariableCacheController::provideNotInCacheDateTimeList(std::shared_ptr<Variable> | |||||
77 | notInCache, 0, dateTime.m_TStart); |
|
77 | notInCache, 0, dateTime.m_TStart); | |
78 | } |
|
78 | } | |
79 | catch (const std::out_of_range &e) { |
|
79 | catch (const std::out_of_range &e) { | |
80 |
qC |
|
80 | qCWarning(LOG_VariableCacheController()) << e.what(); | |
81 | } |
|
81 | } | |
82 |
|
82 | |||
83 | return notInCache; |
|
83 | return notInCache; | |
@@ -90,7 +90,7 VariableCacheController::dateCacheList(std::shared_ptr<Variable> variable) const | |||||
90 | return impl->m_VariableToSqpDateTimeListMap.at(variable); |
|
90 | return impl->m_VariableToSqpDateTimeListMap.at(variable); | |
91 | } |
|
91 | } | |
92 | catch (const std::out_of_range &e) { |
|
92 | catch (const std::out_of_range &e) { | |
93 |
qC |
|
93 | qCWarning(LOG_VariableCacheController()) << e.what(); | |
94 | return QVector<SqpDateTime>{}; |
|
94 | return QVector<SqpDateTime>{}; | |
95 | } |
|
95 | } | |
96 | } |
|
96 | } |
@@ -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,18 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 | this->onRequestDataLoading(selectedVariable, dateTime); | |||
|
129 | } | |||
|
130 | } | |||
|
131 | } | |||
|
132 | ||||
113 |
|
133 | |||
114 | void VariableController::onRequestDataLoading(std::shared_ptr<Variable> variable, |
|
134 | void VariableController::onRequestDataLoading(std::shared_ptr<Variable> variable, | |
115 | const SqpDateTime &dateTime) |
|
135 | const SqpDateTime &dateTime) |
@@ -1,19 +1,38 | |||||
1 | #include "TimeWidget/TimeWidget.h" |
|
1 | #include "TimeWidget/TimeWidget.h" | |
2 | #include "ui_TimeWidget.h" |
|
2 | #include "ui_TimeWidget.h" | |
3 |
|
3 | |||
|
4 | #include <SqpApplication.h> | |||
|
5 | #include <Time/TimeController.h> | |||
4 |
|
6 | |||
5 | TimeWidget::TimeWidget(QWidget *parent) : QWidget{parent}, ui{new Ui::TimeWidget} |
|
7 | TimeWidget::TimeWidget(QWidget *parent) : QWidget{parent}, ui{new Ui::TimeWidget} | |
6 | { |
|
8 | { | |
7 | ui->setupUi(this); |
|
9 | ui->setupUi(this); | |
8 |
|
10 | |||
|
11 | ui->applyToolButton->setIcon(sqpApp->style()->standardIcon(QStyle::SP_DialogApplyButton)); | |||
|
12 | ||||
9 | // Connection |
|
13 | // Connection | |
10 | connect(ui->startDateTimeEdit, &QDateTimeEdit::dateTimeChanged, this, |
|
14 | connect(ui->startDateTimeEdit, &QDateTimeEdit::dateTimeChanged, this, | |
11 | &TimeWidget::onTimeUpdateRequested); |
|
15 | &TimeWidget::onTimeUpdateRequested); | |
12 |
|
16 | |||
13 | connect(ui->endDateTimeEdit, &QDateTimeEdit::dateTimeChanged, this, |
|
17 | connect(ui->endDateTimeEdit, &QDateTimeEdit::dateTimeChanged, this, | |
14 | &TimeWidget::onTimeUpdateRequested); |
|
18 | &TimeWidget::onTimeUpdateRequested); | |
|
19 | ||||
|
20 | ||||
|
21 | connect(ui->applyToolButton, &QToolButton::clicked, &sqpApp->timeController(), | |||
|
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); | |||
15 | } |
|
33 | } | |
16 |
|
34 | |||
|
35 | ||||
17 | TimeWidget::~TimeWidget() |
|
36 | TimeWidget::~TimeWidget() | |
18 | { |
|
37 | { | |
19 | delete ui; |
|
38 | delete ui; |
@@ -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(s |
|
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(); |
@@ -78,6 +78,13 | |||||
78 | </property> |
|
78 | </property> | |
79 | </widget> |
|
79 | </widget> | |
80 | </item> |
|
80 | </item> | |
|
81 | <item> | |||
|
82 | <widget class="QToolButton" name="applyToolButton"> | |||
|
83 | <property name="text"> | |||
|
84 | <string>...</string> | |||
|
85 | </property> | |||
|
86 | </widget> | |||
|
87 | </item> | |||
81 | </layout> |
|
88 | </layout> | |
82 | </widget> |
|
89 | </widget> | |
83 | <resources/> |
|
90 | <resources/> |
General Comments 0
You need to be logged in to leave comments.
Login now