Add 'manage authors' to the authors pulldown menu in edit single

This commit is contained in:
Charles Haley 2011-05-05 22:48:24 +01:00
parent 022925988a
commit 746d16d0ef
2 changed files with 22 additions and 3 deletions

View File

@ -156,7 +156,7 @@ class AuthorsEdit(MultiCompleteComboBox):
TOOLTIP = '' TOOLTIP = ''
LABEL = _('&Author(s):') LABEL = _('&Author(s):')
def __init__(self, parent): def __init__(self, parent, manage_authors):
self.dialog = parent self.dialog = parent
self.books_to_refresh = set([]) self.books_to_refresh = set([])
MultiCompleteComboBox.__init__(self, parent) MultiCompleteComboBox.__init__(self, parent)
@ -164,6 +164,22 @@ class AuthorsEdit(MultiCompleteComboBox):
self.setWhatsThis(self.TOOLTIP) self.setWhatsThis(self.TOOLTIP)
self.setEditable(True) self.setEditable(True)
self.setSizeAdjustPolicy(self.AdjustToMinimumContentsLengthWithIcon) self.setSizeAdjustPolicy(self.AdjustToMinimumContentsLengthWithIcon)
manage_authors.triggered.connect(self.manage_authors)
def manage_authors(self):
if self.original_val != self.current_val:
if (question_dialog(self, _('Authors changed'),
_('You have changed the authors for this book. You must save '
'these changes before you can use Manage authors. Do you '
'want to save these changes?'), show_copy_button=False)):
self.commit(self.db, self.id_)
self.db.commit()
self.original_val = self.current_val
else:
self.current_val = self.original_val
self.dialog.parent().do_author_sort_edit(self, self.id_)
self.initialize(self.db, self.id_)
self.dialog.author_sort.initialize(self.db, self.id_)
def get_default(self): def get_default(self):
return _('Unknown') return _('Unknown')
@ -175,7 +191,7 @@ class AuthorsEdit(MultiCompleteComboBox):
self.clear() self.clear()
for i in all_authors: for i in all_authors:
id, name = i id, name = i
name = [name.strip().replace('|', ',') for n in name.split(',')] name = name.strip().replace('|', ',')
self.addItem(authors_to_string(name)) self.addItem(authors_to_string(name))
self.set_separator('&') self.set_separator('&')
@ -188,6 +204,8 @@ class AuthorsEdit(MultiCompleteComboBox):
au = _('Unknown') au = _('Unknown')
self.current_val = [a.strip().replace('|', ',') for a in au.split(',')] self.current_val = [a.strip().replace('|', ',') for a in au.split(',')]
self.original_val = self.current_val self.original_val = self.current_val
self.id_ = id_
self.db = db
def commit(self, db, id_): def commit(self, db, id_):
authors = self.current_val authors = self.current_val

View File

@ -111,8 +111,9 @@ class MetadataSingleDialogBase(ResizableDialog):
b.m = m = QMenu() b.m = m = QMenu()
ac = m.addAction(QIcon(I('forward.png')), _('Set author sort from author')) ac = m.addAction(QIcon(I('forward.png')), _('Set author sort from author'))
ac2 = m.addAction(QIcon(I('back.png')), _('Set author from author sort')) ac2 = m.addAction(QIcon(I('back.png')), _('Set author from author sort'))
ac3 = m.addAction(QIcon(I('user_profile.png')), _('Manage authors'))
b.setMenu(m) b.setMenu(m)
self.authors = AuthorsEdit(self) self.authors = AuthorsEdit(self, ac3)
self.author_sort = AuthorSortEdit(self, self.authors, b, self.db, ac, self.author_sort = AuthorSortEdit(self, self.authors, b, self.db, ac,
ac2) ac2)
self.basic_metadata_widgets.extend([self.authors, self.author_sort]) self.basic_metadata_widgets.extend([self.authors, self.author_sort])