mirror of
https://github.com/olivierkes/manuskript.git
synced 2024-06-02 11:04:33 +12:00
Fixes drag n drop issue
This commit is contained in:
parent
0758b88910
commit
7e8a4fd045
|
@ -138,13 +138,14 @@ class outlineModel(QAbstractItemModel):
|
||||||
|
|
||||||
flags = QAbstractItemModel.flags(self, index) | Qt.ItemIsEditable
|
flags = QAbstractItemModel.flags(self, index) | Qt.ItemIsEditable
|
||||||
|
|
||||||
if index.isValid() and index.internalPointer().isFolder():
|
|
||||||
|
if index.isValid() and index.internalPointer().isFolder() and index.column() == 0:
|
||||||
flags |= Qt.ItemIsDragEnabled | Qt.ItemIsDropEnabled
|
flags |= Qt.ItemIsDragEnabled | Qt.ItemIsDropEnabled
|
||||||
|
|
||||||
elif index.isValid():
|
elif index.isValid() and index.column() == 0:
|
||||||
flags |= Qt.ItemIsDragEnabled
|
flags |= Qt.ItemIsDragEnabled
|
||||||
|
|
||||||
else:
|
elif not index.isValid():
|
||||||
flags |= Qt.ItemIsDropEnabled
|
flags |= Qt.ItemIsDropEnabled
|
||||||
|
|
||||||
if index.isValid() and index.column() == Outline.compile.value:
|
if index.isValid() and index.column() == Outline.compile.value:
|
||||||
|
@ -179,14 +180,14 @@ class outlineModel(QAbstractItemModel):
|
||||||
#return Qt.MoveAction # Qt.CopyAction |
|
#return Qt.MoveAction # Qt.CopyAction |
|
||||||
return Qt.CopyAction | Qt.MoveAction
|
return Qt.CopyAction | Qt.MoveAction
|
||||||
|
|
||||||
def canDropMomeData(data, action, row, column, parent):
|
#def canDropMimeData(self, data, action, row, column, parent):
|
||||||
if not data.hasFormat("application/xml"):
|
#if not data.hasFormat("application/xml"):
|
||||||
return False
|
#return False
|
||||||
|
|
||||||
if column > 0:
|
#if column > 0:
|
||||||
return False
|
#return False
|
||||||
|
|
||||||
return True
|
#return True
|
||||||
|
|
||||||
def dropMimeData(self, data, action, row, column, parent):
|
def dropMimeData(self, data, action, row, column, parent):
|
||||||
|
|
||||||
|
@ -206,7 +207,7 @@ class outlineModel(QAbstractItemModel):
|
||||||
else:
|
else:
|
||||||
beginRow = self.rowCount() + 1
|
beginRow = self.rowCount() + 1
|
||||||
|
|
||||||
encodedData = str(data.data("application/xml"))
|
encodedData = bytes(data.data("application/xml")).decode()
|
||||||
|
|
||||||
root = ET.XML(encodedData)
|
root = ET.XML(encodedData)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue