Files
qt-migration-legatus/qt5-before/dlbo/Lts/Tools/QLedLine/qledline.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

224 lines
4.4 KiB
C++

/**
* @RDE_HEADER@
* Implements n QLedChars to display a line of Text/Image
* $Id$
* $HeadURL$
* $Author$
* Created by Florian Schult, SLSE, 2016-03-18
*/
#include "qledline.h"
#include <QString>
#include <QLayout>
#include <QTimer>
#include <QImage>
#include "qledchar.h"
QLedLine::QLedLine(QWidget *parent)
: QWidget(parent)
, m_charCount(0)
, m_height(0)
, m_visible(true)
, m_text()
, m_layout(new QHBoxLayout(this))
, m_chars()
, m_flashTimer(new QTimer(this))
, m_color(Qt::red) // Standard color
, m_image()
{
m_layout->setSpacing(0);
m_layout->setContentsMargins(0,0,0,0);
m_layout->setMargin(0);
QSpacerItem *sp1 = new QSpacerItem(0,0, QSizePolicy::Expanding, QSizePolicy::Expanding);
QSpacerItem *sp2 = new QSpacerItem(0,0, QSizePolicy::Expanding, QSizePolicy::Expanding);
m_layout->addSpacerItem(sp1);
m_layout->addSpacerItem(sp2);
m_layout->setAlignment(m_layout, Qt::AlignHCenter);
}
QLedLine::~QLedLine()
{
qDeleteAll(m_chars);
// optional. They have "this" as parent and are QT.
delete m_layout;
delete m_flashTimer;
}
QString QLedLine::shownText() const
{
return m_text.leftJustified(m_chars.size(), QLatin1Char(' '), true);
}
bool QLedLine::isTextVisible() const
{
return m_visible;
}
int QLedLine::flashTime() const
{
return m_flashTimer->interval();
}
QColor QLedLine::color() const
{
return m_color;
}
void QLedLine::setText(const QString &text)
{
m_text = text;
// Todo: Arabic: RightJustified? Automatic?
QString shown = shownText();
for (int i=0; i<m_chars.size(); ++i)
m_chars[i]->setLetter(shown[i]);
}
// Expects a properly sized QImage, corresponding to the count and Pixelsizes of QLedLine and QLedChar
void QLedLine::setImage(const QImage &image)
{
m_image = image;
QImage charImage;
QSize charSize = m_chars[0]->charSize();
for (int i=0; i<m_chars.size(); ++i)
{
charImage = m_image.copy((charSize.width() * i), 0, charSize.width(), charSize.height());
m_chars[i]->setImage(charImage);
}
}
QSize QLedLine::charSize() const
{
return m_chars[0]->charSize();
}
QString QLedLine::text() const
{
return m_text;
}
void QLedLine::addChar()
{
QLedChar *ledChar = new QLedChar(m_height, this, m_text[m_chars.size()]);
ledChar->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
if (!m_chars.isEmpty())
ledChar->setLetterVisible(m_chars[0]->letterVisible());
connect(m_flashTimer, &QTimer::timeout, ledChar, &QLedChar::onFlashTimerTimeout);
ledChar->setColor(m_color);
// Takes the last stretch-item and puts it behind the new added ledChar
QLayoutItem *spacer = m_layout->takeAt(m_layout->count()-1);
m_layout->addWidget(ledChar);
m_layout->addItem(spacer);
m_chars.append(ledChar);
ledChar->setLetter(shownText().at(m_chars.size()-1));
}
void QLedLine::deleteChar()
{
if (m_chars.isEmpty())
return;
delete m_chars.last();
m_chars.remove(m_chars.size()-1);
}
void QLedLine::setCharCount(int charCount)
{
m_charCount = charCount;
while(m_chars.size() != m_charCount)
{
if(m_chars.size() > m_charCount)
deleteChar();
else if(m_chars.size() < m_charCount)
addChar();
}
}
int QLedLine::charCount() const
{
return m_charCount;
}
void QLedLine::setHeight(int height)
{
m_height = height;
for(int i=0; i<m_chars.size(); ++i)
{
m_chars[i]->setCharHeight(m_height);
}
setText(m_text);
}
int QLedLine::height() const
{
return m_height;
}
void QLedLine::setCharCountAndHeight(int charCount, int height)
{
setHeight(height);
setCharCount(charCount);
}
void QLedLine::setColor(const QColor &color)
{
m_color = color;
for (int i=0; i<m_charCount; ++i)
m_chars[i]->setColor(color);
}
void QLedLine::clear()
{
for (int i=0; i<m_charCount; ++i)
{
m_chars[i]->setLetterVisible(false);
m_chars[i]->setLetterVisible(true);
}
}
void QLedLine::setFlashing(int msecs)
{
m_flashTimer->setInterval(msecs);
if (msecs == 0)
{
if (m_visible)
{
for (int i = 0; i < m_chars.size(); ++i)
m_chars[i]->setLetterVisible();
}
m_flashTimer->stop();
}
else
{
if(m_visible)
m_flashTimer->start();
else
m_flashTimer->stop();
}
}
void QLedLine::setTextVisible(bool visible)
{
m_visible = visible;
for (int i=0; i<m_chars.size(); ++i)
m_chars[i]->setLetterVisible(m_visible);
if(m_visible)
{
if(m_flashTimer->interval() > 0)
m_flashTimer->start();
}
else
{
m_flashTimer->stop();
}
}