def showTags(self): tag_model = TagModel() tags = tag_model.getDBTags() tag_placeholder = "Select a tag..." self.view.scroll_tag.addItem(tag_placeholder) for tag in tags: self.view.scroll_tag.addItem(tag[1])
def asyncUpdateContact(self): v = self.view c_id = self.contact.c_id first_name = v.first_name.text() last_name = v.last_name.text() tel = v.telephone.text() email = v.email.text() url = v.url.text() notes = v.notes.toPlainText() if (first_name != "" and first_name is not None and last_name != "" and last_name is not None): modified_contact = ContactModel() modified_contact.setFields(first_name, last_name, tel, email, url, notes) modified_contact.updateContact(c_id) tag_contact_model = ContactTagModel() tag_contact_model.setContactId(c_id) tag_contact_model.deleteContactTagsFromId() tags = v.scrollAreaWidgetContents.layout() items = (tags.itemAt(i).widget() for i in range(tags.count())) # select checked tags and add the info in ContactsTags table as a tuple (c_id, t_id) for i in items: if i.isChecked(): tag_model = TagModel() tag_id = tag_model.getTagIdfromName(i.text()) contact_tag_model = ContactTagModel() contact_tag_model.setContactId(c_id) contact_tag_model.setTagId(tag_id) contact_tag_model.addContactTag()
def addContact(self): first_name = self.view.first_name.text() last_name = self.view.last_name.text() telephone = self.view.telephone.text() email = self.view.email.text() url = self.view.url.text() notes = self.view.notes.toPlainText() # check for minimum data required if ((first_name is not None and first_name != "") or (last_name is not None and last_name != "") and telephone is not None and telephone != ""): new_contact = ContactModel() new_contact.setFields(first_name, last_name, telephone, email, url, notes) new_contact.addContact() # get the contact id from Contacts table in "ContactsManager.db". c_id = new_contact.getContactIdFromNameTel() # select checked tags and add the info in ContactsTags table as a tuple (c_id, t_id) tags = self.view.scrollAreaWidgetContents.layout() items = (tags.itemAt(i).widget() for i in range(tags.count())) for i in items: if i.isChecked(): # print("checked", i) tag_model = TagModel() tag_id = tag_model.getTagIdfromName(i.text()) contact_tag_model = ContactTagModel() contact_tag_model.setContactId(c_id) contact_tag_model.setTagId(tag_id) contact_tag_model.addContactTag() self.showContactList()
def showTags(self): tag_model = TagModel() tags = tag_model.getDBTags() self.view.scrollAreaWidgetContents.layout().setAlignment(Qt.AlignTop) for t in tags: item = QLabel(t[1]) self.view.scrollAreaWidgetContents.layout().addWidget(item)
def showTags(self): tag_model = TagModel() tags = tag_model.getDBTags() for t in tags: checkbox = QCheckBox() checkbox.setMinimumHeight(20) checkbox.setText(t[1]) self.view.scrollAreaWidgetContents.layout().addWidget(checkbox)
def showTags(self): tag_model = TagModel() tags = tag_model.getDBTags() contact_tag_model = ContactTagModel() contact_tag_model.setContactId(self.contact.c_id) contact_tags = contact_tag_model.getTagFromId() current_tags = [] for t in contact_tags: current_tags.append(t[0]) # checkbox tag list for tag in tags: checkbox = QCheckBox() checkbox.setMinimumHeight(20) checkbox.setText(tag[1]) if tag[1] in current_tags: checkbox.setChecked(True) self.view.scrollAreaWidgetContents.layout().addWidget(checkbox)
def addTag(self): tag_name = self.view.tag_name.text() if (tag_name != "" and tag_name is not None): new_tag = TagModel() new_tag.setTagName(tag_name) new_tag.addTag() # when a new tag is added, defaultTagList() is called to refresh the tag list self.defaultTagList() # clear text in qline self.view.tag_name.setText("")
# -*- coding: utf-8 -*-