Files
qt-migration-legatus/qt6-after/qt6-migrated-legatus/TetraIF/LogView/LogViewDateTimeEdit.cpp
T
berrux-dev 473462cbdb Fix LogView consistency and LtsUtilsGuiDds link after the merge
- LogView: take the complete XmlPatterns (d327c66c4) file set - the
  auto-merged mix (XmlPatterns .cpp + validation .hpp) left duplicated
  m_logger members and constructor signature mismatches, because the
  two lineages reworked the module differently.
- LogView CMakeLists: the cleanup version (separate LogViewLogger
  static library, required by tabPluginTetraJson and present in the
  Release 2 target list).
- LtsUtilsGuiDds: link ddscore (BUILD_RTI) for the Core::FunctionReply
  symbols, as in story/release-2-cleanup.

Full-scope ninja all is green; ctest 20/22 (the two failures,
GrantleeParserSmoke and utils_test, are out of the driver's 46-target
scope and 'Not Run' in the official baseline).
2026-11-16 20:24:04 +01:00

87 lines
1.5 KiB
C++

#include "LogViewDateTimeEdit.hpp"
#include <time.h>
#include "LogViewField.hpp"
#include "LogViewTelegram.hpp"
namespace N_LogView
{
LogViewDateTimeEdit::LogViewDateTimeEdit(LogViewField* a_field, QWidget* a_parent, const bool a_readonly)
: QDateTimeEdit(a_parent)
, LogViewWidget(a_field, this, a_parent, a_readonly)
{
if (a_readonly)
{
setReadOnly(true);
setAlignment(a_field->isRightAligned() ? Qt::AlignRight : Qt::AlignLeft);
}
qint64 unixTime = 0;
if (a_field->hasContent())
{
if (a_field->isMSecsField())
unixTime = a_field->value(0, true).toLongLong();
else
unixTime = a_field->value(0, true).toInt() * 1000LL;
}
if (0 == unixTime && !a_readonly)
unixTime = ::time(nullptr) * 1000LL;
setDateTime(QDateTime::fromMSecsSinceEpoch(unixTime));
setDisplayFormat(QLatin1String("dd MMM yyyy hh:mm:ss"));
setCalendarPopup(true);
updateToolTip(QString::number(unixTime));
connect(this, &LogViewDateTimeEdit::editingFinished,
this, &LogViewDateTimeEdit::checkAndOvertakeContent);
}
void LogViewDateTimeEdit::checkAndOvertakeContent()
{
updateToolTip(QString::number(dateTime().toMSecsSinceEpoch() / 1000));
}
bool LogViewDateTimeEdit::saveContent(LogViewTelegram* a_telegram)
{
if (a_telegram->isJsonTelegram())
{
a_telegram->setJsonValue(m_Field->jsonPath(), dateTime().toMSecsSinceEpoch());
}
else
{
a_telegram->setNextFieldAsGpsTimeField();
a_telegram->setUIntX(getSize(), dateTime().toMSecsSinceEpoch() / 1000);
}
return true;
}
}