From 7e8a4fd0451afd224d49fd7496e528759133333a Mon Sep 17 00:00:00 2001 From: Olivier Keshavjee Date: Mon, 8 Jun 2015 13:53:33 +0200 Subject: [PATCH] Fixes drag n drop issue --- src/models/outlineModel.py | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/src/models/outlineModel.py b/src/models/outlineModel.py index 90775597..47fe48ad 100644 --- a/src/models/outlineModel.py +++ b/src/models/outlineModel.py @@ -138,13 +138,14 @@ class outlineModel(QAbstractItemModel): 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 - elif index.isValid(): + elif index.isValid() and index.column() == 0: flags |= Qt.ItemIsDragEnabled - else: + elif not index.isValid(): flags |= Qt.ItemIsDropEnabled if index.isValid() and index.column() == Outline.compile.value: @@ -179,14 +180,14 @@ class outlineModel(QAbstractItemModel): #return Qt.MoveAction # Qt.CopyAction | return Qt.CopyAction | Qt.MoveAction - def canDropMomeData(data, action, row, column, parent): - if not data.hasFormat("application/xml"): - return False + #def canDropMimeData(self, data, action, row, column, parent): + #if not data.hasFormat("application/xml"): + #return False - if column > 0: - return False + #if column > 0: + #return False - return True + #return True def dropMimeData(self, data, action, row, column, parent): @@ -206,7 +207,7 @@ class outlineModel(QAbstractItemModel): else: beginRow = self.rowCount() + 1 - encodedData = str(data.data("application/xml")) + encodedData = bytes(data.data("application/xml")).decode() root = ET.XML(encodedData)