mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Merge branch 'master' of https://github.com/cbhaley/calibre
This commit is contained in:
commit
52a8da38ac
@ -874,6 +874,11 @@ def get_field_list(db, use_defaults=False, pref_data_override=None):
|
|||||||
return [(k,v) for k,v in result.items()]
|
return [(k,v) for k,v in result.items()]
|
||||||
|
|
||||||
|
|
||||||
|
def get_custom_columns_to_display_in_editor(db):
|
||||||
|
return list([k[0] for k in
|
||||||
|
get_field_list(db, use_defaults=db.prefs['edit_metadata_ignore_display_order']) if k[1]])
|
||||||
|
|
||||||
|
|
||||||
def populate_metadata_page(layout, db, book_id, bulk=False, two_column=False, parent=None):
|
def populate_metadata_page(layout, db, book_id, bulk=False, two_column=False, parent=None):
|
||||||
def widget_factory(typ, key):
|
def widget_factory(typ, key):
|
||||||
if bulk:
|
if bulk:
|
||||||
@ -886,7 +891,7 @@ def populate_metadata_page(layout, db, book_id, bulk=False, two_column=False, pa
|
|||||||
fm = db.field_metadata
|
fm = db.field_metadata
|
||||||
|
|
||||||
# Get list of all non-composite custom fields. We must make widgets for these
|
# Get list of all non-composite custom fields. We must make widgets for these
|
||||||
cols = [k[0] for k in get_field_list(db, use_defaults=db.prefs['edit_metadata_ignore_display_order']) if k[1]]
|
cols = get_custom_columns_to_display_in_editor(db)
|
||||||
# This deals with the historical behavior where comments fields go to the
|
# This deals with the historical behavior where comments fields go to the
|
||||||
# bottom, starting on the left hand side. If a comment field is moved to
|
# bottom, starting on the left hand side. If a comment field is moved to
|
||||||
# somewhere else then it isn't moved to either side.
|
# somewhere else then it isn't moved to either side.
|
||||||
|
@ -972,6 +972,7 @@ class GridView(QListView):
|
|||||||
cache_valid = None
|
cache_valid = None
|
||||||
else:
|
else:
|
||||||
# A cover is in the cache. Check whether it is up to date.
|
# A cover is in the cache. Check whether it is up to date.
|
||||||
|
# Note that if tcdata is not None then it is already a PIL image.
|
||||||
has_cover, tcdata, timestamp = db.new_api.cover_or_cache(book_id, timestamp,
|
has_cover, tcdata, timestamp = db.new_api.cover_or_cache(book_id, timestamp,
|
||||||
as_what='pil_image')
|
as_what='pil_image')
|
||||||
if has_cover:
|
if has_cover:
|
||||||
@ -1012,12 +1013,6 @@ class GridView(QListView):
|
|||||||
if cover_tuple.has_cover:
|
if cover_tuple.has_cover:
|
||||||
# cdata contains either the resized thumbnail, the full cover.jpg
|
# cdata contains either the resized thumbnail, the full cover.jpg
|
||||||
# rendered as a PIL image, or None if cover.jpg isn't valid
|
# rendered as a PIL image, or None if cover.jpg isn't valid
|
||||||
if cdata.getbbox() is None and cover_tuple.cache_valid:
|
|
||||||
# Something wrong with the cover data in the cache. Remove it
|
|
||||||
# from the cache and queue it to render again.
|
|
||||||
tc.invalidate((book_id,))
|
|
||||||
self.render_queue.put(book_id)
|
|
||||||
return None
|
|
||||||
if not cover_tuple.cache_valid:
|
if not cover_tuple.cache_valid:
|
||||||
# The cover isn't in the cache, is stale, or isn't a valid
|
# The cover isn't in the cache, is stale, or isn't a valid
|
||||||
# image. We might have the image from cover.jpg, in which case
|
# image. We might have the image from cover.jpg, in which case
|
||||||
@ -1052,6 +1047,20 @@ class GridView(QListView):
|
|||||||
# The cover data isn't valid. Remove it from the cache
|
# The cover data isn't valid. Remove it from the cache
|
||||||
tc.invalidate((book_id,))
|
tc.invalidate((book_id,))
|
||||||
else:
|
else:
|
||||||
|
# Test to see if there is something wrong with the cover data in
|
||||||
|
# the cache. If so, remove it from the cache and queue it to
|
||||||
|
# render again. It isn't clear that this can ever happen. One
|
||||||
|
# possibility is if different versions of calibre are used
|
||||||
|
# interchangeably.
|
||||||
|
def getbbox(img):
|
||||||
|
try:
|
||||||
|
return img.getbbox()
|
||||||
|
except Exception:
|
||||||
|
return None
|
||||||
|
if getbbox(cdata) is None:
|
||||||
|
tc.invalidate((book_id,))
|
||||||
|
self.render_queue.put(book_id)
|
||||||
|
return None
|
||||||
# The data from the cover cache is valid and is already a thumb.
|
# The data from the cover cache is valid and is already a thumb.
|
||||||
thumb = cdata
|
thumb = cdata
|
||||||
else:
|
else:
|
||||||
|
@ -19,7 +19,8 @@ from calibre.constants import ismacos
|
|||||||
from calibre.ebooks.metadata import authors_to_string, string_to_authors
|
from calibre.ebooks.metadata import authors_to_string, string_to_authors
|
||||||
from calibre.ebooks.metadata.book.base import Metadata
|
from calibre.ebooks.metadata.book.base import Metadata
|
||||||
from calibre.gui2 import error_dialog, gprefs, pixmap_to_data
|
from calibre.gui2 import error_dialog, gprefs, pixmap_to_data
|
||||||
from calibre.gui2.custom_column_widgets import Comments, populate_metadata_page
|
from calibre.gui2.custom_column_widgets import (
|
||||||
|
Comments, populate_metadata_page, get_custom_columns_to_display_in_editor)
|
||||||
from calibre.gui2.dialogs.confirm_delete import confirm
|
from calibre.gui2.dialogs.confirm_delete import confirm
|
||||||
from calibre.gui2.metadata.basic_widgets import (
|
from calibre.gui2.metadata.basic_widgets import (
|
||||||
AuthorsEdit, AuthorSortEdit, BuddyLabel, CommentsEdit, Cover, DateEdit,
|
AuthorsEdit, AuthorSortEdit, BuddyLabel, CommentsEdit, Cover, DateEdit,
|
||||||
@ -121,7 +122,7 @@ class MetadataSingleDialogBase(QDialog):
|
|||||||
|
|
||||||
self.create_basic_metadata_widgets()
|
self.create_basic_metadata_widgets()
|
||||||
|
|
||||||
if len(self.db.custom_column_label_map):
|
if len(get_custom_columns_to_display_in_editor(self.db)):
|
||||||
self.create_custom_metadata_widgets()
|
self.create_custom_metadata_widgets()
|
||||||
self.comments_edit_state_at_apply = {self.comments:None}
|
self.comments_edit_state_at_apply = {self.comments:None}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user