def applyTagClicked(self, button): progress = None rows = self.treeSelection.count_selected_rows() tag_name = str(self.tagcombo.get_active_text()) # start the db transaction with DbTxn("Tag not related", self.db) as transaction: tag = self.db.get_tag_from_name(tag_name) if not tag: # create the tag if it doesn't already exist tag = Tag() tag.set_name(tag_name) tag.set_priority(self.db.get_number_of_tags()) tag_handle = self.db.add_tag(tag, transaction) else: tag_handle = tag.get_handle() # if more than 1 person is selected, use a progress indicator if rows > 1: progress = ProgressMeter(self.title, _('Starting')) progress.set_pass( # translators: leave all/any {...} untranslated #TRANS: no singular form needed, as rows is always > 1 ngettext("Setting tag for {number_of} person", "Setting tag for {number_of} people", rows).format(number_of=rows), rows) # iterate through all of the selected rows (model, paths) = self.treeSelection.get_selected_rows() for path in paths: if progress: progress.step() # for the current row, get the GID and the person from the database iter = self.model.get_iter(path) personGid = self.model.get_value(iter, 1) person = self.db.get_person_from_gramps_id(personGid) # add the tag to the person person.add_tag(tag_handle) # save this change self.db.commit_person(person, transaction) # refresh the tags column self.treeView.set_model(None) for path in paths: iter = self.model.get_iter(path) personGid = self.model.get_value(iter, 1) person = self.db.get_person_from_gramps_id(personGid) self.model.set_value(iter, 3, self.get_tag_list(person)) self.treeView.set_model(self.model) self.treeView.expand_all() if progress: progress.close()
def cb_new_tag(self, action): """ Create a new tag and tag the selected objects. """ tag = Tag() tag.set_priority(self.db.get_number_of_tags()) EditTag(self.db, self.uistate, [], tag) if tag.get_handle(): self.tag_selected_rows(tag.get_handle())
def find_tag(self,tagdata): tagname = tagdata["name"] if tagname in self.tags: return self.tags[tagname] tag = Tag() tag.set_name(tagname) tag.set_color(tagdata["color"]) tag.set_priority(tagdata["priority"]) taghandle = self.db.add_tag(tag,self.trans) self.tags[tagname] = taghandle return taghandle
def cb_add_clicked(self, button, top): """ Create a new tag. """ tag = Tag() tag.set_priority(self.db.get_number_of_tags()) EditTag(self.db, self.uistate, self.track, tag) if tag.get_handle(): self.namemodel.add((tag.get_priority(), tag.get_handle(), tag.get_name(), tag.get_color()))
def cb_add_clicked(self, button, top): """ Create a new tag. """ tag = Tag() tag.set_priority(self.db.get_number_of_tags()) edit_dialog = EditTag(self.db, top, tag) edit_dialog.run() if tag.get_handle(): self.namemodel.add((tag.get_priority(), tag.get_handle(), tag.get_name(), tag.get_color()))
def cb_add_clicked(self, button, top): """ Create a new tag. """ tag = Tag() tag.set_priority(self.db.get_number_of_tags()) EditTag(self.db, self.uistate, self.track, tag) if tag.get_handle(): self.namemodel.add((tag.get_priority(), tag.get_handle(), tag.get_name(), tag.get_color()))
def cb_add_clicked(self, button, top): """ Create a new tag. """ tag = Tag() tag.set_priority(self.db.get_number_of_tags()) edit_dialog = EditTag(self.db, top, tag) edit_dialog.run() if tag.get_handle(): self.namemodel.add((tag.get_priority(), tag.get_handle(), tag.get_name(), tag.get_color()))
def create_tag(self, tag_name, tag_color): """ Create a tag if it doesn't already exist. """ tag = self.db.get_tag_from_name(tag_name) if tag is None: tag = Tag() tag.set_name(tag_name) if tag_color is not None: tag.set_color(tag_color) tag.set_priority(self.db.get_number_of_tags()) tag_handle = self.db.add_tag(tag, self.trans) else: tag_handle = tag.get_handle() return tag_handle
def create_tag(self, tag_name, tag_color): """ Create a tag if it doesn't already exist. """ tag = self.db.get_tag_from_name(tag_name) if tag is None: tag = Tag() tag.set_name(tag_name) if tag_color is not None: tag.set_color(tag_color) tag.set_priority(self.db.get_number_of_tags()) tag_handle = self.db.add_tag(tag, self.trans) else: tag_handle = tag.get_handle() return tag_handle
def on_ok_clicked(self, obj): clean = self.clear_button.get_active() copy = self.copy_button.get_active() tag = self.tag_button.get_active() if not (copy or clean or tag): return self.db.disable_signals() if tag: tag_name = _('Legacy place') # start the db transaction with DbTxn("Tag for place titles", self.db) as self.tag_trans: mark = self.db.get_tag_from_name(tag_name) if not mark: # create the tag if it doesn't already exist mark = Tag() mark.set_name(tag_name) mark.set_priority(self.db.get_number_of_tags()) tag_handle = self.db.add_tag(mark, self.tag_trans) else: tag_handle = mark.get_handle() with DbTxn(_("Modify Place titles"), self.db, batch=True) as trans: for row in self.model: if row[1] == True: place = self.db.get_place_from_handle(row[0]) if copy: self.create_note(place, row[2], trans) if clean: place.set_title("") if tag: place.add_tag(tag_handle) self.db.commit_place(place, trans) self.db.enable_signals() self.db.request_rebuild() self.close()
def on_ok_clicked(self, obj): clean = self.clear_button.get_active() copy = self.copy_button.get_active() tag = self.tag_button.get_active() if not (copy or clean or tag): return self.db.disable_signals() if tag: tag_name = _('Legacy place') # start the db transaction with DbTxn("Tag for place titles", self.db) as self.tag_trans: mark = self.db.get_tag_from_name(tag_name) if not mark: # create the tag if it doesn't already exist mark = Tag() mark.set_name(tag_name) mark.set_priority(self.db.get_number_of_tags()) tag_handle = self.db.add_tag(mark, self.tag_trans) else: tag_handle = mark.get_handle() with DbTxn(_("Modify Place titles"), self.db, batch=True) as trans: for row in self.model: if row[1] == True: place = self.db.get_place_from_handle(row[0]) if copy: self.create_note(place, row[2], trans) if clean: place.set_title("") if tag: place.add_tag(tag_handle) self.db.commit_place(place, trans) self.db.enable_signals() self.db.request_rebuild() self.close()
def applyTagClicked(self, button) : progress = None rows = self.treeSelection.count_selected_rows() tag_name = str(self.tagcombo.get_active_text()) # start the db transaction with DbTxn("Tag not related", self.db) as transaction: tag = self.db.get_tag_from_name(tag_name) if not tag: # create the tag if it doesn't already exist tag = Tag() tag.set_name(tag_name) tag.set_priority(self.db.get_number_of_tags()) tag_handle = self.db.add_tag(tag, transaction) else: tag_handle = tag.get_handle() # if more than 1 person is selected, use a progress indicator if rows > 1: progress = ProgressMeter(self.title,_('Starting'), parent=self.window) progress.set_pass( # translators: leave all/any {...} untranslated #TRANS: no singular form needed, as rows is always > 1 ngettext("Setting tag for {number_of} person", "Setting tag for {number_of} people", rows).format(number_of=rows), rows) # iterate through all of the selected rows (model, paths) = self.treeSelection.get_selected_rows() for path in paths: if progress: progress.step() # for the current row, get the GID and the person from the database iter = self.model.get_iter(path) personGid = self.model.get_value(iter, 1) person = self.db.get_person_from_gramps_id(personGid) # add the tag to the person person.add_tag(tag_handle) # save this change self.db.commit_person(person, transaction) # refresh the tags column self.treeView.set_model(None) for path in paths: iter = self.model.get_iter(path) personGid = self.model.get_value(iter, 1) person = self.db.get_person_from_gramps_id(personGid) self.model.set_value(iter, 3, self.get_tag_list(person)) self.treeView.set_model(self.model) self.treeView.expand_all() if progress: progress.close()