Files
qt-migration-legatus/qt6-after/qt6-migrated-legatus/Lts/Common/LtsTimeline/timeline_view_track_handler.cpp
T
torstenandCopilot 7a6be7474e Qt6 migration: Fix BUILD_RTI=OFF build errors in TrainingAreaBase
- 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>
2026-08-23 20:49:23 +02:00

99 lines
2.9 KiB
C++

#include "item.h"
#include "timeline_header_view.h"
#include "timeline_view.h"
#include "timeline_view_resize_handler.h"
#include "track.h"
#include <LtsWidgets/lts_message_dialog.h>
#include <QtWidgets/QApplication>
#include <QtCore/QDebug>
#include <QtGui/QMouseEvent>
namespace LtsTimeline
{
TimelineViewTrackHandler::TimelineViewTrackHandler(TimelineView* view) : m_view(view) {}
TimelineViewTrackHandler::~TimelineViewTrackHandler()
{
m_view = nullptr;
}
void TimelineViewTrackHandler::mouseDoubleClickEvent(QMouseEvent* e)
{
if (e->button() != Qt::LeftButton)
return;
const QModelIndex index = m_view->indexAt(e->pos());
if (!index.isValid() || index.column() != Section::eActuator)
return;
emit m_view->trackActivated(index.data().toInt());
}
void TimelineViewTrackHandler::mousePressEvent(QMouseEvent* e)
{
if (e->button() != Qt::LeftButton)
{
if (e->button() == Qt::RightButton)
emit m_view->customContextMenuRequested(e->pos());
return;
}
const QModelIndex index = m_view->indexAt(e->pos());
if (!index.isValid() || index.column() != Section::eActuator)
return;
try
{
if (!m_view->timelineModel()->isEditable())
return;
const Track& track = m_view->timelineModel()->track(index.data(Qt::UserRole).toInt());
QRect visRect = m_view->visualRect(index);
int buttonLength = visRect.height() / 2;
if (track.hasInsertButton())
{
QRect rect = QRect(visRect.right() - buttonLength, visRect.top(), buttonLength, buttonLength);
if (rect.contains(e->pos()))
{
m_pressedInsertButtonIndex = index;
m_view->timelineModel()->onInsertTrack(index);
return;
}
}
if (track.hasRemoveButton())
{
QRect rect = QRect(visRect.right() - buttonLength, visRect.center().y(), buttonLength, buttonLength);
if (rect.contains(e->pos()))
{
m_pressedRemoveButtonIndex = index;
auto msg = new LtsWidgets::LtsMessageDialogNew(
m_view, {},
QApplication::translate("LtsTimeline",
"Do you really want to remove this filter track and all of its contents?"),
LtsWidgets::Behaviour::Modal, LtsWidgets::Button::Yes | LtsWidgets::Button::Cancel);
QObject::connect(msg, &LtsWidgets::LtsMessageDialogNew::yes, m_view,
[this, index]() { m_view->timelineModel()->onRemoveTrack(index); });
return;
}
}
}
catch (...)
{
}
}
void TimelineViewTrackHandler::mouseReleaseEvent(QMouseEvent* e)
{
Q_UNUSED(e);
m_pressedInsertButtonIndex = {};
m_pressedRemoveButtonIndex = {};
}
} // namespace LtsTimeline