Add drag and drop functionality for outline items to editors

This commit is contained in:
tcsch 2022-08-12 17:10:34 +02:00
parent 48af930b11
commit 22609fa1fd

View file

@ -4,6 +4,7 @@ import locale
from PyQt5.QtCore import QModelIndex, QRect, QPoint, Qt, QObject, QSize
from PyQt5.QtGui import QIcon, QPalette
from PyQt5.QtGui import QDropEvent, QDragEnterEvent
from PyQt5.QtWidgets import QWidget, QPushButton, qApp
from manuskript.functions import mainWindow, appPath
@ -80,6 +81,19 @@ class tabSplitter(QWidget, Ui_tabSplitter):
self.tab.currentChanged.connect(self.mainEditor.tabChanged)
qApp.focusChanged.connect(self.focusChanged)
self.setAcceptDrops(True)
def dragEnterEvent(self, event: QDragEnterEvent) -> None:
if event.mimeData().hasFormat('application/xml'):
event.accept()
else:
event.ignore()
def dropEvent(self, event: QDropEvent) -> None:
itemID = mainWindow().mdlOutline.decodeMimeData(event.mimeData())[0].ID()
itemIndex = mainWindow().mdlOutline.getIndexByID(itemID)
self.mainEditor.setCurrentModelIndex(itemIndex, tabWidget = self.tab)
def updateStyleSheet(self):
self.setStyleSheet(style.mainEditorTabSS())
if self.secondTab: