Пример #1
0
    def do_current_word_changed(self):
        try:
            b = self.ignore_button
        except AttributeError:
            return
        ignored = recognized = in_user_dictionary = False
        current = self.words_view.currentIndex()
        current_word = ''
        if current.isValid():
            row = current.row()
            w = self.words_model.word_for_row(row)
            if w is not None:
                ignored = dictionaries.is_word_ignored(*w)
                recognized = self.words_model.spell_map[w]
                current_word = w[0]
                if recognized:
                    in_user_dictionary = dictionaries.word_in_user_dictionary(*w)
            suggestions = dictionaries.suggestions(*w)
            self.suggested_list.clear()
            for i, s in enumerate(suggestions):
                item = QListWidgetItem(s, self.suggested_list)
                if i == 0:
                    self.suggested_list.setCurrentItem(item)
                    self.suggested_word.setText(s)

        prefix = b.unign_text if ignored else b.ign_text
        b.setText(prefix + ' ' + current_word)
        b.setToolTip(b.unign_tt if ignored else b.ign_tt)
        b.setEnabled(current.isValid() and (ignored or not recognized))
        if not self.user_dictionaries_missing_label.isVisible():
            b = self.add_button
            b.setText(b.remove_text if in_user_dictionary else b.add_text)
            b.setToolTip(b.remove_tt if in_user_dictionary else b.add_tt)
            self.user_dictionaries.setVisible(not in_user_dictionary)
Пример #2
0
 def toggle_ignored(self, row):
     w = self.word_for_row(row)
     if w is not None:
         ignored = dictionaries.is_word_ignored(*w)
         (dictionaries.unignore_word if ignored else dictionaries.ignore_word)(*w)
         self.spell_map[w] = dictionaries.recognized(*w)
         self.update_word(w)
Пример #3
0
 def ignore_words(self, rows):
     words = {self.word_for_row(r) for r in rows}
     words.discard(None)
     for w in words:
         ignored = dictionaries.is_word_ignored(*w)
         (dictionaries.unignore_word if ignored else dictionaries.ignore_word)(*w)
         self.spell_map[w] = dictionaries.recognized(*w)
         self.update_word(w)
Пример #4
0
 def misspelled_text(self, w):
     if self.spell_map[w]:
         return _('Ignored') if dictionaries.is_word_ignored(*w) else ''
     return '✓'