Skip to content

Commit

Permalink
Fix edge case when multi-select editing RARC files
Browse files Browse the repository at this point in the history
  • Loading branch information
LagoLunatic committed Sep 20, 2024
1 parent 3f74cbc commit 5d6563c
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion gcft_ui/custom_widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,13 @@ def setEditorData(self, editor: QComboBox, index):
editor.setCurrentIndex(-1)

def setModelData(self, editor: QComboBox, model, primary_index):
# In order to support multi-select editing, we set the data on the appropriate column for all
# selected rows, instead of just the primary selected row.
selection_model: QItemSelectionModel = editor.parent().parent().selectionModel()
assert primary_index in selection_model.selectedIndexes()
if primary_index not in selection_model.selectedIndexes():
# The user managed to deselect the primary selected item so it won't be covered by the loop.
# Handle this separately so that it's not skipped.
model.setData(primary_index, editor.currentText(), Qt.ItemDataRole.EditRole)
for row_index in selection_model.selectedRows():
item_index = primary_index.siblingAtRow(row_index.row())
model.setData(item_index, editor.currentText(), Qt.ItemDataRole.EditRole)
Expand Down

0 comments on commit 5d6563c

Please sign in to comment.