Commit 54f3ce88 authored by Waqar Ahmed's avatar Waqar Ahmed Committed by Christoph Cullmann
Browse files

Don't allow dropping into different mainWindows for now

parent 615c9fdd
......@@ -787,6 +787,13 @@ void KateViewManager::moveViewToViewSpace(KateViewSpace *dest, KateViewSpace *sr
{
// We always have an active view at this point which is what we are moving
Q_ASSERT(activeView());
// Are we trying to drop into some other mainWindow of current app session?
// shouldn't happen, but just a safe guard
if (src->viewManger() != dest->viewManger()) {
return;
}
auto view = src->takeView(doc);
dest->addView(view);
setActiveSpace(dest);
......
......@@ -404,7 +404,6 @@ void KateViewSpace::registerDocument(KTextEditor::Document *doc)
connect(m_tabBar, &KateTabBar::currentChanged, this, &KateViewSpace::changeView);
}
void KateViewSpace::closeDocument(KTextEditor::Document *doc)
{
// If this is the only view of the document,
......@@ -431,10 +430,17 @@ void KateViewSpace::closeDocument(KTextEditor::Document *doc)
}
}
bool KateViewSpace::acceptsDroppedTab(const class TabMimeData *tabMimeData)
{
return tabMimeData && this != tabMimeData->sourceVS && // must not be same viewspace
viewManger() == tabMimeData->sourceVS->viewManger() && // for now we don't support dropping into different windows
!hasDocument(tabMimeData->doc);
}
void KateViewSpace::dragEnterEvent(QDragEnterEvent *e)
{
auto mimeData = qobject_cast<const TabMimeData *>(e->mimeData());
if (mimeData && this != mimeData->sourceVS && !hasDocument(mimeData->doc)) {
if (acceptsDroppedTab(mimeData)) {
m_dropIndicator.reset(new QRubberBand(QRubberBand::Rectangle, this));
m_dropIndicator->setGeometry(rect());
m_dropIndicator->show();
......
......@@ -44,6 +44,14 @@ public:
*/
void setActive(bool active);
/**
* @return the view manager that this viewspace belongs to
*/
KateViewManager *viewManger() const
{
return m_viewManager;
}
/**
* Create new view for given document
* @param doc document to create view for
......@@ -214,6 +222,7 @@ private Q_SLOTS:
void createNewDocument();
private:
bool acceptsDroppedTab(const class TabMimeData *tabMimeData);
/**
* Returns the amount of documents in KateDocManager that currently
* have no tab in this tab bar.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment