Skip to content

Commit

Permalink
Merge pull request #893 from zeth/javascript_mood
Browse files Browse the repository at this point in the history
Someone was in a JavaScript mood?
  • Loading branch information
TheJackiMonster committed Jun 21, 2021
2 parents a58de3b + bc10cd3 commit a29bf79
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions manuskript/models/abstractModel.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class abstractModel(QAbstractItemModel):
- Interface with QModelIndex and stuff
- XML Import / Export
- Drag'n'drop
Row => item/abstractModel/etc.
Col => data sub-element. Col 1 (second counting) is ID for all model types.
Expand Down Expand Up @@ -429,19 +429,19 @@ def dropMimeData(self, data, action, row, column, parent):
# In case of copy actions, items might be duplicates, so we need new IDs.
# But they might not be, if we cut, then paste. Paste is a Copy Action.
# The first paste would not need new IDs. But subsequent ones will.

# Recursively change the existing IDs to new, unique values. No need to strip out the old
# even if they are not duplicated in pasting. There is no practical need for ID conservation.

if action == Qt.CopyAction:
IDs = self.rootItem.listAllIDs()

for item in items:
if item.ID() in IDs:
item.getUniqueID(recursive=true)
item.getUniqueID(recursive=True)

r = self.insertItems(items, beginRow, parent)

return r

################# ADDING AND REMOVING #################
Expand All @@ -461,12 +461,12 @@ def insertItems(self, items, row, parent=QModelIndex()):
# Insert only if parent is folder
if parentItem.isFolder():
self.beginInsertRows(parent, row, row + len(items) - 1) # Create space.

for i in items:
parentItem.insertChild(row + items.index(i), i)

self.endInsertRows()

return True

else:
Expand Down Expand Up @@ -519,7 +519,7 @@ def removeRows(self, row, count, parent=QModelIndex()):
else:
parentItem = parent.internalPointer()

self._removingRows = True
self._removingRows = True
# Views that are updating can easily know
# if this is due to row removal.
self.beginRemoveRows(parent, row, row + count - 1)
Expand Down

0 comments on commit a29bf79

Please sign in to comment.