From 9106694fd0cc3857419554b7a42311e3c6f8e475 Mon Sep 17 00:00:00 2001 From: Charles Haley <> Date: Fri, 17 Sep 2010 20:03:32 +0100 Subject: [PATCH 1/6] Clean up label names --- src/calibre/gui2/dialogs/metadata_bulk.ui | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/calibre/gui2/dialogs/metadata_bulk.ui b/src/calibre/gui2/dialogs/metadata_bulk.ui index d01d3e2ea8..c12182476c 100644 --- a/src/calibre/gui2/dialogs/metadata_bulk.ui +++ b/src/calibre/gui2/dialogs/metadata_bulk.ui @@ -47,7 +47,7 @@ - + &Author(s): @@ -128,7 +128,7 @@ - + &Publisher: @@ -148,7 +148,7 @@ - + Add ta&gs: @@ -244,7 +244,7 @@ - + Remove &format: @@ -338,7 +338,7 @@ Future conversion of these books will use the default settings. - + Search &field: @@ -348,7 +348,7 @@ Future conversion of these books will use the default settings. - + &Search for: @@ -358,7 +358,7 @@ Future conversion of these books will use the default settings. - + &Replace with: @@ -377,7 +377,7 @@ Future conversion of these books will use the default settings. - + Apply function &after replace: @@ -390,7 +390,7 @@ Future conversion of these books will use the default settings. - + Test &text @@ -400,7 +400,7 @@ Future conversion of these books will use the default settings. - + Test re&sult @@ -410,7 +410,7 @@ Future conversion of these books will use the default settings. - + Your test: From 122c2deffce9a7851cdfae674a95ad34e8e40c7b Mon Sep 17 00:00:00 2001 From: Charles Haley <> Date: Fri, 17 Sep 2010 23:00:29 +0100 Subject: [PATCH 2/6] Reset selection in bulk metadata edit --- src/calibre/gui2/actions/edit_metadata.py | 3 +++ src/calibre/gui2/library/views.py | 15 +++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/src/calibre/gui2/actions/edit_metadata.py b/src/calibre/gui2/actions/edit_metadata.py index ac04652efa..ebac7c9a4f 100644 --- a/src/calibre/gui2/actions/edit_metadata.py +++ b/src/calibre/gui2/actions/edit_metadata.py @@ -173,6 +173,8 @@ class EditMetadataAction(InterfaceAction): ''' rows = [r.row() for r in \ self.gui.library_view.selectionModel().selectedRows()] + db = self.gui.library_view.model().db + ids = [db.id(r) for r in rows] if not rows or len(rows) == 0: d = error_dialog(self.gui, _('Cannot edit metadata'), _('No books selected')) @@ -191,6 +193,7 @@ class EditMetadataAction(InterfaceAction): self.gui.tags_view.recount() if self.gui.cover_flow: self.gui.cover_flow.dataChanged() + self.gui.library_view.select_rows_with_id(ids) # Merge books {{{ def merge_books(self, safe_merge=False): diff --git a/src/calibre/gui2/library/views.py b/src/calibre/gui2/library/views.py index d67d286aeb..b364bd5f70 100644 --- a/src/calibre/gui2/library/views.py +++ b/src/calibre/gui2/library/views.py @@ -479,6 +479,21 @@ class BooksView(QTableView): # {{{ sm = self.selectionModel() sm.select(index, sm.ClearAndSelect|sm.Rows) + def select_rows_with_id(self, ids): + ''' + Loop through the visible rows, selecting any that have db_id in ids + ''' + ids = set(ids) + selmode = self.selectionMode() + self.setSelectionMode(QAbstractItemView.MultiSelection) + self.clearSelection() + db = self.model().db + loc = db.FIELD_MAP['id'] + for i in range(0, len(db.data)): + if db.get_property(i, index_is_id=False, loc=loc) in ids: + self.selectRow(i) + self.setSelectionMode(selmode) + def close(self): self._model.close() From ade36c94fa1b2991774316dea30f9ddd1db64548 Mon Sep 17 00:00:00 2001 From: Charles Haley <> Date: Fri, 17 Sep 2010 23:03:00 +0100 Subject: [PATCH 3/6] Fix a comment. Sigh... --- src/calibre/gui2/library/views.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/calibre/gui2/library/views.py b/src/calibre/gui2/library/views.py index b364bd5f70..77d15e69c6 100644 --- a/src/calibre/gui2/library/views.py +++ b/src/calibre/gui2/library/views.py @@ -481,7 +481,7 @@ class BooksView(QTableView): # {{{ def select_rows_with_id(self, ids): ''' - Loop through the visible rows, selecting any that have db_id in ids + Loop through the visible rows, selecting any that have db_id in list ids ''' ids = set(ids) selmode = self.selectionMode() From 6d2c0268daf595fb87bdf31c1594c5ce774aba58 Mon Sep 17 00:00:00 2001 From: Charles Haley <> Date: Fri, 17 Sep 2010 23:17:25 +0100 Subject: [PATCH 4/6] Fix sorting problems (author_sort) --- src/calibre/library/caches.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/calibre/library/caches.py b/src/calibre/library/caches.py index 4f795ab733..211baeb634 100644 --- a/src/calibre/library/caches.py +++ b/src/calibre/library/caches.py @@ -589,9 +589,9 @@ class ResultCache(SearchQueryParser): if field not in self.field_metadata.iterkeys(): if field in ('author', 'tag', 'comment'): field += 's' - if field == 'date': field = 'timestamp' - elif field == 'title': field = 'sort' - elif field == 'authors': field = 'author_sort' + if field == 'date': field = 'timestamp' + elif field == 'title': field = 'sort' + elif field == 'authors': field = 'author_sort' return field def sort(self, field, ascending, subsort=False): From 21006be2926620a7e307adb4001b2d30abbac7f6 Mon Sep 17 00:00:00 2001 From: Charles Haley <> Date: Sat, 18 Sep 2010 12:35:03 +0100 Subject: [PATCH 5/6] Fix click on link in search/replace not opening browser --- src/calibre/gui2/dialogs/metadata_bulk.ui | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/calibre/gui2/dialogs/metadata_bulk.ui b/src/calibre/gui2/dialogs/metadata_bulk.ui index 18d6760ea7..aca7b0cb75 100644 --- a/src/calibre/gui2/dialogs/metadata_bulk.ui +++ b/src/calibre/gui2/dialogs/metadata_bulk.ui @@ -328,6 +328,9 @@ Future conversion of these books will use the default settings. true + + true + From 9139da12eb488262521a6be0e250e802023a9a6d Mon Sep 17 00:00:00 2001 From: Charles Haley <> Date: Sat, 18 Sep 2010 15:01:31 +0100 Subject: [PATCH 6/6] Change vertical bars to commas in author names --- src/calibre/gui2/dialogs/metadata_bulk.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/calibre/gui2/dialogs/metadata_bulk.py b/src/calibre/gui2/dialogs/metadata_bulk.py index b0ba049a7f..2e5c7838ca 100644 --- a/src/calibre/gui2/dialogs/metadata_bulk.py +++ b/src/calibre/gui2/dialogs/metadata_bulk.py @@ -220,6 +220,8 @@ class MetadataBulkDialog(QDialog, Ui_MetadataBulkDialog): if val: val.sort(cmp=lambda x,y: cmp(x.lower(), y.lower())) val = val[0] + if txt == 'authors': + val = val.replace('|', ',') else: val = '' else: @@ -303,6 +305,8 @@ class MetadataBulkDialog(QDialog, Ui_MetadataBulkDialog): # The standard tags and authors values want to be lists. # All custom columns are to be strings val = fm['is_multiple'].join(val) + elif field == 'authors': + val = [v.replace('|', ',') for v in val] else: val = apply_pattern(val)