Files
qt-migration-legatus/qt6-after/qt6-migrated-legatus/Lts/Common/LtsTimeline/timeline_view_track_handler.cpp
T
torstenandCopilot d6b6ffce7c Apply clang-format to Lts/Common and DTC/enum headers
- Formatted all CodeGen module files (9 files)
- Formatted LtsAppDescriptor module files
- Formatted LtsAppManager/AppChooser files
- Applied clang-format to all DTC and enum headers across modules
- Removed coordTransTests from CommonUnitTestsPlaceholder (moved to tests/)

Cosmetic changes only, no functional modifications.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-08-19 14:46:29 +02:00

99 lines
2.8 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 <QApplication>
#include <QDebug>
#include <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