Remove tag from selected rows
This commit is contained in:
parent
5935a315b2
commit
ab52d0988e
@ -241,14 +241,21 @@ class Tags(DbGUIElement):
|
||||
tag_menu = ''
|
||||
menuitem = '''
|
||||
<item>
|
||||
<attribute name="action">win.TAG-%s</attribute>
|
||||
<attribute name="action">win.%s</attribute>
|
||||
<attribute name="label">%s</attribute>
|
||||
</item>'''
|
||||
|
||||
for tag_name, handle in self.__tag_list:
|
||||
tag_menu += menuitem % (handle, escape(tag_name))
|
||||
tag_menu += menuitem % ("TAG-%s" % handle,
|
||||
"Add tag '%s'" % tag_name)
|
||||
actions.append(('TAG-%s' % handle,
|
||||
make_callback(self.tag_selected_rows, handle)))
|
||||
for tag_name, handle in self.__tag_list:
|
||||
tag_menu += menuitem % ("R-TAG-%s" % handle,
|
||||
"Remove tag '%s'" % tag_name)
|
||||
actions.append(('R-TAG-%s' % handle,
|
||||
make_callback(self.remove_tag_selected_rows,
|
||||
handle)))
|
||||
tag_menu = TAG_MENU % tag_menu
|
||||
|
||||
self.tag_ui = [TAG_1 % tag_menu, TAG_2, TAG_3 % tag_menu]
|
||||
@ -315,6 +322,28 @@ class Tags(DbGUIElement):
|
||||
view.add_tag(trans, object_handle, tag_handle)
|
||||
status.end()
|
||||
|
||||
def remove_tag_selected_rows(self, tag_handle):
|
||||
"""
|
||||
Remove tag from selected rows.
|
||||
"""
|
||||
view = self.uistate.viewmanager.active_page
|
||||
selected = view.selected_handles()
|
||||
# Make the dialog modal so that the user can't start another
|
||||
# database transaction while the one setting tags is still running.
|
||||
pmon = progressdlg.ProgressMonitor(progressdlg.GtkProgressDialog,
|
||||
("", self.uistate.window, Gtk.DialogFlags.MODAL), popup_time=2)
|
||||
status = progressdlg.LongOpStatus(msg=_("Adding Tags"),
|
||||
total_steps=len(selected),
|
||||
interval=len(selected)//20)
|
||||
pmon.add_op(status)
|
||||
tag = self.db.get_tag_from_handle(tag_handle)
|
||||
msg = _('Tag Selection (%s)') % tag.get_name()
|
||||
with DbTxn(msg, self.db) as trans:
|
||||
for object_handle in selected:
|
||||
status.heartbeat()
|
||||
view.remove_tag(trans, object_handle, tag_handle)
|
||||
status.end()
|
||||
|
||||
def cb_menu_position(*args):
|
||||
"""
|
||||
Determine the position of the popup menu.
|
||||
|
@ -559,6 +559,14 @@ class BasePersonView(ListView):
|
||||
person.add_tag(tag_handle)
|
||||
self.dbstate.db.commit_person(person, transaction)
|
||||
|
||||
def remove_tag(self, transaction, person_handle, tag_handle):
|
||||
"""
|
||||
Remove the given tag from the given person.
|
||||
"""
|
||||
person = self.dbstate.db.get_person_from_handle(person_handle)
|
||||
person.remove_tag(tag_handle)
|
||||
self.dbstate.db.commit_person(person, transaction)
|
||||
|
||||
def get_default_gramplets(self):
|
||||
"""
|
||||
Define the default gramplets for the sidebar and bottombar.
|
||||
|
@ -595,6 +595,14 @@ class PlaceBaseView(ListView):
|
||||
place.add_tag(tag_handle)
|
||||
self.dbstate.db.commit_place(place, transaction)
|
||||
|
||||
def remove_tag(self, transaction, place_handle, tag_handle):
|
||||
"""
|
||||
Remove the given tag from the given place.
|
||||
"""
|
||||
place = self.dbstate.db.get_place_from_handle(place_handle)
|
||||
place.remove_tag(tag_handle)
|
||||
self.dbstate.db.commit_place(place, transaction)
|
||||
|
||||
def get_default_gramplets(self):
|
||||
"""
|
||||
Define the default gramplets for the sidebar and bottombar.
|
||||
|
@ -453,6 +453,14 @@ class CitationListView(ListView):
|
||||
citation.add_tag(tag_handle)
|
||||
self.dbstate.db.commit_citation(citation, transaction)
|
||||
|
||||
def remove_tag(self, transaction, citation_handle, tag_handle):
|
||||
"""
|
||||
Remove the given tag from the given citation.
|
||||
"""
|
||||
citation = self.dbstate.db.get_citation_from_handle(citation_handle)
|
||||
citation.remove_tag(tag_handle)
|
||||
self.dbstate.db.commit_citation(citation, transaction)
|
||||
|
||||
def get_default_gramplets(self):
|
||||
"""
|
||||
Define the default gramplets for the sidebar and bottombar.
|
||||
|
@ -742,6 +742,18 @@ class CitationTreeView(ListView):
|
||||
source.add_tag(tag_handle)
|
||||
self.dbstate.db.commit_source(source, transaction)
|
||||
|
||||
def remove_tag(self, transaction, handle, tag_handle):
|
||||
"""
|
||||
Remove the given tag from the given source or citation.
|
||||
"""
|
||||
source, citation = self.get_source_or_citation(handle)
|
||||
if citation:
|
||||
citation.remove_tag(tag_handle)
|
||||
self.dbstate.db.commit_citation(citation, transaction)
|
||||
else:
|
||||
source.remove_tag(tag_handle)
|
||||
self.dbstate.db.commit_source(source, transaction)
|
||||
|
||||
def get_default_gramplets(self):
|
||||
"""
|
||||
Define the default gramplets for the sidebar and bottombar.
|
||||
|
@ -468,6 +468,14 @@ class EventView(ListView):
|
||||
event.add_tag(tag_handle)
|
||||
self.dbstate.db.commit_event(event, transaction)
|
||||
|
||||
def remove_tag(self, transaction, event_handle, tag_handle):
|
||||
"""
|
||||
Remove the given tag from the given event.
|
||||
"""
|
||||
event = self.dbstate.db.get_event_from_handle(event_handle)
|
||||
event.remove_tag(tag_handle)
|
||||
self.dbstate.db.commit_event(event, transaction)
|
||||
|
||||
def get_default_gramplets(self):
|
||||
"""
|
||||
Define the default gramplets for the sidebar and bottombar.
|
||||
|
@ -483,6 +483,14 @@ class FamilyView(ListView):
|
||||
family.add_tag(tag_handle)
|
||||
self.dbstate.db.commit_family(family, transaction)
|
||||
|
||||
def remove_tag(self, transaction, family_handle, tag_handle):
|
||||
"""
|
||||
Remove the given tag from the given family.
|
||||
"""
|
||||
family = self.dbstate.db.get_family_from_handle(family_handle)
|
||||
family.remove_tag(tag_handle)
|
||||
self.dbstate.db.commit_family(family, transaction)
|
||||
|
||||
def get_default_gramplets(self):
|
||||
"""
|
||||
Define the default gramplets for the sidebar and bottombar.
|
||||
|
@ -518,6 +518,14 @@ class MediaView(ListView):
|
||||
media.add_tag(tag_handle)
|
||||
self.dbstate.db.commit_media(media, transaction)
|
||||
|
||||
def remove_tag(self, transaction, media_handle, tag_handle):
|
||||
"""
|
||||
Remove the given tag from the given media object.
|
||||
"""
|
||||
media = self.dbstate.db.get_media_from_handle(media_handle)
|
||||
media.remove_tag(tag_handle)
|
||||
self.dbstate.db.commit_media(media, transaction)
|
||||
|
||||
def get_default_gramplets(self):
|
||||
"""
|
||||
Define the default gramplets for the sidebar and bottombar.
|
||||
|
@ -382,6 +382,14 @@ class NoteView(ListView):
|
||||
note.add_tag(tag_handle)
|
||||
self.dbstate.db.commit_note(note, transaction)
|
||||
|
||||
def remove_tag(self, transaction, note_handle, tag_handle):
|
||||
"""
|
||||
Remove the given tag from the given note.
|
||||
"""
|
||||
note = self.dbstate.db.get_note_from_handle(note_handle)
|
||||
note.remove_tag(tag_handle)
|
||||
self.dbstate.db.commit_note(note, transaction)
|
||||
|
||||
def get_default_gramplets(self):
|
||||
"""
|
||||
Define the default gramplets for the sidebar and bottombar.
|
||||
|
@ -396,6 +396,14 @@ class RepositoryView(ListView):
|
||||
repo.add_tag(tag_handle)
|
||||
self.dbstate.db.commit_repository(repo, transaction)
|
||||
|
||||
def remove_tag(self, transaction, repo_handle, tag_handle):
|
||||
"""
|
||||
Remove the given tag from the given repository.
|
||||
"""
|
||||
repo = self.dbstate.db.get_repository_from_handle(repo_handle)
|
||||
repo.remove_tag(tag_handle)
|
||||
self.dbstate.db.commit_repository(repo, transaction)
|
||||
|
||||
def get_default_gramplets(self):
|
||||
"""
|
||||
Define the default gramplets for the sidebar and bottombar.
|
||||
|
@ -380,6 +380,14 @@ class SourceView(ListView):
|
||||
source.add_tag(tag_handle)
|
||||
self.dbstate.db.commit_source(source, transaction)
|
||||
|
||||
def remove_tag(self, transaction, source_handle, tag_handle):
|
||||
"""
|
||||
Remove the given tag from the given source.
|
||||
"""
|
||||
source = self.dbstate.db.get_source_from_handle(source_handle)
|
||||
source.remove_tag(tag_handle)
|
||||
self.dbstate.db.commit_source(source, transaction)
|
||||
|
||||
def get_default_gramplets(self):
|
||||
"""
|
||||
Define the default gramplets for the sidebar and bottombar.
|
||||
|
Loading…
Reference in New Issue
Block a user