From f1806c4aa2c431c17cb1f126effbb5390e8441aa Mon Sep 17 00:00:00 2001 From: John Schember Date: Mon, 13 Jul 2009 12:57:55 -0400 Subject: [PATCH] Show multiple authors correctly in metadata dialogs. --- src/calibre/gui2/convert/metadata.py | 11 ++++++++--- src/calibre/gui2/dialogs/metadata_single.py | 13 +++++-------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/src/calibre/gui2/convert/metadata.py b/src/calibre/gui2/convert/metadata.py index 82e7b21148..513535df1b 100644 --- a/src/calibre/gui2/convert/metadata.py +++ b/src/calibre/gui2/convert/metadata.py @@ -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() diff --git a/src/calibre/gui2/dialogs/metadata_single.py b/src/calibre/gui2/dialogs/metadata_single.py index 0c2211e5c7..13acd161ae 100644 --- a/src/calibre/gui2/dialogs/metadata_single.py +++ b/src/calibre/gui2/dialogs/metadata_single.py @@ -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)