def load(self, item): self.targetItem = item self.abbrListWidget.clear() if model.TriggerMode.ABBREVIATION in item.modes: for abbr in item.abbreviations: self.abbrListWidget.addItem(AbbrListItem(abbr)) self.removeButton.setEnabled(True) self.abbrListWidget.setCurrentRow(0) else: self.removeButton.setEnabled(False) self.removeTypedCheckbox.setChecked(item.backspace) self._reset_word_char_combobox() wordCharRegex = item.get_word_chars() if wordCharRegex in list(WORD_CHAR_OPTIONS.values()): # Default wordchar regex used for desc, regex in WORD_CHAR_OPTIONS.items(): if item.get_word_chars() == regex: self.wordCharCombo.setCurrentIndex( WORD_CHAR_OPTIONS_ORDERED.index(desc)) break else: # Custom wordchar regex used self.wordCharCombo.addItem(model.extract_wordchars(wordCharRegex)) self.wordCharCombo.setCurrentIndex(len(WORD_CHAR_OPTIONS)) if isinstance(item, model.Folder): self.omitTriggerCheckbox.setVisible(False) else: self.omitTriggerCheckbox.setVisible(True) self.omitTriggerCheckbox.setChecked(item.omitTrigger) if isinstance(item, model.Phrase): self.matchCaseCheckbox.setVisible(True) self.matchCaseCheckbox.setChecked(item.matchCase) else: self.matchCaseCheckbox.setVisible(False) self.ignoreCaseCheckbox.setChecked(item.ignoreCase) self.triggerInsideCheckbox.setChecked(item.triggerInside) self.immediateCheckbox.setChecked(item.immediate) # Enable the OK button only if there are abbreviations in the loaded list. Otherwise only cancel is available # to the user until they add a non-empty abbreviation. self.buttonBox.button(QDialogButtonBox.Ok).setEnabled( bool(self.get_abbrs()))
def load(self, item): self.targetItem = item self.abbrList.get_model().clear() if model.TriggerMode.ABBREVIATION in item.modes: for abbr in item.abbreviations: self.abbrList.get_model().append((abbr.encode("utf-8"), )) self.removeButton.set_sensitive(True) firstIter = self.abbrList.get_model().get_iter_first() self.abbrList.get_selection().select_iter(firstIter) else: self.removeButton.set_sensitive(False) self.removeTypedCheckbox.set_active(item.backspace) self.__resetWordCharCombo() wordCharRegex = item.get_word_chars() if wordCharRegex in WORD_CHAR_OPTIONS.values(): # Default wordchar regex used for desc, regex in WORD_CHAR_OPTIONS.iteritems(): if item.get_word_chars() == regex: self.wordCharCombo.set_active( WORD_CHAR_OPTIONS_ORDERED.index(desc)) break else: # Custom wordchar regex used self.wordCharCombo.append_text( model.extract_wordchars(wordCharRegex).encode("utf-8")) self.wordCharCombo.set_active(len(WORD_CHAR_OPTIONS)) if isinstance(item, model.Folder): self.omitTriggerCheckbox.hide() else: self.omitTriggerCheckbox.show() self.omitTriggerCheckbox.set_active(item.omitTrigger) if isinstance(item, model.Phrase): self.matchCaseCheckbox.show() self.matchCaseCheckbox.set_active(item.matchCase) else: self.matchCaseCheckbox.hide() self.ignoreCaseCheckbox.set_active(item.ignoreCase) self.triggerInsideCheckbox.set_active(item.triggerInside) self.immediateCheckbox.set_active(item.immediate)
def load(self, item): self.targetItem = item self.widget.abbrListWidget.clear() if model.TriggerMode.ABBREVIATION in item.modes: for abbr in item.abbreviations: self.widget.abbrListWidget.addItem(AbbrListItem(abbr)) self.widget.removeButton.setEnabled(True) self.widget.abbrListWidget.setCurrentRow(0) else: self.widget.removeButton.setEnabled(False) self.widget.removeTypedCheckbox.setChecked(item.backspace) self.__resetWordCharCombo() wordCharRegex = item.get_word_chars() if wordCharRegex in WORD_CHAR_OPTIONS.values(): # Default wordchar regex used for desc, regex in WORD_CHAR_OPTIONS.iteritems(): if item.get_word_chars() == regex: self.widget.wordCharCombo.setCurrentIndex( WORD_CHAR_OPTIONS_ORDERED.index(desc)) break else: # Custom wordchar regex used self.widget.wordCharCombo.addItem( model.extract_wordchars(wordCharRegex)) self.widget.wordCharCombo.setCurrentIndex(len(WORD_CHAR_OPTIONS)) if isinstance(item, model.Folder): self.widget.omitTriggerCheckbox.setVisible(False) else: self.widget.omitTriggerCheckbox.setVisible(True) self.widget.omitTriggerCheckbox.setChecked(item.omitTrigger) if isinstance(item, model.Phrase): self.widget.matchCaseCheckbox.setVisible(True) self.widget.matchCaseCheckbox.setChecked(item.matchCase) else: self.widget.matchCaseCheckbox.setVisible(False) self.widget.ignoreCaseCheckbox.setChecked(item.ignoreCase) self.widget.triggerInsideCheckbox.setChecked(item.triggerInside) self.widget.immediateCheckbox.setChecked(item.immediate)
def load(self, item): self.targetItem = item self.abbrList.get_model().clear() if model.TriggerMode.ABBREVIATION in item.modes: for abbr in item.abbreviations: self.abbrList.get_model().append((abbr.encode("utf-8"),)) self.removeButton.set_sensitive(True) firstIter = self.abbrList.get_model().get_iter_first() self.abbrList.get_selection().select_iter(firstIter) else: self.removeButton.set_sensitive(False) self.removeTypedCheckbox.set_active(item.backspace) self.__resetWordCharCombo() wordCharRegex = item.get_word_chars() if wordCharRegex in WORD_CHAR_OPTIONS.values(): # Default wordchar regex used for desc, regex in WORD_CHAR_OPTIONS.iteritems(): if item.get_word_chars() == regex: self.wordCharCombo.set_active(WORD_CHAR_OPTIONS_ORDERED.index(desc)) break else: # Custom wordchar regex used self.wordCharCombo.append_text(model.extract_wordchars(wordCharRegex).encode("utf-8")) self.wordCharCombo.set_active(len(WORD_CHAR_OPTIONS)) if isinstance(item, model.Folder): self.omitTriggerCheckbox.hide() else: self.omitTriggerCheckbox.show() self.omitTriggerCheckbox.set_active(item.omitTrigger) if isinstance(item, model.Phrase): self.matchCaseCheckbox.show() self.matchCaseCheckbox.set_active(item.matchCase) else: self.matchCaseCheckbox.hide() self.ignoreCaseCheckbox.set_active(item.ignoreCase) self.triggerInsideCheckbox.set_active(item.triggerInside) self.immediateCheckbox.set_active(item.immediate)
def load(self, item): self.targetItem = item self.widget.abbrListWidget.clear() if model.TriggerMode.ABBREVIATION in item.modes: for abbr in item.abbreviations: self.widget.abbrListWidget.addItem(AbbrListItem(abbr)) self.widget.removeButton.setEnabled(True) self.widget.abbrListWidget.setCurrentRow(0) else: self.widget.removeButton.setEnabled(False) self.widget.removeTypedCheckbox.setChecked(item.backspace) self.__resetWordCharCombo() wordCharRegex = item.get_word_chars() if wordCharRegex in WORD_CHAR_OPTIONS.values(): # Default wordchar regex used for desc, regex in WORD_CHAR_OPTIONS.iteritems(): if item.get_word_chars() == regex: self.widget.wordCharCombo.setCurrentIndex(WORD_CHAR_OPTIONS_ORDERED.index(desc)) break else: # Custom wordchar regex used self.widget.wordCharCombo.addItem(model.extract_wordchars(wordCharRegex)) self.widget.wordCharCombo.setCurrentIndex(len(WORD_CHAR_OPTIONS)) if isinstance(item, model.Folder): self.widget.omitTriggerCheckbox.setVisible(False) else: self.widget.omitTriggerCheckbox.setVisible(True) self.widget.omitTriggerCheckbox.setChecked(item.omitTrigger) if isinstance(item, model.Phrase): self.widget.matchCaseCheckbox.setVisible(True) self.widget.matchCaseCheckbox.setChecked(item.matchCase) else: self.widget.matchCaseCheckbox.setVisible(False) self.widget.ignoreCaseCheckbox.setChecked(item.ignoreCase) self.widget.triggerInsideCheckbox.setChecked(item.triggerInside) self.widget.immediateCheckbox.setChecked(item.immediate)