diff --git a/src/calibre/gui2/dialogs/metadata_single.py b/src/calibre/gui2/dialogs/metadata_single.py
index d25d0609c8..2ddbec7f20 100644
--- a/src/calibre/gui2/dialogs/metadata_single.py
+++ b/src/calibre/gui2/dialogs/metadata_single.py
@@ -265,12 +265,6 @@ class MetadataSingleDialog(ResizableDialog, Ui_MetadataSingleDialog):
if not isbn:
isbn = ''
self.isbn.setText(isbn)
- au = self.db.authors(row)
- if au:
- au = [a.strip().replace('|', ',') for a in au.split(',')]
- self.authors.setText(authors_to_string(au))
- else:
- self.authors.setText('')
aus = self.db.author_sort(row)
self.author_sort.setText(aus if aus else '')
tags = self.db.tags(row)
@@ -295,7 +289,7 @@ class MetadataSingleDialog(ResizableDialog, Ui_MetadataSingleDialog):
Format(self.formats, ext, size)
- self.initialize_series_and_publisher()
+ self.initialize_combos()
self.series_index.setValue(self.db.series_index(row))
QObject.connect(self.series, SIGNAL('currentIndexChanged(int)'), self.enable_series_index)
@@ -331,6 +325,30 @@ class MetadataSingleDialog(ResizableDialog, Ui_MetadataSingleDialog):
def cover_dropped(self):
self.cover_changed = True
+ def initialize_combos(self):
+ self.initalize_authors()
+ self.initialize_series()
+ self.initialize_publisher()
+
+ self.layout().activate()
+
+ 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)
+
def initialize_series(self):
self.series.setSizeAdjustPolicy(self.series.AdjustToContentsOnFirstShow)
all_series = self.db.all_series()
@@ -349,8 +367,7 @@ class MetadataSingleDialog(ResizableDialog, Ui_MetadataSingleDialog):
self.series.setCurrentIndex(idx)
self.enable_series_index()
- def initialize_series_and_publisher(self):
- self.initialize_series()
+ def initialize_publisher(self):
all_publishers = self.db.all_publishers()
all_publishers.sort(cmp=lambda x, y : cmp(x[1], y[1]))
publisher_id = self.db.publisher_id(self.row)
@@ -366,9 +383,6 @@ class MetadataSingleDialog(ResizableDialog, Ui_MetadataSingleDialog):
if idx is not None:
self.publisher.setCurrentIndex(idx)
-
- self.layout().activate()
-
def edit_tags(self):
d = TagEditor(self, self.db, self.row)
d.exec_()
diff --git a/src/calibre/gui2/dialogs/metadata_single.ui b/src/calibre/gui2/dialogs/metadata_single.ui
index bbf1bb0f7b..ff98d22ad3 100644
--- a/src/calibre/gui2/dialogs/metadata_single.ui
+++ b/src/calibre/gui2/dialogs/metadata_single.ui
@@ -121,9 +121,6 @@
Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter
-
- authors
-
-
@@ -345,9 +342,6 @@
- -
-
-
-
@@ -371,6 +365,13 @@
+ -
+
+
+ true
+
+
+
@@ -655,7 +656,6 @@
title
swap_button
- authors
author_sort
auto_author_sort
rating
diff --git a/src/calibre/gui2/widgets.py b/src/calibre/gui2/widgets.py
index 3f7734f8c9..abfe137b99 100644
--- a/src/calibre/gui2/widgets.py
+++ b/src/calibre/gui2/widgets.py
@@ -493,6 +493,8 @@ class EnComboBox(QComboBox):
QComboBox.__init__(self, *args)
self.setLineEdit(EnLineEdit(self))
+ def text(self):
+ return qstring_to_unicode(self.currentText())
class PythonHighlighter(QSyntaxHighlighter):
diff --git a/src/calibre/library/database.py b/src/calibre/library/database.py
index 72b629db0b..ed92853df2 100644
--- a/src/calibre/library/database.py
+++ b/src/calibre/library/database.py
@@ -928,6 +928,10 @@ ALTER TABLE books ADD COLUMN isbn TEXT DEFAULT "" COLLATE NOCASE;
except:
pass
+ def author_id(self, index, index_is_id=False):
+ id = index if index_is_id else self.id(index)
+ return self.conn.get('SELECT author from books_authors_link WHERE book=?', (id,), all=False)
+
def isbn(self, idx, index_is_id=False):
id = idx if index_is_id else self.id(idx)
return self.conn.get('SELECT isbn FROM books WHERE id=?',(id,), all=False)