summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Swift/QtUI/QtTabWidget.cpp23
-rw-r--r--Swift/QtUI/QtTabWidget.h6
-rw-r--r--Swift/QtUI/Trellis/QtDNDTabBar.h3
3 files changed, 31 insertions, 1 deletions
diff --git a/Swift/QtUI/QtTabWidget.cpp b/Swift/QtUI/QtTabWidget.cpp
index 9f353d7..cda1847 100644
--- a/Swift/QtUI/QtTabWidget.cpp
+++ b/Swift/QtUI/QtTabWidget.cpp
@@ -6,6 +6,8 @@
#include <Swift/QtUI/QtTabWidget.h>
+#include <Swift/QtUI/Trellis/QtDNDTabBar.h>
+
namespace Swift {
QtTabWidget::QtTabWidget(QWidget* parent) : QTabWidget(parent) {
@@ -22,5 +24,26 @@ QTabBar* QtTabWidget::tabBar() {
void QtTabWidget::setTabBar(QTabBar* tabBar) {
QTabWidget::setTabBar(tabBar);
+ if (dynamic_cast<QtDNDTabBar*>(tabBar)) {
+ setAcceptDrops(true);
+ }
+ else {
+ setAcceptDrops(false);
+ }
+}
+
+void QtTabWidget::dragEnterEvent(QDragEnterEvent* event) {
+ QtDNDTabBar* dndTabBar = dynamic_cast<QtDNDTabBar*>(tabBar());
+ if (dndTabBar) {
+ dndTabBar->dragEnterEvent(event);
+ }
}
+
+void QtTabWidget::dropEvent(QDropEvent* event) {
+ QtDNDTabBar* dndTabBar = dynamic_cast<QtDNDTabBar*>(tabBar());
+ if (dndTabBar) {
+ dndTabBar->dropEvent(event);
+ }
+}
+
}
diff --git a/Swift/QtUI/QtTabWidget.h b/Swift/QtUI/QtTabWidget.h
index de1a846..a9d0df8 100644
--- a/Swift/QtUI/QtTabWidget.h
+++ b/Swift/QtUI/QtTabWidget.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010 Isode Limited.
+ * Copyright (c) 2010-2016 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -17,5 +17,9 @@ namespace Swift {
QTabBar* tabBar();
void setTabBar(QTabBar* tabBar);
+
+ protected:
+ virtual void dragEnterEvent(QDragEnterEvent* event);
+ virtual void dropEvent(QDropEvent* event);
};
}
diff --git a/Swift/QtUI/Trellis/QtDNDTabBar.h b/Swift/QtUI/Trellis/QtDNDTabBar.h
index 40eb66d..e9b6771 100644
--- a/Swift/QtUI/Trellis/QtDNDTabBar.h
+++ b/Swift/QtUI/Trellis/QtDNDTabBar.h
@@ -8,6 +8,8 @@
#include <QTabBar>
+#include <Swift/QtUI/QtTabWidget.h>
+
namespace Swift {
class QtDNDTabBar : public QTabBar {
@@ -22,6 +24,7 @@ class QtDNDTabBar : public QTabBar {
virtual QSize sizeHint() const;
+ friend class QtTabWidget;
signals:
void onDropSucceeded();