From bcd009afb5661de15ecb4edbde2319339e221b61 Mon Sep 17 00:00:00 2001 From: zccrs Date: Fri, 26 Jan 2018 16:31:33 +0800 Subject: [PATCH] feat: add "target" argument for DTabBar::tabDroped Change-Id: I58310eac5c52f14e96a7e23ca8ce756a2135b333 --- src/widgets/dtabbar.cpp | 7 +++++-- src/widgets/dtabbar.h | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/widgets/dtabbar.cpp b/src/widgets/dtabbar.cpp index 9c5f4a5a9..6b49d2e5b 100644 --- a/src/widgets/dtabbar.cpp +++ b/src/widgets/dtabbar.cpp @@ -264,12 +264,15 @@ class DTabBarPrivate : public QTabBar, public DObjectPrivate void DTabBarPrivate::startDrag(int tabIndex) { - Qt::DropAction action = drag->exec(Qt::MoveAction, Qt::MoveAction); + Qt::DropAction action = drag->exec(Qt::MoveAction | Qt::CopyAction, Qt::CopyAction); if (action == Qt::IgnoreAction) { Q_EMIT q_func()->tabReleaseRequested(tabIndex); } else if (drag->target() != this) { - Q_EMIT q_func()->tabDroped(tabIndex, action); + if (DTabBarPrivate *tbp = qobject_cast(drag->target())) + Q_EMIT q_func()->tabDroped(tabIndex, action, tbp->q_func()); + else + Q_EMIT q_func()->tabDroped(tabIndex, action, drag->target()); } drag->setProperty("_d_DTabBarPrivate_drity", true); diff --git a/src/widgets/dtabbar.h b/src/widgets/dtabbar.h index 82576f8c1..dcf0ce193 100644 --- a/src/widgets/dtabbar.h +++ b/src/widgets/dtabbar.h @@ -163,7 +163,7 @@ class DTabBar : public QWidget, public DObject void tabBarDoubleClicked(int index); void tabAddRequested(); void tabReleaseRequested(int index); - void tabDroped(int index, Qt::DropAction action); + void tabDroped(int index, Qt::DropAction action, QObject *target); public Q_SLOTS: void setCurrentIndex(int index);