From cfa57f63df7e4fe8d683082e780b7df31c52fabb Mon Sep 17 00:00:00 2001 From: John Schember Date: Sun, 16 Jan 2011 17:14:26 -0500 Subject: [PATCH] GUI: Have Authors combo boxes use completion using & just like tags use completion with , --- src/calibre/gui2/convert/metadata.py | 3 + src/calibre/gui2/convert/metadata.ui | 69 +++++++++------------ src/calibre/gui2/dialogs/metadata_bulk.py | 4 ++ src/calibre/gui2/dialogs/metadata_bulk.ui | 19 +++--- src/calibre/gui2/dialogs/metadata_single.py | 4 ++ src/calibre/gui2/dialogs/metadata_single.ui | 51 +++++++-------- src/calibre/gui2/dialogs/search.py | 3 + src/calibre/gui2/dialogs/search.ui | 13 ++-- src/calibre/gui2/widgets.py | 16 +++++ 9 files changed, 104 insertions(+), 78 deletions(-) diff --git a/src/calibre/gui2/convert/metadata.py b/src/calibre/gui2/convert/metadata.py index de03033060..5f39202e26 100644 --- a/src/calibre/gui2/convert/metadata.py +++ b/src/calibre/gui2/convert/metadata.py @@ -68,6 +68,9 @@ class MetadataWidget(Widget, Ui_Form): def initialize_metadata_options(self): self.initialize_combos() self.author.editTextChanged.connect(self.deduce_author_sort) + self.author.set_separator('&') + self.author.set_space_before_sep(True) + self.author.update_items_cache(self.db.all_author_names()) mi = self.db.get_metadata(self.book_id, index_is_id=True) self.title.setText(mi.title) diff --git a/src/calibre/gui2/convert/metadata.ui b/src/calibre/gui2/convert/metadata.ui index 5735193424..24b7c0904a 100644 --- a/src/calibre/gui2/convert/metadata.ui +++ b/src/calibre/gui2/convert/metadata.ui @@ -20,38 +20,8 @@ Book Cover - - - - - - - 0 - 0 - - - - - - - - - - Use cover from &source file - - - true - - - - - 6 - - - 0 - @@ -64,12 +34,6 @@ - - 6 - - - 0 - @@ -86,7 +50,7 @@ ... - + :/images/document_open.png:/images/document_open.png @@ -95,6 +59,30 @@ + + + + Use cover from &source file + + + true + + + + + + + + + + 0 + 0 + + + + + + opt_prefer_metadata_cover @@ -255,7 +243,7 @@ - + true @@ -320,6 +308,11 @@
calibre/gui2/widgets.h
1 + + CompleteComboBox + QComboBox +
widgets.h
+
title diff --git a/src/calibre/gui2/dialogs/metadata_bulk.py b/src/calibre/gui2/dialogs/metadata_bulk.py index c7d5add912..2b3a319663 100644 --- a/src/calibre/gui2/dialogs/metadata_bulk.py +++ b/src/calibre/gui2/dialogs/metadata_bulk.py @@ -726,6 +726,10 @@ class MetadataBulkDialog(ResizableDialog, Ui_MetadataBulkDialog): name = name.strip().replace('|', ',') self.authors.addItem(name) self.authors.setEditText('') + + self.authors.set_separator('&') + self.authors.set_space_before_sep(True) + self.authors.update_items_cache(self.db.all_author_names()) def initialize_series(self): all_series = self.db.all_series() diff --git a/src/calibre/gui2/dialogs/metadata_bulk.ui b/src/calibre/gui2/dialogs/metadata_bulk.ui index b826f8d48d..3950026325 100644 --- a/src/calibre/gui2/dialogs/metadata_bulk.ui +++ b/src/calibre/gui2/dialogs/metadata_bulk.ui @@ -14,7 +14,7 @@ Edit Meta information - + :/images/edit_input.png:/images/edit_input.png @@ -45,7 +45,7 @@ 0 0 842 - 589 + 553 @@ -76,7 +76,7 @@
- + true @@ -210,7 +210,7 @@ Open Tag Editor - + :/images/chapters.png:/images/chapters.png @@ -381,7 +381,7 @@ from the value in the box ... - + :/images/trash.png:/images/trash.png @@ -874,8 +874,8 @@ not multiple and the destination field is multiple 0 0 - 197 - 60 + 231 + 82 @@ -964,6 +964,11 @@ not multiple and the destination field is multiple QLineEdit
widgets.h
+ + CompleteComboBox + QComboBox +
widgets.h
+
authors diff --git a/src/calibre/gui2/dialogs/metadata_single.py b/src/calibre/gui2/dialogs/metadata_single.py index 139b8a2ebe..4ca2072317 100644 --- a/src/calibre/gui2/dialogs/metadata_single.py +++ b/src/calibre/gui2/dialogs/metadata_single.py @@ -724,6 +724,10 @@ class MetadataSingleDialog(ResizableDialog, Ui_MetadataSingleDialog): au = _('Unknown') au = ' & '.join([a.strip().replace('|', ',') for a in au.split(',')]) self.authors.setEditText(au) + + self.authors.set_separator('&') + self.authors.set_space_before_sep(True) + self.authors.update_items_cache(self.db.all_author_names()) def initialize_series(self): self.series.setSizeAdjustPolicy(self.series.AdjustToContentsOnFirstShow) diff --git a/src/calibre/gui2/dialogs/metadata_single.ui b/src/calibre/gui2/dialogs/metadata_single.ui index b95267a618..b2f42937da 100644 --- a/src/calibre/gui2/dialogs/metadata_single.ui +++ b/src/calibre/gui2/dialogs/metadata_single.ui @@ -20,7 +20,7 @@ Edit Meta Information - + :/images/edit_input.png:/images/edit_input.png @@ -43,8 +43,8 @@ 0 0 - 986 - 677 + 955 + 665 @@ -125,7 +125,7 @@ Using this button to create title sort will change title sort from red to green. ... - + :/images/auto_author_sort.png:/images/auto_author_sort.png @@ -152,7 +152,7 @@ Using this button to create title sort will change title sort from red to green. ... - + :/images/swap.png:/images/swap.png @@ -186,7 +186,7 @@ Using this button to create author sort will change author sort from red to gree ... - + :/images/auto_author_sort.png:/images/auto_author_sort.png @@ -240,7 +240,7 @@ Using this button to create author sort will change author sort from red to gree
- + true @@ -352,7 +352,7 @@ If the box is colored green, then text matches the individual author's sort stri Open Tag Editor - + :/images/chapters.png:/images/chapters.png @@ -405,7 +405,7 @@ If the box is colored green, then text matches the individual author's sort stri ... - + :/images/trash.png:/images/trash.png @@ -491,7 +491,7 @@ If the box is colored green, then text matches the individual author's sort stri Clear published date - + :/images/trash.png:/images/trash.png @@ -550,15 +550,9 @@ If the box is colored green, then text matches the individual author's sort stri - - 6 - QLayout::SetMaximumSize - - 0 - @@ -571,19 +565,13 @@ If the box is colored green, then text matches the individual author's sort stri - - 6 - - - 0 - &Browse - + :/images/document_open.png:/images/document_open.png @@ -597,7 +585,7 @@ If the box is colored green, then text matches the individual author's sort stri T&rim - + :/images/trim.png:/images/trim.png @@ -611,7 +599,7 @@ If the box is colored green, then text matches the individual author's sort stri &Remove - + :/images/trash.png:/images/trash.png @@ -702,7 +690,7 @@ If the box is colored green, then text matches the individual author's sort stri ... - + :/images/add_book.png:/images/add_book.png @@ -722,7 +710,7 @@ If the box is colored green, then text matches the individual author's sort stri ... - + :/images/trash.png:/images/trash.png @@ -742,7 +730,7 @@ If the box is colored green, then text matches the individual author's sort stri ... - + :/images/book.png:/images/book.png @@ -762,7 +750,7 @@ If the box is colored green, then text matches the individual author's sort stri - + :/images/edit_input.png:/images/edit_input.png @@ -863,6 +851,11 @@ If the box is colored green, then text matches the individual author's sort stri
calibre/gui2/comments_editor.h
1 + + CompleteComboBox + QComboBox +
widgets.h
+
title diff --git a/src/calibre/gui2/dialogs/search.py b/src/calibre/gui2/dialogs/search.py index 4f72fa915e..95c7cf9225 100644 --- a/src/calibre/gui2/dialogs/search.py +++ b/src/calibre/gui2/dialogs/search.py @@ -31,6 +31,9 @@ class SearchDialog(QDialog, Ui_Dialog): self.authors_box.setEditText('') self.authors_box.completer().setCompletionMode(QCompleter.PopupCompletion) self.authors_box.setAutoCompletionCaseSensitivity(Qt.CaseInsensitive) + self.authors_box.set_separator('&') + self.authors_box.set_space_before_sep(True) + self.authors_box.update_items_cache(self.db.all_author_names()) all_series = db.all_series() all_series.sort(key=lambda x : sort_key(x[1])) diff --git a/src/calibre/gui2/dialogs/search.ui b/src/calibre/gui2/dialogs/search.ui index 519ae8c462..06ea9de379 100644 --- a/src/calibre/gui2/dialogs/search.ui +++ b/src/calibre/gui2/dialogs/search.ui @@ -6,15 +6,15 @@ 0 0 - 731 - 411 + 752 + 472
Advanced Search - + :/images/search.png:/images/search.png @@ -265,7 +265,7 @@
- + Enter an author's name. Only one author can be used. @@ -364,6 +364,11 @@ QLineEdit
widgets.h
+ + CompleteComboBox + QComboBox +
widgets.h
+
all diff --git a/src/calibre/gui2/widgets.py b/src/calibre/gui2/widgets.py index 6e2d52f835..0bb5ee7634 100644 --- a/src/calibre/gui2/widgets.py +++ b/src/calibre/gui2/widgets.py @@ -540,6 +540,22 @@ class EnComboBox(QComboBox): idx = 0 self.setCurrentIndex(idx) +class CompleteComboBox(EnComboBox): + + def __init__(self, *args): + EnComboBox.__init__(self, *args) + self.setLineEdit(CompleteLineEdit(self)) + + def update_items_cache(self, complete_items): + self.lineEdit().update_items_cache(complete_items) + + def set_separator(self, sep): + self.lineEdit().set_separator(sep) + + def set_space_before_sep(self, space_before): + self.lineEdit().set_space_before_sep(space_before) + + class HistoryLineEdit(QComboBox): lost_focus = pyqtSignal()