Someone was in a JavaScript mood?

This commit is contained in:
Zeth Green 2021-06-21 02:43:09 +01:00
parent a58de3b1f6
commit bc10cd3671

View file

@ -38,7 +38,7 @@ class abstractModel(QAbstractItemModel):
- Interface with QModelIndex and stuff - Interface with QModelIndex and stuff
- XML Import / Export - XML Import / Export
- Drag'n'drop - Drag'n'drop
Row => item/abstractModel/etc. Row => item/abstractModel/etc.
Col => data sub-element. Col 1 (second counting) is ID for all model types. Col => data sub-element. Col 1 (second counting) is ID for all model types.
@ -429,19 +429,19 @@ class abstractModel(QAbstractItemModel):
# In case of copy actions, items might be duplicates, so we need new IDs. # 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. # 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. # 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 # 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. # even if they are not duplicated in pasting. There is no practical need for ID conservation.
if action == Qt.CopyAction: if action == Qt.CopyAction:
IDs = self.rootItem.listAllIDs() IDs = self.rootItem.listAllIDs()
for item in items: for item in items:
if item.ID() in IDs: if item.ID() in IDs:
item.getUniqueID(recursive=true) item.getUniqueID(recursive=True)
r = self.insertItems(items, beginRow, parent) r = self.insertItems(items, beginRow, parent)
return r return r
################# ADDING AND REMOVING ################# ################# ADDING AND REMOVING #################
@ -461,12 +461,12 @@ class abstractModel(QAbstractItemModel):
# Insert only if parent is folder # Insert only if parent is folder
if parentItem.isFolder(): if parentItem.isFolder():
self.beginInsertRows(parent, row, row + len(items) - 1) # Create space. self.beginInsertRows(parent, row, row + len(items) - 1) # Create space.
for i in items: for i in items:
parentItem.insertChild(row + items.index(i), i) parentItem.insertChild(row + items.index(i), i)
self.endInsertRows() self.endInsertRows()
return True return True
else: else:
@ -519,7 +519,7 @@ class abstractModel(QAbstractItemModel):
else: else:
parentItem = parent.internalPointer() parentItem = parent.internalPointer()
self._removingRows = True self._removingRows = True
# Views that are updating can easily know # Views that are updating can easily know
# if this is due to row removal. # if this is due to row removal.
self.beginRemoveRows(parent, row, row + count - 1) self.beginRemoveRows(parent, row, row + count - 1)