diff --git a/src/ViewContainer.cpp b/src/ViewContainer.cpp index afecf786..58bdbd0d 100644 --- a/src/ViewContainer.cpp +++ b/src/ViewContainer.cpp @@ -316,19 +316,25 @@ void ViewContainerTabBar::setDropIndicator(int index, bool drawDisabled) _dropIndicator->move(mapTo(parentWidget(), pos)); _dropIndicator->show(); } + +void ViewContainerTabBar::setSupportedMimeType(const QString& mimeType) +{ + _supportedMimeType = mimeType; +} + void ViewContainerTabBar::dragLeaveEvent(QDragLeaveEvent*) { setDropIndicator(-1); } void ViewContainerTabBar::dragEnterEvent(QDragEnterEvent* event) { - if (event->mimeData()->hasFormat(ViewProperties::mimeType()) && + if (event->mimeData()->hasFormat(_supportedMimeType) && event->source() != 0) event->acceptProposedAction(); } void ViewContainerTabBar::dragMoveEvent(QDragMoveEvent* event) { - if (event->mimeData()->hasFormat(ViewProperties::mimeType()) + if (event->mimeData()->hasFormat(_supportedMimeType) && event->source() != 0) { int index = dropIndex(event->pos()); if (index == -1) @@ -375,7 +381,7 @@ void ViewContainerTabBar::dropEvent(QDropEvent* event) { setDropIndicator(-1); - if (!event->mimeData()->hasFormat(ViewProperties::mimeType())) { + if (!event->mimeData()->hasFormat(_supportedMimeType)) { event->ignore(); return; } @@ -429,6 +435,7 @@ TabbedViewContainer::TabbedViewContainer(NavigationPosition position , QObject* // The tab bar _tabBar = new ViewContainerTabBar(_containerWidget, this); + _tabBar->setSupportedMimeType(ViewProperties::mimeType()); connect(_tabBar, SIGNAL(currentChanged(int)), this, SLOT(currentTabChanged(int))); connect(_tabBar, SIGNAL(tabDoubleClicked(int)), this, SLOT(tabDoubleClicked(int))); diff --git a/src/ViewContainer.h b/src/ViewContainer.h index e1a14cd6..3f512ab3 100644 --- a/src/ViewContainer.h +++ b/src/ViewContainer.h @@ -362,6 +362,9 @@ public: // returns a pixmap image of a tab for use with QDrag QPixmap dragDropPixmap(int tab); + // set the mimetype of which the tabbar support d&d + void setSupportedMimeType(const QString& mimeType); + signals: void querySourceIndex(const QDropEvent* event, int& sourceIndex) const; @@ -386,6 +389,7 @@ private: QLabel* _dropIndicator; int _dropIndicatorIndex; bool _drawIndicatorDisabled; + QString _supportedMimeType; }; /**