TimeController.cpp
51 lines
| 1.1 KiB
| text/x-c
|
CppLexer
r190 | #include "Time/TimeController.h" | |||
r884 | #include <QDataStream> | |||
r190 | Q_LOGGING_CATEGORY(LOG_TimeController, "TimeController") | |||
struct TimeController::TimeControllerPrivate { | ||||
r512 | SqpRange m_DateTime; | |||
r190 | }; | |||
TimeController::TimeController(QObject *parent) | ||||
: QObject{parent}, impl{spimpl::make_unique_impl<TimeControllerPrivate>()} | ||||
{ | ||||
qCDebug(LOG_TimeController()) << tr("TimeController construction"); | ||||
} | ||||
r512 | SqpRange TimeController::dateTime() const noexcept | |||
r190 | { | |||
return impl->m_DateTime; | ||||
} | ||||
r884 | QByteArray TimeController::mimeDataForTimeRange(const SqpRange &timeRange) | |||
{ | ||||
QByteArray encodedData; | ||||
QDataStream stream{&encodedData, QIODevice::WriteOnly}; | ||||
stream << timeRange.m_TStart << timeRange.m_TEnd; | ||||
return encodedData; | ||||
} | ||||
SqpRange TimeController::timeRangeForMimeData(const QByteArray &mimeData) | ||||
{ | ||||
QDataStream stream{mimeData}; | ||||
SqpRange timeRange; | ||||
stream >> timeRange.m_TStart >> timeRange.m_TEnd; | ||||
return timeRange; | ||||
} | ||||
r512 | void TimeController::onTimeToUpdate(SqpRange dateTime) | |||
r190 | { | |||
impl->m_DateTime = dateTime; | ||||
r302 | } | |||
r190 | ||||
r302 | void TimeController::onTimeNotify() | |||
{ | ||||
emit timeUpdated(impl->m_DateTime); | ||||
r190 | } | |||