Add button to automatically fill in Author sort field from Author field

This commit is contained in:
Kovid Goyal 2008-09-05 17:32:31 -07:00
parent 04a5bf16bd
commit 9e9e10c388
5 changed files with 1510 additions and 9 deletions

View File

@ -256,7 +256,6 @@ if __name__ == '__main__':
with open('images.qrc', 'wb') as f:
f.write(manifest)
subprocess.check_call(['pyrcc4', '-o', images, 'images.qrc'])
os.remove('images.qrc')
else:
print 'Images are up to date'
finally:

View File

@ -241,7 +241,7 @@ class OPF(MetaInformation):
def get_title(self):
title = self.soup.package.metadata.find('dc:title')
if title:
if title and title.string:
return self.ENTITY_PATTERN.sub(entity_to_unicode, title.string).strip()
return self.default_title.strip()

View File

@ -145,6 +145,8 @@ class MetadataSingleDialog(QDialog, Ui_MetadataSingleDialog):
self.edit_tags)
QObject.connect(self.remove_series_button, SIGNAL('clicked()'),
self.remove_unused_series)
QObject.connect(self.auto_author_sort, SIGNAL('clicked()'),
self.deduce_author_sort)
self.connect(self.swap_button, SIGNAL('clicked()'), self.swap_title_author)
self.timeout = float(prefs['network_timeout'])
self.title.setText(db.title(row))
@ -195,6 +197,16 @@ class MetadataSingleDialog(QDialog, Ui_MetadataSingleDialog):
if not pm.isNull():
self.cover.setPixmap(pm)
def deduce_author_sort(self):
au = unicode(self.authors.text())
tokens = au.split()
for x in (',', ';'):
if x in tokens:
tokens.remove(x)
if tokens:
tokens = [tokens[-1]+';'] + tokens[:-1]
self.author_sort.setText(u' '.join(tokens))
def swap_title_author(self):
title = self.title.text()
self.title.setText(self.authors.text())

View File

@ -5,7 +5,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>796</width>
<width>923</width>
<height>715</height>
</rect>
</property>
@ -116,11 +116,29 @@
</widget>
</item>
<item row="2" column="1" colspan="2" >
<widget class="QLineEdit" name="author_sort" >
<property name="toolTip" >
<string>Specify how the author(s) of this book should be sorted. For example Charles Dickens should be sorted as Dickens, Charles.</string>
</property>
</widget>
<layout class="QHBoxLayout" name="horizontalLayout" >
<item>
<widget class="QLineEdit" name="author_sort" >
<property name="toolTip" >
<string>Specify how the author(s) of this book should be sorted. For example Charles Dickens should be sorted as Dickens, Charles.</string>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="auto_author_sort" >
<property name="toolTip" >
<string>Automatically create the author sort entry based on the current author entry</string>
</property>
<property name="text" >
<string>...</string>
</property>
<property name="icon" >
<iconset resource="../images.qrc" >
<normaloff>:/images/auto_author_sort.svg</normaloff>:/images/auto_author_sort.svg</iconset>
</property>
</widget>
</item>
</layout>
</item>
<item row="3" column="0" >
<widget class="QLabel" name="label_6" >

File diff suppressed because it is too large Load Diff

After

Width:  |  Height:  |  Size: 46 KiB