224 self.__texteditType = editType |
224 self.__texteditType = editType |
225 |
225 |
226 self.wordCheckBox.setVisible(editType in ( |
226 self.wordCheckBox.setVisible(editType in ( |
227 EricTextEditType.QTEXTEDIT, EricTextEditType.QTEXTBROWSER |
227 EricTextEditType.QTEXTEDIT, EricTextEditType.QTEXTBROWSER |
228 )) |
228 )) |
|
229 self.infoLabel.setVisible(editType == EricTextEditType.QWEBENGINEVIEW) |
229 if editType == EricTextEditType.QWEBENGINEVIEW: |
230 if editType == EricTextEditType.QWEBENGINEVIEW: |
230 self.__textedit.page().findTextFinished.connect( |
231 self.__textedit.page().findTextFinished.connect( |
231 self.__findTextFinished) |
232 self.__findTextFinished) |
232 |
233 |
233 def detachTextEdit(self): |
234 def detachTextEdit(self): |
304 @param txt text of the combobox |
305 @param txt text of the combobox |
305 @type str |
306 @type str |
306 """ |
307 """ |
307 self.__setSearchButtons(txt != "") |
308 self.__setSearchButtons(txt != "") |
308 |
309 |
309 self.infoLabel.hide() |
310 if self.__texteditType == EricTextEditType.QWEBENGINEVIEW: |
|
311 self.infoLabel.clear() |
|
312 else: |
|
313 self.infoLabel.hide() |
310 self.__setFindtextComboBackground(False) |
314 self.__setFindtextComboBackground(False) |
311 |
315 |
312 def __setSearchButtons(self, enabled): |
316 def __setSearchButtons(self, enabled): |
313 """ |
317 """ |
314 Private slot to set the state of the search buttons. |
318 Private slot to set the state of the search buttons. |
363 """ |
367 """ |
364 if not self.__textedit: |
368 if not self.__textedit: |
365 return |
369 return |
366 |
370 |
367 self.infoLabel.clear() |
371 self.infoLabel.clear() |
368 self.infoLabel.hide() |
372 if self.__texteditType != EricTextEditType.QWEBENGINEVIEW: |
|
373 self.infoLabel.hide() |
369 self.__setFindtextComboBackground(False) |
374 self.__setFindtextComboBackground(False) |
370 |
375 |
371 txt = self.findtextCombo.currentText() |
376 txt = self.findtextCombo.currentText() |
372 if not txt: |
377 if not txt: |
373 return |
378 return |
382 self.findtextCombo.addItems(self.findHistory) |
387 self.findtextCombo.addItems(self.findHistory) |
383 |
388 |
384 if self.__texteditType in ( |
389 if self.__texteditType in ( |
385 EricTextEditType.QTEXTBROWSER, EricTextEditType.QTEXTEDIT |
390 EricTextEditType.QTEXTBROWSER, EricTextEditType.QTEXTEDIT |
386 ): |
391 ): |
387 ok = self.__findPrevNextQTextEdit(backwards) |
392 self.__findPrevNextQTextEdit(backwards) |
388 self.__findNextPrevCallback(ok) |
|
389 elif self.__texteditType == EricTextEditType.QWEBENGINEVIEW: |
393 elif self.__texteditType == EricTextEditType.QWEBENGINEVIEW: |
390 self.__findPrevNextQWebEngineView(backwards) |
394 self.__findPrevNextQWebEngineView(backwards) |
391 |
395 |
392 def __findPrevNextQTextEdit(self, backwards): |
396 def __findPrevNextQTextEdit(self, backwards): |
393 """ |
397 """ |
421 # move to start of document |
425 # move to start of document |
422 cursor.movePosition(moveOp) |
426 cursor.movePosition(moveOp) |
423 self.__textedit.setTextCursor(cursor) |
427 self.__textedit.setTextCursor(cursor) |
424 ok = self.__textedit.find(self.findtextCombo.currentText(), flags) |
428 ok = self.__textedit.find(self.findtextCombo.currentText(), flags) |
425 |
429 |
426 return ok |
430 if not ok: |
|
431 self.infoLabel.setText( |
|
432 self.tr("'{0}' was not found.").format( |
|
433 self.findtextCombo.currentText()) |
|
434 ) |
|
435 self.infoLabel.show() |
|
436 self.__setFindtextComboBackground(True) |
427 |
437 |
428 def __findPrevNextQWebEngineView(self, backwards): |
438 def __findPrevNextQWebEngineView(self, backwards): |
429 """ |
439 """ |
430 Private method to to search the associated edit widget of |
440 Private method to to search the associated edit widget of |
431 type QWebEngineView. |
441 type QWebEngineView. |
438 findFlags = QWebEnginePage.FindFlag(0) |
448 findFlags = QWebEnginePage.FindFlag(0) |
439 if self.caseCheckBox.isChecked(): |
449 if self.caseCheckBox.isChecked(): |
440 findFlags |= QWebEnginePage.FindFlag.FindCaseSensitively |
450 findFlags |= QWebEnginePage.FindFlag.FindCaseSensitively |
441 if backwards: |
451 if backwards: |
442 findFlags |= QWebEnginePage.FindFlag.FindBackward |
452 findFlags |= QWebEnginePage.FindFlag.FindBackward |
443 self.__textedit.findText(self.findtextCombo.currentText(), |
453 self.__textedit.findText(self.findtextCombo.currentText(), findFlags) |
444 findFlags, self.__findNextPrevCallback) |
|
445 |
|
446 def __findNextPrevCallback(self, found): |
|
447 """ |
|
448 Private method to process the result of the last search. |
|
449 |
|
450 @param found flag indicating if the last search succeeded |
|
451 @type bool |
|
452 """ |
|
453 if not found: |
|
454 txt = self.findtextCombo.currentText() |
|
455 self.infoLabel.setText( |
|
456 self.tr("'{0}' was not found.").format(txt)) |
|
457 self.infoLabel.show() |
|
458 self.__setFindtextComboBackground(True) |
|
459 |
454 |
460 def __setFindtextComboBackground(self, error): |
455 def __setFindtextComboBackground(self, error): |
461 """ |
456 """ |
462 Private slot to change the findtext combo background to indicate |
457 Private slot to change the findtext combo background to indicate |
463 errors. |
458 errors. |
482 |
477 |
483 @param result reference to the QWebEngineFindTextResult object of the |
478 @param result reference to the QWebEngineFindTextResult object of the |
484 last search |
479 last search |
485 @type QWebEngineFindTextResult |
480 @type QWebEngineFindTextResult |
486 """ |
481 """ |
487 self.infoLabel.setText(self.tr("Match {0} of {1}").format( |
482 if result.numberOfMatches() == 0: |
488 result.activeMatch(), result.numberOfMatches()) |
483 self.infoLabel.setText( |
489 ) |
484 self.tr("'{0}' was not found.").format( |
490 self.infoLabel.show() |
485 self.findtextCombo.currentText()) |
|
486 ) |
|
487 self.__setFindtextComboBackground(True) |
|
488 else: |
|
489 self.infoLabel.setText(self.tr("Match {0} of {1}").format( |
|
490 result.activeMatch(), result.numberOfMatches()) |
|
491 ) |
491 |
492 |
492 def showInfo(self, info): |
493 def showInfo(self, info): |
493 """ |
494 """ |
494 Public method to show some information in the info label. |
495 Public method to show some information in the info label. |
495 |
496 |