##// END OF EJS Templates
Tests clear() and size() methods
Tests clear() and size() methods

File last commit:

r512:d00d6fd96c10
r517:16e3b7f34e6f
Show More
TimeWidget.cpp
50 lines | 1.5 KiB | text/x-c | CppLexer
#include "TimeWidget/TimeWidget.h"
#include "ui_TimeWidget.h"
#include <Common/DateUtils.h>
#include <SqpApplication.h>
#include <Time/TimeController.h>
TimeWidget::TimeWidget(QWidget *parent) : QWidget{parent}, ui{new Ui::TimeWidget}
{
ui->setupUi(this);
ui->applyToolButton->setIcon(sqpApp->style()->standardIcon(QStyle::SP_DialogApplyButton));
// Connection
connect(ui->startDateTimeEdit, &QDateTimeEdit::dateTimeChanged, this,
&TimeWidget::onTimeUpdateRequested);
connect(ui->endDateTimeEdit, &QDateTimeEdit::dateTimeChanged, this,
&TimeWidget::onTimeUpdateRequested);
connect(ui->applyToolButton, &QToolButton::clicked, &sqpApp->timeController(),
&TimeController::onTimeNotify);
// Initialisation
auto endDateTime = QDateTime::currentDateTimeUtc();
auto startDateTime = endDateTime.addSecs(-3600); // one hour before
ui->startDateTimeEdit->setDateTime(startDateTime);
ui->endDateTimeEdit->setDateTime(endDateTime);
auto dateTime = SqpRange{DateUtils::secondsSinceEpoch(startDateTime),
DateUtils::secondsSinceEpoch(endDateTime)};
sqpApp->timeController().onTimeToUpdate(dateTime);
}
TimeWidget::~TimeWidget()
{
delete ui;
}
void TimeWidget::onTimeUpdateRequested()
{
auto dateTime = SqpRange{DateUtils::secondsSinceEpoch(ui->startDateTimeEdit->dateTime()),
DateUtils::secondsSinceEpoch(ui->endDateTimeEdit->dateTime())};
emit timeUpdated(std::move(dateTime));
}