Files
qt-migration-legatus/qt5-before/dlbo/Lts/Common/LtsTimeline/item_delegate.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
6.0 KiB
C++

/**
* @RDE_HEADER@
* manages each row in view which type of container is suitable for current situation
* $Id: ItemDelegate.cpp 49755 2020-02-04 08:44:47Z ehrlicher $
* $HeadURL: svn://192.168.133.21/TDS/branches/product/features/hotline/Lts/Common/LtsTimelineClassic/ItemDelegate.cpp $
* $Author: ehrlicher $
* Created by Mike Wille, SLSE, 2014-10-01
*/
#include "item_delegate.h"
#include "item.h"
#include "track.h"
#include "timeline_view.h"
#include <QGuiApplication>
#include <QModelIndex>
#include <QPainter>
#include <QRect>
#include <QDebug>
namespace LtsTimeline
{
ItemDelegate::ItemDelegate(TimelineView *parent)
: QStyledItemDelegate(parent)
, m_view(parent)
, m_pushButton(new QPushButton)
, m_pushButtonPressed(new QPushButton)
{
m_pushButtonPressed->setDown(true);
}
ItemDelegate::~ItemDelegate()
{
m_pushButton->deleteLater();
m_pushButton = nullptr;
m_pushButtonPressed->deleteLater();
m_pushButtonPressed = nullptr;
}
///////////////////////////////////////////////////////////////////////////////
// PUBLIC
QSize ItemDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const
{
Q_UNUSED(option);
Q_UNUSED(index);
return QSize(100, 50);
}
void ItemDelegate::paintDragItems(QPainter *painter) const
{
painter->save();
const QRect rightSectionRect = QRect(QPoint(m_view->m_header->sectionPosition(Section::eItems), 0),
QPoint(m_view->geometry().right(), m_view->geometry().bottom()));
painter->setClipRect(rightSectionRect);
int dx = m_view->m_dragHandler->deltaX();
int dy = m_view->m_dragHandler->deltaY();
try
{
for (const int &itemId : m_view->m_dragHandler->m_dragItemIds)
{
Item &item = m_view->timelineModel()->item(itemId);
if (item.startTime() + item.duration() < m_view->currentTime())
continue;
if (item.startTime() > m_view->endTime())
break;
// ERROR_LOG(m_view->m_logger) << "item = " << itemId << " | track = " << m_view->m_model->track(item.parentTrackId()).text();
const QModelIndex rowIndex(m_view->timelineModel()->indexOfTrack(item.parentTrackId()));
const QModelIndex columnIndex(m_view->timelineModel()->index(rowIndex.row(), 1, rowIndex.parent()));
const QRect visualRect(m_view->visualRect(columnIndex));
int left = m_view->toPixel(item.startTime()) + dx;
int right = m_view->toPixel(item.startTime() + item.duration()) + dx;
int top = visualRect.top() + dy;
int bottom = visualRect.bottom() + dy;
QStyleOptionViewItem option;
option.rect = QRect(left, top, right - left - 1, bottom - top);
item.paint(painter, option, columnIndex, m_view->selectedItemIds().contains(itemId));
}
}
catch (...) {}
painter->restore();
}
void ItemDelegate::paintTrackButtons(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
{
try
{
const Track &track = m_view->timelineModel()->track(index.data(Qt::UserRole).toInt());
// const Track &track = m_view->timelineModel()->track(index.internalId());
int buttonLength = option.rect.height() / 2;
if (track.hasInsertButton())
{
QPushButton *button = m_view->m_trackHandler->isInsertButtonPressed(index) ? m_pushButtonPressed : m_pushButton;
QRect rect = QRect(0, 0, buttonLength, buttonLength);
button->setGeometry(rect);
button->setText(QStringLiteral("+"));
button->setEnabled(m_view->timelineModel()->isEditable());
QPixmap map = button->grab();
painter->drawPixmap(option.rect.right() - buttonLength, option.rect.top(), map);
}
if (track.hasRemoveButton())
{
QPushButton *button = m_view->m_trackHandler->isRemoveButtonPressed(index) ? m_pushButtonPressed : m_pushButton;
QRect rect = QRect(0, 0, buttonLength, buttonLength);
button->setGeometry(rect);
button->setText(QStringLiteral("-"));
button->setEnabled(m_view->timelineModel()->isEditable());
QPixmap map = button->grab();
painter->drawPixmap(option.rect.right() - buttonLength, option.rect.center().y(), map);
}
}
catch (...) {}
}
///////////////////////////////////////////////////////////////////////////////
// PRIVATE
void ItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
{
if (index.column() == Section::eActuator)
{
painter->save();
QStyledItemDelegate::paint(painter, option, index);
paintTrackButtons(painter, option, index);
painter->restore();
return;
}
auto drawItem = [this, &option, &painter, &index](const Item &item)
{
// if (item->startTime() + item->duration() < m_view->currentTime())
// continue;
// if (item->startTime() > m_view->endTime())
// break;
if (m_view->timelineModel()->isEditable())
if (m_view->m_dragHandler->m_dragItemIds.contains(item.id()))
return;
QStyleOptionViewItem opt = option;
opt.rect.setLeft(std::max(m_view->toPixel(item.startTime()), option.rect.left()));
opt.rect.setRight(std::min(m_view->toPixel(item.startTime() + item.duration()), option.rect.right()) - 1);
item.paint(painter, opt, index, m_view->selectedItemIds().contains(item.id()));
};
try
{
const Track &track = m_view->timelineModel()->track(index.data().toInt());
painter->save();
// painter->setPen(Qt::black);
// painter->drawRect(option.rect);
painter->setClipping(true);
painter->setClipRect(option.rect);
const Items &items = track.items();
for (const ItemPtr &item : items)
drawItem(static_cast<Item &>(*item.get()));
const QSet<int> copyItemIds = track.copyItemIds();
for (const int &itemId : copyItemIds)
{
try
{
const Item &item = m_view->timelineModel()->item(itemId);
drawItem(item);
}
catch(...)
{
fprintf(stderr, "ItemDelegate::paint: cannot find item copy of %d\n", itemId);
}
}
painter->restore();
}
catch (...)
{
ERROR_LOG(m_view->m_logger) << "ItemDelegate::paint -> CATCH";
}
}
} // namespace LtsTimeline