eric6/E5Gui/E5Completers.py

Sat, 27 Feb 2021 12:08:23 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sat, 27 Feb 2021 12:08:23 +0100
changeset 8138
169e65a6787c
parent 7923
91e843545d9a
child 8043
0acf98cd089a
child 8143
2c730d5fd177
permissions
-rw-r--r--

Shell: added functionality to show a prompt when the main client process has exited (e.g. a script ended).

55
b5c84934de9c Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
b5c84934de9c Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
2
7923
91e843545d9a Updated copyright for 2021.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7900
diff changeset
3 # Copyright (c) 2007 - 2021 Detlev Offenbach <detlev@die-offenbachs.de>
55
b5c84934de9c Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
4 #
b5c84934de9c Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
5
b5c84934de9c Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
6 """
b5c84934de9c Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
7 Module implementing various kinds of completers.
b5c84934de9c Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
8 """
b5c84934de9c Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
9
4598
a5fba000224f Extended the file completers to set the root directory of the model.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4595
diff changeset
10 import os
a5fba000224f Extended the file completers to set the root directory of the model.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4595
diff changeset
11
3656
441956d8fce5 Started porting eric5 to PyQt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3178
diff changeset
12 from PyQt5.QtCore import QDir, Qt, QStringListModel
441956d8fce5 Started porting eric5 to PyQt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3178
diff changeset
13 from PyQt5.QtWidgets import QCompleter, QFileSystemModel
55
b5c84934de9c Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
14
529
86332f558b7b Changed file and dir completers to be case insensitive on Windows platforms.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 55
diff changeset
15 from Globals import isWindowsPlatform
86332f558b7b Changed file and dir completers to be case insensitive on Windows platforms.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 55
diff changeset
16
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
17
55
b5c84934de9c Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
18 class E5FileCompleter(QCompleter):
b5c84934de9c Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
19 """
b5c84934de9c Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
20 Class implementing a completer for file names.
b5c84934de9c Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
21 """
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
22 def __init__(self, parent=None,
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
23 completionMode=QCompleter.PopupCompletion,
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
24 showHidden=False):
55
b5c84934de9c Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
25 """
b5c84934de9c Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
26 Constructor
b5c84934de9c Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
27
b5c84934de9c Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
28 @param parent parent widget of the completer (QWidget)
7900
72b88fb20261 Corrected the use of '@keyparam' in the source documentation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7780
diff changeset
29 @param completionMode completion mode of the
55
b5c84934de9c Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
30 completer (QCompleter.CompletionMode)
7900
72b88fb20261 Corrected the use of '@keyparam' in the source documentation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7780
diff changeset
31 @param showHidden flag indicating to show hidden entries as well
2990
583beaf0b4b8 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2822
diff changeset
32 (boolean)
55
b5c84934de9c Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
33 """
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
34 super(E5FileCompleter, self).__init__(parent)
2822
449de130268e Changed the obsoleted use of QDirModel to QFileSystemModel.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2820
diff changeset
35 self.__model = QFileSystemModel(self)
55
b5c84934de9c Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
36 if showHidden:
564
b3d966393ba9 Did some code cleanup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 529
diff changeset
37 self.__model.setFilter(
3034
7ce719013078 Fixed various coding style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2990
diff changeset
38 QDir.Filters(QDir.Dirs | QDir.Files | QDir.Drives |
55
b5c84934de9c Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
39 QDir.AllDirs | QDir.Hidden))
b5c84934de9c Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
40 else:
2990
583beaf0b4b8 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2822
diff changeset
41 self.__model.setFilter(QDir.Filters(
583beaf0b4b8 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2822
diff changeset
42 QDir.Dirs | QDir.Files | QDir.Drives | QDir.AllDirs))
4595
f0e48b3e31d4 Fixed an issue with the file system completers not completing.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
43 self.__model.setRootPath("")
55
b5c84934de9c Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
44 self.setModel(self.__model)
b5c84934de9c Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
45 self.setCompletionMode(completionMode)
529
86332f558b7b Changed file and dir completers to be case insensitive on Windows platforms.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 55
diff changeset
46 if isWindowsPlatform():
86332f558b7b Changed file and dir completers to be case insensitive on Windows platforms.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 55
diff changeset
47 self.setCaseSensitivity(Qt.CaseInsensitive)
55
b5c84934de9c Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
48 if parent:
b5c84934de9c Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
49 parent.setCompleter(self)
4598
a5fba000224f Extended the file completers to set the root directory of the model.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4595
diff changeset
50
a5fba000224f Extended the file completers to set the root directory of the model.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4595
diff changeset
51 def setRootPath(self, path):
a5fba000224f Extended the file completers to set the root directory of the model.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4595
diff changeset
52 """
a5fba000224f Extended the file completers to set the root directory of the model.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4595
diff changeset
53 Public method to set the root path of the model.
a5fba000224f Extended the file completers to set the root directory of the model.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4595
diff changeset
54
a5fba000224f Extended the file completers to set the root directory of the model.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4595
diff changeset
55 @param path root path for the model
a5fba000224f Extended the file completers to set the root directory of the model.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4595
diff changeset
56 @type str
a5fba000224f Extended the file completers to set the root directory of the model.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4595
diff changeset
57 """
a5fba000224f Extended the file completers to set the root directory of the model.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4595
diff changeset
58 if not os.path.isdir(path):
a5fba000224f Extended the file completers to set the root directory of the model.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4595
diff changeset
59 path = os.path.dirname(path)
a5fba000224f Extended the file completers to set the root directory of the model.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4595
diff changeset
60 self.__model.setRootPath(path)
a5fba000224f Extended the file completers to set the root directory of the model.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4595
diff changeset
61
a5fba000224f Extended the file completers to set the root directory of the model.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4595
diff changeset
62 def rootPath(self):
a5fba000224f Extended the file completers to set the root directory of the model.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4595
diff changeset
63 """
a5fba000224f Extended the file completers to set the root directory of the model.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4595
diff changeset
64 Public method to get the root path of the model.
a5fba000224f Extended the file completers to set the root directory of the model.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4595
diff changeset
65
a5fba000224f Extended the file completers to set the root directory of the model.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4595
diff changeset
66 @return root path of the model
a5fba000224f Extended the file completers to set the root directory of the model.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4595
diff changeset
67 @rtype str
a5fba000224f Extended the file completers to set the root directory of the model.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4595
diff changeset
68 """
a5fba000224f Extended the file completers to set the root directory of the model.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4595
diff changeset
69 return self.__model.rootPath()
55
b5c84934de9c Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
70
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
71
55
b5c84934de9c Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
72 class E5DirCompleter(QCompleter):
b5c84934de9c Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
73 """
b5c84934de9c Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
74 Class implementing a completer for directory names.
b5c84934de9c Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
75 """
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
76 def __init__(self, parent=None,
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
77 completionMode=QCompleter.PopupCompletion,
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
78 showHidden=False):
55
b5c84934de9c Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
79 """
b5c84934de9c Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
80 Constructor
b5c84934de9c Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
81
b5c84934de9c Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
82 @param parent parent widget of the completer (QWidget)
7900
72b88fb20261 Corrected the use of '@keyparam' in the source documentation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7780
diff changeset
83 @param completionMode completion mode of the
55
b5c84934de9c Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
84 completer (QCompleter.CompletionMode)
7900
72b88fb20261 Corrected the use of '@keyparam' in the source documentation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7780
diff changeset
85 @param showHidden flag indicating to show hidden entries as well
2990
583beaf0b4b8 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2822
diff changeset
86 (boolean)
55
b5c84934de9c Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
87 """
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
88 super(E5DirCompleter, self).__init__(parent)
2822
449de130268e Changed the obsoleted use of QDirModel to QFileSystemModel.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2820
diff changeset
89 self.__model = QFileSystemModel(self)
55
b5c84934de9c Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
90 if showHidden:
564
b3d966393ba9 Did some code cleanup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 529
diff changeset
91 self.__model.setFilter(
55
b5c84934de9c Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
92 QDir.Filters(QDir.Drives | QDir.AllDirs | QDir.Hidden))
b5c84934de9c Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
93 else:
564
b3d966393ba9 Did some code cleanup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 529
diff changeset
94 self.__model.setFilter(
55
b5c84934de9c Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
95 QDir.Filters(QDir.Drives | QDir.AllDirs))
4595
f0e48b3e31d4 Fixed an issue with the file system completers not completing.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
96 self.__model.setRootPath("")
55
b5c84934de9c Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
97 self.setModel(self.__model)
b5c84934de9c Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
98 self.setCompletionMode(completionMode)
529
86332f558b7b Changed file and dir completers to be case insensitive on Windows platforms.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 55
diff changeset
99 if isWindowsPlatform():
86332f558b7b Changed file and dir completers to be case insensitive on Windows platforms.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 55
diff changeset
100 self.setCaseSensitivity(Qt.CaseInsensitive)
55
b5c84934de9c Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
101 if parent:
b5c84934de9c Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
102 parent.setCompleter(self)
4598
a5fba000224f Extended the file completers to set the root directory of the model.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4595
diff changeset
103
a5fba000224f Extended the file completers to set the root directory of the model.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4595
diff changeset
104 def setRootPath(self, path):
a5fba000224f Extended the file completers to set the root directory of the model.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4595
diff changeset
105 """
a5fba000224f Extended the file completers to set the root directory of the model.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4595
diff changeset
106 Public method to set the root path of the model.
a5fba000224f Extended the file completers to set the root directory of the model.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4595
diff changeset
107
a5fba000224f Extended the file completers to set the root directory of the model.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4595
diff changeset
108 @param path root path for the model
a5fba000224f Extended the file completers to set the root directory of the model.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4595
diff changeset
109 @type str
a5fba000224f Extended the file completers to set the root directory of the model.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4595
diff changeset
110 """
a5fba000224f Extended the file completers to set the root directory of the model.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4595
diff changeset
111 if not os.path.isdir(path):
a5fba000224f Extended the file completers to set the root directory of the model.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4595
diff changeset
112 path = os.path.dirname(path)
a5fba000224f Extended the file completers to set the root directory of the model.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4595
diff changeset
113 self.__model.setRootPath(path)
a5fba000224f Extended the file completers to set the root directory of the model.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4595
diff changeset
114
a5fba000224f Extended the file completers to set the root directory of the model.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4595
diff changeset
115 def rootPath(self):
a5fba000224f Extended the file completers to set the root directory of the model.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4595
diff changeset
116 """
a5fba000224f Extended the file completers to set the root directory of the model.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4595
diff changeset
117 Public method to get the root path of the model.
a5fba000224f Extended the file completers to set the root directory of the model.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4595
diff changeset
118
a5fba000224f Extended the file completers to set the root directory of the model.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4595
diff changeset
119 @return root path of the model
a5fba000224f Extended the file completers to set the root directory of the model.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4595
diff changeset
120 @rtype str
a5fba000224f Extended the file completers to set the root directory of the model.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4595
diff changeset
121 """
a5fba000224f Extended the file completers to set the root directory of the model.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4595
diff changeset
122 return self.__model.rootPath()
55
b5c84934de9c Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
123
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
124
55
b5c84934de9c Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
125 class E5StringListCompleter(QCompleter):
b5c84934de9c Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
126 """
529
86332f558b7b Changed file and dir completers to be case insensitive on Windows platforms.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 55
diff changeset
127 Class implementing a completer for string lists.
55
b5c84934de9c Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
128 """
5651
982465f8389c Fixed a few code style issues related to the usage of mutable types for default arguments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
129 def __init__(self, parent=None, strings=None,
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
130 completionMode=QCompleter.PopupCompletion):
55
b5c84934de9c Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
131 """
b5c84934de9c Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
132 Constructor
b5c84934de9c Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
133
b5c84934de9c Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
134 @param parent parent widget of the completer (QWidget)
2990
583beaf0b4b8 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2822
diff changeset
135 @param strings list of string to load into the completer
583beaf0b4b8 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2822
diff changeset
136 (list of strings)
7900
72b88fb20261 Corrected the use of '@keyparam' in the source documentation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7780
diff changeset
137 @param completionMode completion mode of the
55
b5c84934de9c Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
138 completer (QCompleter.CompletionMode)
b5c84934de9c Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
139 """
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
140 super(E5StringListCompleter, self).__init__(parent)
5651
982465f8389c Fixed a few code style issues related to the usage of mutable types for default arguments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
141 self.__model = QStringListModel(
982465f8389c Fixed a few code style issues related to the usage of mutable types for default arguments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
142 [] if strings is None else strings[:],
982465f8389c Fixed a few code style issues related to the usage of mutable types for default arguments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
143 parent)
55
b5c84934de9c Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
144 self.setModel(self.__model)
b5c84934de9c Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
145 self.setCompletionMode(completionMode)
b5c84934de9c Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
146 if parent:
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
147 parent.setCompleter(self)

eric ide

mercurial