TimeWidget.cpp
47 lines
| 1.5 KiB
| text/x-c
|
CppLexer
r134 | #include "TimeWidget/TimeWidget.h" | |||
#include "ui_TimeWidget.h" | ||||
r302 | #include <SqpApplication.h> | |||
#include <Time/TimeController.h> | ||||
r192 | ||||
r134 | TimeWidget::TimeWidget(QWidget *parent) : QWidget{parent}, ui{new Ui::TimeWidget} | |||
{ | ||||
ui->setupUi(this); | ||||
r192 | ||||
r302 | ui->applyToolButton->setIcon(sqpApp->style()->standardIcon(QStyle::SP_DialogApplyButton)); | |||
r192 | // Connection | |||
connect(ui->startDateTimeEdit, &QDateTimeEdit::dateTimeChanged, this, | ||||
&TimeWidget::onTimeUpdateRequested); | ||||
connect(ui->endDateTimeEdit, &QDateTimeEdit::dateTimeChanged, this, | ||||
&TimeWidget::onTimeUpdateRequested); | ||||
r302 | ||||
connect(ui->applyToolButton, &QToolButton::clicked, &sqpApp->timeController(), | ||||
&TimeController::onTimeNotify); | ||||
r304 | ||||
// Initialisation | ||||
ui->startDateTimeEdit->setDateTime( | ||||
QDateTime::currentDateTime().addSecs(-3600)); // one hour berefore | ||||
ui->endDateTimeEdit->setDateTime(QDateTime::currentDateTime()); | ||||
auto dateTime | ||||
= SqpDateTime{QDateTime::currentDateTime().addSecs(-3600).toMSecsSinceEpoch() / 1000.0, | ||||
QDateTime::currentDateTime().toMSecsSinceEpoch() / 1000.0}; | ||||
sqpApp->timeController().onTimeToUpdate(dateTime); | ||||
r134 | } | |||
r302 | ||||
r134 | TimeWidget::~TimeWidget() | |||
{ | ||||
delete ui; | ||||
} | ||||
r192 | ||||
void TimeWidget::onTimeUpdateRequested() | ||||
{ | ||||
Alexandre Leroux
|
r488 | auto dateTime = SqpDateTime{DateUtils::secondsSinceEpoch(ui->startDateTimeEdit->dateTime()), | ||
DateUtils::secondsSinceEpoch(ui->endDateTimeEdit->dateTime())}; | ||||
r192 | ||||
emit timeUpdated(std::move(dateTime)); | ||||
} | ||||