Files
qt-migration-legatus/qt5-before/dlbo/Lts/Common/LtsWidgets/lts_grid_layout.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

136 lines
2.9 KiB
C++

/**
* @RDE_HEADER@
* GridLaout with auto column layouter.
* Layouts all widgets depending on the maxColumn value
* releayouts if maxColumn changed
* $Id$
* $HeadURL$
* $Author$
*/
#include "lts_grid_layout.h"
#include <QResizeEvent>
namespace LtsWidgets
{
LtsGridLayout::LtsGridLayout(LtsWidgets::ButtonSize buttonSize, QWidget *parent, int maxColumn)
: QGridLayout(parent)
, m_buttonSize(buttonSize)
, m_defaultMaxColumn(maxColumn)
, m_maxColumn(maxColumn)
, m_colSize(0)
, m_autoSize(maxColumn < 0)
{
setSizeConstraint(SizeConstraint::SetNoConstraint);
//setHorizontalSpacing(1);
setVerticalSpacing(1);
setMargin(0);
}
void LtsGridLayout::add_widget(QWidget *widget)
{
for (auto it = m_widgetList.cbegin(); it != m_widgetList.cend(); ++it)
{
if (*it == widget)
return;
}
connect(widget, &QWidget::destroyed, this, &LtsGridLayout::onWidgetDestroyed);
addWidgetInternal(widget);
m_widgetList.push_back(widget);
}
void LtsGridLayout::setAutoSize(bool enable)
{
m_autoSize = enable;
if (m_autoSize == false)
setMaxColumn(1);
else
{
m_maxColumn = -1;
m_oldSize = QSize();
m_oldGeo = QRect();
QResizeEvent e(sizeHint(), sizeHint());
onParentResize(&e);
setGeometry(QRect(0, 0, sizeHint().width(), sizeHint().height()));
}
}
void LtsGridLayout::setMaxColumn(int max)
{
m_maxColumn = max;
m_defaultMaxColumn = max;
//resetInternalSize
m_colSize = 0;
for (QWidget *wid : qAsConst(m_widgetList))
removeWidget(wid);
for (QWidget *wid : qAsConst(m_widgetList))
addWidgetInternal(wid);
}
void LtsGridLayout::addWidgetInternal(QWidget *widget)
{
int current_row = 0;
int current_column = 0;
while (QLayoutItem *item = itemAtPosition(current_row, current_column))
{
if (!item->widget())
{
removeItem(item);
continue;
}
if (current_column == (m_maxColumn - 1))
{
current_column = 0;
++current_row;
}
else
++current_column;
}
if (current_row == 0)
m_colSize += 1;
QGridLayout::addWidget(widget, current_row, current_column);
}
void LtsGridLayout::onParentResize(QResizeEvent *e)
{
if (m_autoSize && m_oldSize != e->size())
{
bool bigger = (e->size().width() > m_oldSize.width());
m_oldSize = e->size();
int newWidth = m_oldSize.width();
int maxIconsInRow = newWidth / (static_cast<int>(m_buttonSize) + 4);
if (!bigger && newWidth <= (static_cast<int>(m_buttonSize)*m_colSize - static_cast<int>(m_buttonSize) / 2))
maxIconsInRow--;
if (m_maxColumn != maxIconsInRow)
setMaxColumn(maxIconsInRow);
}
}
void LtsGridLayout::onWidgetDestroyed()
{
QWidget *s = qobject_cast<QWidget*>(sender());
for (auto it = m_widgetList.begin(); it != m_widgetList.end(); ++it)
{
if (*it == s)
{
QGridLayout::removeWidget(s);
m_widgetList.erase(it);
setMaxColumn(m_maxColumn); // resort, also remove the layoutitem
break;
}
}
}
} // namespace LtsWidgets