From e41f8b3a70bcdae8d83a14280faaeb643d8164b2 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Fri, 2 Jan 2009 16:43:21 -0800 Subject: [PATCH] Add completion for author and publisher fields in edit metadata dialog. Fixes #1383 (useful feature ideas) and #1521 --- src/calibre/devices/cybookg3/books.py | 7 ++-- src/calibre/devices/cybookg3/driver.py | 2 +- src/calibre/gui2/dialogs/metadata_single.py | 40 ++++++++++++++++----- src/calibre/gui2/dialogs/metadata_single.ui | 34 ++++++++---------- src/calibre/library/database.py | 14 +++++++- 5 files changed, 64 insertions(+), 33 deletions(-) diff --git a/src/calibre/devices/cybookg3/books.py b/src/calibre/devices/cybookg3/books.py index 5c15919ea6..4e46faca42 100644 --- a/src/calibre/devices/cybookg3/books.py +++ b/src/calibre/devices/cybookg3/books.py @@ -1,5 +1,5 @@ __license__ = 'GPL v3' -__copyright__ = '2008, Kovid Goyal ' +__copyright__ = '2009, John Schember - - - - Change the author(s) of this book. Multiple authors should be separated by an &. If the author name contains an &, use && to represent it. - - - @@ -111,7 +104,7 @@ Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - authors + author_sort @@ -185,13 +178,6 @@ - - - - Change the publisher of this book - - - @@ -330,6 +316,16 @@ + + + + true + + + + + + @@ -615,8 +611,8 @@ accept() - 257 - 646 + 261 + 710 157 @@ -631,8 +627,8 @@ reject() - 325 - 646 + 329 + 710 286 diff --git a/src/calibre/library/database.py b/src/calibre/library/database.py index 122bded333..f14a1174fc 100644 --- a/src/calibre/library/database.py +++ b/src/calibre/library/database.py @@ -943,7 +943,11 @@ ALTER TABLE books ADD COLUMN isbn TEXT DEFAULT "" COLLATE NOCASE; if index_is_id: return self.conn.get('SELECT publisher FROM meta WHERE id=?', (index,), all=False) return self.data[index][3] - + + def publisher_id(self, index, index_is_id=False): + id = index if index_is_id else self.id(index) + return self.conn.get('SELECT publisher from books_publishers_link WHERE book=?', (id,), all=False) + def rating(self, index, index_is_id=False): if index_is_id: return self.conn.get('SELECT rating FROM meta WHERE id=?', (index,), all=False) @@ -1041,6 +1045,14 @@ ALTER TABLE books ADD COLUMN isbn TEXT DEFAULT "" COLLATE NOCASE; def all_series(self): return [ (i[0], i[1]) for i in \ self.conn.get('SELECT id, name FROM series')] + + def all_authors(self): + return [ (i[0], i[1]) for i in \ + self.conn.get('SELECT id, name FROM authors')] + + def all_publishers(self): + return [ (i[0], i[1]) for i in \ + self.conn.get('SELECT id, name FROM publishers')] def all_tags(self): return [i[0].strip() for i in self.conn.get('SELECT name FROM tags') if i[0].strip()]