def _currentCellChanged(self, currentRow, currentColumn, previousRow, previousColumn): widget = self.cellWidget(currentRow, currentColumn) if self._widget_is_selectable(widget): self._current_variant = widget.variant else: self._current_variant = None self.setCurrentIndex(QtCore.QModelIndex()) # update other variants, this causes them to show/hide the depends icon if previousColumn != currentColumn: for _, widget in self._iter_column_widgets(previousColumn, VariantCellWidget): widget.set_reference_sibling(None) for _, widget in self._iter_column_widgets(currentColumn, VariantCellWidget): widget.set_reference_sibling(self._current_variant) # new selection is failing to cause a paint update sometimes?? This # seems to help but does not 100% fix the problem. self.update(self.model().index(previousRow, previousColumn)) self.update(self.model().index(currentRow, currentColumn)) self.variantSelected.emit(self._current_variant)
def _clear_selection(self): self.clearSelection() self.setCurrentIndex(QtCore.QModelIndex())
def _itemSelectionChanged(self): if not self.selectedIndexes(): self.setCurrentIndex(QtCore.QModelIndex())