From ae747ae2769277f232eaa20edaec76f92d53e0c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20=C5=A0pirk?= Date: Wed, 25 Sep 2024 14:11:45 +0200 Subject: [PATCH] adapt channel moving to reverse channel order --- libshvvisu/src/timeline/graphwidget.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/libshvvisu/src/timeline/graphwidget.cpp b/libshvvisu/src/timeline/graphwidget.cpp index 43251c9bd..54c567a37 100644 --- a/libshvvisu/src/timeline/graphwidget.cpp +++ b/libshvvisu/src/timeline/graphwidget.cpp @@ -533,11 +533,11 @@ void GraphWidget::moveDropMarker(const QPoint &mouse_pos) int ix = moveChannelTragetIndex(mouse_pos); if (ix < gr->channelCount()) { QRect ch_rect = gr->channelAt(ix)->verticalHeaderRect(); - m_channelHeaderMoveContext->channelDropMarker->move(ch_rect.left(), ch_rect.bottom() - m_channelHeaderMoveContext->channelDropMarker->height() / 2); + m_channelHeaderMoveContext->channelDropMarker->move(ch_rect.left(), ch_rect.top() - m_channelHeaderMoveContext->channelDropMarker->height() / 2); } else { QRect ch_rect = gr->channelAt(ix - 1)->verticalHeaderRect(); - m_channelHeaderMoveContext->channelDropMarker->move(ch_rect.left(), ch_rect.top() - m_channelHeaderMoveContext->channelDropMarker->height() / 2); + m_channelHeaderMoveContext->channelDropMarker->move(ch_rect.left(), ch_rect.bottom() - m_channelHeaderMoveContext->channelDropMarker->height() / 2); } } @@ -548,7 +548,7 @@ int GraphWidget::moveChannelTragetIndex(const QPoint &mouse_pos) const const GraphChannel *ch = gr->channelAt(i); QRect ch_rect = ch->verticalHeaderRect(); if (ch_rect.contains(mouse_pos)) { - if (mouse_pos.y() - ch_rect.top() > ch_rect.bottom() - mouse_pos.y()) { + if (mouse_pos.y() - ch_rect.top() <= ch_rect.bottom() - mouse_pos.y()) { return i; } int j = i; @@ -562,9 +562,11 @@ int GraphWidget::moveChannelTragetIndex(const QPoint &mouse_pos) const return j; } } - } } + if (gr->channelCount() && mouse_pos.y() > gr->channelAt(gr->channelCount() - 1)->verticalHeaderRect().bottom()) { + return static_cast(gr->channelCount()); + } return 0; }