##// END OF EJS Templates
Drop of variable, graph and zones on the time widget
Drop of variable, graph and zones on the time widget

File last commit:

r878:e439cb403ff9
r878:e439cb403ff9
Show More
TimeWidget.cpp
96 lines | 2.6 KiB | text/x-c | CppLexer
Add the TimeWidget
r134 #include "TimeWidget/TimeWidget.h"
#include "ui_TimeWidget.h"
Alexandre Leroux
Passes TimeWidget in UTC...
r489 #include <Common/DateUtils.h>
Drop of variable, graph and zones on the time widget
r878 #include <Common/MimeTypesDef.h>
Add apply button and its connection for timewidget
r302 #include <SqpApplication.h>
#include <Time/TimeController.h>
add TimeWidget connection
r192
Drop of variable, graph and zones on the time widget
r878 #include <QDragEnterEvent>
#include <QDropEvent>
#include <QMimeData>
Add the TimeWidget
r134 TimeWidget::TimeWidget(QWidget *parent) : QWidget{parent}, ui{new Ui::TimeWidget}
{
ui->setupUi(this);
add TimeWidget connection
r192
Add apply button and its connection for timewidget
r302 ui->applyToolButton->setIcon(sqpApp->style()->standardIcon(QStyle::SP_DialogApplyButton));
add TimeWidget connection
r192 // Connection
connect(ui->startDateTimeEdit, &QDateTimeEdit::dateTimeChanged, this,
&TimeWidget::onTimeUpdateRequested);
connect(ui->endDateTimeEdit, &QDateTimeEdit::dateTimeChanged, this,
&TimeWidget::onTimeUpdateRequested);
Add apply button and its connection for timewidget
r302
connect(ui->applyToolButton, &QToolButton::clicked, &sqpApp->timeController(),
&TimeController::onTimeNotify);
Temporal parameters of the selected variables can be updated using the...
r304
// Initialisation
Alexandre Leroux
Passes TimeWidget in UTC...
r489 auto endDateTime = QDateTime::currentDateTimeUtc();
auto startDateTime = endDateTime.addSecs(-3600); // one hour before
ui->startDateTimeEdit->setDateTime(startDateTime);
ui->endDateTimeEdit->setDateTime(endDateTime);
Change SqpRange for SqpDateTime
r512 auto dateTime = SqpRange{DateUtils::secondsSinceEpoch(startDateTime),
DateUtils::secondsSinceEpoch(endDateTime)};
Temporal parameters of the selected variables can be updated using the...
r304
sqpApp->timeController().onTimeToUpdate(dateTime);
Add the TimeWidget
r134 }
Add apply button and its connection for timewidget
r302
Add the TimeWidget
r134 TimeWidget::~TimeWidget()
{
delete ui;
}
add TimeWidget connection
r192
Drop of variable, graph and zones on the time widget
r878 void TimeWidget::setTimeRange(SqpRange time)
{
auto startDateTime = DateUtils::dateTime(time.m_TStart);
auto endDateTime = DateUtils::dateTime(time.m_TEnd);
ui->startDateTimeEdit->setDateTime(startDateTime);
ui->endDateTimeEdit->setDateTime(endDateTime);
}
add TimeWidget connection
r192 void TimeWidget::onTimeUpdateRequested()
{
Change SqpRange for SqpDateTime
r512 auto dateTime = SqpRange{DateUtils::secondsSinceEpoch(ui->startDateTimeEdit->dateTime()),
DateUtils::secondsSinceEpoch(ui->endDateTimeEdit->dateTime())};
add TimeWidget connection
r192
emit timeUpdated(std::move(dateTime));
}
Drop of variable, graph and zones on the time widget
r878
void TimeWidget::dragEnterEvent(QDragEnterEvent *event)
{
if (event->mimeData()->hasFormat(MIME_TYPE_TIME_RANGE)) {
event->acceptProposedAction();
setStyleSheet("QDateTimeEdit{background-color: #BBD5EE; border:2px solid #2A7FD4}");
}
else {
event->ignore();
}
}
void TimeWidget::dragLeaveEvent(QDragLeaveEvent *event)
{
setStyleSheet(QString());
}
void TimeWidget::dropEvent(QDropEvent *event)
{
if (event->mimeData()->hasFormat(MIME_TYPE_TIME_RANGE)) {
auto mimeData = event->mimeData()->data(MIME_TYPE_TIME_RANGE);
auto timeRange = TimeController::timeRangeForMimeData(mimeData);
setTimeRange(timeRange);
}
else {
event->ignore();
}
setStyleSheet(QString());
}