def search(self): value = self.search_field.text() self.empty.setStyleSheet("") self.empty.setText(u"") contacts = [] try: contacts = PhoneNumber.filter(number__icontains=int(value)) except ValueError: contacts = PhoneNumber.filter(contact__name__icontains=value) pass try: value = contacts.get() self.parent.table_contact.refresh_(search=value) self.search_field.clear() except AttributeError: pass except: self.empty.setStyleSheet("font-size:20px; color: red") self.empty.setText(u"%s n'existe pas" % value)
def finder(self): completion_values = [] search_term = self.search_field.text() try: contacts = PhoneNumber.filter(number__icontains=int(search_term)) except ValueError: contacts = Contact.filter(name__icontains=search_term) for contact in contacts: completion_values.append(contact.__unicode__()) completer = QtGui.QCompleter(completion_values, parent=self) completer.setCaseSensitivity(QtCore.Qt.CaseInsensitive) completer.setCompletionMode(QtGui.QCompleter.UnfilteredPopupCompletion) self.search_field.setCompleter(completer)
def set_data_for(self, group_id=None, search=None): if search: self.data = [("", tel.contact.name) for tel in PhoneNumber.filter().group_by('contact') if search.contact == tel.contact] else: self.data = [("", contact.name) for contact in Contact.all()] if group_id: if group_id == ALL_CONTACTS: qs = ContactGroup.filter().group_by('contact') else: qs = ContactGroup.filter(group__id=group_id) self.data = [("", contact_gp.contact.name) for contact_gp in qs]
def addressbook_transfer(contact_id): numbers = PhoneNumber.filter(contact=Contact.get(id=int(contact_id))) data = {'transfers': [tr.to_dict() \ for tr in Transfer.filter(number__in=numbers)]} return json.dumps(data)
def click_item(self, row, column, *args): number = PhoneNumber.filter(contact__name=self.data[row][1]).get() self.parent.table_info.refresh_(number) self.parent.table_transf.refresh_(number)