eric6/QScintilla/SpellingDictionaryEditDialog.py

Wed, 01 Jan 2020 11:57:23 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Wed, 01 Jan 2020 11:57:23 +0100
changeset 7360
9190402e4505
parent 7229
53054eb5b15a
child 7781
607a6098cb44
permissions
-rw-r--r--

Updated copyright for 2020.

2211
86bdcfac4a4a Added a dialog to edit the various spell checking dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
86bdcfac4a4a Added a dialog to edit the various spell checking dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
2
7360
9190402e4505 Updated copyright for 2020.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
3 # Copyright (c) 2012 - 2020 Detlev Offenbach <detlev@die-offenbachs.de>
2211
86bdcfac4a4a Added a dialog to edit the various spell checking dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
4 #
86bdcfac4a4a Added a dialog to edit the various spell checking dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
5
86bdcfac4a4a Added a dialog to edit the various spell checking dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
6 """
86bdcfac4a4a Added a dialog to edit the various spell checking dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
7 Module implementing a dialog to edit the various spell checking dictionaries.
86bdcfac4a4a Added a dialog to edit the various spell checking dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
8 """
86bdcfac4a4a Added a dialog to edit the various spell checking dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
9
2525
8b507a9a2d40 Script changes: Future import added, super calls modified and unicode behavior for str.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 2302
diff changeset
10
2211
86bdcfac4a4a Added a dialog to edit the various spell checking dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
11 import os
86bdcfac4a4a Added a dialog to edit the various spell checking dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
12
3656
441956d8fce5 Started porting eric5 to PyQt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3484
diff changeset
13 from PyQt5.QtCore import pyqtSlot, Qt, QSortFilterProxyModel, QStringListModel
441956d8fce5 Started porting eric5 to PyQt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3484
diff changeset
14 from PyQt5.QtWidgets import QDialog
2211
86bdcfac4a4a Added a dialog to edit the various spell checking dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
15
86bdcfac4a4a Added a dialog to edit the various spell checking dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
16 from .Ui_SpellingDictionaryEditDialog import Ui_SpellingDictionaryEditDialog
86bdcfac4a4a Added a dialog to edit the various spell checking dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
17
86bdcfac4a4a Added a dialog to edit the various spell checking dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
18
86bdcfac4a4a Added a dialog to edit the various spell checking dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
19 class SpellingDictionaryEditDialog(QDialog, Ui_SpellingDictionaryEditDialog):
86bdcfac4a4a Added a dialog to edit the various spell checking dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
20 """
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
21 Class implementing a dialog to edit the various spell checking
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
22 dictionaries.
2211
86bdcfac4a4a Added a dialog to edit the various spell checking dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
23 """
86bdcfac4a4a Added a dialog to edit the various spell checking dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
24 def __init__(self, data, info, parent=None):
86bdcfac4a4a Added a dialog to edit the various spell checking dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
25 """
86bdcfac4a4a Added a dialog to edit the various spell checking dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
26 Constructor
86bdcfac4a4a Added a dialog to edit the various spell checking dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
27
86bdcfac4a4a Added a dialog to edit the various spell checking dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
28 @param data contents to be edited (string)
86bdcfac4a4a Added a dialog to edit the various spell checking dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
29 @param info info string to show at the header (string)
86bdcfac4a4a Added a dialog to edit the various spell checking dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
30 @param parent reference to the parent widget (QWidget)
86bdcfac4a4a Added a dialog to edit the various spell checking dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
31 """
2525
8b507a9a2d40 Script changes: Future import added, super calls modified and unicode behavior for str.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 2302
diff changeset
32 super(SpellingDictionaryEditDialog, self).__init__(parent)
2211
86bdcfac4a4a Added a dialog to edit the various spell checking dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
33 self.setupUi(self)
86bdcfac4a4a Added a dialog to edit the various spell checking dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
34
86bdcfac4a4a Added a dialog to edit the various spell checking dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
35 self.infoLabel.setText(info)
86bdcfac4a4a Added a dialog to edit the various spell checking dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
36
5439
7ae65fa937a3 Some improvements to the spell checker to deal with empty lines in user or project dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
37 self.__model = QStringListModel(
7ae65fa937a3 Some improvements to the spell checker to deal with empty lines in user or project dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
38 [line.strip() for line in data.splitlines() if line.strip()],
7ae65fa937a3 Some improvements to the spell checker to deal with empty lines in user or project dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
39 self)
2211
86bdcfac4a4a Added a dialog to edit the various spell checking dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
40 self.__model.sort(0)
86bdcfac4a4a Added a dialog to edit the various spell checking dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
41 self.__proxyModel = QSortFilterProxyModel(self)
86bdcfac4a4a Added a dialog to edit the various spell checking dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
42 self.__proxyModel.setFilterCaseSensitivity(Qt.CaseInsensitive)
86bdcfac4a4a Added a dialog to edit the various spell checking dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
43 self.__proxyModel.setDynamicSortFilter(True)
86bdcfac4a4a Added a dialog to edit the various spell checking dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
44 self.__proxyModel.setSourceModel(self.__model)
86bdcfac4a4a Added a dialog to edit the various spell checking dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
45 self.wordList.setModel(self.__proxyModel)
86bdcfac4a4a Added a dialog to edit the various spell checking dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
46
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
47 self.searchEdit.textChanged.connect(
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
48 self.__proxyModel.setFilterFixedString)
2211
86bdcfac4a4a Added a dialog to edit the various spell checking dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
49
3345
071afe8be2a1 Changed signal/slot usage to not use constructs like 'triggered[()].connect(...)' anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
50 self.removeButton.clicked.connect(self.wordList.removeSelected)
071afe8be2a1 Changed signal/slot usage to not use constructs like 'triggered[()].connect(...)' anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
51 self.removeAllButton.clicked.connect(self.wordList.removeAll)
2211
86bdcfac4a4a Added a dialog to edit the various spell checking dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
52
86bdcfac4a4a Added a dialog to edit the various spell checking dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
53 @pyqtSlot()
86bdcfac4a4a Added a dialog to edit the various spell checking dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
54 def on_addButton_clicked(self):
86bdcfac4a4a Added a dialog to edit the various spell checking dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
55 """
86bdcfac4a4a Added a dialog to edit the various spell checking dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
56 Private slot to handle adding an entry.
86bdcfac4a4a Added a dialog to edit the various spell checking dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
57 """
86bdcfac4a4a Added a dialog to edit the various spell checking dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
58 self.__model.insertRow(self.__model.rowCount())
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
59 self.wordList.edit(
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
60 self.__proxyModel.index(self.__model.rowCount() - 1, 0))
2211
86bdcfac4a4a Added a dialog to edit the various spell checking dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
61
86bdcfac4a4a Added a dialog to edit the various spell checking dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
62 def getData(self):
86bdcfac4a4a Added a dialog to edit the various spell checking dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
63 """
86bdcfac4a4a Added a dialog to edit the various spell checking dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
64 Public method to get the data.
86bdcfac4a4a Added a dialog to edit the various spell checking dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
65
86bdcfac4a4a Added a dialog to edit the various spell checking dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
66 @return data of the dialog (string)
86bdcfac4a4a Added a dialog to edit the various spell checking dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
67 """
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
68 return os.linesep.join(
5439
7ae65fa937a3 Some improvements to the spell checker to deal with empty lines in user or project dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
69 [line.strip() for line in self.__model.stringList()
7ae65fa937a3 Some improvements to the spell checker to deal with empty lines in user or project dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
70 if line.strip()]) + os.linesep

eric ide

mercurial