Continues migration with DDS, Common
This commit is contained in:
1 parent
9b15cee841
commit
fa48db111e
668 files changed
+111841
-2
No files matched your search
+181
@@ -0,0 +1,181 @@
|
||||
#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())
|
||||
{
|
||||
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;
|
||||
|
||||
|
||||
|
||||
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();
|
||||
|
||||
|
||||
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)
|
||||
{
|
||||
if (event->buttons() != Qt::LeftButton)
|
||||
return;
|
||||
|
||||
QPoint cursorPos = m_tcw->mapFromGlobal(event->globalPos());
|
||||
|
||||
|
||||
if (!m_tcw->m_mainSelected
|
||||
|| ((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;
|
||||
|
||||
if (drag->exec(Qt::MoveAction) == Qt::MoveAction)
|
||||
{
|
||||
if (!m_tcw->isMultiLineMultiSelectionMode())
|
||||
{
|
||||
|
||||
for (auto i = selectedOld.begin(); i != selectedOld.end(); ++i)
|
||||
emit m_tcw->signalTrackEntryDeleted((*i)->m_topicId);
|
||||
qDeleteAll(selectedOld);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user