From 5d6563c170e2f355bac88c6672b1b731281aae14 Mon Sep 17 00:00:00 2001 From: LagoLunatic Date: Fri, 20 Sep 2024 17:15:54 -0400 Subject: [PATCH] Fix edge case when multi-select editing RARC files --- gcft_ui/custom_widgets.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/gcft_ui/custom_widgets.py b/gcft_ui/custom_widgets.py index 1e3e7c0..153a65f 100644 --- a/gcft_ui/custom_widgets.py +++ b/gcft_ui/custom_widgets.py @@ -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)