QScintilla/SpellingDictionaryEditDialog.py

Wed, 30 Apr 2014 23:13:40 +0200

author
T.Rzepka <Tobias.Rzepka@gmail.com>
date
Wed, 30 Apr 2014 23:13:40 +0200
branch
5_4_x
changeset 3553
389f83a37571
parent 3160
209a07d7e401
child 3178
f25fc1364c88
child 3345
071afe8be2a1
permissions
-rw-r--r--

Missing translation added; Translations regenerated.

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
3160
209a07d7e401 Updated copyright for 2014.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3011
diff changeset
3 # Copyright (c) 2012 - 2014 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
86bdcfac4a4a Added a dialog to edit the various spell checking dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
10 import os
86bdcfac4a4a Added a dialog to edit the various spell checking dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
11
86bdcfac4a4a Added a dialog to edit the various spell checking dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
12 from PyQt4.QtCore import pyqtSlot, Qt
86bdcfac4a4a Added a dialog to edit the various spell checking dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
13 from PyQt4.QtGui import QDialog, QStringListModel, QSortFilterProxyModel
86bdcfac4a4a Added a dialog to edit the various spell checking dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
14
86bdcfac4a4a Added a dialog to edit the various spell checking dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
15 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
16
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 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
19 """
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
20 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
21 dictionaries.
2211
86bdcfac4a4a Added a dialog to edit the various spell checking dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
22 """
86bdcfac4a4a Added a dialog to edit the various spell checking dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
23 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
24 """
86bdcfac4a4a Added a dialog to edit the various spell checking dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
25 Constructor
86bdcfac4a4a Added a dialog to edit the various spell checking dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
26
86bdcfac4a4a Added a dialog to edit the various spell checking dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
27 @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
28 @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
29 @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
30 """
86bdcfac4a4a Added a dialog to edit the various spell checking dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
31 super().__init__(parent)
86bdcfac4a4a Added a dialog to edit the various spell checking dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
32 self.setupUi(self)
86bdcfac4a4a Added a dialog to edit the various spell checking dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
33
86bdcfac4a4a Added a dialog to edit the various spell checking dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
34 self.infoLabel.setText(info)
86bdcfac4a4a Added a dialog to edit the various spell checking dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
35
86bdcfac4a4a Added a dialog to edit the various spell checking dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
36 self.__model = QStringListModel(data.splitlines(), self)
86bdcfac4a4a Added a dialog to edit the various spell checking dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
37 self.__model.sort(0)
86bdcfac4a4a Added a dialog to edit the various spell checking dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
38 self.__proxyModel = QSortFilterProxyModel(self)
86bdcfac4a4a Added a dialog to edit the various spell checking dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
39 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
40 self.__proxyModel.setDynamicSortFilter(True)
86bdcfac4a4a Added a dialog to edit the various spell checking dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
41 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
42 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
43
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
44 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
45 self.__proxyModel.setFilterFixedString)
2211
86bdcfac4a4a Added a dialog to edit the various spell checking dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
46
86bdcfac4a4a Added a dialog to edit the various spell checking dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
47 self.removeButton.clicked[()].connect(self.wordList.removeSelected)
86bdcfac4a4a Added a dialog to edit the various spell checking dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
48 self.removeAllButton.clicked[()].connect(self.wordList.removeAll)
86bdcfac4a4a Added a dialog to edit the various spell checking dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
49
86bdcfac4a4a Added a dialog to edit the various spell checking dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
50 @pyqtSlot()
86bdcfac4a4a Added a dialog to edit the various spell checking dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
51 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
52 """
86bdcfac4a4a Added a dialog to edit the various spell checking dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
53 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
54 """
86bdcfac4a4a Added a dialog to edit the various spell checking dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
55 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
56 self.wordList.edit(
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
57 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
58
86bdcfac4a4a Added a dialog to edit the various spell checking dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
59 def getData(self):
86bdcfac4a4a Added a dialog to edit the various spell checking dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
60 """
86bdcfac4a4a Added a dialog to edit the various spell checking dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
61 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
62
86bdcfac4a4a Added a dialog to edit the various spell checking dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
63 @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
64 """
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
65 return os.linesep.join(
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
66 [line for line in self.__model.stringList() if line])

eric ide

mercurial