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

184 lines
4.5 KiB
C++

#include "track_drag_handler.h"
#include "track_content_widget.h"
#include "track_entry.h"
#include "tools.h"
#include "track_widget.h"
#include "script_timeline.h"
#include <LtsWidgets/lts_message_dialog.h>
#include <QDragEnterEvent>
#include <QDropEvent>
#include <QDrag>
#include <QMimeData>
#include <QGuiApplication>
#include <QApplication>
#include <QDebug>
namespace LtsScriptTimeline
{
void DragHandler::dragEnterEvent(QDragEnterEvent *event)
{
if (m_tcw->isMultiLineMultiSelectionMode()) // in multiline selection mode, ignore enter events from other tracks
{
if (event->source() != m_tcw)
{
event->ignore();
return;
}
else
{
for (const auto &tcw : qAsConst(m_tcwCorresponding))
tcw->dragEnter(tcw->selectedItemsToData(tcw->m_tools->getTime(m_dragStartPos.x())));
}
}
m_tcw->dragEnd();
if (!event->mimeData()->hasFormat(TrackContentWidget::mime))
return;
if (m_tcw->dragEnter(event->mimeData()->data(TrackContentWidget::mime)))
event->acceptProposedAction();
}
void DragHandler::dragLeaveEvent(QDragLeaveEvent *event)
{
if (m_tcw->isMultiLineMultiSelectionMode())
{
event->ignore();
for (const auto &tcw : qAsConst(m_tcwCorresponding))
tcw->dragEnd();
}
m_tcw->dragEnd();
}
void DragHandler::dropEvent(QDropEvent *event)
{
int dropPos = event->pos().x();
int dropTime = m_tcw->m_tools->getTime(dropPos, m_tcw->m_isFilter) - m_tcw->m_dragOffsetTime;
/*
* If set, check other track content widget for collisions to avoid parallel topics of same type,
* since not all topics can be played on both screens at the same time.
*/
for (const auto &tcw : qAsConst(m_tcwCorresponding))
{
bool hasParallelTopicsOfSameType = TrackContentWidget::checkForParallelTopics(tcw, m_tcw->m_preview, dropTime);
if (hasParallelTopicsOfSameType)
{
new LtsWidgets::LtsMessageDialogNew(m_tcw, TrackContentWidget::parallelError(), QObject::tr("Error"));
break;
}
}
if (m_tcw->dragDrop(dropPos))
event->acceptProposedAction();
else
emit m_tcw->signalMultiLineMultiSelectionDone(0);
}
void DragHandler::dragMoveEvent(QDragMoveEvent *event)
{
int pos = event->pos().x();
if (m_tcw->dragMove(pos))
event->acceptProposedAction();
// only called from the master
if (m_tcw->isMultiLineMultiSelectionMode())
emit m_tcw->signalMultiLineMultiSelectionMove(pos);
}
void DragHandler::mousePressEvent(QMouseEvent *event)
{
if (event->buttons() != Qt::LeftButton)
return;
m_dragStartPos = event->pos();
}
void DragHandler::mouseMoveEvent(QMouseEvent *event) // before a drag is started - drag is started here
{
if (event->buttons() != Qt::LeftButton)
return;
QPoint cursorPos = m_tcw->mapFromGlobal(event->globalPos());
// check if it's a drag *pun unintended*
if (!m_tcw->m_mainSelected /* only allow drag if there was ANY te under the cursor */
|| ((cursorPos - m_dragStartPos).manhattanLength() < QApplication::startDragDistance()
&& (m_dragStartPos - cursorPos).manhattanLength() < QApplication::startDragDistance()))
return;
QVector<TrackEntry *> selected = m_tcw->getSelectedEntries();
if (selected.isEmpty())
return;
int cursorPosTime = m_tcw->m_tools->getTime(m_dragStartPos.x());
QMimeData *mimeData = new QMimeData();
mimeData->setData(TrackContentWidget::mime, m_tcw->selectedItemsToData(cursorPosTime));
QDrag *drag = new QDrag(m_tcw);
drag->setMimeData(mimeData);
if (m_tcw->isMultiLineMultiSelectionMode())
emit m_tcw->signalMultiLineMultiSelectionStart(cursorPosTime);
QVector<TrackEntry *> selectedOld = m_tcw->m_selected; // copy list, only delete OLD selection [NOTE: m_selected has to be fetched BEFORE exec(), otherwise m_select has changed (due to new / moved TEs!)
if (drag->exec(Qt::MoveAction) == Qt::MoveAction)
{
if (!m_tcw->isMultiLineMultiSelectionMode())
{
// move action - TEs were moved
for (auto i = selectedOld.begin(); i != selectedOld.end(); ++i)
emit m_tcw->signalTrackEntryDeleted((*i)->m_topicId); // triggers the deletion of old filters
qDeleteAll(selectedOld);
}
}
else // user pressed escape while dragging
{
emit m_tcw->signalMultiLineMultiSelectionDone(-1);
}
}
void DragHandler::keyPressEvent(QKeyEvent *event)
{
switch (event->key())
{
case Qt::Key_Left:
{
emit m_tcw->signalMoveAll(-1);
break;
}
case Qt::Key_Right:
{
emit m_tcw->signalMoveAll(1);
break;
}
default:
{
break;
}
}
}
} // namespace LtsScriptTimeline