52 self.findHistory = vm.getSRHistory('search') |
52 self.findHistory = vm.getSRHistory('search') |
53 if replace: |
53 if replace: |
54 from .Ui_ReplaceWidget import Ui_ReplaceWidget |
54 from .Ui_ReplaceWidget import Ui_ReplaceWidget |
55 self.replaceHistory = vm.getSRHistory('replace') |
55 self.replaceHistory = vm.getSRHistory('replace') |
56 self.ui = Ui_ReplaceWidget() |
56 self.ui = Ui_ReplaceWidget() |
57 whatsThis = self.trUtf8( |
57 whatsThis = self.tr( |
58 r"""<b>Find and Replace</b> |
58 r"""<b>Find and Replace</b> |
59 <p>This dialog is used to find some text and replace it with another text. |
59 <p>This dialog is used to find some text and replace it with another text. |
60 By checking the various checkboxes, the search can be made more specific. |
60 By checking the various checkboxes, the search can be made more specific. |
61 The search string might be a regular expression. In a regular expression, |
61 The search string might be a regular expression. In a regular expression, |
62 special characters interpreted are:</p> |
62 special characters interpreted are:</p> |
63 """ |
63 """ |
64 ) |
64 ) |
65 else: |
65 else: |
66 from .Ui_SearchWidget import Ui_SearchWidget |
66 from .Ui_SearchWidget import Ui_SearchWidget |
67 self.ui = Ui_SearchWidget() |
67 self.ui = Ui_SearchWidget() |
68 whatsThis = self.trUtf8( |
68 whatsThis = self.tr( |
69 r"""<b>Find</b> |
69 r"""<b>Find</b> |
70 <p>This dialog is used to find some text. By checking the various checkboxes, |
70 <p>This dialog is used to find some text. By checking the various checkboxes, |
71 the search can be made more specific. The search string might be a regular |
71 the search can be made more specific. The search string might be a regular |
72 expression. In a regular expression, special characters interpreted are:</p> |
72 expression. In a regular expression, special characters interpreted are:</p> |
73 """ |
73 """ |
74 ) |
74 ) |
75 self.ui.setupUi(self) |
75 self.ui.setupUi(self) |
76 if not replace: |
76 if not replace: |
77 self.ui.wrapCheckBox.setChecked(True) |
77 self.ui.wrapCheckBox.setChecked(True) |
78 |
78 |
79 whatsThis += self.trUtf8( |
79 whatsThis += self.tr( |
80 r"""<table border="0"> |
80 r"""<table border="0"> |
81 <tr><td><code>.</code></td><td>Matches any character</td></tr> |
81 <tr><td><code>.</code></td><td>Matches any character</td></tr> |
82 <tr><td><code>\(</code></td><td>This marks the start of a region for tagging a |
82 <tr><td><code>\(</code></td><td>This marks the start of a region for tagging a |
83 match.</td></tr> |
83 match.</td></tr> |
84 <tr><td><code>\)</code></td><td>This marks the end of a tagged region. |
84 <tr><td><code>\)</code></td><td>This marks the end of a tagged region. |
140 if replace: |
140 if replace: |
141 self.ui.replacetextCombo.lineEdit().returnPressed.connect( |
141 self.ui.replacetextCombo.lineEdit().returnPressed.connect( |
142 self.on_replaceButton_clicked) |
142 self.on_replaceButton_clicked) |
143 |
143 |
144 self.findNextAct = E5Action( |
144 self.findNextAct = E5Action( |
145 self.trUtf8('Find Next'), |
145 self.tr('Find Next'), |
146 self.trUtf8('Find Next'), |
146 self.tr('Find Next'), |
147 0, 0, self, 'search_widget_find_next') |
147 0, 0, self, 'search_widget_find_next') |
148 self.findNextAct.triggered[()].connect(self.on_findNextButton_clicked) |
148 self.findNextAct.triggered.connect(self.on_findNextButton_clicked) |
149 self.findNextAct.setEnabled(False) |
149 self.findNextAct.setEnabled(False) |
150 self.ui.findtextCombo.addAction(self.findNextAct) |
150 self.ui.findtextCombo.addAction(self.findNextAct) |
151 |
151 |
152 self.findPrevAct = E5Action( |
152 self.findPrevAct = E5Action( |
153 self.trUtf8('Find Prev'), |
153 self.tr('Find Prev'), |
154 self.trUtf8('Find Prev'), |
154 self.tr('Find Prev'), |
155 0, 0, self, 'search_widget_find_prev') |
155 0, 0, self, 'search_widget_find_prev') |
156 self.findPrevAct.triggered[()].connect(self.on_findPrevButton_clicked) |
156 self.findPrevAct.triggered.connect(self.on_findPrevButton_clicked) |
157 self.findPrevAct.setEnabled(False) |
157 self.findPrevAct.setEnabled(False) |
158 self.ui.findtextCombo.addAction(self.findPrevAct) |
158 self.ui.findtextCombo.addAction(self.findPrevAct) |
159 |
159 |
160 self.havefound = False |
160 self.havefound = False |
161 self.__pos = None |
161 self.__pos = None |
245 self.ui.replaceButton.setEnabled(True) |
245 self.ui.replaceButton.setEnabled(True) |
246 self.ui.replaceSearchButton.setEnabled(True) |
246 self.ui.replaceSearchButton.setEnabled(True) |
247 else: |
247 else: |
248 E5MessageBox.information( |
248 E5MessageBox.information( |
249 self, self.windowTitle(), |
249 self, self.windowTitle(), |
250 self.trUtf8("'{0}' was not found.").format(txt)) |
250 self.tr("'{0}' was not found.").format(txt)) |
251 |
251 |
252 @pyqtSlot() |
252 @pyqtSlot() |
253 def on_findPrevButton_clicked(self): |
253 def on_findPrevButton_clicked(self): |
254 """ |
254 """ |
255 Private slot to find the previous occurrence of text. |
255 Private slot to find the previous occurrence of text. |
282 self.ui.replaceButton.setEnabled(True) |
282 self.ui.replaceButton.setEnabled(True) |
283 self.ui.replaceSearchButton.setEnabled(True) |
283 self.ui.replaceSearchButton.setEnabled(True) |
284 else: |
284 else: |
285 E5MessageBox.information( |
285 E5MessageBox.information( |
286 self, self.windowTitle(), |
286 self, self.windowTitle(), |
287 self.trUtf8("'{0}' was not found.").format(txt)) |
287 self.tr("'{0}' was not found.").format(txt)) |
288 |
288 |
289 def __findByReturnPressed(self): |
289 def __findByReturnPressed(self): |
290 """ |
290 """ |
291 Private slot to handle the returnPressed signal of the findtext |
291 Private slot to handle the returnPressed signal of the findtext |
292 combobox. |
292 combobox. |
642 if not ok: |
642 if not ok: |
643 self.ui.replaceButton.setEnabled(False) |
643 self.ui.replaceButton.setEnabled(False) |
644 self.ui.replaceSearchButton.setEnabled(False) |
644 self.ui.replaceSearchButton.setEnabled(False) |
645 E5MessageBox.information( |
645 E5MessageBox.information( |
646 self, self.windowTitle(), |
646 self, self.windowTitle(), |
647 self.trUtf8("'{0}' was not found.").format(ftxt)) |
647 self.tr("'{0}' was not found.").format(ftxt)) |
648 else: |
648 else: |
649 self.ui.replaceButton.setEnabled(False) |
649 self.ui.replaceButton.setEnabled(False) |
650 self.ui.replaceSearchButton.setEnabled(False) |
650 self.ui.replaceSearchButton.setEnabled(False) |
651 |
651 |
652 self.__finding = False |
652 self.__finding = False |
764 self.ui.replaceSearchButton.setEnabled(False) |
764 self.ui.replaceSearchButton.setEnabled(False) |
765 |
765 |
766 if found: |
766 if found: |
767 E5MessageBox.information( |
767 E5MessageBox.information( |
768 self, self.windowTitle(), |
768 self, self.windowTitle(), |
769 self.trUtf8("Replaced {0} occurrences.") |
769 self.tr("Replaced {0} occurrences.") |
770 .format(replacements)) |
770 .format(replacements)) |
771 else: |
771 else: |
772 E5MessageBox.information( |
772 E5MessageBox.information( |
773 self, self.windowTitle(), |
773 self, self.windowTitle(), |
774 self.trUtf8("Nothing replaced because '{0}' was not found.") |
774 self.tr("Nothing replaced because '{0}' was not found.") |
775 .format(ftxt)) |
775 .format(ftxt)) |
776 |
776 |
777 aw.setCursorPosition(cline, cindex) |
777 aw.setCursorPosition(cline, cindex) |
778 aw.ensureCursorVisible() |
778 aw.ensureCursorVisible() |
779 |
779 |
921 |
921 |
922 self.setMaximumHeight(srHeight) |
922 self.setMaximumHeight(srHeight) |
923 |
923 |
924 self.__searchReplaceWidget.searchListChanged.connect( |
924 self.__searchReplaceWidget.searchListChanged.connect( |
925 self.searchListChanged) |
925 self.searchListChanged) |
926 self.__leftButton.clicked[()].connect(self.__slideLeft) |
926 self.__leftButton.clicked.connect(self.__slideLeft) |
927 self.__rightButton.clicked[()].connect(self.__slideRight) |
927 self.__rightButton.clicked.connect(self.__slideRight) |
928 |
928 |
929 def findNext(self): |
929 def findNext(self): |
930 """ |
930 """ |
931 Public slot to find the next occurrence of text. |
931 Public slot to find the next occurrence of text. |
932 """ |
932 """ |