|
1 <?xml version="1.0" encoding="utf-8"?> |
|
2 <!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Strict//EN' |
|
3 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd'> |
|
4 <html><head> |
|
5 <title>eric4.Helpviewer.History.HistoryCompleter</title> |
|
6 <style> |
|
7 body { |
|
8 background:white; |
|
9 margin: 0em 1em 10em 1em; |
|
10 color: black; |
|
11 } |
|
12 |
|
13 h1 { color: white; background: #4FA4FF; } |
|
14 h2 { color: white; background: #4FA4FF; } |
|
15 h3 { color: white; background: #00557F; } |
|
16 h4 { color: white; background: #00557F; } |
|
17 |
|
18 a { color: #AA5500; } |
|
19 |
|
20 </style> |
|
21 </head> |
|
22 <body><a NAME="top" ID="top"></a> |
|
23 <h1>eric4.Helpviewer.History.HistoryCompleter</h1> |
|
24 <p> |
|
25 Module implementing a special completer for the history. |
|
26 </p> |
|
27 <h3>Global Attributes</h3> |
|
28 <table> |
|
29 <tr><td>None</td></tr> |
|
30 </table> |
|
31 <h3>Classes</h3> |
|
32 <table> |
|
33 <tr> |
|
34 <td><a href="#HistoryCompleter">HistoryCompleter</a></td> |
|
35 <td></td> |
|
36 </tr><tr> |
|
37 <td><a href="#HistoryCompletionModel">HistoryCompletionModel</a></td> |
|
38 <td>Class implementing a special model for history based completions.</td> |
|
39 </tr><tr> |
|
40 <td><a href="#HistoryCompletionView">HistoryCompletionView</a></td> |
|
41 <td>Class implementing a special completer view for history based completions.</td> |
|
42 </tr> |
|
43 </table> |
|
44 <h3>Functions</h3> |
|
45 <table> |
|
46 <tr><td>None</td></tr> |
|
47 </table> |
|
48 <hr /><hr /> |
|
49 <a NAME="HistoryCompleter" ID="HistoryCompleter"></a> |
|
50 <h2>HistoryCompleter</h2> |
|
51 |
|
52 <h3>Derived from</h3> |
|
53 QCompleter |
|
54 <h3>Class Attributes</h3> |
|
55 <table> |
|
56 <tr><td>None</td></tr> |
|
57 </table> |
|
58 <h3>Methods</h3> |
|
59 <table> |
|
60 <tr> |
|
61 <td><a href="#HistoryCompleter.__init__">HistoryCompleter</a></td> |
|
62 <td>Constructor</td> |
|
63 </tr><tr> |
|
64 <td><a href="#HistoryCompleter.__updateFilter">__updateFilter</a></td> |
|
65 <td>Private slot to update the search string.</td> |
|
66 </tr><tr> |
|
67 <td><a href="#HistoryCompleter.pathFromIndex">pathFromIndex</a></td> |
|
68 <td>Public method to get a path for a given index.</td> |
|
69 </tr><tr> |
|
70 <td><a href="#HistoryCompleter.splitPath">splitPath</a></td> |
|
71 <td>Public method to split the given path into strings, that are used to match at each level in the model.</td> |
|
72 </tr> |
|
73 </table> |
|
74 <a NAME="HistoryCompleter.__init__" ID="HistoryCompleter.__init__"></a> |
|
75 <h4>HistoryCompleter (Constructor)</h4> |
|
76 <b>HistoryCompleter</b>(<i>model, parent = None</i>) |
|
77 <p> |
|
78 Constructor |
|
79 </p><dl> |
|
80 <dt><i>model</i></dt> |
|
81 <dd> |
|
82 reference to the model (QAbstractItemModel) |
|
83 </dd><dt><i>parent</i></dt> |
|
84 <dd> |
|
85 reference to the parent object (QObject) |
|
86 </dd> |
|
87 </dl><a NAME="HistoryCompleter.__updateFilter" ID="HistoryCompleter.__updateFilter"></a> |
|
88 <h4>HistoryCompleter.__updateFilter</h4> |
|
89 <b>__updateFilter</b>(<i></i>) |
|
90 <p> |
|
91 Private slot to update the search string. |
|
92 </p><a NAME="HistoryCompleter.pathFromIndex" ID="HistoryCompleter.pathFromIndex"></a> |
|
93 <h4>HistoryCompleter.pathFromIndex</h4> |
|
94 <b>pathFromIndex</b>(<i>idx</i>) |
|
95 <p> |
|
96 Public method to get a path for a given index. |
|
97 </p><dl> |
|
98 <dt><i>idx</i></dt> |
|
99 <dd> |
|
100 reference to the index (QModelIndex) |
|
101 </dd> |
|
102 </dl><dl> |
|
103 <dt>Returns:</dt> |
|
104 <dd> |
|
105 the actual URL from the history (string) |
|
106 </dd> |
|
107 </dl><a NAME="HistoryCompleter.splitPath" ID="HistoryCompleter.splitPath"></a> |
|
108 <h4>HistoryCompleter.splitPath</h4> |
|
109 <b>splitPath</b>(<i>path</i>) |
|
110 <p> |
|
111 Public method to split the given path into strings, that are used to match |
|
112 at each level in the model. |
|
113 </p><dl> |
|
114 <dt><i>path</i></dt> |
|
115 <dd> |
|
116 path to be split (string) |
|
117 </dd> |
|
118 </dl><dl> |
|
119 <dt>Returns:</dt> |
|
120 <dd> |
|
121 list of path elements (list of strings) |
|
122 </dd> |
|
123 </dl> |
|
124 <div align="right"><a href="#top">Up</a></div> |
|
125 <hr /><hr /> |
|
126 <a NAME="HistoryCompletionModel" ID="HistoryCompletionModel"></a> |
|
127 <h2>HistoryCompletionModel</h2> |
|
128 <p> |
|
129 Class implementing a special model for history based completions. |
|
130 </p> |
|
131 <h3>Derived from</h3> |
|
132 QSortFilterProxyModel |
|
133 <h3>Class Attributes</h3> |
|
134 <table> |
|
135 <tr><td>HistoryCompletionRole</td></tr> |
|
136 </table> |
|
137 <h3>Methods</h3> |
|
138 <table> |
|
139 <tr> |
|
140 <td><a href="#HistoryCompletionModel.__init__">HistoryCompletionModel</a></td> |
|
141 <td>Constructor</td> |
|
142 </tr><tr> |
|
143 <td><a href="#HistoryCompletionModel.data">data</a></td> |
|
144 <td>Public method to get data from the model.</td> |
|
145 </tr><tr> |
|
146 <td><a href="#HistoryCompletionModel.filterAcceptsRow">filterAcceptsRow</a></td> |
|
147 <td>Protected method to determine, if the row is acceptable.</td> |
|
148 </tr><tr> |
|
149 <td><a href="#HistoryCompletionModel.isValid">isValid</a></td> |
|
150 <td>Public method to check the model for validity.</td> |
|
151 </tr><tr> |
|
152 <td><a href="#HistoryCompletionModel.lessThan">lessThan</a></td> |
|
153 <td>Protected method used to sort the displayed items.</td> |
|
154 </tr><tr> |
|
155 <td><a href="#HistoryCompletionModel.searchString">searchString</a></td> |
|
156 <td>Public method to get the current search string.</td> |
|
157 </tr><tr> |
|
158 <td><a href="#HistoryCompletionModel.setSearchString">setSearchString</a></td> |
|
159 <td>Public method to set the current search string.</td> |
|
160 </tr><tr> |
|
161 <td><a href="#HistoryCompletionModel.setValid">setValid</a></td> |
|
162 <td>Public method to set the model's validity.</td> |
|
163 </tr> |
|
164 </table> |
|
165 <a NAME="HistoryCompletionModel.__init__" ID="HistoryCompletionModel.__init__"></a> |
|
166 <h4>HistoryCompletionModel (Constructor)</h4> |
|
167 <b>HistoryCompletionModel</b>(<i>parent = None</i>) |
|
168 <p> |
|
169 Constructor |
|
170 </p><dl> |
|
171 <dt><i>parent</i></dt> |
|
172 <dd> |
|
173 reference to the parent object (QObject) |
|
174 </dd> |
|
175 </dl><a NAME="HistoryCompletionModel.data" ID="HistoryCompletionModel.data"></a> |
|
176 <h4>HistoryCompletionModel.data</h4> |
|
177 <b>data</b>(<i>index, role = Qt.DisplayRole</i>) |
|
178 <p> |
|
179 Public method to get data from the model. |
|
180 </p><dl> |
|
181 <dt><i>index</i></dt> |
|
182 <dd> |
|
183 index of history entry to get data for (QModelIndex) |
|
184 </dd><dt><i>role</i></dt> |
|
185 <dd> |
|
186 data role (integer) |
|
187 </dd> |
|
188 </dl><dl> |
|
189 <dt>Returns:</dt> |
|
190 <dd> |
|
191 history entry data (QVariant) |
|
192 </dd> |
|
193 </dl><a NAME="HistoryCompletionModel.filterAcceptsRow" ID="HistoryCompletionModel.filterAcceptsRow"></a> |
|
194 <h4>HistoryCompletionModel.filterAcceptsRow</h4> |
|
195 <b>filterAcceptsRow</b>(<i>sourceRow, sourceParent</i>) |
|
196 <p> |
|
197 Protected method to determine, if the row is acceptable. |
|
198 </p><dl> |
|
199 <dt><i>sourceRow</i></dt> |
|
200 <dd> |
|
201 row number in the source model (integer) |
|
202 </dd><dt><i>sourceParent</i></dt> |
|
203 <dd> |
|
204 index of the source item (QModelIndex) |
|
205 </dd> |
|
206 </dl><dl> |
|
207 <dt>Returns:</dt> |
|
208 <dd> |
|
209 flag indicating acceptance (boolean) |
|
210 </dd> |
|
211 </dl><a NAME="HistoryCompletionModel.isValid" ID="HistoryCompletionModel.isValid"></a> |
|
212 <h4>HistoryCompletionModel.isValid</h4> |
|
213 <b>isValid</b>(<i></i>) |
|
214 <p> |
|
215 Public method to check the model for validity. |
|
216 </p><dl> |
|
217 <dt><i>flag</i></dt> |
|
218 <dd> |
|
219 indicating a valid status (boolean) |
|
220 </dd> |
|
221 </dl><a NAME="HistoryCompletionModel.lessThan" ID="HistoryCompletionModel.lessThan"></a> |
|
222 <h4>HistoryCompletionModel.lessThan</h4> |
|
223 <b>lessThan</b>(<i>left, right</i>) |
|
224 <p> |
|
225 Protected method used to sort the displayed items. |
|
226 </p><p> |
|
227 It implements a special sorting function based on the history entry's |
|
228 frequency giving a bonus to hits that match on a word boundary so that |
|
229 e.g. "dot.python-projects.org" is a better result for typing "dot" than |
|
230 "slashdot.org". However, it only looks for the string in the host name, |
|
231 not the entire URL, since while it makes sense to e.g. give |
|
232 "www.phoronix.com" a bonus for "ph", it does NOT make sense to give |
|
233 "www.yadda.com/foo.php" the bonus. |
|
234 </p><dl> |
|
235 <dt><i>left</i></dt> |
|
236 <dd> |
|
237 index of left item (QModelIndex) |
|
238 </dd><dt><i>right</i></dt> |
|
239 <dd> |
|
240 index of right item (QModelIndex) |
|
241 </dd> |
|
242 </dl><dl> |
|
243 <dt>Returns:</dt> |
|
244 <dd> |
|
245 true, if left is less than right (boolean) |
|
246 </dd> |
|
247 </dl><a NAME="HistoryCompletionModel.searchString" ID="HistoryCompletionModel.searchString"></a> |
|
248 <h4>HistoryCompletionModel.searchString</h4> |
|
249 <b>searchString</b>(<i></i>) |
|
250 <p> |
|
251 Public method to get the current search string. |
|
252 </p><dl> |
|
253 <dt>Returns:</dt> |
|
254 <dd> |
|
255 current search string (string) |
|
256 </dd> |
|
257 </dl><a NAME="HistoryCompletionModel.setSearchString" ID="HistoryCompletionModel.setSearchString"></a> |
|
258 <h4>HistoryCompletionModel.setSearchString</h4> |
|
259 <b>setSearchString</b>(<i>string</i>) |
|
260 <p> |
|
261 Public method to set the current search string. |
|
262 </p><dl> |
|
263 <dt><i>string</i></dt> |
|
264 <dd> |
|
265 new search string (string) |
|
266 </dd> |
|
267 </dl><a NAME="HistoryCompletionModel.setValid" ID="HistoryCompletionModel.setValid"></a> |
|
268 <h4>HistoryCompletionModel.setValid</h4> |
|
269 <b>setValid</b>(<i>valid</i>) |
|
270 <p> |
|
271 Public method to set the model's validity. |
|
272 </p><dl> |
|
273 <dt><i>valid</i></dt> |
|
274 <dd> |
|
275 flag indicating the new valid status (boolean) |
|
276 </dd> |
|
277 </dl> |
|
278 <div align="right"><a href="#top">Up</a></div> |
|
279 <hr /><hr /> |
|
280 <a NAME="HistoryCompletionView" ID="HistoryCompletionView"></a> |
|
281 <h2>HistoryCompletionView</h2> |
|
282 <p> |
|
283 Class implementing a special completer view for history based completions. |
|
284 </p> |
|
285 <h3>Derived from</h3> |
|
286 QTableView |
|
287 <h3>Class Attributes</h3> |
|
288 <table> |
|
289 <tr><td>None</td></tr> |
|
290 </table> |
|
291 <h3>Methods</h3> |
|
292 <table> |
|
293 <tr> |
|
294 <td><a href="#HistoryCompletionView.__init__">HistoryCompletionView</a></td> |
|
295 <td>Constructor</td> |
|
296 </tr><tr> |
|
297 <td><a href="#HistoryCompletionView.resizeEvent">resizeEvent</a></td> |
|
298 <td>Protected method handling resize events.</td> |
|
299 </tr><tr> |
|
300 <td><a href="#HistoryCompletionView.sizeHintForRow">sizeHintForRow</a></td> |
|
301 <td>Public method to give a size hint for rows.</td> |
|
302 </tr> |
|
303 </table> |
|
304 <a NAME="HistoryCompletionView.__init__" ID="HistoryCompletionView.__init__"></a> |
|
305 <h4>HistoryCompletionView (Constructor)</h4> |
|
306 <b>HistoryCompletionView</b>(<i>parent = None</i>) |
|
307 <p> |
|
308 Constructor |
|
309 </p><dl> |
|
310 <dt><i>parent</i></dt> |
|
311 <dd> |
|
312 reference to the parent widget (QWidget) |
|
313 </dd> |
|
314 </dl><a NAME="HistoryCompletionView.resizeEvent" ID="HistoryCompletionView.resizeEvent"></a> |
|
315 <h4>HistoryCompletionView.resizeEvent</h4> |
|
316 <b>resizeEvent</b>(<i>evt</i>) |
|
317 <p> |
|
318 Protected method handling resize events. |
|
319 </p><dl> |
|
320 <dt><i>evt</i></dt> |
|
321 <dd> |
|
322 reference to the resize event (QResizeEvent) |
|
323 </dd> |
|
324 </dl><a NAME="HistoryCompletionView.sizeHintForRow" ID="HistoryCompletionView.sizeHintForRow"></a> |
|
325 <h4>HistoryCompletionView.sizeHintForRow</h4> |
|
326 <b>sizeHintForRow</b>(<i>row</i>) |
|
327 <p> |
|
328 Public method to give a size hint for rows. |
|
329 </p><dl> |
|
330 <dt><i>row</i></dt> |
|
331 <dd> |
|
332 row number (integer) |
|
333 </dd> |
|
334 </dl> |
|
335 <div align="right"><a href="#top">Up</a></div> |
|
336 <hr /> |
|
337 </body></html> |