--- a/src/eric7/ViewManager/BookmarkedFilesDialog.py Wed Jul 13 11:16:20 2022 +0200 +++ b/src/eric7/ViewManager/BookmarkedFilesDialog.py Wed Jul 13 14:55:47 2022 +0200 @@ -22,42 +22,41 @@ """ Class implementing a configuration dialog for the bookmarked files menu. """ + def __init__(self, bookmarks, parent=None): """ Constructor - + @param bookmarks list of bookmarked files (list of strings) @param parent parent widget (QWidget) """ super().__init__(parent) self.setupUi(self) - + self.filePicker.setMode(EricPathPickerModes.OPEN_FILE_MODE) - + self.bookmarks = bookmarks[:] for bookmark in self.bookmarks: itm = QListWidgetItem(bookmark, self.filesList) if not pathlib.Path(bookmark).exists(): itm.setBackground(QColor(Qt.GlobalColor.red)) - + if len(self.bookmarks): self.filesList.setCurrentRow(0) - + def on_filePicker_textChanged(self, txt): """ Private slot to handle the textChanged signal of the file edit. - + @param txt the text of the file edit (string) """ self.addButton.setEnabled(txt != "") - self.changeButton.setEnabled( - txt != "" and - self.filesList.currentRow() != -1) - + self.changeButton.setEnabled(txt != "" and self.filesList.currentRow() != -1) + def on_filesList_currentRowChanged(self, row): """ Private slot to set the lineedit depending on the selected entry. - + @param row the current row (integer) """ if row == -1: @@ -72,10 +71,10 @@ self.downButton.setEnabled(row != maxIndex) self.deleteButton.setEnabled(True) self.changeButton.setEnabled(True) - + bookmark = self.bookmarks[row] self.filePicker.setText(bookmark) - + @pyqtSlot() def on_addButton_clicked(self): """ @@ -90,7 +89,7 @@ self.bookmarks.append(bookmark) row = self.filesList.currentRow() self.on_filesList_currentRowChanged(row) - + @pyqtSlot() def on_changeButton_clicked(self): """ @@ -105,7 +104,7 @@ itm.setBackground(QColor(Qt.GlobalColor.red)) else: itm.setBackground(QColor()) - + @pyqtSlot() def on_deleteButton_clicked(self): """ @@ -117,7 +116,7 @@ del self.bookmarks[row] row = self.filesList.currentRow() self.on_filesList_currentRowChanged(row) - + @pyqtSlot() def on_downButton_clicked(self): """ @@ -128,7 +127,7 @@ if row == rows - 1: # we're already at the end return - + self.__swap(row, row + 1) itm = self.filesList.takeItem(row) self.filesList.insertItem(row + 1, itm) @@ -138,7 +137,7 @@ self.downButton.setEnabled(False) else: self.downButton.setEnabled(True) - + @pyqtSlot() def on_upButton_clicked(self): """ @@ -148,7 +147,7 @@ if row == 0: # we're already at the top return - + self.__swap(row - 1, row) itm = self.filesList.takeItem(row) self.filesList.insertItem(row - 1, itm) @@ -158,19 +157,19 @@ else: self.upButton.setEnabled(True) self.downButton.setEnabled(True) - + def getBookmarkedFiles(self): """ Public method to retrieve the tools list. - + @return a list of filenames (list of strings) """ return self.bookmarks - + def __swap(self, itm1, itm2): """ Private method used two swap two list entries given by their index. - + @param itm1 index of first entry (int) @param itm2 index of second entry (int) """