From 524928c6bc74a79f210843cebeb7a3007d855e46 Mon Sep 17 00:00:00 2001
From: Charles Haley <>
Date: Thu, 16 Sep 2010 19:34:17 +0100
Subject: [PATCH 1/2] Add coloring to author_sort box in edit metadata single
---
src/calibre/gui2/dialogs/metadata_single.py | 24 +++++++++++++++++++++
1 file changed, 24 insertions(+)
diff --git a/src/calibre/gui2/dialogs/metadata_single.py b/src/calibre/gui2/dialogs/metadata_single.py
index 3d79b01c14..ac10847f3d 100644
--- a/src/calibre/gui2/dialogs/metadata_single.py
+++ b/src/calibre/gui2/dialogs/metadata_single.py
@@ -375,6 +375,10 @@ class MetadataSingleDialog(ResizableDialog, Ui_MetadataSingleDialog):
self.remove_unused_series)
QObject.connect(self.auto_author_sort, SIGNAL('clicked()'),
self.deduce_author_sort)
+ self.connect(self.author_sort, SIGNAL('textChanged(const QString&)'),
+ self.author_sort_box_changed)
+ self.connect(self.authors, SIGNAL('editTextChanged(const QString&)'),
+ self.authors_box_changed)
self.connect(self.formats, SIGNAL('itemDoubleClicked(QListWidgetItem*)'),
self.show_format)
self.connect(self.formats, SIGNAL('delete_format()'), self.remove_format)
@@ -467,6 +471,26 @@ class MetadataSingleDialog(ResizableDialog, Ui_MetadataSingleDialog):
for c in range(2, len(ans[i].widgets), 2):
w.setTabOrder(ans[i].widgets[c-1], ans[i].widgets[c+1])
+ def authors_box_changed(self, txt):
+ aus = unicode(txt)
+ aus = re.sub(r'\s+et al\.$', '', aus)
+ aus = self.db.author_sort_from_authors(string_to_authors(aus))
+ self.mark_author_sort(normal=(unicode(self.author_sort.text()) == aus))
+
+ def author_sort_box_changed(self, txt):
+ au = unicode(self.authors.text())
+ au = re.sub(r'\s+et al\.$', '', au)
+ au = self.db.author_sort_from_authors(string_to_authors(au))
+ self.mark_author_sort(normal=(au == txt))
+
+ def mark_author_sort(self, normal=True):
+ if normal:
+ col = 'rgb(0, 255, 0, 20%)'
+ else:
+ col = 'rgb(255, 0, 0, 20%)'
+ self.author_sort.setStyleSheet('QLineEdit { color: black; '
+ 'background-color: %s; }'%col)
+
def validate_isbn(self, isbn):
isbn = unicode(isbn).strip()
if not isbn:
From 5ccc90ed0ca226656ed342264da201e0fc613834 Mon Sep 17 00:00:00 2001
From: Charles Haley <>
Date: Thu, 16 Sep 2010 21:00:13 +0100
Subject: [PATCH 2/2] Add tooltips for coloring author sort.
---
src/calibre/gui2/dialogs/metadata_single.ui | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/src/calibre/gui2/dialogs/metadata_single.ui b/src/calibre/gui2/dialogs/metadata_single.ui
index 7184192eba..74febf9c29 100644
--- a/src/calibre/gui2/dialogs/metadata_single.ui
+++ b/src/calibre/gui2/dialogs/metadata_single.ui
@@ -151,14 +151,16 @@
-
- Specify how the author(s) of this book should be sorted. For example Charles Dickens should be sorted as Dickens, Charles.
+ Specify how the author(s) of this book should be sorted. For example Charles Dickens should be sorted as Dickens, Charles.
+If the box is colored green, then text matches the individual author's sort strings. If it is colored red, then the authors and this text do not match.
-
- Automatically create the author sort entry based on the current author entry
+ Automatically create the author sort entry based on the current author entry.
+Using this button to create author sort will change author sort from red to green.
...