##// END OF EJS Templates
Switch to speasy...
Switch to speasy Signed-off-by: Alexis Jeandet <alexis.jeandet@member.fsf.org>

File last commit:

r1495:9c439b3d7daf
r1510:0046d29d6c44 PySide2
Show More
TimeWidget.cpp
158 lines | 3.9 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>
New data sources system switch complete...
r1495 #include <MimeTypes/MimeTypes.h>
Drop of variable, graph and zones on the time widget
r878
Rename "DragDropHelper" in "DragDropGuiController"
r1075 #include <DragAndDrop/DragDropGuiController.h>
Add apply button and its connection for timewidget
r302 #include <SqpApplication.h>
#include <Time/TimeController.h>
add TimeWidget connection
r192
Drag of the time widget on a graph
r879 #include <QDrag>
Drop of variable, graph and zones on the time widget
r878 #include <QDragEnterEvent>
#include <QDropEvent>
#include <QMimeData>
Made core module a git submodule, ready to start switching to new...
r1347 #include <QStyle>
Drop of variable, graph and zones on the time widget
r878
Drag of the time widget on a graph
r879
Refactored main toolbar to make it suck less :)...
r1462 struct TimeWidget::TimeWidgetPrivate
{
Drag of the time widget on a graph
r879
explicit TimeWidgetPrivate() {}
QPoint m_DragStartPosition;
};
Refactored main toolbar to make it suck less :)...
r1462 TimeWidget::TimeWidget(QWidget* parent)
: QWidget { parent }
, ui { new Ui::TimeWidget }
, impl { spimpl::make_unique_impl<TimeWidgetPrivate>() }
Add the TimeWidget
r134 {
ui->setupUi(this);
add TimeWidget connection
r192
// Connection
connect(ui->startDateTimeEdit, &QDateTimeEdit::dateTimeChanged, this,
Refactored main toolbar to make it suck less :)...
r1462 &TimeWidget::onTimeUpdateRequested);
add TimeWidget connection
r192
connect(ui->endDateTimeEdit, &QDateTimeEdit::dateTimeChanged, this,
Refactored main toolbar to make it suck less :)...
r1462 &TimeWidget::onTimeUpdateRequested);
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);
Refactored main toolbar to make it suck less :)...
r1462 auto dateTime = DateTimeRange { DateUtils::secondsSinceEpoch(startDateTime),
DateUtils::secondsSinceEpoch(endDateTime) };
Temporal parameters of the selected variables can be updated using the...
r304
Some WIP refactoring, trying to remove TimeController object...
r1345 sqpApp->timeController().setDateTimeRange(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
Renamed SqpRange to DateTimeRange, introduced VariableController2 to...
r1346 void TimeWidget::setTimeRange(DateTimeRange time)
Drop of variable, graph and zones on the time widget
r878 {
auto startDateTime = DateUtils::dateTime(time.m_TStart);
auto endDateTime = DateUtils::dateTime(time.m_TEnd);
ui->startDateTimeEdit->setDateTime(startDateTime);
ui->endDateTimeEdit->setDateTime(endDateTime);
}
Renamed SqpRange to DateTimeRange, introduced VariableController2 to...
r1346 DateTimeRange TimeWidget::timeRange() const
add TimeWidget connection
r192 {
Refactored main toolbar to make it suck less :)...
r1462 return DateTimeRange { DateUtils::secondsSinceEpoch(ui->startDateTimeEdit->dateTime()),
DateUtils::secondsSinceEpoch(ui->endDateTimeEdit->dateTime()) };
Drag of the time widget on a graph
r879 }
add TimeWidget connection
r192
Drag of the time widget on a graph
r879 void TimeWidget::onTimeUpdateRequested()
{
auto dateTime = timeRange();
Spectrogram segfault should be fixed now, added ability to provide Spectrogram min sampling time to avoid computation when possible...
r1467 emit timeUpdated(dateTime);
Removed old IDataProvider IF, some small steps toward new VC integration...
r1351 sqpApp->timeController().setDateTimeRange(dateTime);
add TimeWidget connection
r192 }
Drop of variable, graph and zones on the time widget
r878
Refactored main toolbar to make it suck less :)...
r1462 void TimeWidget::dragEnterEvent(QDragEnterEvent* event)
Drop of variable, graph and zones on the time widget
r878 {
New data sources system switch complete...
r1495 if (event->mimeData()->hasFormat(MIME::MIME_TYPE_TIME_RANGE))
Refactored main toolbar to make it suck less :)...
r1462 {
Drop of variable, graph and zones on the time widget
r878 event->acceptProposedAction();
setStyleSheet("QDateTimeEdit{background-color: #BBD5EE; border:2px solid #2A7FD4}");
}
Refactored main toolbar to make it suck less :)...
r1462 else
{
Drop of variable, graph and zones on the time widget
r878 event->ignore();
}
}
Refactored main toolbar to make it suck less :)...
r1462 void TimeWidget::dragLeaveEvent(QDragLeaveEvent* event)
Drop of variable, graph and zones on the time widget
r878 {
Refactored main toolbar to make it suck less :)...
r1462 setStyleSheet(QString {});
Drop of variable, graph and zones on the time widget
r878 }
Refactored main toolbar to make it suck less :)...
r1462 void TimeWidget::dropEvent(QDropEvent* event)
Drop of variable, graph and zones on the time widget
r878 {
New data sources system switch complete...
r1495 if (event->mimeData()->hasFormat(MIME::MIME_TYPE_TIME_RANGE))
Refactored main toolbar to make it suck less :)...
r1462 {
New data sources system switch complete...
r1495 auto mimeData = event->mimeData()->data(MIME::MIME_TYPE_TIME_RANGE);
Drop of variable, graph and zones on the time widget
r878 auto timeRange = TimeController::timeRangeForMimeData(mimeData);
setTimeRange(timeRange);
}
Refactored main toolbar to make it suck less :)...
r1462 else
{
Drop of variable, graph and zones on the time widget
r878 event->ignore();
}
Refactored main toolbar to make it suck less :)...
r1462 setStyleSheet(QString {});
Drop of variable, graph and zones on the time widget
r878 }
Drag of the time widget on a graph
r879
Refactored main toolbar to make it suck less :)...
r1462 void TimeWidget::mousePressEvent(QMouseEvent* event)
Drag of the time widget on a graph
r879 {
Refactored main toolbar to make it suck less :)...
r1462 if (event->button() == Qt::LeftButton)
{
Drag of the time widget on a graph
r879 impl->m_DragStartPosition = event->pos();
}
QWidget::mousePressEvent(event);
}
Refactored main toolbar to make it suck less :)...
r1462 void TimeWidget::mouseMoveEvent(QMouseEvent* event)
Drag of the time widget on a graph
r879 {
Refactored main toolbar to make it suck less :)...
r1462 if (!(event->buttons() & Qt::LeftButton))
{
Drag of the time widget on a graph
r879 return;
}
if ((event->pos() - impl->m_DragStartPosition).manhattanLength()
Refactored main toolbar to make it suck less :)...
r1462 < QApplication::startDragDistance())
{
Drag of the time widget on a graph
r879 return;
}
// Note: The management of the drag object is done by Qt
Refactored main toolbar to make it suck less :)...
r1462 auto drag = new QDrag { this };
Drag of the time widget on a graph
r879
auto mimeData = new QMimeData;
auto timeData = TimeController::mimeDataForTimeRange(timeRange());
New data sources system switch complete...
r1495 mimeData->setData(MIME::MIME_TYPE_TIME_RANGE, timeData);
Drag of the time widget on a graph
r879
drag->setMimeData(mimeData);
Refactored main toolbar to make it suck less :)...
r1462 auto pixmap = QPixmap { ":/icones/time.png" };
show a clock icon during the drag of the TimeWidget
r935 drag->setPixmap(pixmap.scaledToWidth(22));
Drag of the time widget on a graph
r879
Rename "DragDropHelper" in "DragDropGuiController"
r1075 sqpApp->dragDropGuiController().resetDragAndDrop();
Drag of the time widget on a graph
r879
// Note: The exec() is blocking on windows but not on linux and macOS
drag->exec(Qt::MoveAction | Qt::CopyAction);
QWidget::mouseMoveEvent(event);
}