QScintilla/SearchReplaceWidget.py

changeset 3190
a9a94491c4fd
parent 3160
209a07d7e401
child 3345
071afe8be2a1
equal deleted inserted replaced
3189:9a21c547de5f 3190:a9a94491c4fd
50 self.findHistory = vm.getSRHistory('search') 50 self.findHistory = vm.getSRHistory('search')
51 if replace: 51 if replace:
52 from .Ui_ReplaceWidget import Ui_ReplaceWidget 52 from .Ui_ReplaceWidget import Ui_ReplaceWidget
53 self.replaceHistory = vm.getSRHistory('replace') 53 self.replaceHistory = vm.getSRHistory('replace')
54 self.ui = Ui_ReplaceWidget() 54 self.ui = Ui_ReplaceWidget()
55 whatsThis = self.trUtf8( 55 whatsThis = self.tr(
56 r"""<b>Find and Replace</b> 56 r"""<b>Find and Replace</b>
57 <p>This dialog is used to find some text and replace it with another text. 57 <p>This dialog is used to find some text and replace it with another text.
58 By checking the various checkboxes, the search can be made more specific. 58 By checking the various checkboxes, the search can be made more specific.
59 The search string might be a regular expression. In a regular expression, 59 The search string might be a regular expression. In a regular expression,
60 special characters interpreted are:</p> 60 special characters interpreted are:</p>
61 """ 61 """
62 ) 62 )
63 else: 63 else:
64 from .Ui_SearchWidget import Ui_SearchWidget 64 from .Ui_SearchWidget import Ui_SearchWidget
65 self.ui = Ui_SearchWidget() 65 self.ui = Ui_SearchWidget()
66 whatsThis = self.trUtf8( 66 whatsThis = self.tr(
67 r"""<b>Find</b> 67 r"""<b>Find</b>
68 <p>This dialog is used to find some text. By checking the various checkboxes, 68 <p>This dialog is used to find some text. By checking the various checkboxes,
69 the search can be made more specific. The search string might be a regular 69 the search can be made more specific. The search string might be a regular
70 expression. In a regular expression, special characters interpreted are:</p> 70 expression. In a regular expression, special characters interpreted are:</p>
71 """ 71 """
72 ) 72 )
73 self.ui.setupUi(self) 73 self.ui.setupUi(self)
74 if not replace: 74 if not replace:
75 self.ui.wrapCheckBox.setChecked(True) 75 self.ui.wrapCheckBox.setChecked(True)
76 76
77 whatsThis += self.trUtf8( 77 whatsThis += self.tr(
78 r"""<table border="0"> 78 r"""<table border="0">
79 <tr><td><code>.</code></td><td>Matches any character</td></tr> 79 <tr><td><code>.</code></td><td>Matches any character</td></tr>
80 <tr><td><code>\(</code></td><td>This marks the start of a region for tagging a 80 <tr><td><code>\(</code></td><td>This marks the start of a region for tagging a
81 match.</td></tr> 81 match.</td></tr>
82 <tr><td><code>\)</code></td><td>This marks the end of a tagged region. 82 <tr><td><code>\)</code></td><td>This marks the end of a tagged region.
138 if replace: 138 if replace:
139 self.ui.replacetextCombo.lineEdit().returnPressed.connect( 139 self.ui.replacetextCombo.lineEdit().returnPressed.connect(
140 self.on_replaceButton_clicked) 140 self.on_replaceButton_clicked)
141 141
142 self.findNextAct = E5Action( 142 self.findNextAct = E5Action(
143 self.trUtf8('Find Next'), 143 self.tr('Find Next'),
144 self.trUtf8('Find Next'), 144 self.tr('Find Next'),
145 0, 0, self, 'search_widget_find_next') 145 0, 0, self, 'search_widget_find_next')
146 self.findNextAct.triggered[()].connect(self.on_findNextButton_clicked) 146 self.findNextAct.triggered[()].connect(self.on_findNextButton_clicked)
147 self.findNextAct.setEnabled(False) 147 self.findNextAct.setEnabled(False)
148 self.ui.findtextCombo.addAction(self.findNextAct) 148 self.ui.findtextCombo.addAction(self.findNextAct)
149 149
150 self.findPrevAct = E5Action( 150 self.findPrevAct = E5Action(
151 self.trUtf8('Find Prev'), 151 self.tr('Find Prev'),
152 self.trUtf8('Find Prev'), 152 self.tr('Find Prev'),
153 0, 0, self, 'search_widget_find_prev') 153 0, 0, self, 'search_widget_find_prev')
154 self.findPrevAct.triggered[()].connect(self.on_findPrevButton_clicked) 154 self.findPrevAct.triggered[()].connect(self.on_findPrevButton_clicked)
155 self.findPrevAct.setEnabled(False) 155 self.findPrevAct.setEnabled(False)
156 self.ui.findtextCombo.addAction(self.findPrevAct) 156 self.ui.findtextCombo.addAction(self.findPrevAct)
157 157
243 self.ui.replaceButton.setEnabled(True) 243 self.ui.replaceButton.setEnabled(True)
244 self.ui.replaceSearchButton.setEnabled(True) 244 self.ui.replaceSearchButton.setEnabled(True)
245 else: 245 else:
246 E5MessageBox.information( 246 E5MessageBox.information(
247 self, self.windowTitle(), 247 self, self.windowTitle(),
248 self.trUtf8("'{0}' was not found.").format(txt)) 248 self.tr("'{0}' was not found.").format(txt))
249 249
250 @pyqtSlot() 250 @pyqtSlot()
251 def on_findPrevButton_clicked(self): 251 def on_findPrevButton_clicked(self):
252 """ 252 """
253 Private slot to find the previous occurrence of text. 253 Private slot to find the previous occurrence of text.
280 self.ui.replaceButton.setEnabled(True) 280 self.ui.replaceButton.setEnabled(True)
281 self.ui.replaceSearchButton.setEnabled(True) 281 self.ui.replaceSearchButton.setEnabled(True)
282 else: 282 else:
283 E5MessageBox.information( 283 E5MessageBox.information(
284 self, self.windowTitle(), 284 self, self.windowTitle(),
285 self.trUtf8("'{0}' was not found.").format(txt)) 285 self.tr("'{0}' was not found.").format(txt))
286 286
287 def __findByReturnPressed(self): 287 def __findByReturnPressed(self):
288 """ 288 """
289 Private slot to handle the returnPressed signal of the findtext 289 Private slot to handle the returnPressed signal of the findtext
290 combobox. 290 combobox.
640 if not ok: 640 if not ok:
641 self.ui.replaceButton.setEnabled(False) 641 self.ui.replaceButton.setEnabled(False)
642 self.ui.replaceSearchButton.setEnabled(False) 642 self.ui.replaceSearchButton.setEnabled(False)
643 E5MessageBox.information( 643 E5MessageBox.information(
644 self, self.windowTitle(), 644 self, self.windowTitle(),
645 self.trUtf8("'{0}' was not found.").format(ftxt)) 645 self.tr("'{0}' was not found.").format(ftxt))
646 else: 646 else:
647 self.ui.replaceButton.setEnabled(False) 647 self.ui.replaceButton.setEnabled(False)
648 self.ui.replaceSearchButton.setEnabled(False) 648 self.ui.replaceSearchButton.setEnabled(False)
649 649
650 self.__finding = False 650 self.__finding = False
762 self.ui.replaceSearchButton.setEnabled(False) 762 self.ui.replaceSearchButton.setEnabled(False)
763 763
764 if found: 764 if found:
765 E5MessageBox.information( 765 E5MessageBox.information(
766 self, self.windowTitle(), 766 self, self.windowTitle(),
767 self.trUtf8("Replaced {0} occurrences.") 767 self.tr("Replaced {0} occurrences.")
768 .format(replacements)) 768 .format(replacements))
769 else: 769 else:
770 E5MessageBox.information( 770 E5MessageBox.information(
771 self, self.windowTitle(), 771 self, self.windowTitle(),
772 self.trUtf8("Nothing replaced because '{0}' was not found.") 772 self.tr("Nothing replaced because '{0}' was not found.")
773 .format(ftxt)) 773 .format(ftxt))
774 774
775 aw.setCursorPosition(cline, cindex) 775 aw.setCursorPosition(cline, cindex)
776 aw.ensureCursorVisible() 776 aw.ensureCursorVisible()
777 777

eric ide

mercurial