Files
qt-migration-legatus/qt5-before/dlbo/Lts/Common/LtsScriptTimeline/track_header.cpp
T
torstenandCopilot 7173785915 Qt6 Migration: Complete migration with DDS/RTI support and build validation
Major Changes:
- Merged latest Qt5 devel content from dlbo (292 files changed, 7 new dirs)
- Consolidated forward-declarations and include folders
- Removed unneeded modules per Niklas' repo check list

Build System Fixes:
- Fixed CMake VERSION_GREATER syntax in ParticipantManagement/CMakeLists.txt
- Added VLC packages (libvlc-dev, vlc-plugin-base) to docker_build.sh
- Added PostgreSQL dev packages (libpq-dev, postgresql-server-dev-all) to Dockerfile
- Fixed locale warnings (ANSI_X3.4-1968 → C.UTF-8)
- Fixed ArcGIS SDK path warnings when BUILD_ARCGIS=OFF

Code Generation Fixes:
- Fixed IDL enum collisions (PortType→CorePortType/DdsutPortType, PdmEventType)
- Fixed Grantlee template svc_translation.cpp.grantlee:
  - Changed {{ idl_enum.name }}_def:: to {{ idl_enum.name }}::
  - Fixed .underlying() calls for C++11 scoped enums (enum class)
- Removed generated files from repo (moc_*, *_dtc.h, *_ftc.h)

Validation:
- BUILD_RTI=ON: SUCCESS
- BUILD_RTI=OFF: SUCCESS
- C++17 standard maintained for RTI 7.7 compatibility
- Ubuntu 26.04 Docker environment verified

Remaining Warnings (expected):
- BgViewer, KDChart, KDReports, Poppler-Qt6 not found (optional features)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-09-15 18:20:26 +00:00

192 lines
4.2 KiB
C++

#include "track_header.h"
#include "tools.h"
#include <QPainter>
#include <QBrush>
#include <QPen>
#include <QColor>
#include <QCursor>
#include <QMouseEvent>
#include <QFontMetrics>
#include <QFont>
#include <QTime>
#include <QApplication>
#include <QDebug>
namespace LtsScriptTimeline
{
TrackHeader::TrackHeader(QWidget *parent)
: QWidget(parent)
, m_indicatorTime(-1)
, m_textMargin(12)
, m_textSpacing(10)
, m_indicatorLock(false)
, m_tools(nullptr)
{
setCursor(Qt::IBeamCursor);
m_timeFormat = QStringLiteral("HH:mm:ss"); // TODO: load time format or whatever
}
void TrackHeader::setTools(Tools *tools)
{
m_tools = tools;
}
void TrackHeader::mousePressEvent(QMouseEvent *event)
{
if (event->buttons() != Qt::LeftButton)
return;
if (!m_indicatorLock)
{
setIndicatorTime(m_tools->getTime(event->localPos().x()));
emit signalHeaderIndicatorTimeUserChanged(m_indicatorTime);
}
}
void TrackHeader::setIndicatorTime(int time)
{
m_indicatorTime = time;
emit signalHeaderIndicatorTimeChanged(m_indicatorTime);
update();
}
void TrackHeader::recreatePositionLabels()
{
// get font metrics by probing
QTime t;
t.setHMS(23, 59, 59);
QFontMetrics fm(QApplication::font());
//m_currentTextHeight = fm.height(); TODO: impl usage
#if QT_VERSION < QT_VERSION_CHECK(5, 11, 0)
int currentTextWidth = fm.width(t.toString());
#else
int currentTextWidth = fm.horizontalAdvance(t.toString());
#endif
if (currentTextWidth < 1 /*|| m_currentTextHeight < 1*/)
{
qCritical() << "TrackHeader::recreatePositionLabels: invalid text size";
return;
}
// find where to put texts
int currentTextWidthTime = m_tools->getDuration(currentTextWidth);
int time = m_tools->getDuration(m_textMargin);
int end = (m_tools->m_timelineLength * 2) + currentTextWidthTime;
int paintStartTime = m_tools->getTime(0) - currentTextWidthTime; // allow drawing from Timeline-Start + Text-End
int paintEndTime = m_tools->getTime(width() * 2);
int count = 0;
m_positionMarkers.clear();
//qCritical() << "time" << time << "end" << end << "paintStartTime" << paintStartTime << "paintEndTime" << paintEndTime;
int textSpacingTime = m_tools->getDuration(m_textSpacing);
while (time < end && count < 5000)
{
//qCritical() << "time =" << time << "count =" << count;
if (time >= paintStartTime && time <= paintEndTime)
{
//qCritical() << "added time" << time;
m_positionMarkers.append(m_tools->getPos(time));
}
time += currentTextWidthTime + textSpacingTime;
count++;
}
// TODO: tell all tcws' !!
update();
}
void TrackHeader::resizeEvent(QResizeEvent *event)
{
recreatePositionLabels();
QWidget::resizeEvent(event);
}
void TrackHeader::updateMe()
{
recreatePositionLabels();
update();
}
void TrackHeader::paintEvent(QPaintEvent *event)
{
QPainter painter(this);
QWidget::paintEvent(event);
painter.save();
// draw base
painter.setPen(QGuiApplication::palette().windowText().color());
painter.setBrush(QGuiApplication::palette().window().color());
painter.drawRect(rect().adjusted(0, 0, -1, -1));
int h = height();
// draw position pointer (if available)
if (m_indicatorTime > -1 && m_indicatorTime <= m_tools->getTime(width()))
{
painter.setPen(QColor("cyan"));
int indicatorPos = m_tools->getPos(m_indicatorTime);
painter.drawLine(indicatorPos, h - (h / 4), indicatorPos, h);
}
// draw position texts
painter.setPen(QGuiApplication::palette().windowText().color());
//qCritical() << "draw position texts";
for (auto i = m_positionMarkers.constBegin(); i != m_positionMarkers.constEnd(); ++i)
{
int pos = *i;
//qCritical() << "pos" << pos;
int time = m_tools->getTime(pos);
//qCritical() << "time" << time;
QTime t = QTime::fromMSecsSinceStartOfDay(time * 1000);
//qCritical() << "t" << t;
QString x = t.toString(m_timeFormat);
//qCritical() << "x" << x;
painter.drawText(pos, h / 2 /* TODO: calc exactly*/, x);
painter.save();
painter.setPen(QGuiApplication::palette().link().color());
painter.drawLine(pos, (h / 2) + 2, pos, h); // time indicator
painter.restore();
//qCritical() << "drew at" << pos << "/" << x;
}
painter.restore();
}
} // namespace LtsScriptTimeline