##// END OF EJS Templates
Implements filter function for data source...
Implements filter function for data source An item is valid if one of its metadata matches the text in the seach box

File last commit:

r304:08349e12a7ef
r477:eab21078feec
Show More
TimeWidget.cpp
48 lines | 1.5 KiB | text/x-c | CppLexer
#include "TimeWidget/TimeWidget.h"
#include "ui_TimeWidget.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
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);
}
TimeWidget::~TimeWidget()
{
delete ui;
}
void TimeWidget::onTimeUpdateRequested()
{
auto dateTime = SqpDateTime{
static_cast<double>(ui->startDateTimeEdit->dateTime().toMSecsSinceEpoch() / 1000.),
static_cast<double>(ui->endDateTimeEdit->dateTime().toMSecsSinceEpoch()) / 1000.};
emit timeUpdated(std::move(dateTime));
}