|
1 <!DOCTYPE html> |
|
2 <html><head> |
|
3 <title>eric7.UI.FindFileWidget</title> |
|
4 <meta charset="UTF-8"> |
|
5 <link rel="stylesheet" href="styles.css"> |
|
6 </head> |
|
7 <body> |
|
8 <a NAME="top" ID="top"></a> |
|
9 <h1>eric7.UI.FindFileWidget</h1> |
|
10 |
|
11 <p> |
|
12 Module implementing a dialog to search for text in files. |
|
13 </p> |
|
14 <h3>Global Attributes</h3> |
|
15 |
|
16 <table> |
|
17 <tr><td>None</td></tr> |
|
18 </table> |
|
19 <h3>Classes</h3> |
|
20 |
|
21 <table> |
|
22 |
|
23 <tr> |
|
24 <td><a href="#FindFileWidget">FindFileWidget</a></td> |
|
25 <td>Class implementing a widget to search for text in files and replace it with some other text.</td> |
|
26 </tr> |
|
27 </table> |
|
28 <h3>Functions</h3> |
|
29 |
|
30 <table> |
|
31 <tr><td>None</td></tr> |
|
32 </table> |
|
33 <hr /> |
|
34 <hr /> |
|
35 <a NAME="FindFileWidget" ID="FindFileWidget"></a> |
|
36 <h2>FindFileWidget</h2> |
|
37 |
|
38 <p> |
|
39 Class implementing a widget to search for text in files and replace it |
|
40 with some other text. |
|
41 </p> |
|
42 <p> |
|
43 The occurrences found are displayed in a tree showing the file name, |
|
44 the line number and the text found. The file will be opened upon a double |
|
45 click onto the respective entry of the list. If the widget is in replace |
|
46 mode the line below shows the text after replacement. Replacements can |
|
47 be authorized by ticking them on. Pressing the replace button performs |
|
48 all ticked replacement operations. |
|
49 </p> |
|
50 <h3>Signals</h3> |
|
51 <dl> |
|
52 |
|
53 <dt>designerFile(str)</dt> |
|
54 <dd> |
|
55 emitted to open a Qt-Designer file |
|
56 </dd> |
|
57 <dt>sourceFile(str, int, str, int, int)</dt> |
|
58 <dd> |
|
59 emitted to open a source file |
|
60 at a specificline |
|
61 </dd> |
|
62 </dl> |
|
63 <h3>Derived from</h3> |
|
64 QWidget, Ui_FindFileWidget |
|
65 <h3>Class Attributes</h3> |
|
66 |
|
67 <table> |
|
68 <tr><td>endRole</td></tr><tr><td>lineRole</td></tr><tr><td>md5Role</td></tr><tr><td>replaceRole</td></tr><tr><td>startRole</td></tr> |
|
69 </table> |
|
70 <h3>Class Methods</h3> |
|
71 |
|
72 <table> |
|
73 <tr><td>None</td></tr> |
|
74 </table> |
|
75 <h3>Methods</h3> |
|
76 |
|
77 <table> |
|
78 |
|
79 <tr> |
|
80 <td><a href="#FindFileWidget.__init__">FindFileWidget</a></td> |
|
81 <td>Constructor</td> |
|
82 </tr> |
|
83 <tr> |
|
84 <td><a href="#FindFileWidget.__contextMenuRequested">__contextMenuRequested</a></td> |
|
85 <td>Private slot to handle the context menu request.</td> |
|
86 </tr> |
|
87 <tr> |
|
88 <td><a href="#FindFileWidget.__copyToClipboard">__copyToClipboard</a></td> |
|
89 <td>Private slot to copy the path of an entry to the clipboard.</td> |
|
90 </tr> |
|
91 <tr> |
|
92 <td><a href="#FindFileWidget.__createItem">__createItem</a></td> |
|
93 <td>Private method to create an entry in the file list.</td> |
|
94 </tr> |
|
95 <tr> |
|
96 <td><a href="#FindFileWidget.__doSearch">__doSearch</a></td> |
|
97 <td>Private slot to handle the find button being pressed.</td> |
|
98 </tr> |
|
99 <tr> |
|
100 <td><a href="#FindFileWidget.__enableFindButton">__enableFindButton</a></td> |
|
101 <td>Private slot called to enable the find button.</td> |
|
102 </tr> |
|
103 <tr> |
|
104 <td><a href="#FindFileWidget.__getFileList">__getFileList</a></td> |
|
105 <td>Private method to get a list of files to search.</td> |
|
106 </tr> |
|
107 <tr> |
|
108 <td><a href="#FindFileWidget.__openFile">__openFile</a></td> |
|
109 <td>Private slot to open the currently selected entry.</td> |
|
110 </tr> |
|
111 <tr> |
|
112 <td><a href="#FindFileWidget.__projectClosed">__projectClosed</a></td> |
|
113 <td>Private slot to react to the closing of a project.</td> |
|
114 </tr> |
|
115 <tr> |
|
116 <td><a href="#FindFileWidget.__projectOpened">__projectOpened</a></td> |
|
117 <td>Private slot to react to the opening of a project.</td> |
|
118 </tr> |
|
119 <tr> |
|
120 <td><a href="#FindFileWidget.__stopSearch">__stopSearch</a></td> |
|
121 <td>Private slot to handle the stop button being pressed.</td> |
|
122 </tr> |
|
123 <tr> |
|
124 <td><a href="#FindFileWidget.__stripEol">__stripEol</a></td> |
|
125 <td>Private method to strip the eol part.</td> |
|
126 </tr> |
|
127 <tr> |
|
128 <td><a href="#FindFileWidget.__toggleReplaceMode">__toggleReplaceMode</a></td> |
|
129 <td>Private slot to toggle the dialog mode.</td> |
|
130 </tr> |
|
131 <tr> |
|
132 <td><a href="#FindFileWidget.activate">activate</a></td> |
|
133 <td>Public method to activate the widget with a given mode, a text to search for and some search parameters.</td> |
|
134 </tr> |
|
135 <tr> |
|
136 <td><a href="#FindFileWidget.on_dirButton_clicked">on_dirButton_clicked</a></td> |
|
137 <td>Private slot to handle the selection of the 'Directory' radio button.</td> |
|
138 </tr> |
|
139 <tr> |
|
140 <td><a href="#FindFileWidget.on_dirPicker_editTextChanged">on_dirPicker_editTextChanged</a></td> |
|
141 <td>Private slot to handle the textChanged signal of the directory picker.</td> |
|
142 </tr> |
|
143 <tr> |
|
144 <td><a href="#FindFileWidget.on_filterCheckBox_clicked">on_filterCheckBox_clicked</a></td> |
|
145 <td>Private slot to handle the selection of the file filter check box.</td> |
|
146 </tr> |
|
147 <tr> |
|
148 <td><a href="#FindFileWidget.on_filterEdit_textEdited">on_filterEdit_textEdited</a></td> |
|
149 <td>Private slot to handle the textChanged signal of the file filter edit.</td> |
|
150 </tr> |
|
151 <tr> |
|
152 <td><a href="#FindFileWidget.on_findList_itemDoubleClicked">on_findList_itemDoubleClicked</a></td> |
|
153 <td>Private slot to handle the double click on a file item.</td> |
|
154 </tr> |
|
155 <tr> |
|
156 <td><a href="#FindFileWidget.on_findtextCombo_editTextChanged">on_findtextCombo_editTextChanged</a></td> |
|
157 <td>Private slot to handle the editTextChanged signal of the find text combo.</td> |
|
158 </tr> |
|
159 <tr> |
|
160 <td><a href="#FindFileWidget.on_openFilesButton_clicked">on_openFilesButton_clicked</a></td> |
|
161 <td>Private slot to handle the selection of the 'Open Files' radio button.</td> |
|
162 </tr> |
|
163 <tr> |
|
164 <td><a href="#FindFileWidget.on_projectButton_clicked">on_projectButton_clicked</a></td> |
|
165 <td>Private slot to handle the selection of the 'Project' radio button.</td> |
|
166 </tr> |
|
167 <tr> |
|
168 <td><a href="#FindFileWidget.on_replaceButton_clicked">on_replaceButton_clicked</a></td> |
|
169 <td>Private slot to perform the requested replace actions.</td> |
|
170 </tr> |
|
171 <tr> |
|
172 <td><a href="#FindFileWidget.on_replacetextCombo_editTextChanged">on_replacetextCombo_editTextChanged</a></td> |
|
173 <td>Private slot to handle the editTextChanged signal of the replace text combo.</td> |
|
174 </tr> |
|
175 <tr> |
|
176 <td><a href="#FindFileWidget.setOpenFiles">setOpenFiles</a></td> |
|
177 <td>Public slot to set the mode to search in open files.</td> |
|
178 </tr> |
|
179 <tr> |
|
180 <td><a href="#FindFileWidget.setSearchDirectory">setSearchDirectory</a></td> |
|
181 <td>Public slot to set the name of the directory to search in.</td> |
|
182 </tr> |
|
183 </table> |
|
184 <h3>Static Methods</h3> |
|
185 |
|
186 <table> |
|
187 <tr><td>None</td></tr> |
|
188 </table> |
|
189 |
|
190 <a NAME="FindFileWidget.__init__" ID="FindFileWidget.__init__"></a> |
|
191 <h4>FindFileWidget (Constructor)</h4> |
|
192 <b>FindFileWidget</b>(<i>project, parent=None</i>) |
|
193 |
|
194 <p> |
|
195 Constructor |
|
196 </p> |
|
197 <dl> |
|
198 |
|
199 <dt><i>project</i> (Project)</dt> |
|
200 <dd> |
|
201 reference to the project object |
|
202 </dd> |
|
203 <dt><i>parent</i> (QWidget (optional))</dt> |
|
204 <dd> |
|
205 parent widget of this dialog (defaults to None) |
|
206 </dd> |
|
207 </dl> |
|
208 <a NAME="FindFileWidget.__contextMenuRequested" ID="FindFileWidget.__contextMenuRequested"></a> |
|
209 <h4>FindFileWidget.__contextMenuRequested</h4> |
|
210 <b>__contextMenuRequested</b>(<i>pos</i>) |
|
211 |
|
212 <p> |
|
213 Private slot to handle the context menu request. |
|
214 </p> |
|
215 <dl> |
|
216 |
|
217 <dt><i>pos</i> (QPoint)</dt> |
|
218 <dd> |
|
219 position the context menu shall be shown |
|
220 </dd> |
|
221 </dl> |
|
222 <a NAME="FindFileWidget.__copyToClipboard" ID="FindFileWidget.__copyToClipboard"></a> |
|
223 <h4>FindFileWidget.__copyToClipboard</h4> |
|
224 <b>__copyToClipboard</b>(<i></i>) |
|
225 |
|
226 <p> |
|
227 Private slot to copy the path of an entry to the clipboard. |
|
228 </p> |
|
229 <a NAME="FindFileWidget.__createItem" ID="FindFileWidget.__createItem"></a> |
|
230 <h4>FindFileWidget.__createItem</h4> |
|
231 <b>__createItem</b>(<i>file, line, text, start, end, replTxt="", md5=""</i>) |
|
232 |
|
233 <p> |
|
234 Private method to create an entry in the file list. |
|
235 </p> |
|
236 <dl> |
|
237 |
|
238 <dt><i>file</i> (str)</dt> |
|
239 <dd> |
|
240 filename of file |
|
241 </dd> |
|
242 <dt><i>line</i> (int)</dt> |
|
243 <dd> |
|
244 line number |
|
245 </dd> |
|
246 <dt><i>text</i> (str)</dt> |
|
247 <dd> |
|
248 text found |
|
249 </dd> |
|
250 <dt><i>start</i> (int)</dt> |
|
251 <dd> |
|
252 start position of match |
|
253 </dd> |
|
254 <dt><i>end</i> (int)</dt> |
|
255 <dd> |
|
256 end position of match |
|
257 </dd> |
|
258 <dt><i>replTxt</i> (str (optional))</dt> |
|
259 <dd> |
|
260 text with replacements applied (defaults to "") |
|
261 </dd> |
|
262 <dt><i>md5</i> (str (optional))</dt> |
|
263 <dd> |
|
264 MD5 hash of the file (defaults to "") |
|
265 </dd> |
|
266 </dl> |
|
267 <a NAME="FindFileWidget.__doSearch" ID="FindFileWidget.__doSearch"></a> |
|
268 <h4>FindFileWidget.__doSearch</h4> |
|
269 <b>__doSearch</b>(<i></i>) |
|
270 |
|
271 <p> |
|
272 Private slot to handle the find button being pressed. |
|
273 </p> |
|
274 <a NAME="FindFileWidget.__enableFindButton" ID="FindFileWidget.__enableFindButton"></a> |
|
275 <h4>FindFileWidget.__enableFindButton</h4> |
|
276 <b>__enableFindButton</b>(<i></i>) |
|
277 |
|
278 <p> |
|
279 Private slot called to enable the find button. |
|
280 </p> |
|
281 <a NAME="FindFileWidget.__getFileList" ID="FindFileWidget.__getFileList"></a> |
|
282 <h4>FindFileWidget.__getFileList</h4> |
|
283 <b>__getFileList</b>(<i>path, filterRe, excludeHiddenDirs=False, excludeHiddenFiles=False</i>) |
|
284 |
|
285 <p> |
|
286 Private method to get a list of files to search. |
|
287 </p> |
|
288 <dl> |
|
289 |
|
290 <dt><i>path</i> (str)</dt> |
|
291 <dd> |
|
292 the root directory to search in |
|
293 </dd> |
|
294 <dt><i>filterRe</i> (regexp object)</dt> |
|
295 <dd> |
|
296 regular expression defining the filter |
|
297 criteria |
|
298 </dd> |
|
299 <dt><i>excludeHiddenDirs</i> (bool)</dt> |
|
300 <dd> |
|
301 flag indicating to exclude hidden directories |
|
302 </dd> |
|
303 <dt><i>excludeHiddenFiles</i> (bool)</dt> |
|
304 <dd> |
|
305 flag indicating to exclude hidden files |
|
306 </dd> |
|
307 </dl> |
|
308 <dl> |
|
309 <dt>Return:</dt> |
|
310 <dd> |
|
311 list of files to be processed |
|
312 </dd> |
|
313 </dl> |
|
314 <dl> |
|
315 <dt>Return Type:</dt> |
|
316 <dd> |
|
317 list of str |
|
318 </dd> |
|
319 </dl> |
|
320 <a NAME="FindFileWidget.__openFile" ID="FindFileWidget.__openFile"></a> |
|
321 <h4>FindFileWidget.__openFile</h4> |
|
322 <b>__openFile</b>(<i></i>) |
|
323 |
|
324 <p> |
|
325 Private slot to open the currently selected entry. |
|
326 </p> |
|
327 <a NAME="FindFileWidget.__projectClosed" ID="FindFileWidget.__projectClosed"></a> |
|
328 <h4>FindFileWidget.__projectClosed</h4> |
|
329 <b>__projectClosed</b>(<i></i>) |
|
330 |
|
331 <p> |
|
332 Private slot to react to the closing of a project. |
|
333 </p> |
|
334 <a NAME="FindFileWidget.__projectOpened" ID="FindFileWidget.__projectOpened"></a> |
|
335 <h4>FindFileWidget.__projectOpened</h4> |
|
336 <b>__projectOpened</b>(<i></i>) |
|
337 |
|
338 <p> |
|
339 Private slot to react to the opening of a project. |
|
340 </p> |
|
341 <a NAME="FindFileWidget.__stopSearch" ID="FindFileWidget.__stopSearch"></a> |
|
342 <h4>FindFileWidget.__stopSearch</h4> |
|
343 <b>__stopSearch</b>(<i></i>) |
|
344 |
|
345 <p> |
|
346 Private slot to handle the stop button being pressed. |
|
347 </p> |
|
348 <a NAME="FindFileWidget.__stripEol" ID="FindFileWidget.__stripEol"></a> |
|
349 <h4>FindFileWidget.__stripEol</h4> |
|
350 <b>__stripEol</b>(<i>txt</i>) |
|
351 |
|
352 <p> |
|
353 Private method to strip the eol part. |
|
354 </p> |
|
355 <dl> |
|
356 |
|
357 <dt><i>txt</i> (str)</dt> |
|
358 <dd> |
|
359 line of text that should be treated |
|
360 </dd> |
|
361 </dl> |
|
362 <dl> |
|
363 <dt>Return:</dt> |
|
364 <dd> |
|
365 text with eol stripped |
|
366 </dd> |
|
367 </dl> |
|
368 <dl> |
|
369 <dt>Return Type:</dt> |
|
370 <dd> |
|
371 str |
|
372 </dd> |
|
373 </dl> |
|
374 <a NAME="FindFileWidget.__toggleReplaceMode" ID="FindFileWidget.__toggleReplaceMode"></a> |
|
375 <h4>FindFileWidget.__toggleReplaceMode</h4> |
|
376 <b>__toggleReplaceMode</b>(<i></i>) |
|
377 |
|
378 <p> |
|
379 Private slot to toggle the dialog mode. |
|
380 </p> |
|
381 <a NAME="FindFileWidget.activate" ID="FindFileWidget.activate"></a> |
|
382 <h4>FindFileWidget.activate</h4> |
|
383 <b>activate</b>(<i>replaceMode=False, txt="", searchDir="", openFiles=False</i>) |
|
384 |
|
385 <p> |
|
386 Public method to activate the widget with a given mode, a text |
|
387 to search for and some search parameters. |
|
388 </p> |
|
389 <dl> |
|
390 |
|
391 <dt><i>replaceMode</i> (bool (optional))</dt> |
|
392 <dd> |
|
393 flag indicating replacement mode (defaults to False) |
|
394 </dd> |
|
395 <dt><i>txt</i> (str (optional))</dt> |
|
396 <dd> |
|
397 text to be searched for (defaults to "") |
|
398 </dd> |
|
399 <dt><i>searchDir</i> (str (optional))</dt> |
|
400 <dd> |
|
401 directory to search in (defaults to "") |
|
402 </dd> |
|
403 <dt><i>openFiles</i> (bool (optional))</dt> |
|
404 <dd> |
|
405 flag indicating to operate on open files only |
|
406 (defaults to False) |
|
407 </dd> |
|
408 </dl> |
|
409 <a NAME="FindFileWidget.on_dirButton_clicked" ID="FindFileWidget.on_dirButton_clicked"></a> |
|
410 <h4>FindFileWidget.on_dirButton_clicked</h4> |
|
411 <b>on_dirButton_clicked</b>(<i></i>) |
|
412 |
|
413 <p> |
|
414 Private slot to handle the selection of the 'Directory' radio button. |
|
415 </p> |
|
416 <a NAME="FindFileWidget.on_dirPicker_editTextChanged" ID="FindFileWidget.on_dirPicker_editTextChanged"></a> |
|
417 <h4>FindFileWidget.on_dirPicker_editTextChanged</h4> |
|
418 <b>on_dirPicker_editTextChanged</b>(<i>text</i>) |
|
419 |
|
420 <p> |
|
421 Private slot to handle the textChanged signal of the directory |
|
422 picker. |
|
423 </p> |
|
424 <dl> |
|
425 |
|
426 <dt><i>text</i></dt> |
|
427 <dd> |
|
428 (ignored) |
|
429 </dd> |
|
430 </dl> |
|
431 <a NAME="FindFileWidget.on_filterCheckBox_clicked" ID="FindFileWidget.on_filterCheckBox_clicked"></a> |
|
432 <h4>FindFileWidget.on_filterCheckBox_clicked</h4> |
|
433 <b>on_filterCheckBox_clicked</b>(<i></i>) |
|
434 |
|
435 <p> |
|
436 Private slot to handle the selection of the file filter check box. |
|
437 </p> |
|
438 <a NAME="FindFileWidget.on_filterEdit_textEdited" ID="FindFileWidget.on_filterEdit_textEdited"></a> |
|
439 <h4>FindFileWidget.on_filterEdit_textEdited</h4> |
|
440 <b>on_filterEdit_textEdited</b>(<i>text</i>) |
|
441 |
|
442 <p> |
|
443 Private slot to handle the textChanged signal of the file filter edit. |
|
444 </p> |
|
445 <dl> |
|
446 |
|
447 <dt><i>text</i></dt> |
|
448 <dd> |
|
449 (ignored) |
|
450 </dd> |
|
451 </dl> |
|
452 <a NAME="FindFileWidget.on_findList_itemDoubleClicked" ID="FindFileWidget.on_findList_itemDoubleClicked"></a> |
|
453 <h4>FindFileWidget.on_findList_itemDoubleClicked</h4> |
|
454 <b>on_findList_itemDoubleClicked</b>(<i>itm, column</i>) |
|
455 |
|
456 <p> |
|
457 Private slot to handle the double click on a file item. |
|
458 </p> |
|
459 <p> |
|
460 It emits the signal sourceFile or designerFile depending on the file |
|
461 extension. |
|
462 </p> |
|
463 <dl> |
|
464 |
|
465 <dt><i>itm</i> (QTreeWidgetItem)</dt> |
|
466 <dd> |
|
467 the double clicked tree item |
|
468 </dd> |
|
469 <dt><i>column</i> (int)</dt> |
|
470 <dd> |
|
471 column that was double clicked (ignored) |
|
472 </dd> |
|
473 </dl> |
|
474 <a NAME="FindFileWidget.on_findtextCombo_editTextChanged" ID="FindFileWidget.on_findtextCombo_editTextChanged"></a> |
|
475 <h4>FindFileWidget.on_findtextCombo_editTextChanged</h4> |
|
476 <b>on_findtextCombo_editTextChanged</b>(<i>text</i>) |
|
477 |
|
478 <p> |
|
479 Private slot to handle the editTextChanged signal of the find |
|
480 text combo. |
|
481 </p> |
|
482 <dl> |
|
483 |
|
484 <dt><i>text</i></dt> |
|
485 <dd> |
|
486 (ignored) |
|
487 </dd> |
|
488 </dl> |
|
489 <a NAME="FindFileWidget.on_openFilesButton_clicked" ID="FindFileWidget.on_openFilesButton_clicked"></a> |
|
490 <h4>FindFileWidget.on_openFilesButton_clicked</h4> |
|
491 <b>on_openFilesButton_clicked</b>(<i></i>) |
|
492 |
|
493 <p> |
|
494 Private slot to handle the selection of the 'Open Files' radio button. |
|
495 </p> |
|
496 <a NAME="FindFileWidget.on_projectButton_clicked" ID="FindFileWidget.on_projectButton_clicked"></a> |
|
497 <h4>FindFileWidget.on_projectButton_clicked</h4> |
|
498 <b>on_projectButton_clicked</b>(<i></i>) |
|
499 |
|
500 <p> |
|
501 Private slot to handle the selection of the 'Project' radio button. |
|
502 </p> |
|
503 <a NAME="FindFileWidget.on_replaceButton_clicked" ID="FindFileWidget.on_replaceButton_clicked"></a> |
|
504 <h4>FindFileWidget.on_replaceButton_clicked</h4> |
|
505 <b>on_replaceButton_clicked</b>(<i></i>) |
|
506 |
|
507 <p> |
|
508 Private slot to perform the requested replace actions. |
|
509 </p> |
|
510 <a NAME="FindFileWidget.on_replacetextCombo_editTextChanged" ID="FindFileWidget.on_replacetextCombo_editTextChanged"></a> |
|
511 <h4>FindFileWidget.on_replacetextCombo_editTextChanged</h4> |
|
512 <b>on_replacetextCombo_editTextChanged</b>(<i>text</i>) |
|
513 |
|
514 <p> |
|
515 Private slot to handle the editTextChanged signal of the replace |
|
516 text combo. |
|
517 </p> |
|
518 <dl> |
|
519 |
|
520 <dt><i>text</i></dt> |
|
521 <dd> |
|
522 (ignored) |
|
523 </dd> |
|
524 </dl> |
|
525 <a NAME="FindFileWidget.setOpenFiles" ID="FindFileWidget.setOpenFiles"></a> |
|
526 <h4>FindFileWidget.setOpenFiles</h4> |
|
527 <b>setOpenFiles</b>(<i></i>) |
|
528 |
|
529 <p> |
|
530 Public slot to set the mode to search in open files. |
|
531 </p> |
|
532 <a NAME="FindFileWidget.setSearchDirectory" ID="FindFileWidget.setSearchDirectory"></a> |
|
533 <h4>FindFileWidget.setSearchDirectory</h4> |
|
534 <b>setSearchDirectory</b>(<i>searchDir</i>) |
|
535 |
|
536 <p> |
|
537 Public slot to set the name of the directory to search in. |
|
538 </p> |
|
539 <dl> |
|
540 |
|
541 <dt><i>searchDir</i> (str)</dt> |
|
542 <dd> |
|
543 name of the directory to search in |
|
544 </dd> |
|
545 </dl> |
|
546 <div align="right"><a href="#top">Up</a></div> |
|
547 <hr /> |
|
548 </body></html> |