Show multiple authors correctly in metadata dialogs.

This commit is contained in:
John Schember 2009-07-13 12:57:55 -04:00
parent dcdda76dbc
commit f1806c4aa2
2 changed files with 13 additions and 11 deletions

View File

@ -39,8 +39,8 @@ class MetadataWidget(Widget, Ui_Form):
mi = self.db.get_metadata(self.book_id, index_is_id=True)
self.title.setText(mi.title)
if mi.authors:
self.author.setCurrentIndex(self.author.findText(authors_to_string(mi.authors)))
# if mi.authors:
# self.author.setCurrentIndex(self.author.findText(authors_to_string(mi.authors)))
if mi.publisher:
self.publisher.setCurrentIndex(self.publisher.findText(mi.publisher))
self.author_sort.setText(mi.author_sort if mi.author_sort else '')
@ -75,7 +75,12 @@ class MetadataWidget(Widget, Ui_Form):
id, name = i
name = authors_to_string([name.strip().replace('|', ',') for n in name.split(',')])
self.author.addItem(name)
self.author.setCurrentIndex(-1)
au = self.db.authors(self.book_id, True)
if not au:
au = _('Unknown')
au = ' & '.join([a.strip().replace('|', ',') for a in au.split(',')])
self.author.setEditText(au)
def initialize_series(self):
all_series = self.db.all_series()

View File

@ -330,19 +330,16 @@ class MetadataSingleDialog(ResizableDialog, Ui_MetadataSingleDialog):
def initalize_authors(self):
all_authors = self.db.all_authors()
all_authors.sort(cmp=lambda x, y : cmp(x[1], y[1]))
author_id = self.db.author_id(self.row)
idx, c = None, 0
for i in all_authors:
id, name = i
if id == author_id:
idx = c
name = [name.strip().replace('|', ',') for n in name.split(',')]
self.authors.addItem(authors_to_string(name))
c += 1
self.authors.setEditText('')
if idx is not None:
self.authors.setCurrentIndex(idx)
au = self.db.authors(self.row)
if not au:
au = _('Unknown')
au = ' & '.join([a.strip().replace('|', ',') for a in au.split(',')])
self.authors.setEditText(au)
def initialize_series(self):
self.series.setSizeAdjustPolicy(self.series.AdjustToContentsOnFirstShow)