src/eric7/QScintilla/SpellingDictionaryEditDialog.py

branch
eric7
changeset 9221
bf71ee032bb4
parent 9209
b99e7fd55fd3
child 9473
3f23dbf37dbe
equal deleted inserted replaced
9220:e9e7eca7efee 9221:bf71ee032bb4
18 class SpellingDictionaryEditDialog(QDialog, Ui_SpellingDictionaryEditDialog): 18 class SpellingDictionaryEditDialog(QDialog, Ui_SpellingDictionaryEditDialog):
19 """ 19 """
20 Class implementing a dialog to edit the various spell checking 20 Class implementing a dialog to edit the various spell checking
21 dictionaries. 21 dictionaries.
22 """ 22 """
23
23 def __init__(self, data, info, parent=None): 24 def __init__(self, data, info, parent=None):
24 """ 25 """
25 Constructor 26 Constructor
26 27
27 @param data contents to be edited (string) 28 @param data contents to be edited (string)
28 @param info info string to show at the header (string) 29 @param info info string to show at the header (string)
29 @param parent reference to the parent widget (QWidget) 30 @param parent reference to the parent widget (QWidget)
30 """ 31 """
31 super().__init__(parent) 32 super().__init__(parent)
32 self.setupUi(self) 33 self.setupUi(self)
33 34
34 self.infoLabel.setText(info) 35 self.infoLabel.setText(info)
35 36
36 self.__model = QStringListModel( 37 self.__model = QStringListModel(
37 [line.strip() for line in data.splitlines() if line.strip()], 38 [line.strip() for line in data.splitlines() if line.strip()], self
38 self) 39 )
39 self.__model.sort(0) 40 self.__model.sort(0)
40 self.__proxyModel = QSortFilterProxyModel(self) 41 self.__proxyModel = QSortFilterProxyModel(self)
41 self.__proxyModel.setFilterCaseSensitivity( 42 self.__proxyModel.setFilterCaseSensitivity(Qt.CaseSensitivity.CaseInsensitive)
42 Qt.CaseSensitivity.CaseInsensitive)
43 self.__proxyModel.setDynamicSortFilter(True) 43 self.__proxyModel.setDynamicSortFilter(True)
44 self.__proxyModel.setSourceModel(self.__model) 44 self.__proxyModel.setSourceModel(self.__model)
45 self.wordList.setModel(self.__proxyModel) 45 self.wordList.setModel(self.__proxyModel)
46 46
47 self.searchEdit.textChanged.connect( 47 self.searchEdit.textChanged.connect(self.__proxyModel.setFilterFixedString)
48 self.__proxyModel.setFilterFixedString) 48
49
50 self.removeButton.clicked.connect(self.wordList.removeSelected) 49 self.removeButton.clicked.connect(self.wordList.removeSelected)
51 self.removeAllButton.clicked.connect(self.wordList.removeAll) 50 self.removeAllButton.clicked.connect(self.wordList.removeAll)
52 51
53 @pyqtSlot() 52 @pyqtSlot()
54 def on_addButton_clicked(self): 53 def on_addButton_clicked(self):
55 """ 54 """
56 Private slot to handle adding an entry. 55 Private slot to handle adding an entry.
57 """ 56 """
58 self.__model.insertRow(self.__model.rowCount()) 57 self.__model.insertRow(self.__model.rowCount())
59 self.wordList.edit( 58 self.wordList.edit(self.__proxyModel.index(self.__model.rowCount() - 1, 0))
60 self.__proxyModel.index(self.__model.rowCount() - 1, 0)) 59
61
62 def getData(self): 60 def getData(self):
63 """ 61 """
64 Public method to get the data. 62 Public method to get the data.
65 63
66 @return data of the dialog (string) 64 @return data of the dialog (string)
67 """ 65 """
68 return os.linesep.join( 66 return (
69 [line.strip() for line in self.__model.stringList() 67 os.linesep.join(
70 if line.strip()]) + os.linesep 68 [line.strip() for line in self.__model.stringList() if line.strip()]
69 )
70 + os.linesep
71 )

eric ide

mercurial