Sat, 19 Oct 2013 17:42:18 +0200
Fixed a bunch of indentation issues.
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1 | # -*- coding: utf-8 -*- |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
2 | |
2302
f29e9405c851
Updated copyright for 2013.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2214
diff
changeset
|
3 | # Copyright (c) 2002 - 2013 Detlev Offenbach <detlev@die-offenbachs.de> |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
4 | # |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
5 | |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
6 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
7 | Module implementing a dialog to search for text in files. |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
8 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
9 | |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
10 | import os |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
11 | import re |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
12 | |
1112
8a7d1b9d18db
Improved code quality by getting rid of star imports. That way pyflakes can do its job. A few bugs fixed found by flakes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
13 | from PyQt4.QtCore import pyqtSignal, Qt, pyqtSlot |
3012
d177226027e2
Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2965
diff
changeset
|
14 | from PyQt4.QtGui import QCursor, QDialog, QApplication, QMenu, \ |
d177226027e2
Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2965
diff
changeset
|
15 | QDialogButtonBox, QTreeWidgetItem |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
16 | |
55
b5c84934de9c
Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
53
diff
changeset
|
17 | from E5Gui.E5Application import e5App |
882
34b86be88bf0
Redid the native file dialog code to be future proof.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
880
diff
changeset
|
18 | from E5Gui import E5MessageBox, E5FileDialog |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
19 | |
12
1d8dd9706f46
First commit after changing to Python 3.1.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7
diff
changeset
|
20 | from .Ui_FindFileDialog import Ui_FindFileDialog |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
21 | |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
22 | import Utilities |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
23 | import Preferences |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
24 | |
945
8cd4d08fa9f6
Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
894
diff
changeset
|
25 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
26 | class FindFileDialog(QDialog, Ui_FindFileDialog): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
27 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
28 | Class implementing a dialog to search for text in files. |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
29 | |
846
869c200be26e
Fixed an omission in the find and replace dialog and formatted it according PEP 8.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
791
diff
changeset
|
30 | The occurrences found are displayed in a QTreeWidget showing the filename, |
869c200be26e
Fixed an omission in the find and replace dialog and formatted it according PEP 8.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
791
diff
changeset
|
31 | the linenumber and the found text. The file will be opened upon a double |
869c200be26e
Fixed an omission in the find and replace dialog and formatted it according PEP 8.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
791
diff
changeset
|
32 | click onto the respective entry of the list. |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
33 | |
846
869c200be26e
Fixed an omission in the find and replace dialog and formatted it according PEP 8.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
791
diff
changeset
|
34 | @signal sourceFile(str, int, str, int, int) emitted to open a source file |
869c200be26e
Fixed an omission in the find and replace dialog and formatted it according PEP 8.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
791
diff
changeset
|
35 | at a line |
501
5c615a85241a
Finished porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
500
diff
changeset
|
36 | @signal designerFile(str) emitted to open a Qt-Designer file |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
37 | """ |
476
121633976eca
Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
458
diff
changeset
|
38 | sourceFile = pyqtSignal(str, int, str, int, int) |
500
c3abc7895a01
Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
489
diff
changeset
|
39 | designerFile = pyqtSignal(str) |
476
121633976eca
Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
458
diff
changeset
|
40 | |
945
8cd4d08fa9f6
Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
894
diff
changeset
|
41 | lineRole = Qt.UserRole + 1 |
8cd4d08fa9f6
Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
894
diff
changeset
|
42 | startRole = Qt.UserRole + 2 |
8cd4d08fa9f6
Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
894
diff
changeset
|
43 | endRole = Qt.UserRole + 3 |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
44 | replaceRole = Qt.UserRole + 4 |
945
8cd4d08fa9f6
Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
894
diff
changeset
|
45 | md5Role = Qt.UserRole + 5 |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
46 | |
945
8cd4d08fa9f6
Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
894
diff
changeset
|
47 | def __init__(self, project, replaceMode=False, parent=None): |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
48 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
49 | Constructor |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
50 | |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
51 | @param project reference to the project object |
2965
d133c7edd88a
Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2302
diff
changeset
|
52 | @param replaceMode flag indicating the replace dialog mode (boolean) |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
53 | @param parent parent widget of this dialog (QWidget) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
54 | """ |
1131
7781e396c903
Changed the code to use super() to access the superclass.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1112
diff
changeset
|
55 | super().__init__(parent) |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
56 | self.setupUi(self) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
57 | self.setWindowFlags(Qt.WindowFlags(Qt.Window)) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
58 | |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
59 | self.__replaceMode = replaceMode |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
60 | |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
61 | self.stopButton = \ |
945
8cd4d08fa9f6
Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
894
diff
changeset
|
62 | self.buttonBox.addButton(self.trUtf8("Stop"), |
846
869c200be26e
Fixed an omission in the find and replace dialog and formatted it according PEP 8.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
791
diff
changeset
|
63 | QDialogButtonBox.ActionRole) |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
64 | self.stopButton.setEnabled(False) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
65 | |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
66 | self.findButton = \ |
945
8cd4d08fa9f6
Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
894
diff
changeset
|
67 | self.buttonBox.addButton(self.trUtf8("Find"), |
846
869c200be26e
Fixed an omission in the find and replace dialog and formatted it according PEP 8.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
791
diff
changeset
|
68 | QDialogButtonBox.ActionRole) |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
69 | self.findButton.setEnabled(False) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
70 | self.findButton.setDefault(True) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
71 | |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
72 | if self.__replaceMode: |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
73 | self.replaceButton.setEnabled(False) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
74 | self.setWindowTitle(self.trUtf8("Replace in Files")) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
75 | else: |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
76 | self.replaceLabel.hide() |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
77 | self.replacetextCombo.hide() |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
78 | self.replaceButton.hide() |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
79 | |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
80 | self.findProgressLabel.setMaximumWidth(550) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
81 | |
268
f6f53503b8d6
Changed the Find in Files dialog to remember the history of the search string, replace string and the search directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
248
diff
changeset
|
82 | self.searchHistory = Preferences.toList( |
846
869c200be26e
Fixed an omission in the find and replace dialog and formatted it according PEP 8.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
791
diff
changeset
|
83 | Preferences.Prefs.settings.value( |
869c200be26e
Fixed an omission in the find and replace dialog and formatted it according PEP 8.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
791
diff
changeset
|
84 | "FindFileDialog/SearchHistory")) |
268
f6f53503b8d6
Changed the Find in Files dialog to remember the history of the search string, replace string and the search directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
248
diff
changeset
|
85 | self.replaceHistory = Preferences.toList( |
846
869c200be26e
Fixed an omission in the find and replace dialog and formatted it according PEP 8.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
791
diff
changeset
|
86 | Preferences.Prefs.settings.value( |
869c200be26e
Fixed an omission in the find and replace dialog and formatted it according PEP 8.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
791
diff
changeset
|
87 | "FindFileDialog/ReplaceHistory")) |
268
f6f53503b8d6
Changed the Find in Files dialog to remember the history of the search string, replace string and the search directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
248
diff
changeset
|
88 | self.dirHistory = Preferences.toList( |
846
869c200be26e
Fixed an omission in the find and replace dialog and formatted it according PEP 8.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
791
diff
changeset
|
89 | Preferences.Prefs.settings.value( |
869c200be26e
Fixed an omission in the find and replace dialog and formatted it according PEP 8.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
791
diff
changeset
|
90 | "FindFileDialog/DirectoryHistory")) |
268
f6f53503b8d6
Changed the Find in Files dialog to remember the history of the search string, replace string and the search directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
248
diff
changeset
|
91 | self.findtextCombo.addItems(self.searchHistory) |
f6f53503b8d6
Changed the Find in Files dialog to remember the history of the search string, replace string and the search directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
248
diff
changeset
|
92 | self.replacetextCombo.addItems(self.replaceHistory) |
f6f53503b8d6
Changed the Find in Files dialog to remember the history of the search string, replace string and the search directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
248
diff
changeset
|
93 | self.dirCombo.addItems(self.dirHistory) |
f6f53503b8d6
Changed the Find in Files dialog to remember the history of the search string, replace string and the search directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
248
diff
changeset
|
94 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
95 | self.project = project |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
96 | |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
97 | self.findList.headerItem().setText(self.findList.columnCount(), "") |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
98 | self.findList.header().setSortIndicator(0, Qt.AscendingOrder) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
99 | self.__section0Size = self.findList.header().sectionSize(0) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
100 | self.findList.setExpandsOnDoubleClick(False) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
101 | if self.__replaceMode: |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
102 | font = self.findList.font() |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
103 | if Utilities.isWindowsPlatform(): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
104 | font.setFamily("Lucida Console") |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
105 | else: |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
106 | font.setFamily("Monospace") |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
107 | self.findList.setFont(font) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
108 | |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
109 | # Qt Designer form files |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
110 | self.filterForms = r'.*\.ui$' |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
111 | self.formsExt = ['*.ui'] |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
112 | |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
113 | # Corba interface files |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
114 | self.filterInterfaces = r'.*\.idl$' |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
115 | self.interfacesExt = ['*.idl'] |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
116 | |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
117 | # Qt resources files |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
118 | self.filterResources = r'.*\.qrc$' |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
119 | self.resourcesExt = ['*.qrc'] |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
120 | |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
121 | self.__cancelSearch = False |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
122 | self.__lastFileItem = None |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
123 | self.__populating = False |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
124 | |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
125 | self.setContextMenuPolicy(Qt.CustomContextMenu) |
458
1695e7a2db54
Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
432
diff
changeset
|
126 | self.customContextMenuRequested.connect(self.__contextMenuRequested) |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
127 | |
846
869c200be26e
Fixed an omission in the find and replace dialog and formatted it according PEP 8.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
791
diff
changeset
|
128 | def __createItem(self, file, line, text, start, end, replTxt="", md5=""): |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
129 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
130 | Private method to create an entry in the file list. |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
131 | |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
132 | @param file filename of file (string) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
133 | @param line line number (integer) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
134 | @param text text found (string) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
135 | @param start start position of match (integer) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
136 | @param end end position of match (integer) |
682
91114a975eda
Added a check to the find and replace dialog to make sure, that no external changes were done between the find run and the replace run.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
654
diff
changeset
|
137 | @param replTxt text with replacements applied (string) |
91114a975eda
Added a check to the find and replace dialog to make sure, that no external changes were done between the find run and the replace run.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
654
diff
changeset
|
138 | @keyparam md5 MD5 hash of the file (string) |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
139 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
140 | if self.__lastFileItem is None: |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
141 | # It's a new file |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
142 | self.__lastFileItem = QTreeWidgetItem(self.findList, [file]) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
143 | self.__lastFileItem.setFirstColumnSpanned(True) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
144 | self.__lastFileItem.setExpanded(True) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
145 | if self.__replaceMode: |
3030
4a0a82ddd9d2
Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3020
diff
changeset
|
146 | self.__lastFileItem.setFlags( |
3034
7ce719013078
Fixed various coding style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3030
diff
changeset
|
147 | self.__lastFileItem.flags() | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
148 | Qt.ItemFlags(Qt.ItemIsUserCheckable | Qt.ItemIsTristate)) |
945
8cd4d08fa9f6
Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
894
diff
changeset
|
149 | # Qt bug: |
8cd4d08fa9f6
Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
894
diff
changeset
|
150 | # item is not user checkable if setFirstColumnSpanned |
846
869c200be26e
Fixed an omission in the find and replace dialog and formatted it according PEP 8.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
791
diff
changeset
|
151 | # is True (< 4.5.0) |
682
91114a975eda
Added a check to the find and replace dialog to make sure, that no external changes were done between the find run and the replace run.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
654
diff
changeset
|
152 | self.__lastFileItem.setData(0, self.md5Role, md5) |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
153 | |
1640
1699d46026cd
Fixed a compatibility issue with Qt 4.8.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
154 | itm = QTreeWidgetItem(self.__lastFileItem) |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
155 | itm.setTextAlignment(0, Qt.AlignRight) |
1640
1699d46026cd
Fixed a compatibility issue with Qt 4.8.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
156 | itm.setData(0, Qt.DisplayRole, line) |
1699d46026cd
Fixed a compatibility issue with Qt 4.8.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
157 | itm.setData(1, Qt.DisplayRole, text) |
7
c679fb30c8f3
Change code dealing with QVariant (and QSettings) to use the PyQt4 QVariant v2 API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6
diff
changeset
|
158 | itm.setData(0, self.lineRole, line) |
c679fb30c8f3
Change code dealing with QVariant (and QSettings) to use the PyQt4 QVariant v2 API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6
diff
changeset
|
159 | itm.setData(0, self.startRole, start) |
c679fb30c8f3
Change code dealing with QVariant (and QSettings) to use the PyQt4 QVariant v2 API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6
diff
changeset
|
160 | itm.setData(0, self.endRole, end) |
c679fb30c8f3
Change code dealing with QVariant (and QSettings) to use the PyQt4 QVariant v2 API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6
diff
changeset
|
161 | itm.setData(0, self.replaceRole, replTxt) |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
162 | if self.__replaceMode: |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
163 | itm.setFlags(itm.flags() | Qt.ItemFlags(Qt.ItemIsUserCheckable)) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
164 | itm.setCheckState(0, Qt.Checked) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
165 | self.replaceButton.setEnabled(True) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
166 | |
945
8cd4d08fa9f6
Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
894
diff
changeset
|
167 | def show(self, txt=""): |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
168 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
169 | Overwritten method to enable/disable the project button. |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
170 | |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
171 | @param txt text to be shown in the searchtext combo (string) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
172 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
173 | if self.project and self.project.isOpen(): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
174 | self.projectButton.setEnabled(True) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
175 | else: |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
176 | self.projectButton.setEnabled(False) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
177 | self.dirButton.setChecked(True) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
178 | |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
179 | self.findtextCombo.setEditText(txt) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
180 | self.findtextCombo.lineEdit().selectAll() |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
181 | self.findtextCombo.setFocus() |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
182 | |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
183 | if self.__replaceMode: |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
184 | self.findList.clear() |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
185 | self.replacetextCombo.setEditText("") |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
186 | |
1131
7781e396c903
Changed the code to use super() to access the superclass.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1112
diff
changeset
|
187 | super().show() |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
188 | |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
189 | def on_findtextCombo_editTextChanged(self, text): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
190 | """ |
846
869c200be26e
Fixed an omission in the find and replace dialog and formatted it according PEP 8.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
791
diff
changeset
|
191 | Private slot to handle the editTextChanged signal of the find |
869c200be26e
Fixed an omission in the find and replace dialog and formatted it according PEP 8.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
791
diff
changeset
|
192 | text combo. |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
193 | |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
194 | @param text (ignored) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
195 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
196 | self.__enableFindButton() |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
197 | |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
198 | def on_replacetextCombo_editTextChanged(self, text): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
199 | """ |
846
869c200be26e
Fixed an omission in the find and replace dialog and formatted it according PEP 8.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
791
diff
changeset
|
200 | Private slot to handle the editTextChanged signal of the replace |
869c200be26e
Fixed an omission in the find and replace dialog and formatted it according PEP 8.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
791
diff
changeset
|
201 | text combo. |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
202 | |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
203 | @param text (ignored) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
204 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
205 | self.__enableFindButton() |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
206 | |
268
f6f53503b8d6
Changed the Find in Files dialog to remember the history of the search string, replace string and the search directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
248
diff
changeset
|
207 | def on_dirCombo_editTextChanged(self, text): |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
208 | """ |
846
869c200be26e
Fixed an omission in the find and replace dialog and formatted it according PEP 8.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
791
diff
changeset
|
209 | Private slot to handle the textChanged signal of the directory |
869c200be26e
Fixed an omission in the find and replace dialog and formatted it according PEP 8.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
791
diff
changeset
|
210 | combo box. |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
211 | |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
212 | @param text (ignored) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
213 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
214 | self.__enableFindButton() |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
215 | |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
216 | @pyqtSlot() |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
217 | def on_projectButton_clicked(self): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
218 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
219 | Private slot to handle the selection of the project radio button. |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
220 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
221 | self.__enableFindButton() |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
222 | |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
223 | @pyqtSlot() |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
224 | def on_dirButton_clicked(self): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
225 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
226 | Private slot to handle the selection of the project radio button. |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
227 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
228 | self.__enableFindButton() |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
229 | |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
230 | @pyqtSlot() |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
231 | def on_filterCheckBox_clicked(self): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
232 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
233 | Private slot to handle the selection of the file filter check box. |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
234 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
235 | self.__enableFindButton() |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
236 | |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
237 | @pyqtSlot(str) |
489
844a0a278269
Fixed an issue in the find in files dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
476
diff
changeset
|
238 | def on_filterEdit_textEdited(self, text): |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
239 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
240 | Private slot to handle the textChanged signal of the file filter edit. |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
241 | |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
242 | @param text (ignored) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
243 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
244 | self.__enableFindButton() |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
245 | |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
246 | def __enableFindButton(self): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
247 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
248 | Private slot called to enable the find button. |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
249 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
250 | if self.findtextCombo.currentText() == "" or \ |
3034
7ce719013078
Fixed various coding style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3030
diff
changeset
|
251 | (self.__replaceMode and |
846
869c200be26e
Fixed an omission in the find and replace dialog and formatted it according PEP 8.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
791
diff
changeset
|
252 | self.replacetextCombo.currentText() == "") or \ |
3034
7ce719013078
Fixed various coding style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3030
diff
changeset
|
253 | (self.dirButton.isChecked() and |
7ce719013078
Fixed various coding style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3030
diff
changeset
|
254 | (self.dirCombo.currentText() == "" or |
846
869c200be26e
Fixed an omission in the find and replace dialog and formatted it according PEP 8.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
791
diff
changeset
|
255 | not os.path.exists(os.path.abspath( |
869c200be26e
Fixed an omission in the find and replace dialog and formatted it according PEP 8.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
791
diff
changeset
|
256 | self.dirCombo.currentText())))) or \ |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
257 | (self.filterCheckBox.isChecked() and self.filterEdit.text() == ""): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
258 | self.findButton.setEnabled(False) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
259 | self.buttonBox.button(QDialogButtonBox.Close).setDefault(True) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
260 | else: |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
261 | self.findButton.setEnabled(True) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
262 | self.findButton.setDefault(True) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
263 | |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
264 | def on_buttonBox_clicked(self, button): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
265 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
266 | Private slot called by a button of the button box clicked. |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
267 | |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
268 | @param button button that was clicked (QAbstractButton) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
269 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
270 | if button == self.findButton: |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
271 | self.__doSearch() |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
272 | elif button == self.stopButton: |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
273 | self.__stopSearch() |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
274 | |
855
d8c4113a9274
Fixed an issue of the find/replace in file dialog where a replace would change the eol as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
846
diff
changeset
|
275 | def __stripEol(self, txt): |
d8c4113a9274
Fixed an issue of the find/replace in file dialog where a replace would change the eol as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
846
diff
changeset
|
276 | """ |
d8c4113a9274
Fixed an issue of the find/replace in file dialog where a replace would change the eol as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
846
diff
changeset
|
277 | Private method to strip the eol part. |
d8c4113a9274
Fixed an issue of the find/replace in file dialog where a replace would change the eol as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
846
diff
changeset
|
278 | |
d8c4113a9274
Fixed an issue of the find/replace in file dialog where a replace would change the eol as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
846
diff
changeset
|
279 | @param txt line of text that should be treated (string) |
d8c4113a9274
Fixed an issue of the find/replace in file dialog where a replace would change the eol as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
846
diff
changeset
|
280 | @return text with eol stripped (string) |
d8c4113a9274
Fixed an issue of the find/replace in file dialog where a replace would change the eol as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
846
diff
changeset
|
281 | """ |
d8c4113a9274
Fixed an issue of the find/replace in file dialog where a replace would change the eol as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
846
diff
changeset
|
282 | return txt.replace("\r", "").replace("\n", "") |
d8c4113a9274
Fixed an issue of the find/replace in file dialog where a replace would change the eol as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
846
diff
changeset
|
283 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
284 | def __stopSearch(self): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
285 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
286 | Private slot to handle the stop button being pressed. |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
287 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
288 | self.__cancelSearch = True |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
289 | |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
290 | def __doSearch(self): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
291 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
292 | Private slot to handle the find button being pressed. |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
293 | """ |
846
869c200be26e
Fixed an omission in the find and replace dialog and formatted it according PEP 8.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
791
diff
changeset
|
294 | if self.__replaceMode and \ |
869c200be26e
Fixed an omission in the find and replace dialog and formatted it according PEP 8.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
791
diff
changeset
|
295 | not e5App().getObject("ViewManager").checkAllDirty(): |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
296 | return |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
297 | |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
298 | self.__cancelSearch = False |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
299 | |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
300 | if self.filterCheckBox.isChecked(): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
301 | fileFilter = self.filterEdit.text() |
489
844a0a278269
Fixed an issue in the find in files dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
476
diff
changeset
|
302 | fileFilterList = \ |
3034
7ce719013078
Fixed various coding style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3030
diff
changeset
|
303 | ["^{0}$".format(filter.replace(".", "\.").replace("*", ".*")) |
489
844a0a278269
Fixed an issue in the find in files dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
476
diff
changeset
|
304 | for filter in fileFilter.split(";")] |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
305 | filterRe = re.compile("|".join(fileFilterList)) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
306 | |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
307 | if self.projectButton.isChecked(): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
308 | if self.filterCheckBox.isChecked(): |
3034
7ce719013078
Fixed various coding style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3030
diff
changeset
|
309 | files = [self.project.getRelativePath(file) |
7ce719013078
Fixed various coding style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3030
diff
changeset
|
310 | for file in |
846
869c200be26e
Fixed an omission in the find and replace dialog and formatted it according PEP 8.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
791
diff
changeset
|
311 | self.__getFileList( |
3039
8dd0165d805d
Fixed a bunch of indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3034
diff
changeset
|
312 | self.project.getProjectPath(), filterRe)] |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
313 | else: |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
314 | files = [] |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
315 | if self.sourcesCheckBox.isChecked(): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
316 | files += self.project.pdata["SOURCES"] |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
317 | if self.formsCheckBox.isChecked(): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
318 | files += self.project.pdata["FORMS"] |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
319 | if self.interfacesCheckBox.isChecked(): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
320 | files += self.project.pdata["INTERFACES"] |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
321 | if self.resourcesCheckBox.isChecked(): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
322 | files += self.project.pdata["RESOURCES"] |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
323 | elif self.dirButton.isChecked(): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
324 | if not self.filterCheckBox.isChecked(): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
325 | filters = [] |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
326 | if self.sourcesCheckBox.isChecked(): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
327 | filters.extend( |
846
869c200be26e
Fixed an omission in the find and replace dialog and formatted it according PEP 8.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
791
diff
changeset
|
328 | ["^{0}$".format( |
869c200be26e
Fixed an omission in the find and replace dialog and formatted it according PEP 8.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
791
diff
changeset
|
329 | assoc.replace(".", "\.").replace("*", ".*")) |
869c200be26e
Fixed an omission in the find and replace dialog and formatted it according PEP 8.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
791
diff
changeset
|
330 | for assoc in list( |
3039
8dd0165d805d
Fixed a bunch of indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3034
diff
changeset
|
331 | Preferences.getEditorLexerAssocs().keys()) |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
332 | if assoc not in self.formsExt + self.interfacesExt]) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
333 | if self.formsCheckBox.isChecked(): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
334 | filters.append(self.filterForms) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
335 | if self.interfacesCheckBox.isChecked(): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
336 | filters.append(self.filterInterfaces) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
337 | if self.resourcesCheckBox.isChecked(): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
338 | filters.append(self.filterResources) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
339 | filterString = "|".join(filters) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
340 | filterRe = re.compile(filterString) |
846
869c200be26e
Fixed an omission in the find and replace dialog and formatted it according PEP 8.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
791
diff
changeset
|
341 | files = self.__getFileList( |
945
8cd4d08fa9f6
Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
894
diff
changeset
|
342 | os.path.abspath(self.dirCombo.currentText()), |
846
869c200be26e
Fixed an omission in the find and replace dialog and formatted it according PEP 8.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
791
diff
changeset
|
343 | filterRe) |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
344 | elif self.openFilesButton.isChecked(): |
2214
4ce1ebcc3806
Added actions to open the find in files and replace in files dialogs in a mode that searches open files only.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1640
diff
changeset
|
345 | vm = e5App().getObject("ViewManager") |
4ce1ebcc3806
Added actions to open the find in files and replace in files dialogs in a mode that searches open files only.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1640
diff
changeset
|
346 | vm.checkAllDirty() |
4ce1ebcc3806
Added actions to open the find in files and replace in files dialogs in a mode that searches open files only.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1640
diff
changeset
|
347 | files = vm.getOpenFilenames() |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
348 | |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
349 | self.findList.clear() |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
350 | QApplication.processEvents() |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
351 | QApplication.processEvents() |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
352 | self.findProgress.setMaximum(len(files)) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
353 | |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
354 | # retrieve the values |
945
8cd4d08fa9f6
Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
894
diff
changeset
|
355 | reg = self.regexpCheckBox.isChecked() |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
356 | wo = self.wordCheckBox.isChecked() |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
357 | cs = self.caseCheckBox.isChecked() |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
358 | ct = self.findtextCombo.currentText() |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
359 | if reg: |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
360 | txt = ct |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
361 | else: |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
362 | txt = re.escape(ct) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
363 | if wo: |
432
497e188ee86e
Did some more string format conversions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
293
diff
changeset
|
364 | txt = "\\b{0}\\b".format(txt) |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
365 | flags = re.UNICODE | re.LOCALE |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
366 | if not cs: |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
367 | flags |= re.IGNORECASE |
6
52e8c820d0dd
Removed some superfluous unicode() calls.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
368 | try: |
52e8c820d0dd
Removed some superfluous unicode() calls.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
369 | search = re.compile(txt, flags) |
12
1d8dd9706f46
First commit after changing to Python 3.1.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7
diff
changeset
|
370 | except re.error as why: |
3020
542e97d4ecb3
Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3012
diff
changeset
|
371 | E5MessageBox.critical( |
542e97d4ecb3
Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3012
diff
changeset
|
372 | self, |
6
52e8c820d0dd
Removed some superfluous unicode() calls.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
373 | self.trUtf8("Invalid search expression"), |
52e8c820d0dd
Removed some superfluous unicode() calls.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
374 | self.trUtf8("""<p>The search expression is not valid.</p>""" |
12
1d8dd9706f46
First commit after changing to Python 3.1.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7
diff
changeset
|
375 | """<p>Error: {0}</p>""").format(str(why))) |
6
52e8c820d0dd
Removed some superfluous unicode() calls.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
376 | self.stopButton.setEnabled(False) |
52e8c820d0dd
Removed some superfluous unicode() calls.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
377 | self.findButton.setEnabled(True) |
52e8c820d0dd
Removed some superfluous unicode() calls.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
378 | self.findButton.setDefault(True) |
52e8c820d0dd
Removed some superfluous unicode() calls.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
379 | return |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
380 | # reset the findtextCombo |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
381 | if ct in self.searchHistory: |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
382 | self.searchHistory.remove(ct) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
383 | self.searchHistory.insert(0, ct) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
384 | self.findtextCombo.clear() |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
385 | self.findtextCombo.addItems(self.searchHistory) |
846
869c200be26e
Fixed an omission in the find and replace dialog and formatted it according PEP 8.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
791
diff
changeset
|
386 | Preferences.Prefs.settings.setValue( |
945
8cd4d08fa9f6
Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
894
diff
changeset
|
387 | "FindFileDialog/SearchHistory", |
846
869c200be26e
Fixed an omission in the find and replace dialog and formatted it according PEP 8.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
791
diff
changeset
|
388 | self.searchHistory[:30]) |
268
f6f53503b8d6
Changed the Find in Files dialog to remember the history of the search string, replace string and the search directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
248
diff
changeset
|
389 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
390 | if self.__replaceMode: |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
391 | replTxt = self.replacetextCombo.currentText() |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
392 | if replTxt in self.replaceHistory: |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
393 | self.replaceHistory.remove(replTxt) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
394 | self.replaceHistory.insert(0, replTxt) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
395 | self.replacetextCombo.clear() |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
396 | self.replacetextCombo.addItems(self.replaceHistory) |
846
869c200be26e
Fixed an omission in the find and replace dialog and formatted it according PEP 8.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
791
diff
changeset
|
397 | Preferences.Prefs.settings.setValue( |
945
8cd4d08fa9f6
Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
894
diff
changeset
|
398 | "FindFileDialog/ReplaceHistory", |
846
869c200be26e
Fixed an omission in the find and replace dialog and formatted it according PEP 8.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
791
diff
changeset
|
399 | self.replaceHistory[:30]) |
268
f6f53503b8d6
Changed the Find in Files dialog to remember the history of the search string, replace string and the search directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
248
diff
changeset
|
400 | |
f6f53503b8d6
Changed the Find in Files dialog to remember the history of the search string, replace string and the search directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
248
diff
changeset
|
401 | if self.dirButton.isChecked(): |
293
9ecc02b50325
Fixed a variable naming issue in FindFileDialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
268
diff
changeset
|
402 | searchDir = self.dirCombo.currentText() |
9ecc02b50325
Fixed a variable naming issue in FindFileDialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
268
diff
changeset
|
403 | if searchDir in self.dirHistory: |
9ecc02b50325
Fixed a variable naming issue in FindFileDialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
268
diff
changeset
|
404 | self.dirHistory.remove(searchDir) |
9ecc02b50325
Fixed a variable naming issue in FindFileDialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
268
diff
changeset
|
405 | self.dirHistory.insert(0, searchDir) |
268
f6f53503b8d6
Changed the Find in Files dialog to remember the history of the search string, replace string and the search directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
248
diff
changeset
|
406 | self.dirCombo.clear() |
f6f53503b8d6
Changed the Find in Files dialog to remember the history of the search string, replace string and the search directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
248
diff
changeset
|
407 | self.dirCombo.addItems(self.dirHistory) |
846
869c200be26e
Fixed an omission in the find and replace dialog and formatted it according PEP 8.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
791
diff
changeset
|
408 | Preferences.Prefs.settings.setValue( |
945
8cd4d08fa9f6
Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
894
diff
changeset
|
409 | "FindFileDialog/DirectoryHistory", |
846
869c200be26e
Fixed an omission in the find and replace dialog and formatted it according PEP 8.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
791
diff
changeset
|
410 | self.dirHistory[:30]) |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
411 | |
489
844a0a278269
Fixed an issue in the find in files dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
476
diff
changeset
|
412 | # set the button states |
844a0a278269
Fixed an issue in the find in files dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
476
diff
changeset
|
413 | self.stopButton.setEnabled(True) |
844a0a278269
Fixed an issue in the find in files dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
476
diff
changeset
|
414 | self.stopButton.setDefault(True) |
844a0a278269
Fixed an issue in the find in files dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
476
diff
changeset
|
415 | self.findButton.setEnabled(False) |
844a0a278269
Fixed an issue in the find in files dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
476
diff
changeset
|
416 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
417 | # now go through all the files |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
418 | self.__populating = True |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
419 | self.findList.setUpdatesEnabled(False) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
420 | progress = 0 |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
421 | breakSearch = False |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
422 | for file in files: |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
423 | self.__lastFileItem = None |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
424 | if self.__cancelSearch or breakSearch: |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
425 | break |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
426 | |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
427 | self.findProgressLabel.setPath(file) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
428 | |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
429 | if self.projectButton.isChecked(): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
430 | fn = os.path.join(self.project.ppath, file) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
431 | else: |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
432 | fn = file |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
433 | # read the file and split it into textlines |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
434 | try: |
682
91114a975eda
Added a check to the find and replace dialog to make sure, that no external changes were done between the find run and the replace run.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
654
diff
changeset
|
435 | text, encoding, hash = Utilities.readEncodedFileWithHash(fn) |
855
d8c4113a9274
Fixed an issue of the find/replace in file dialog where a replace would change the eol as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
846
diff
changeset
|
436 | lines = text.splitlines(True) |
45
9a18f4dbb493
Did a lot of encoding related stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
42
diff
changeset
|
437 | except (UnicodeError, IOError): |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
438 | progress += 1 |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
439 | self.findProgress.setValue(progress) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
440 | continue |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
441 | |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
442 | # now perform the search and display the lines found |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
443 | count = 0 |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
444 | for line in lines: |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
445 | if self.__cancelSearch: |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
446 | break |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
447 | |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
448 | count += 1 |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
449 | contains = search.search(line) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
450 | if contains: |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
451 | start = contains.start() |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
452 | end = contains.end() |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
453 | if self.__replaceMode: |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
454 | rline = search.sub(replTxt, line) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
455 | else: |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
456 | rline = "" |
855
d8c4113a9274
Fixed an issue of the find/replace in file dialog where a replace would change the eol as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
846
diff
changeset
|
457 | line = self.__stripEol(line) |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
458 | if len(line) > 1024: |
432
497e188ee86e
Did some more string format conversions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
293
diff
changeset
|
459 | line = "{0} ...".format(line[:1024]) |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
460 | if self.__replaceMode: |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
461 | if len(rline) > 1024: |
432
497e188ee86e
Did some more string format conversions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
293
diff
changeset
|
462 | rline = "{0} ...".format(line[:1024]) |
855
d8c4113a9274
Fixed an issue of the find/replace in file dialog where a replace would change the eol as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
846
diff
changeset
|
463 | line = "- {0}\n+ {1}".format( |
d8c4113a9274
Fixed an issue of the find/replace in file dialog where a replace would change the eol as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
846
diff
changeset
|
464 | line, self.__stripEol(rline)) |
945
8cd4d08fa9f6
Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
894
diff
changeset
|
465 | self.__createItem(file, count, line, start, end, |
846
869c200be26e
Fixed an omission in the find and replace dialog and formatted it according PEP 8.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
791
diff
changeset
|
466 | rline, hash) |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
467 | |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
468 | if self.feelLikeCheckBox.isChecked(): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
469 | fn = os.path.join(self.project.ppath, file) |
476
121633976eca
Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
458
diff
changeset
|
470 | self.sourceFile.emit(fn, count, "", start, end) |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
471 | QApplication.processEvents() |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
472 | breakSearch = True |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
473 | break |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
474 | |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
475 | QApplication.processEvents() |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
476 | |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
477 | progress += 1 |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
478 | self.findProgress.setValue(progress) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
479 | |
42
23b45a742e17
Fixed a bunch of issues including a workaround for a bug in the Python email package (s. EmailDialog.py).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
13
diff
changeset
|
480 | if not files: |
23b45a742e17
Fixed a bunch of issues including a workaround for a bug in the Python email package (s. EmailDialog.py).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
13
diff
changeset
|
481 | self.findProgress.setMaximum(1) |
23b45a742e17
Fixed a bunch of issues including a workaround for a bug in the Python email package (s. EmailDialog.py).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
13
diff
changeset
|
482 | self.findProgress.setValue(1) |
23b45a742e17
Fixed a bunch of issues including a workaround for a bug in the Python email package (s. EmailDialog.py).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
13
diff
changeset
|
483 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
484 | self.findProgressLabel.setPath("") |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
485 | |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
486 | self.findList.setUpdatesEnabled(True) |
945
8cd4d08fa9f6
Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
894
diff
changeset
|
487 | self.findList.sortItems(self.findList.sortColumn(), |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
488 | self.findList.header().sortIndicatorOrder()) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
489 | self.findList.resizeColumnToContents(1) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
490 | if self.__replaceMode: |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
491 | self.findList.header().resizeSection(0, self.__section0Size + 30) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
492 | self.findList.header().setStretchLastSection(True) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
493 | self.__populating = False |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
494 | |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
495 | self.stopButton.setEnabled(False) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
496 | self.findButton.setEnabled(True) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
497 | self.findButton.setDefault(True) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
498 | |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
499 | if breakSearch: |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
500 | self.close() |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
501 | |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
502 | def on_findList_itemDoubleClicked(self, itm, column): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
503 | """ |
945
8cd4d08fa9f6
Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
894
diff
changeset
|
504 | Private slot to handle the double click on a file item. |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
505 | |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
506 | It emits the signal |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
507 | sourceFile or designerFile depending on the file extension. |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
508 | |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
509 | @param itm the double clicked tree item (QTreeWidgetItem) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
510 | @param column column that was double clicked (integer) (ignored) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
511 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
512 | if itm.parent(): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
513 | file = itm.parent().text(0) |
7
c679fb30c8f3
Change code dealing with QVariant (and QSettings) to use the PyQt4 QVariant v2 API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6
diff
changeset
|
514 | line = itm.data(0, self.lineRole) |
c679fb30c8f3
Change code dealing with QVariant (and QSettings) to use the PyQt4 QVariant v2 API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6
diff
changeset
|
515 | start = itm.data(0, self.startRole) |
c679fb30c8f3
Change code dealing with QVariant (and QSettings) to use the PyQt4 QVariant v2 API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6
diff
changeset
|
516 | end = itm.data(0, self.endRole) |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
517 | else: |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
518 | file = itm.text(0) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
519 | line = 1 |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
520 | start = 0 |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
521 | end = 0 |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
522 | |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
523 | if self.project: |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
524 | fn = os.path.join(self.project.ppath, file) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
525 | else: |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
526 | fn = file |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
527 | if fn.endswith('.ui'): |
500
c3abc7895a01
Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
489
diff
changeset
|
528 | self.designerFile.emit(fn) |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
529 | else: |
476
121633976eca
Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
458
diff
changeset
|
530 | self.sourceFile.emit(fn, line, "", start, end) |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
531 | |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
532 | @pyqtSlot() |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
533 | def on_dirSelectButton_clicked(self): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
534 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
535 | Private slot to display a directory selection dialog. |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
536 | """ |
882
34b86be88bf0
Redid the native file dialog code to be future proof.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
880
diff
changeset
|
537 | directory = E5FileDialog.getExistingDirectory( |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
538 | self, |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
539 | self.trUtf8("Select directory"), |
268
f6f53503b8d6
Changed the Find in Files dialog to remember the history of the search string, replace string and the search directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
248
diff
changeset
|
540 | self.dirCombo.currentText(), |
882
34b86be88bf0
Redid the native file dialog code to be future proof.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
880
diff
changeset
|
541 | E5FileDialog.Options(E5FileDialog.ShowDirsOnly)) |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
542 | |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
543 | if directory: |
268
f6f53503b8d6
Changed the Find in Files dialog to remember the history of the search string, replace string and the search directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
248
diff
changeset
|
544 | self.dirCombo.setEditText(Utilities.toNativeSeparators(directory)) |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
545 | |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
546 | def __getFileList(self, path, filterRe): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
547 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
548 | Private method to get a list of files to search. |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
549 | |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
550 | @param path the root directory to search in (string) |
846
869c200be26e
Fixed an omission in the find and replace dialog and formatted it according PEP 8.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
791
diff
changeset
|
551 | @param filterRe regular expression defining the filter |
869c200be26e
Fixed an omission in the find and replace dialog and formatted it according PEP 8.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
791
diff
changeset
|
552 | criteria (regexp object) |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
553 | @return list of files to be processed (list of strings) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
554 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
555 | path = os.path.abspath(path) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
556 | files = [] |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
557 | for dirname, _, names in os.walk(path): |
3034
7ce719013078
Fixed various coding style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3030
diff
changeset
|
558 | files.extend([os.path.join(dirname, f) |
7ce719013078
Fixed various coding style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3030
diff
changeset
|
559 | for f in names |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
560 | if re.match(filterRe, f)] |
3039
8dd0165d805d
Fixed a bunch of indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3034
diff
changeset
|
561 | ) |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
562 | return files |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
563 | |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
564 | def setSearchDirectory(self, searchDir): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
565 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
566 | Public slot to set the name of the directory to search in. |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
567 | |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
568 | @param searchDir name of the directory to search in (string) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
569 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
570 | self.dirButton.setChecked(True) |
268
f6f53503b8d6
Changed the Find in Files dialog to remember the history of the search string, replace string and the search directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
248
diff
changeset
|
571 | self.dirCombo.setEditText(Utilities.toNativeSeparators(searchDir)) |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
572 | |
2214
4ce1ebcc3806
Added actions to open the find in files and replace in files dialogs in a mode that searches open files only.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1640
diff
changeset
|
573 | def setOpenFiles(self): |
4ce1ebcc3806
Added actions to open the find in files and replace in files dialogs in a mode that searches open files only.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1640
diff
changeset
|
574 | """ |
4ce1ebcc3806
Added actions to open the find in files and replace in files dialogs in a mode that searches open files only.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1640
diff
changeset
|
575 | Public slot to set the mode to search in open files. |
4ce1ebcc3806
Added actions to open the find in files and replace in files dialogs in a mode that searches open files only.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1640
diff
changeset
|
576 | """ |
4ce1ebcc3806
Added actions to open the find in files and replace in files dialogs in a mode that searches open files only.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1640
diff
changeset
|
577 | self.openFilesButton.setChecked(True) |
4ce1ebcc3806
Added actions to open the find in files and replace in files dialogs in a mode that searches open files only.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1640
diff
changeset
|
578 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
579 | @pyqtSlot() |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
580 | def on_replaceButton_clicked(self): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
581 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
582 | Private slot to perform the requested replace actions. |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
583 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
584 | self.findProgress.setMaximum(self.findList.topLevelItemCount()) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
585 | self.findProgress.setValue(0) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
586 | |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
587 | progress = 0 |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
588 | for index in range(self.findList.topLevelItemCount()): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
589 | itm = self.findList.topLevelItem(index) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
590 | if itm.checkState(0) in [Qt.PartiallyChecked, Qt.Checked]: |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
591 | file = itm.text(0) |
682
91114a975eda
Added a check to the find and replace dialog to make sure, that no external changes were done between the find run and the replace run.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
654
diff
changeset
|
592 | origHash = itm.data(0, self.md5Role) |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
593 | |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
594 | self.findProgressLabel.setPath(file) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
595 | |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
596 | if self.projectButton.isChecked(): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
597 | fn = os.path.join(self.project.ppath, file) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
598 | else: |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
599 | fn = file |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
600 | |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
601 | # read the file and split it into textlines |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
602 | try: |
846
869c200be26e
Fixed an omission in the find and replace dialog and formatted it according PEP 8.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
791
diff
changeset
|
603 | text, encoding, hash = \ |
869c200be26e
Fixed an omission in the find and replace dialog and formatted it according PEP 8.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
791
diff
changeset
|
604 | Utilities.readEncodedFileWithHash(fn) |
855
d8c4113a9274
Fixed an issue of the find/replace in file dialog where a replace would change the eol as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
846
diff
changeset
|
605 | lines = text.splitlines(True) |
1112
8a7d1b9d18db
Improved code quality by getting rid of star imports. That way pyflakes can do its job. A few bugs fixed found by flakes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
606 | except (UnicodeError, IOError) as err: |
3020
542e97d4ecb3
Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3012
diff
changeset
|
607 | E5MessageBox.critical( |
542e97d4ecb3
Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3012
diff
changeset
|
608 | self, |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
609 | self.trUtf8("Replace in Files"), |
846
869c200be26e
Fixed an omission in the find and replace dialog and formatted it according PEP 8.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
791
diff
changeset
|
610 | self.trUtf8( |
869c200be26e
Fixed an omission in the find and replace dialog and formatted it according PEP 8.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
791
diff
changeset
|
611 | """<p>Could not read the file <b>{0}</b>.""" |
3034
7ce719013078
Fixed various coding style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3030
diff
changeset
|
612 | """ Skipping it.</p><p>Reason: {1}</p>""") |
3039
8dd0165d805d
Fixed a bunch of indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3034
diff
changeset
|
613 | .format(fn, str(err)) |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
614 | ) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
615 | progress += 1 |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
616 | self.findProgress.setValue(progress) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
617 | continue |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
618 | |
682
91114a975eda
Added a check to the find and replace dialog to make sure, that no external changes were done between the find run and the replace run.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
654
diff
changeset
|
619 | # Check the original and the current hash. Skip the file, |
91114a975eda
Added a check to the find and replace dialog to make sure, that no external changes were done between the find run and the replace run.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
654
diff
changeset
|
620 | # if hashes are different. |
91114a975eda
Added a check to the find and replace dialog to make sure, that no external changes were done between the find run and the replace run.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
654
diff
changeset
|
621 | if origHash != hash: |
3020
542e97d4ecb3
Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3012
diff
changeset
|
622 | E5MessageBox.critical( |
542e97d4ecb3
Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3012
diff
changeset
|
623 | self, |
682
91114a975eda
Added a check to the find and replace dialog to make sure, that no external changes were done between the find run and the replace run.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
654
diff
changeset
|
624 | self.trUtf8("Replace in Files"), |
846
869c200be26e
Fixed an omission in the find and replace dialog and formatted it according PEP 8.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
791
diff
changeset
|
625 | self.trUtf8( |
869c200be26e
Fixed an omission in the find and replace dialog and formatted it according PEP 8.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
791
diff
changeset
|
626 | """<p>The current and the original hash of the""" |
869c200be26e
Fixed an omission in the find and replace dialog and formatted it according PEP 8.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
791
diff
changeset
|
627 | """ file <b>{0}</b> are different. Skipping it.""" |
3034
7ce719013078
Fixed various coding style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3030
diff
changeset
|
628 | """</p><p>Hash 1: {1}</p><p>Hash 2: {2}</p>""") |
3039
8dd0165d805d
Fixed a bunch of indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3034
diff
changeset
|
629 | .format(fn, origHash, hash) |
682
91114a975eda
Added a check to the find and replace dialog to make sure, that no external changes were done between the find run and the replace run.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
654
diff
changeset
|
630 | ) |
91114a975eda
Added a check to the find and replace dialog to make sure, that no external changes were done between the find run and the replace run.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
654
diff
changeset
|
631 | progress += 1 |
91114a975eda
Added a check to the find and replace dialog to make sure, that no external changes were done between the find run and the replace run.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
654
diff
changeset
|
632 | self.findProgress.setValue(progress) |
91114a975eda
Added a check to the find and replace dialog to make sure, that no external changes were done between the find run and the replace run.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
654
diff
changeset
|
633 | continue |
91114a975eda
Added a check to the find and replace dialog to make sure, that no external changes were done between the find run and the replace run.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
654
diff
changeset
|
634 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
635 | # replace the lines authorized by the user |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
636 | for cindex in range(itm.childCount()): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
637 | citm = itm.child(cindex) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
638 | if citm.checkState(0) == Qt.Checked: |
7
c679fb30c8f3
Change code dealing with QVariant (and QSettings) to use the PyQt4 QVariant v2 API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6
diff
changeset
|
639 | line = citm.data(0, self.lineRole) |
c679fb30c8f3
Change code dealing with QVariant (and QSettings) to use the PyQt4 QVariant v2 API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6
diff
changeset
|
640 | rline = citm.data(0, self.replaceRole) |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
641 | lines[line - 1] = rline |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
642 | |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
643 | # write the file |
855
d8c4113a9274
Fixed an issue of the find/replace in file dialog where a replace would change the eol as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
846
diff
changeset
|
644 | txt = "".join(lines) |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
645 | try: |
45
9a18f4dbb493
Did a lot of encoding related stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
42
diff
changeset
|
646 | Utilities.writeEncodedFile(fn, txt, encoding) |
9a18f4dbb493
Did a lot of encoding related stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
42
diff
changeset
|
647 | except (IOError, Utilities.CodingError, UnicodeError) as err: |
3020
542e97d4ecb3
Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3012
diff
changeset
|
648 | E5MessageBox.critical( |
542e97d4ecb3
Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3012
diff
changeset
|
649 | self, |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
650 | self.trUtf8("Replace in Files"), |
846
869c200be26e
Fixed an omission in the find and replace dialog and formatted it according PEP 8.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
791
diff
changeset
|
651 | self.trUtf8( |
869c200be26e
Fixed an omission in the find and replace dialog and formatted it according PEP 8.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
791
diff
changeset
|
652 | """<p>Could not save the file <b>{0}</b>.""" |
3034
7ce719013078
Fixed various coding style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3030
diff
changeset
|
653 | """ Skipping it.</p><p>Reason: {1}</p>""") |
3039
8dd0165d805d
Fixed a bunch of indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3034
diff
changeset
|
654 | .format(fn, str(err)) |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
655 | ) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
656 | |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
657 | progress += 1 |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
658 | self.findProgress.setValue(progress) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
659 | |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
660 | self.findProgressLabel.setPath("") |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
661 | |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
662 | self.findList.clear() |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
663 | self.replaceButton.setEnabled(False) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
664 | self.findButton.setEnabled(True) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
665 | self.findButton.setDefault(True) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
666 | |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
667 | def __contextMenuRequested(self, pos): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
668 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
669 | Private slot to handle the context menu request. |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
670 | |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
671 | @param pos position the context menu shall be shown (QPoint) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
672 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
673 | menu = QMenu(self) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
674 | |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
675 | menu.addAction(self.trUtf8("Open"), self.__openFile) |
945
8cd4d08fa9f6
Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
894
diff
changeset
|
676 | menu.addAction(self.trUtf8("Copy Path to Clipboard"), |
846
869c200be26e
Fixed an omission in the find and replace dialog and formatted it according PEP 8.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
791
diff
changeset
|
677 | self.__copyToClipboard) |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
678 | |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
679 | menu.exec_(QCursor.pos()) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
680 | |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
681 | def __openFile(self): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
682 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
683 | Private slot to open the currently selected entry. |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
684 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
685 | itm = self.findList.selectedItems()[0] |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
686 | self.on_findList_itemDoubleClicked(itm, 0) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
687 | |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
688 | def __copyToClipboard(self): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
689 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
690 | Private method to copy the path of an entry to the clipboard. |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
691 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
692 | itm = self.findList.selectedItems()[0] |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
693 | if itm.parent(): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
694 | fn = itm.parent().text(0) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
695 | else: |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
696 | fn = itm.text(0) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
697 | |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
698 | cb = QApplication.clipboard() |
654
72d4c6f31157
Fixed an issue in the FindFileDialog class replacing text.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
564
diff
changeset
|
699 | cb.setText(fn) |