- training_area_telegrams.cpp: Fixed QJsonObject initializer syntax (Qt6 requires {{}} not ({}))
- training_area_telegrams.cpp: Fixed fromJson() methods to access m_* members directly
- training_area_telegrams.cpp: Fixed brace mismatches in multiple toJson() methods
- training_area_telegrams.h: Changed Header struct to public members for consistency
- tx_mixin.cpp: Fixed getEquipmentNumber() template for direct member access
- lts_coordinate.cpp: Added missing #include <iomanip>
- MIGRATION_STATUS.md: Added migration progress tracking document
C++17 constraint enforced due to RTI Connext DDS 7.7.0 incompatibility with C++20+
Build status: BUILD_RTI=OFF successful (0 errors, warnings only)
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
67 lines
1.5 KiB
C++
67 lines
1.5 KiB
C++
/**
|
|
* @RDE_HEADER@
|
|
* LtsWidget - a QLabel which elides the text if necessary
|
|
* $Id$
|
|
* $HeadURL$
|
|
* $Author$
|
|
* Created by Christian Ehrlicher, NLE, 2018-12-17
|
|
*/
|
|
|
|
#include "lts_elided_label.h"
|
|
|
|
#include <QtGui/QPaintEvent>
|
|
#include <QtGui/QResizeEvent>
|
|
|
|
|
|
namespace LtsWidgets
|
|
{
|
|
void LtsElidedLabel::setElideMode(Qt::TextElideMode elideMode)
|
|
{
|
|
m_elideMode = elideMode;
|
|
m_cachedText.clear();
|
|
update();
|
|
}
|
|
|
|
void LtsElidedLabel::resizeEvent(QResizeEvent *e)
|
|
{
|
|
QLabel::resizeEvent(e);
|
|
m_cachedText.clear();
|
|
}
|
|
|
|
void LtsElidedLabel::paintEvent(QPaintEvent *e)
|
|
{
|
|
if (m_elideMode == Qt::ElideNone)
|
|
return QLabel::paintEvent(e);
|
|
|
|
updateCachedTexts();
|
|
QLabel::setText(m_cachedElidedText);
|
|
QLabel::paintEvent(e);
|
|
QLabel::setText(m_cachedText);
|
|
}
|
|
|
|
void LtsElidedLabel::updateCachedTexts()
|
|
{
|
|
// setText() is not virtual ... :/
|
|
const auto txt = text();
|
|
if (m_cachedText == txt)
|
|
return;
|
|
m_cachedText = txt;
|
|
const QFontMetrics fm(fontMetrics());
|
|
m_cachedElidedText = fm.elidedText(text(),
|
|
m_elideMode,
|
|
width(),
|
|
Qt::TextShowMnemonic);
|
|
if (!m_cachedText.isEmpty())
|
|
{
|
|
const QString showFirstCharacter = m_cachedText.at(0) + QStringLiteral("...");
|
|
#if QT_VERSION < QT_VERSION_CHECK(5, 11, 0)
|
|
const int width = fm.width(showFirstCharacter);
|
|
#else
|
|
const int width = fm.horizontalAdvance(showFirstCharacter);
|
|
#endif
|
|
setMinimumWidth(width + 1);
|
|
}
|
|
}
|
|
|
|
} // namespace LtsWidgets
|