mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-08 10:44:09 -04:00
Duplicates dialog: Sort sub-list of matching books already in calibre by author for easier inspection. Fixes #1851386 [[enhancement] sort authors per title in duplicated window after import](https://bugs.launchpad.net/calibre/+bug/1851386)
This commit is contained in:
parent
f6a511e291
commit
bcc9f16df2
@ -14,6 +14,7 @@ from PyQt5.Qt import (
|
|||||||
|
|
||||||
from calibre.gui2 import gprefs
|
from calibre.gui2 import gprefs
|
||||||
from calibre.ebooks.metadata import authors_to_string
|
from calibre.ebooks.metadata import authors_to_string
|
||||||
|
from calibre.utils.icu import primary_sort_key
|
||||||
from polyglot.builtins import unicode_type, range
|
from polyglot.builtins import unicode_type, range
|
||||||
|
|
||||||
|
|
||||||
@ -119,12 +120,18 @@ class DuplicatesQuestion(QDialog):
|
|||||||
|
|
||||||
add_child(_('Already in calibre:')).setData(0, Qt.FontRole, itf)
|
add_child(_('Already in calibre:')).setData(0, Qt.FontRole, itf)
|
||||||
|
|
||||||
|
author_text = {}
|
||||||
for book_id in matching_books:
|
for book_id in matching_books:
|
||||||
aut = [a.replace('|', ',') for a in (db.authors(book_id,
|
author_text[book_id] = authors_to_string([a.replace('|', ',') for a in (db.authors(book_id,
|
||||||
index_is_id=True) or '').split(',')]
|
index_is_id=True) or '').split(',')])
|
||||||
|
|
||||||
|
def key(x):
|
||||||
|
return primary_sort_key(unicode_type(author_text[x]))
|
||||||
|
|
||||||
|
for book_id in sorted(matching_books, key=key):
|
||||||
add_child(ta%dict(
|
add_child(ta%dict(
|
||||||
title=db.title(book_id, index_is_id=True),
|
title=db.title(book_id, index_is_id=True),
|
||||||
author=authors_to_string(aut),
|
author=author_text[book_id],
|
||||||
formats=db.formats(book_id, index_is_id=True,
|
formats=db.formats(book_id, index_is_id=True,
|
||||||
verify_formats=False)))
|
verify_formats=False)))
|
||||||
add_child('')
|
add_child('')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user