##// END OF EJS Templates
Add apply button and its connection for timewidget
perrinel -
r302:c121d060318a
parent child
Show More
@@ -1,37 +1,40
1 #ifndef SCIQLOP_TIMECONTROLLER_H
1 #ifndef SCIQLOP_TIMECONTROLLER_H
2 #define SCIQLOP_TIMECONTROLLER_H
2 #define SCIQLOP_TIMECONTROLLER_H
3
3
4 #include <Data/SqpDateTime.h>
4 #include <Data/SqpDateTime.h>
5
5
6 #include <QLoggingCategory>
6 #include <QLoggingCategory>
7 #include <QObject>
7 #include <QObject>
8
8
9 #include <Common/spimpl.h>
9 #include <Common/spimpl.h>
10
10
11
11
12 Q_DECLARE_LOGGING_CATEGORY(LOG_TimeController)
12 Q_DECLARE_LOGGING_CATEGORY(LOG_TimeController)
13
13
14 /**
14 /**
15 * @brief The TimeController class aims to handle the Time parameters notification in SciQlop.
15 * @brief The TimeController class aims to handle the Time parameters notification in SciQlop.
16 */
16 */
17 class TimeController : public QObject {
17 class TimeController : public QObject {
18 Q_OBJECT
18 Q_OBJECT
19 public:
19 public:
20 explicit TimeController(QObject *parent = 0);
20 explicit TimeController(QObject *parent = 0);
21
21
22 SqpDateTime dateTime() const noexcept;
22 SqpDateTime dateTime() const noexcept;
23
23
24 signals:
24 signals:
25 /// Signal emitted to notify that time parameters has beed updated
25 /// Signal emitted to notify that time parameters has beed updated
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. Call timeUpdated signal
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;
35 };
38 };
36
39
37 #endif // SCIQLOP_TIMECONTROLLER_H
40 #endif // SCIQLOP_TIMECONTROLLER_H
@@ -1,26 +1,29
1 #include "Time/TimeController.h"
1 #include "Time/TimeController.h"
2
2
3 Q_LOGGING_CATEGORY(LOG_TimeController, "TimeController")
3 Q_LOGGING_CATEGORY(LOG_TimeController, "TimeController")
4
4
5 struct TimeController::TimeControllerPrivate {
5 struct TimeController::TimeControllerPrivate {
6
6
7 SqpDateTime m_DateTime;
7 SqpDateTime m_DateTime;
8 };
8 };
9
9
10 TimeController::TimeController(QObject *parent)
10 TimeController::TimeController(QObject *parent)
11 : QObject{parent}, impl{spimpl::make_unique_impl<TimeControllerPrivate>()}
11 : QObject{parent}, impl{spimpl::make_unique_impl<TimeControllerPrivate>()}
12 {
12 {
13 qCDebug(LOG_TimeController()) << tr("TimeController construction");
13 qCDebug(LOG_TimeController()) << tr("TimeController construction");
14 }
14 }
15
15
16 SqpDateTime TimeController::dateTime() const noexcept
16 SqpDateTime TimeController::dateTime() const noexcept
17 {
17 {
18 return impl->m_DateTime;
18 return impl->m_DateTime;
19 }
19 }
20
20
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 }
@@ -1,29 +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);
15 }
23 }
16
24
25
17 TimeWidget::~TimeWidget()
26 TimeWidget::~TimeWidget()
18 {
27 {
19 delete ui;
28 delete ui;
20 }
29 }
21
30
22 void TimeWidget::onTimeUpdateRequested()
31 void TimeWidget::onTimeUpdateRequested()
23 {
32 {
24 auto dateTime = SqpDateTime{
33 auto dateTime = SqpDateTime{
25 static_cast<double>(ui->startDateTimeEdit->dateTime().toMSecsSinceEpoch() / 1000.),
34 static_cast<double>(ui->startDateTimeEdit->dateTime().toMSecsSinceEpoch() / 1000.),
26 static_cast<double>(ui->endDateTimeEdit->dateTime().toMSecsSinceEpoch()) / 1000.};
35 static_cast<double>(ui->endDateTimeEdit->dateTime().toMSecsSinceEpoch()) / 1000.};
27
36
28 emit timeUpdated(std::move(dateTime));
37 emit timeUpdated(std::move(dateTime));
29 }
38 }
@@ -1,85 +1,92
1 <?xml version="1.0" encoding="UTF-8"?>
1 <?xml version="1.0" encoding="UTF-8"?>
2 <ui version="4.0">
2 <ui version="4.0">
3 <class>TimeWidget</class>
3 <class>TimeWidget</class>
4 <widget class="QWidget" name="TimeWidget">
4 <widget class="QWidget" name="TimeWidget">
5 <property name="geometry">
5 <property name="geometry">
6 <rect>
6 <rect>
7 <x>0</x>
7 <x>0</x>
8 <y>0</y>
8 <y>0</y>
9 <width>716</width>
9 <width>716</width>
10 <height>48</height>
10 <height>48</height>
11 </rect>
11 </rect>
12 </property>
12 </property>
13 <property name="sizePolicy">
13 <property name="sizePolicy">
14 <sizepolicy hsizetype="Fixed" vsizetype="Preferred">
14 <sizepolicy hsizetype="Fixed" vsizetype="Preferred">
15 <horstretch>0</horstretch>
15 <horstretch>0</horstretch>
16 <verstretch>0</verstretch>
16 <verstretch>0</verstretch>
17 </sizepolicy>
17 </sizepolicy>
18 </property>
18 </property>
19 <property name="windowTitle">
19 <property name="windowTitle">
20 <string>Form</string>
20 <string>Form</string>
21 </property>
21 </property>
22 <layout class="QHBoxLayout" name="horizontalLayout_2">
22 <layout class="QHBoxLayout" name="horizontalLayout_2">
23 <item>
23 <item>
24 <widget class="QLabel" name="label">
24 <widget class="QLabel" name="label">
25 <property name="sizePolicy">
25 <property name="sizePolicy">
26 <sizepolicy hsizetype="Minimum" vsizetype="Preferred">
26 <sizepolicy hsizetype="Minimum" vsizetype="Preferred">
27 <horstretch>0</horstretch>
27 <horstretch>0</horstretch>
28 <verstretch>0</verstretch>
28 <verstretch>0</verstretch>
29 </sizepolicy>
29 </sizepolicy>
30 </property>
30 </property>
31 <property name="text">
31 <property name="text">
32 <string>TStart :</string>
32 <string>TStart :</string>
33 </property>
33 </property>
34 </widget>
34 </widget>
35 </item>
35 </item>
36 <item>
36 <item>
37 <widget class="QDateTimeEdit" name="startDateTimeEdit">
37 <widget class="QDateTimeEdit" name="startDateTimeEdit">
38 <property name="sizePolicy">
38 <property name="sizePolicy">
39 <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
39 <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
40 <horstretch>0</horstretch>
40 <horstretch>0</horstretch>
41 <verstretch>0</verstretch>
41 <verstretch>0</verstretch>
42 </sizepolicy>
42 </sizepolicy>
43 </property>
43 </property>
44 <property name="displayFormat">
44 <property name="displayFormat">
45 <string>dd/MM/yyyy HH:mm:ss:zzz</string>
45 <string>dd/MM/yyyy HH:mm:ss:zzz</string>
46 </property>
46 </property>
47 <property name="calendarPopup">
47 <property name="calendarPopup">
48 <bool>true</bool>
48 <bool>true</bool>
49 </property>
49 </property>
50 </widget>
50 </widget>
51 </item>
51 </item>
52 <item>
52 <item>
53 <widget class="QLabel" name="label_2">
53 <widget class="QLabel" name="label_2">
54 <property name="sizePolicy">
54 <property name="sizePolicy">
55 <sizepolicy hsizetype="Minimum" vsizetype="Preferred">
55 <sizepolicy hsizetype="Minimum" vsizetype="Preferred">
56 <horstretch>0</horstretch>
56 <horstretch>0</horstretch>
57 <verstretch>0</verstretch>
57 <verstretch>0</verstretch>
58 </sizepolicy>
58 </sizepolicy>
59 </property>
59 </property>
60 <property name="text">
60 <property name="text">
61 <string>TEnd :</string>
61 <string>TEnd :</string>
62 </property>
62 </property>
63 </widget>
63 </widget>
64 </item>
64 </item>
65 <item>
65 <item>
66 <widget class="QDateTimeEdit" name="endDateTimeEdit">
66 <widget class="QDateTimeEdit" name="endDateTimeEdit">
67 <property name="sizePolicy">
67 <property name="sizePolicy">
68 <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
68 <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
69 <horstretch>0</horstretch>
69 <horstretch>0</horstretch>
70 <verstretch>0</verstretch>
70 <verstretch>0</verstretch>
71 </sizepolicy>
71 </sizepolicy>
72 </property>
72 </property>
73 <property name="displayFormat">
73 <property name="displayFormat">
74 <string>dd/MM/yyyy HH:mm:ss:zzz</string>
74 <string>dd/MM/yyyy HH:mm:ss:zzz</string>
75 </property>
75 </property>
76 <property name="calendarPopup">
76 <property name="calendarPopup">
77 <bool>true</bool>
77 <bool>true</bool>
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/>
84 <connections/>
91 <connections/>
85 </ui>
92 </ui>
General Comments 0
You need to be logged in to leave comments. Login now