@@ -1,37 +1,40 | |||
|
1 | 1 | #ifndef SCIQLOP_TIMECONTROLLER_H |
|
2 | 2 | #define SCIQLOP_TIMECONTROLLER_H |
|
3 | 3 | |
|
4 | 4 | #include <Data/SqpDateTime.h> |
|
5 | 5 | |
|
6 | 6 | #include <QLoggingCategory> |
|
7 | 7 | #include <QObject> |
|
8 | 8 | |
|
9 | 9 | #include <Common/spimpl.h> |
|
10 | 10 | |
|
11 | 11 | |
|
12 | 12 | Q_DECLARE_LOGGING_CATEGORY(LOG_TimeController) |
|
13 | 13 | |
|
14 | 14 | /** |
|
15 | 15 | * @brief The TimeController class aims to handle the Time parameters notification in SciQlop. |
|
16 | 16 | */ |
|
17 | 17 | class TimeController : public QObject { |
|
18 | 18 | Q_OBJECT |
|
19 | 19 | public: |
|
20 | 20 | explicit TimeController(QObject *parent = 0); |
|
21 | 21 | |
|
22 | 22 | SqpDateTime dateTime() const noexcept; |
|
23 | 23 | |
|
24 | 24 | signals: |
|
25 | 25 | /// Signal emitted to notify that time parameters has beed updated |
|
26 | 26 | void timeUpdated(SqpDateTime time); |
|
27 | 27 | |
|
28 | 28 | public slots: |
|
29 |
/// Slot called when a new dateTime has been defined. |
|
|
29 | /// Slot called when a new dateTime has been defined. | |
|
30 | 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 | 35 | private: |
|
33 | 36 | class TimeControllerPrivate; |
|
34 | 37 | spimpl::unique_impl_ptr<TimeControllerPrivate> impl; |
|
35 | 38 | }; |
|
36 | 39 | |
|
37 | 40 | #endif // SCIQLOP_TIMECONTROLLER_H |
@@ -1,26 +1,29 | |||
|
1 | 1 | #include "Time/TimeController.h" |
|
2 | 2 | |
|
3 | 3 | Q_LOGGING_CATEGORY(LOG_TimeController, "TimeController") |
|
4 | 4 | |
|
5 | 5 | struct TimeController::TimeControllerPrivate { |
|
6 | 6 | |
|
7 | 7 | SqpDateTime m_DateTime; |
|
8 | 8 | }; |
|
9 | 9 | |
|
10 | 10 | TimeController::TimeController(QObject *parent) |
|
11 | 11 | : QObject{parent}, impl{spimpl::make_unique_impl<TimeControllerPrivate>()} |
|
12 | 12 | { |
|
13 | 13 | qCDebug(LOG_TimeController()) << tr("TimeController construction"); |
|
14 | 14 | } |
|
15 | 15 | |
|
16 | 16 | SqpDateTime TimeController::dateTime() const noexcept |
|
17 | 17 | { |
|
18 | 18 | return impl->m_DateTime; |
|
19 | 19 | } |
|
20 | 20 | |
|
21 | 21 | void TimeController::onTimeToUpdate(SqpDateTime dateTime) |
|
22 | 22 | { |
|
23 | 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 | } |
@@ -1,29 +1,38 | |||
|
1 | 1 | #include "TimeWidget/TimeWidget.h" |
|
2 | 2 | #include "ui_TimeWidget.h" |
|
3 | 3 | |
|
4 | #include <SqpApplication.h> | |
|
5 | #include <Time/TimeController.h> | |
|
4 | 6 | |
|
5 | 7 | TimeWidget::TimeWidget(QWidget *parent) : QWidget{parent}, ui{new Ui::TimeWidget} |
|
6 | 8 | { |
|
7 | 9 | ui->setupUi(this); |
|
8 | 10 | |
|
11 | ui->applyToolButton->setIcon(sqpApp->style()->standardIcon(QStyle::SP_DialogApplyButton)); | |
|
12 | ||
|
9 | 13 | // Connection |
|
10 | 14 | connect(ui->startDateTimeEdit, &QDateTimeEdit::dateTimeChanged, this, |
|
11 | 15 | &TimeWidget::onTimeUpdateRequested); |
|
12 | 16 | |
|
13 | 17 | connect(ui->endDateTimeEdit, &QDateTimeEdit::dateTimeChanged, this, |
|
14 | 18 | &TimeWidget::onTimeUpdateRequested); |
|
19 | ||
|
20 | ||
|
21 | connect(ui->applyToolButton, &QToolButton::clicked, &sqpApp->timeController(), | |
|
22 | &TimeController::onTimeNotify); | |
|
15 | 23 | } |
|
16 | 24 | |
|
25 | ||
|
17 | 26 | TimeWidget::~TimeWidget() |
|
18 | 27 | { |
|
19 | 28 | delete ui; |
|
20 | 29 | } |
|
21 | 30 | |
|
22 | 31 | void TimeWidget::onTimeUpdateRequested() |
|
23 | 32 | { |
|
24 | 33 | auto dateTime = SqpDateTime{ |
|
25 | 34 | static_cast<double>(ui->startDateTimeEdit->dateTime().toMSecsSinceEpoch() / 1000.), |
|
26 | 35 | static_cast<double>(ui->endDateTimeEdit->dateTime().toMSecsSinceEpoch()) / 1000.}; |
|
27 | 36 | |
|
28 | 37 | emit timeUpdated(std::move(dateTime)); |
|
29 | 38 | } |
@@ -1,85 +1,92 | |||
|
1 | 1 | <?xml version="1.0" encoding="UTF-8"?> |
|
2 | 2 | <ui version="4.0"> |
|
3 | 3 | <class>TimeWidget</class> |
|
4 | 4 | <widget class="QWidget" name="TimeWidget"> |
|
5 | 5 | <property name="geometry"> |
|
6 | 6 | <rect> |
|
7 | 7 | <x>0</x> |
|
8 | 8 | <y>0</y> |
|
9 | 9 | <width>716</width> |
|
10 | 10 | <height>48</height> |
|
11 | 11 | </rect> |
|
12 | 12 | </property> |
|
13 | 13 | <property name="sizePolicy"> |
|
14 | 14 | <sizepolicy hsizetype="Fixed" vsizetype="Preferred"> |
|
15 | 15 | <horstretch>0</horstretch> |
|
16 | 16 | <verstretch>0</verstretch> |
|
17 | 17 | </sizepolicy> |
|
18 | 18 | </property> |
|
19 | 19 | <property name="windowTitle"> |
|
20 | 20 | <string>Form</string> |
|
21 | 21 | </property> |
|
22 | 22 | <layout class="QHBoxLayout" name="horizontalLayout_2"> |
|
23 | 23 | <item> |
|
24 | 24 | <widget class="QLabel" name="label"> |
|
25 | 25 | <property name="sizePolicy"> |
|
26 | 26 | <sizepolicy hsizetype="Minimum" vsizetype="Preferred"> |
|
27 | 27 | <horstretch>0</horstretch> |
|
28 | 28 | <verstretch>0</verstretch> |
|
29 | 29 | </sizepolicy> |
|
30 | 30 | </property> |
|
31 | 31 | <property name="text"> |
|
32 | 32 | <string>TStart :</string> |
|
33 | 33 | </property> |
|
34 | 34 | </widget> |
|
35 | 35 | </item> |
|
36 | 36 | <item> |
|
37 | 37 | <widget class="QDateTimeEdit" name="startDateTimeEdit"> |
|
38 | 38 | <property name="sizePolicy"> |
|
39 | 39 | <sizepolicy hsizetype="Preferred" vsizetype="Fixed"> |
|
40 | 40 | <horstretch>0</horstretch> |
|
41 | 41 | <verstretch>0</verstretch> |
|
42 | 42 | </sizepolicy> |
|
43 | 43 | </property> |
|
44 | 44 | <property name="displayFormat"> |
|
45 | 45 | <string>dd/MM/yyyy HH:mm:ss:zzz</string> |
|
46 | 46 | </property> |
|
47 | 47 | <property name="calendarPopup"> |
|
48 | 48 | <bool>true</bool> |
|
49 | 49 | </property> |
|
50 | 50 | </widget> |
|
51 | 51 | </item> |
|
52 | 52 | <item> |
|
53 | 53 | <widget class="QLabel" name="label_2"> |
|
54 | 54 | <property name="sizePolicy"> |
|
55 | 55 | <sizepolicy hsizetype="Minimum" vsizetype="Preferred"> |
|
56 | 56 | <horstretch>0</horstretch> |
|
57 | 57 | <verstretch>0</verstretch> |
|
58 | 58 | </sizepolicy> |
|
59 | 59 | </property> |
|
60 | 60 | <property name="text"> |
|
61 | 61 | <string>TEnd :</string> |
|
62 | 62 | </property> |
|
63 | 63 | </widget> |
|
64 | 64 | </item> |
|
65 | 65 | <item> |
|
66 | 66 | <widget class="QDateTimeEdit" name="endDateTimeEdit"> |
|
67 | 67 | <property name="sizePolicy"> |
|
68 | 68 | <sizepolicy hsizetype="Preferred" vsizetype="Fixed"> |
|
69 | 69 | <horstretch>0</horstretch> |
|
70 | 70 | <verstretch>0</verstretch> |
|
71 | 71 | </sizepolicy> |
|
72 | 72 | </property> |
|
73 | 73 | <property name="displayFormat"> |
|
74 | 74 | <string>dd/MM/yyyy HH:mm:ss:zzz</string> |
|
75 | 75 | </property> |
|
76 | 76 | <property name="calendarPopup"> |
|
77 | 77 | <bool>true</bool> |
|
78 | 78 | </property> |
|
79 | 79 | </widget> |
|
80 | 80 | </item> |
|
81 | <item> | |
|
82 | <widget class="QToolButton" name="applyToolButton"> | |
|
83 | <property name="text"> | |
|
84 | <string>...</string> | |
|
85 | </property> | |
|
86 | </widget> | |
|
87 | </item> | |
|
81 | 88 | </layout> |
|
82 | 89 | </widget> |
|
83 | 90 | <resources/> |
|
84 | 91 | <connections/> |
|
85 | 92 | </ui> |
General Comments 0
You need to be logged in to leave comments.
Login now