mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Merge from custcol trunk
This commit is contained in:
commit
644e440df9
@ -141,7 +141,10 @@ def prints(*args, **kwargs):
|
|||||||
raise
|
raise
|
||||||
arg = repr(arg)
|
arg = repr(arg)
|
||||||
|
|
||||||
file.write(arg)
|
try:
|
||||||
|
file.write(arg)
|
||||||
|
except:
|
||||||
|
file.write(repr(arg))
|
||||||
if i != len(args)-1:
|
if i != len(args)-1:
|
||||||
file.write(sep)
|
file.write(sep)
|
||||||
file.write(end)
|
file.write(end)
|
||||||
|
@ -16,7 +16,8 @@ from calibre import prints, guess_type
|
|||||||
from calibre.devices.errors import DeviceError
|
from calibre.devices.errors import DeviceError
|
||||||
from calibre.constants import DEBUG
|
from calibre.constants import DEBUG
|
||||||
from calibre.ebooks.chardet import xml_to_unicode
|
from calibre.ebooks.chardet import xml_to_unicode
|
||||||
from calibre.ebooks.metadata import string_to_authors, authors_to_string
|
from calibre.ebooks.metadata import string_to_authors, authors_to_string, \
|
||||||
|
title_sort
|
||||||
|
|
||||||
# Utility functions {{{
|
# Utility functions {{{
|
||||||
EMPTY_CARD_CACHE = '''\
|
EMPTY_CARD_CACHE = '''\
|
||||||
@ -325,6 +326,7 @@ class XMLCache(object):
|
|||||||
if record is None:
|
if record is None:
|
||||||
record = self.create_text_record(root, i, book.lpath)
|
record = self.create_text_record(root, i, book.lpath)
|
||||||
self.update_text_record(record, book, path, i)
|
self.update_text_record(record, book, path, i)
|
||||||
|
|
||||||
bl_pmap = playlist_map[i]
|
bl_pmap = playlist_map[i]
|
||||||
self.update_playlists(i, root, booklist, bl_pmap,
|
self.update_playlists(i, root, booklist, bl_pmap,
|
||||||
collections_attributes)
|
collections_attributes)
|
||||||
@ -339,15 +341,12 @@ class XMLCache(object):
|
|||||||
collections_attributes):
|
collections_attributes):
|
||||||
collections = booklist.get_collections(collections_attributes)
|
collections = booklist.get_collections(collections_attributes)
|
||||||
for category, books in collections.items():
|
for category, books in collections.items():
|
||||||
for b in books:
|
|
||||||
if self.book_by_lpath(b.lpath, root) is None:
|
|
||||||
print b.lpath
|
|
||||||
records = [self.book_by_lpath(b.lpath, root) for b in books]
|
records = [self.book_by_lpath(b.lpath, root) for b in books]
|
||||||
# Remove any books that were not found, although this
|
# Remove any books that were not found, although this
|
||||||
# *should* never happen
|
# *should* never happen
|
||||||
if DEBUG and None in records:
|
if DEBUG and None in records:
|
||||||
prints('WARNING: Some elements in the JSON cache were not'
|
prints('WARNING: Some elements in the JSON cache were not'
|
||||||
'found in the XML cache')
|
' found in the XML cache')
|
||||||
records = [x for x in records if x is not None]
|
records = [x for x in records if x is not None]
|
||||||
for rec in records:
|
for rec in records:
|
||||||
if rec.get('id', None) is None:
|
if rec.get('id', None) is None:
|
||||||
@ -416,6 +415,10 @@ class XMLCache(object):
|
|||||||
record.set('date', date)
|
record.set('date', date)
|
||||||
record.set('size', str(os.stat(path).st_size))
|
record.set('size', str(os.stat(path).st_size))
|
||||||
record.set('title', book.title)
|
record.set('title', book.title)
|
||||||
|
ts = book.title_sort
|
||||||
|
if not ts:
|
||||||
|
ts = title_sort(book.title)
|
||||||
|
record.set('titleSorter', ts)
|
||||||
record.set('author', authors_to_string(book.authors))
|
record.set('author', authors_to_string(book.authors))
|
||||||
ext = os.path.splitext(path)[1]
|
ext = os.path.splitext(path)[1]
|
||||||
if ext:
|
if ext:
|
||||||
|
@ -8,7 +8,8 @@ __docformat__ = 'restructuredtext en'
|
|||||||
import os
|
import os
|
||||||
from functools import partial
|
from functools import partial
|
||||||
|
|
||||||
from PyQt4.Qt import QTableView, Qt, QAbstractItemView, QMenu, pyqtSignal
|
from PyQt4.Qt import QTableView, Qt, QAbstractItemView, QMenu, pyqtSignal, \
|
||||||
|
QModelIndex
|
||||||
|
|
||||||
from calibre.gui2.library.delegates import RatingDelegate, PubDateDelegate, \
|
from calibre.gui2.library.delegates import RatingDelegate, PubDateDelegate, \
|
||||||
TextDelegate, DateDelegate, TagsDelegate, CcTextDelegate, \
|
TextDelegate, DateDelegate, TagsDelegate, CcTextDelegate, \
|
||||||
@ -110,17 +111,21 @@ class BooksView(QTableView): # {{{
|
|||||||
ac = a if self._model.sorted_on[1] == Qt.AscendingOrder else d
|
ac = a if self._model.sorted_on[1] == Qt.AscendingOrder else d
|
||||||
ac.setCheckable(True)
|
ac.setCheckable(True)
|
||||||
ac.setChecked(True)
|
ac.setChecked(True)
|
||||||
m = self.column_header_context_menu.addMenu(
|
if col not in ('ondevice', 'rating', 'inlibrary') and \
|
||||||
_('Change text alignment for %s') % name)
|
(not self.model().is_custom_column(col) or \
|
||||||
al = self._model.alignment_map.get(col, 'left')
|
self.model().custom_columns[col]['datatype'] not in ('bool',
|
||||||
for x, t in (('left', _('Left')), ('right', _('Right')), ('center',
|
'rating')):
|
||||||
_('Center'))):
|
m = self.column_header_context_menu.addMenu(
|
||||||
a = m.addAction(t,
|
_('Change text alignment for %s') % name)
|
||||||
partial(self.column_header_context_handler,
|
al = self._model.alignment_map.get(col, 'left')
|
||||||
action='align_'+x, column=col))
|
for x, t in (('left', _('Left')), ('right', _('Right')), ('center',
|
||||||
if al == x:
|
_('Center'))):
|
||||||
a.setCheckable(True)
|
a = m.addAction(t,
|
||||||
a.setChecked(True)
|
partial(self.column_header_context_handler,
|
||||||
|
action='align_'+x, column=col))
|
||||||
|
if al == x:
|
||||||
|
a.setCheckable(True)
|
||||||
|
a.setChecked(True)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -288,6 +293,12 @@ class BooksView(QTableView): # {{{
|
|||||||
old_state['sort_history'] = tweaks['sort_columns_at_startup']
|
old_state['sort_history'] = tweaks['sort_columns_at_startup']
|
||||||
|
|
||||||
self.apply_state(old_state)
|
self.apply_state(old_state)
|
||||||
|
|
||||||
|
# Resize all rows to have the correct height
|
||||||
|
if self.model().rowCount(QModelIndex()) > 0:
|
||||||
|
self.resizeRowToContents(0)
|
||||||
|
self.verticalHeader().setDefaultSectionSize(self.rowHeight(0))
|
||||||
|
|
||||||
self.was_restored = True
|
self.was_restored = True
|
||||||
|
|
||||||
# }}}
|
# }}}
|
||||||
|
@ -636,16 +636,9 @@ class Main(MainWindow, Ui_MainWindow, DeviceGUI):
|
|||||||
self.download_scheduled_recipe, Qt.QueuedConnection)
|
self.download_scheduled_recipe, Qt.QueuedConnection)
|
||||||
self.library_view.verticalHeader().sectionClicked.connect(self.view_specific_book)
|
self.library_view.verticalHeader().sectionClicked.connect(self.view_specific_book)
|
||||||
|
|
||||||
if self.library_view.model().rowCount(None) > 1:
|
|
||||||
self.library_view.resizeRowToContents(0)
|
|
||||||
height = self.library_view.rowHeight(0)
|
|
||||||
else:
|
|
||||||
height = None
|
|
||||||
for view in ('library', 'memory', 'card_a', 'card_b'):
|
for view in ('library', 'memory', 'card_a', 'card_b'):
|
||||||
view = getattr(self, view+'_view')
|
view = getattr(self, view+'_view')
|
||||||
view.verticalHeader().sectionDoubleClicked.connect(self.view_specific_book)
|
view.verticalHeader().sectionDoubleClicked.connect(self.view_specific_book)
|
||||||
if height is not None:
|
|
||||||
view.verticalHeader().setDefaultSectionSize(height)
|
|
||||||
|
|
||||||
self.location_view.setCurrentIndex(self.location_view.model().index(0))
|
self.location_view.setCurrentIndex(self.location_view.model().index(0))
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user