From 4b338c527419a9e6ccd5780f3d9e815b46cb611f Mon Sep 17 00:00:00 2001 From: John Schember Date: Sun, 5 Jul 2009 18:35:23 -0400 Subject: [PATCH] Auto completes in convert dialog. --- src/calibre/gui2/convert/metadata.py | 47 ++++++++++++++++++----- src/calibre/gui2/convert/metadata.ui | 43 ++++++++++----------- src/calibre/gui2/dialogs/metadata_bulk.py | 1 - 3 files changed, 59 insertions(+), 32 deletions(-) diff --git a/src/calibre/gui2/convert/metadata.py b/src/calibre/gui2/convert/metadata.py index 01eb5bee1c..82e7b21148 100644 --- a/src/calibre/gui2/convert/metadata.py +++ b/src/calibre/gui2/convert/metadata.py @@ -35,21 +35,17 @@ class MetadataWidget(Widget, Ui_Form): self.connect(self.cover_button, SIGNAL("clicked()"), self.select_cover) def initialize_metadata_options(self): - all_series = self.db.all_series() - all_series.sort(cmp=lambda x, y : cmp(x[1], y[1])) - for series in all_series: - self.series.addItem(series[1]) - self.series.setCurrentIndex(-1) + self.initialize_combos() mi = self.db.get_metadata(self.book_id, index_is_id=True) self.title.setText(mi.title) if mi.authors: - self.author.setText(authors_to_string(mi.authors)) - else: - self.author.setText('') - self.publisher.setText(mi.publisher if mi.publisher else '') + 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 '') self.tags.setText(', '.join(mi.tags if mi.tags else [])) + self.tags.update_tags_cache(self.db.all_tags()) self.comment.setText(mi.comments if mi.comments else '') if mi.series: self.series.setCurrentIndex(self.series.findText(mi.series)) @@ -66,6 +62,39 @@ class MetadataWidget(Widget, Ui_Form): if not pm.isNull(): self.cover.setPixmap(pm) + def initialize_combos(self): + self.initalize_authors() + self.initialize_series() + self.initialize_publisher() + + def initalize_authors(self): + all_authors = self.db.all_authors() + all_authors.sort(cmp=lambda x, y : cmp(x[1], y[1])) + + for i in all_authors: + id, name = i + name = authors_to_string([name.strip().replace('|', ',') for n in name.split(',')]) + self.author.addItem(name) + self.author.setCurrentIndex(-1) + + def initialize_series(self): + all_series = self.db.all_series() + all_series.sort(cmp=lambda x, y : cmp(x[1], y[1])) + + for i in all_series: + id, name = i + self.series.addItem(name) + self.series.setCurrentIndex(-1) + + def initialize_publisher(self): + all_publishers = self.db.all_publishers() + all_publishers.sort(cmp=lambda x, y : cmp(x[1], y[1])) + + for i in all_publishers: + id, name = i + self.publisher.addItem(name) + self.publisher.setCurrentIndex(-1) + def get_title_and_authors(self): title = unicode(self.title.text()).strip() if not title: diff --git a/src/calibre/gui2/convert/metadata.ui b/src/calibre/gui2/convert/metadata.ui index e4533de24c..3abe8ece55 100644 --- a/src/calibre/gui2/convert/metadata.ui +++ b/src/calibre/gui2/convert/metadata.ui @@ -143,19 +143,6 @@ - - - - - 1 - 0 - - - - Change the author(s) of this book. Multiple authors should be separated by an &. If the author name contains an &, use && to represent it. - - - @@ -195,13 +182,6 @@ - - - - Change the publisher of this book - - - @@ -216,7 +196,7 @@ - + Tags categorize the book. This is particularly useful while searching. <br><br>They can be any words or phrases, separated by commas. @@ -276,6 +256,20 @@ + + + + true + + + + + + + true + + + @@ -329,11 +323,16 @@ QComboBox
widgets.h
+ + TagsLineEdit + QLineEdit +
widgets.h
+
- + diff --git a/src/calibre/gui2/dialogs/metadata_bulk.py b/src/calibre/gui2/dialogs/metadata_bulk.py index 5b3b7fa3d4..622ea95a2b 100644 --- a/src/calibre/gui2/dialogs/metadata_bulk.py +++ b/src/calibre/gui2/dialogs/metadata_bulk.py @@ -42,7 +42,6 @@ class MetadataBulkDialog(QDialog, Ui_MetadataBulkDialog): self.exec_() - def initialize_combos(self): self.initalize_authors() self.initialize_series()