def createEditor(self, parent, options, index): nonlocal owwidget edit = QLineEdit(parent) wordlist = [''] + ToLatLon.valid_values( owwidget.ID_TYPE[owwidget.str_type]) edit.setCompleter( QCompleter(wordlist, edit, caseSensitivity=Qt.CaseInsensitive, filterMode=Qt.MatchContains)) def save_and_commit(): if edit.text() and edit.text() in wordlist: model = index.model() pindex = QPersistentModelIndex(index) if pindex.isValid(): new_index = pindex.sibling(pindex.row(), pindex.column()) save = model.setData(new_index, edit.text(), Qt.EditRole) if save: owwidget.commit() return edit.clear() edit.editingFinished.connect(save_and_commit) return edit
def createEditor(self, p_int, parent): nonlocal owwidget edit = QLineEdit(parent) wordlist = [''] + ToLatLon.valid_values( owwidget.ID_TYPE[owwidget.str_type]) edit.setCompleter( QCompleter(wordlist, edit, caseSensitivity=Qt.CaseInsensitive, filterMode=Qt.MatchContains)) return edit
def region_attr_changed(self): if self.data is None: return if self.str_attr: # Auto-detect the type of region in the attribute and set its combo values = self._get_data_values() func = ToLatLon.detect_input(values) str_type = next((k for k, v in self.ID_TYPE.items() if v == func), None) if str_type is not None and str_type != self.str_type: self.str_type = str_type self.commit()
def test_cc_name_mapping(self): # check if the CC_NAME_TO_CC_NAME maps to known values known_countries = set(ToLatLon.valid_values(ToLatLon.from_cc_name)) mapped_countries = set(CC_NAME_TO_CC_NAME.values()) self.assertSetEqual(mapped_countries - known_countries, set())