Update tagging to work with new transaction code
svn: r16690
This commit is contained in:
@ -183,9 +183,8 @@ class SidebarFilter(DbGUIElement):
|
|||||||
"""
|
"""
|
||||||
Called when tags are deleted.
|
Called when tags are deleted.
|
||||||
"""
|
"""
|
||||||
for handle in handle_list:
|
self.__tag_list = [item for item in self.__tag_list
|
||||||
tag = self.dbstate.db.get_tag_from_handle(handle)
|
if item[1] not in handle_list]
|
||||||
self.__tag_list.remove((tag.get_name(), handle))
|
|
||||||
self.on_tags_changed([item[0] for item in self.__tag_list])
|
self.on_tags_changed([item[0] for item in self.__tag_list])
|
||||||
|
|
||||||
def _tag_rebuild(self):
|
def _tag_rebuild(self):
|
||||||
|
@ -43,6 +43,7 @@ import gtk
|
|||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
from gen.ggettext import sgettext as _
|
from gen.ggettext import sgettext as _
|
||||||
from gen.lib import Tag
|
from gen.lib import Tag
|
||||||
|
from gen.db import DbTxn
|
||||||
from gui.dbguielement import DbGUIElement
|
from gui.dbguielement import DbGUIElement
|
||||||
from ListModel import ListModel, NOSORT, COLOR, INTEGER
|
from ListModel import ListModel, NOSORT, COLOR, INTEGER
|
||||||
import const
|
import const
|
||||||
@ -169,9 +170,8 @@ class Tags(DbGUIElement):
|
|||||||
"""
|
"""
|
||||||
Called when tags are deleted.
|
Called when tags are deleted.
|
||||||
"""
|
"""
|
||||||
for handle in handle_list:
|
self.__tag_list = [item for item in self.__tag_list
|
||||||
tag = self.db.get_tag_from_handle(handle)
|
if item[1] not in handle_list]
|
||||||
self.__tag_list.remove((tag.get_name(), handle))
|
|
||||||
self.update_tag_menu()
|
self.update_tag_menu()
|
||||||
|
|
||||||
def _tag_rebuild(self):
|
def _tag_rebuild(self):
|
||||||
@ -267,17 +267,17 @@ class Tags(DbGUIElement):
|
|||||||
interval=len(selected)//20,
|
interval=len(selected)//20,
|
||||||
can_cancel=True)
|
can_cancel=True)
|
||||||
pmon.add_op(status)
|
pmon.add_op(status)
|
||||||
trans = self.db.transaction_begin()
|
tag = self.db.get_tag_from_handle(tag_handle)
|
||||||
for object_handle in selected:
|
msg = _('Tag Selection (%s)') % tag.get_name()
|
||||||
status.heartbeat()
|
with DbTxn(msg, self.db) as trans:
|
||||||
if status.should_cancel():
|
for object_handle in selected:
|
||||||
break
|
status.heartbeat()
|
||||||
view.add_tag(trans, object_handle, tag_handle)
|
if status.should_cancel():
|
||||||
if not status.was_cancelled():
|
break
|
||||||
tag = self.db.get_tag_from_handle(tag_handle)
|
view.add_tag(trans, object_handle, tag_handle)
|
||||||
msg = _('Tag Selection (%s)') % tag.get_name()
|
if status.was_cancelled():
|
||||||
self.db.transaction_commit(trans, msg)
|
self.db.transaction_abort(trans)
|
||||||
status.end()
|
status.end()
|
||||||
|
|
||||||
def cb_menu_position(menu, button):
|
def cb_menu_position(menu, button):
|
||||||
"""
|
"""
|
||||||
@ -325,9 +325,9 @@ class OrganizeTagsDialog(object):
|
|||||||
break
|
break
|
||||||
|
|
||||||
# Save changed priority values
|
# Save changed priority values
|
||||||
trans = self.db.transaction_begin()
|
with DbTxn(_('Change Tag Priority'), self.db) as trans:
|
||||||
if self.__change_tag_priority(trans):
|
if not self.__change_tag_priority(trans):
|
||||||
self.db.transaction_commit(trans, _('Change Tag Priority'))
|
self.db.transaction_abort(trans)
|
||||||
|
|
||||||
self.top.destroy()
|
self.top.destroy()
|
||||||
|
|
||||||
@ -504,22 +504,23 @@ class OrganizeTagsDialog(object):
|
|||||||
can_cancel=True)
|
can_cancel=True)
|
||||||
pmon.add_op(status)
|
pmon.add_op(status)
|
||||||
|
|
||||||
trans = self.db.transaction_begin()
|
msg = _('Delete Tag (%s)') % tag_name
|
||||||
for classname, handle in links:
|
with DbTxn(_('Change Tag Priority'), self.db) as trans:
|
||||||
status.heartbeat()
|
for classname, handle in links:
|
||||||
if status.should_cancel():
|
status.heartbeat()
|
||||||
break
|
if status.should_cancel():
|
||||||
obj = fnc[classname][0](handle) # get from handle
|
break
|
||||||
obj.remove_tag(tag_handle)
|
obj = fnc[classname][0](handle) # get from handle
|
||||||
fnc[classname][1](obj, trans) # commit
|
obj.remove_tag(tag_handle)
|
||||||
|
fnc[classname][1](obj, trans) # commit
|
||||||
|
|
||||||
self.db.remove_tag(tag_handle, trans)
|
self.db.remove_tag(tag_handle, trans)
|
||||||
self.__change_tag_priority(trans)
|
self.__change_tag_priority(trans)
|
||||||
if not status.was_cancelled():
|
if status.was_cancelled():
|
||||||
msg = _('Delete Tag (%s)') % tag_name
|
self.db.transaction_abort(trans)
|
||||||
self.db.transaction_commit(trans, msg)
|
else:
|
||||||
store.remove(iter_)
|
store.remove(iter_)
|
||||||
status.end()
|
status.end()
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
@ -561,17 +562,15 @@ class EditTag(object):
|
|||||||
return
|
return
|
||||||
|
|
||||||
if not self.tag.get_handle():
|
if not self.tag.get_handle():
|
||||||
trans = self.db.transaction_begin()
|
msg = _("Add Tag (%s)") % self.tag.get_name()
|
||||||
self.db.add_tag(self.tag, trans)
|
with DbTxn(msg, self.db) as trans:
|
||||||
self.db.transaction_commit(trans,
|
self.db.add_tag(self.tag, trans)
|
||||||
_("Add Tag (%s)") % self.tag.get_name())
|
|
||||||
else:
|
else:
|
||||||
orig = self.db.get_tag_from_handle(self.tag.get_handle())
|
orig = self.db.get_tag_from_handle(self.tag.get_handle())
|
||||||
if cmp(self.tag.serialize(), orig.serialize()):
|
if cmp(self.tag.serialize(), orig.serialize()):
|
||||||
trans = self.db.transaction_begin()
|
msg = _("Edit Tag (%s)") % self.tag.get_name()
|
||||||
self.db.commit_tag(self.tag, trans)
|
with DbTxn(msg, self.db) as trans:
|
||||||
self.db.transaction_commit(trans,
|
self.db.commit_tag(self.tag, trans)
|
||||||
_("Edit Tag (%s)") % self.tag.get_name())
|
|
||||||
|
|
||||||
def _create_dialog(self):
|
def _create_dialog(self):
|
||||||
"""
|
"""
|
||||||
|
Reference in New Issue
Block a user