Exemple #1
0
    def find(self, forwards=True):
        text = unicode(self.search_text.text()).strip()
        flags = QWebPage.FindFlags(0) if forwards else QWebPage.FindBackward
        d = self.dest_list
        if d.count() == 1:
            flags |= QWebPage.FindWrapsAroundDocument
        if not self.view.findText(text, flags) and text:
            if d.count() == 1:
                return error_dialog(self,
                                    _('No match found'),
                                    _('No match found for: %s') % text,
                                    show=True)

            delta = 1 if forwards else -1
            current = unicode(d.currentItem().data(Qt.DisplayRole).toString())
            next_index = (d.currentRow() + delta) % d.count()
            next = unicode(d.item(next_index).data(Qt.DisplayRole).toString())
            msg = '<p>' + _(
                'No matches for %(text)s found in the current file [%(current)s].'
                ' Do you want to search in the %(which)s file [%(next)s]?')
            msg = msg % dict(text=text,
                             current=current,
                             next=next,
                             which=_('next') if forwards else _('previous'))
            if question_dialog(self, _('No match found'), msg):
                self.pending_search = self.find_next if forwards else self.find_previous
                d.setCurrentRow(next_index)
Exemple #2
0
 def findMain(self, text, flags):
     viewFlags = QWebPage.FindFlags(
         flags) | QWebPage.FindWrapsAroundDocument
     if flags:
         self.notesView.findText(text, viewFlags)
         return self.notesEdit.find(text, flags)
     else:
         self.notesView.findText(text)
         return self.notesEdit.find(text)
Exemple #3
0
 def find(self, direction):
     text = unicode(self.search.text())
     self.view.findText(text, QWebPage.FindWrapsAroundDocument | (
         QWebPage.FindBackward if direction == 'prev' else QWebPage.FindFlags(0)))