From b07d9cc97615506756c9d058d7b663cc78c2a83e Mon Sep 17 00:00:00 2001 From: David Rosca Date: Mon, 12 Feb 2018 16:26:54 +0100 Subject: [PATCH] TabBar: Support drop moving tabs from the same tabbar Closes #2602 --- src/lib/tabwidget/tabbar.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/lib/tabwidget/tabbar.cpp b/src/lib/tabwidget/tabbar.cpp index 911b62585..393fe1f9b 100644 --- a/src/lib/tabwidget/tabbar.cpp +++ b/src/lib/tabwidget/tabbar.cpp @@ -642,7 +642,7 @@ void TabBar::dragMoveEvent(QDragMoveEvent *event) const int index = tabAt(event->pos()); const QMimeData* mime = event->mimeData(); - if (index == -1 || (mime->hasFormat(MIMETYPE) && event->source() == this)) { + if (index == -1) { ComboTabBar::dragMoveEvent(event); return; } @@ -680,10 +680,6 @@ void TabBar::dropEvent(QDropEvent* event) event->acceptProposedAction(); - if (mime->hasFormat(MIMETYPE) && event->source() == this) { - return; - } - TabBar *sourceTabBar = qobject_cast(event->source()); int index = tabAt(event->pos()); @@ -722,9 +718,13 @@ void TabBar::dropEvent(QDropEvent* event) } else if (mime->hasFormat(MIMETYPE) && sourceTabBar) { WebTab *tab = sourceTabBar->webTab(); if (tab) { - sourceTabBar->m_tabWidget->detachTab(tab); - tab->setPinned(index < pinnedTabsCount()); - m_tabWidget->insertView(newIndex, tab, Qz::NT_SelectedTab); + if (sourceTabBar == this) { + tab->moveTab(newIndex > tab->tabIndex() ? newIndex - 1 : newIndex); + } else { + sourceTabBar->m_tabWidget->detachTab(tab); + tab->setPinned(index < pinnedTabsCount()); + m_tabWidget->insertView(newIndex, tab, Qz::NT_SelectedTab); + } } } }