diff -r e9e7eca7efee -r bf71ee032bb4 src/eric7/EricWidgets/EricListSelectionDialog.py --- a/src/eric7/EricWidgets/EricListSelectionDialog.py Wed Jul 13 11:16:20 2022 +0200 +++ b/src/eric7/EricWidgets/EricListSelectionDialog.py Wed Jul 13 14:55:47 2022 +0200 @@ -9,7 +9,10 @@ from PyQt6.QtCore import pyqtSlot, Qt from PyQt6.QtWidgets import ( - QDialog, QDialogButtonBox, QAbstractItemView, QListWidgetItem + QDialog, + QDialogButtonBox, + QAbstractItemView, + QListWidgetItem, ) from .Ui_EricListSelectionDialog import Ui_EricListSelectionDialog @@ -19,14 +22,20 @@ """ Class implementing a dialog to select from a list of strings. """ - def __init__(self, entries, - selectionMode=QAbstractItemView.SelectionMode - .ExtendedSelection, - title="", message="", checkBoxSelection=False, - doubleClickOk=False, parent=None): + + def __init__( + self, + entries, + selectionMode=QAbstractItemView.SelectionMode.ExtendedSelection, + title="", + message="", + checkBoxSelection=False, + doubleClickOk=False, + parent=None, + ): """ Constructor - + @param entries list of entries to select from @type list of str @param selectionMode selection mode for the list @@ -46,44 +55,45 @@ """ super().__init__(parent) self.setupUi(self) - + if title: self.setWindowTitle(title) if message: self.messageLabel.setText(message) - + self.__checkCount = 0 self.__isCheckBoxSelection = checkBoxSelection if self.__isCheckBoxSelection: self.selectionList.setSelectionMode( - QAbstractItemView.SelectionMode.NoSelection) + QAbstractItemView.SelectionMode.NoSelection + ) for entry in entries: itm = QListWidgetItem(entry) - itm.setFlags(Qt.ItemFlag.ItemIsUserCheckable | - Qt.ItemFlag.ItemIsEnabled) + itm.setFlags( + Qt.ItemFlag.ItemIsUserCheckable | Qt.ItemFlag.ItemIsEnabled + ) itm.setCheckState(Qt.CheckState.Unchecked) self.selectionList.addItem(itm) else: self.selectionList.setSelectionMode(selectionMode) self.selectionList.addItems(entries) - - self.buttonBox.button( - QDialogButtonBox.StandardButton.Ok).setEnabled(False) - + + self.buttonBox.button(QDialogButtonBox.StandardButton.Ok).setEnabled(False) + @pyqtSlot() def on_selectionList_itemSelectionChanged(self): """ Private slot handling a change of the selection. """ if not self.__isCheckBoxSelection: - self.buttonBox.button( - QDialogButtonBox.StandardButton.Ok).setEnabled( - len(self.selectionList.selectedItems()) > 0) - + self.buttonBox.button(QDialogButtonBox.StandardButton.Ok).setEnabled( + len(self.selectionList.selectedItems()) > 0 + ) + def on_selectionList_itemChanged(self, itm): """ Private slot handling a change of an item. - + @param itm reference to the changed item @type QListWidgetItem """ @@ -92,29 +102,29 @@ self.__checkCount += 1 else: self.__checkCount -= 1 - self.buttonBox.button( - QDialogButtonBox.StandardButton.Ok).setEnabled( - self.__checkCount > 0) - + self.buttonBox.button(QDialogButtonBox.StandardButton.Ok).setEnabled( + self.__checkCount > 0 + ) + @pyqtSlot(QListWidgetItem) def on_selectionList_itemDoubleClicked(self, item): """ Private slot handling double clicking an item. - + @param item double clicked item @type QListWidgetItem """ if ( - not self.__isCheckBoxSelection and - self.selectionList.selectionMode() == - QAbstractItemView.SelectionMode.SingleSelection + not self.__isCheckBoxSelection + and self.selectionList.selectionMode() + == QAbstractItemView.SelectionMode.SingleSelection ): self.accept() - + def getSelection(self): """ Public method to retrieve the selected items. - + @return selected entries @rtype list of str """