mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Merge from trunk
This commit is contained in:
commit
63c1fe0eb5
@ -30,7 +30,7 @@ def authors_to_string(authors):
|
||||
|
||||
def author_to_author_sort(author):
|
||||
method = tweaks['author_sort_copy_method']
|
||||
if method == 'copy' or (method == 'comma' and author.count(',') > 0):
|
||||
if method == 'copy' or (method == 'comma' and ',' in author):
|
||||
return author
|
||||
tokens = author.split()
|
||||
tokens = tokens[-1:] + tokens[:-1]
|
||||
|
@ -741,7 +741,7 @@ class OPF(object):
|
||||
|
||||
def fset(self, val):
|
||||
for tag in list(self.tags_path(self.metadata)):
|
||||
self.metadata.remove(tag)
|
||||
tag.getparent().remove(tag)
|
||||
for tag in val:
|
||||
elem = self.create_metadata_element('subject')
|
||||
self.set_text(elem, unicode(tag))
|
||||
|
@ -6,8 +6,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>410</width>
|
||||
<height>239</height>
|
||||
<width>730</width>
|
||||
<height>342</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
@ -47,9 +47,6 @@
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
<zorder>buttonBox</zorder>
|
||||
<zorder>table</zorder>
|
||||
<zorder>buttonBox</zorder>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections>
|
||||
|
@ -420,8 +420,11 @@ class BooksModel(QAbstractTableModel): # {{{
|
||||
pt.orig_file_path = os.path.abspath(src.name)
|
||||
pt.seek(0)
|
||||
if set_metadata:
|
||||
_set_metadata(pt, self.db.get_metadata(id, get_cover=True, index_is_id=True),
|
||||
try:
|
||||
_set_metadata(pt, self.db.get_metadata(id, get_cover=True, index_is_id=True),
|
||||
format)
|
||||
except:
|
||||
traceback.print_exc()
|
||||
pt.close()
|
||||
def to_uni(x):
|
||||
if isbytestring(x):
|
||||
|
@ -13,8 +13,8 @@ from functools import partial
|
||||
from PyQt4.Qt import Qt, QTreeView, QApplication, pyqtSignal, QCheckBox, \
|
||||
QFont, QSize, QIcon, QPoint, QVBoxLayout, QComboBox, \
|
||||
QAbstractItemModel, QVariant, QModelIndex, QMenu, \
|
||||
QPushButton, QWidget
|
||||
from PyQt4.Qt import QItemDelegate, QString, QPen, QColor, QLinearGradient, QBrush
|
||||
QPushButton, QWidget, QItemDelegate, QString, QPen, \
|
||||
QColor, QLinearGradient, QBrush
|
||||
|
||||
from calibre.gui2 import config, NONE
|
||||
from calibre.utils.config import prefs, tweaks
|
||||
|
@ -308,10 +308,10 @@ class SchemaUpgrade(object):
|
||||
{vcn},
|
||||
(SELECT COUNT(id) FROM books_{tn}_link WHERE {cn}={tn}.id) count,
|
||||
(SELECT AVG(ratings.rating)
|
||||
FROM books_{tn}_link as tl, books_ratings_link as bl, ratings
|
||||
WHERE tl.{cn}={tn}.id and bl.book=tl.book and
|
||||
ratings.id = bl.rating and ratings.rating <> 0) avg_rating,
|
||||
{scn} as sort
|
||||
FROM books_{tn}_link AS tl, books_ratings_link AS bl, ratings
|
||||
WHERE tl.{cn}={tn}.id AND bl.book=tl.book AND
|
||||
ratings.id = bl.rating AND ratings.rating <> 0) avg_rating,
|
||||
{scn} AS sort
|
||||
FROM {tn};
|
||||
DROP VIEW IF EXISTS tag_browser_filtered_{tn};
|
||||
CREATE VIEW tag_browser_filtered_{tn} AS SELECT
|
||||
@ -320,11 +320,11 @@ class SchemaUpgrade(object):
|
||||
(SELECT COUNT(books_{tn}_link.id) FROM books_{tn}_link WHERE
|
||||
{cn}={tn}.id AND books_list_filter(book)) count,
|
||||
(SELECT AVG(ratings.rating)
|
||||
FROM books_{tn}_link as tl, books_ratings_link as bl, ratings
|
||||
WHERE tl.{cn}={tn}.id and bl.book=tl.book and
|
||||
ratings.id = bl.rating and ratings.rating <> 0 AND
|
||||
FROM books_{tn}_link AS tl, books_ratings_link AS bl, ratings
|
||||
WHERE tl.{cn}={tn}.id AND bl.book=tl.book AND
|
||||
ratings.id = bl.rating AND ratings.rating <> 0 AND
|
||||
books_list_filter(bl.book)) avg_rating,
|
||||
{scn} as sort
|
||||
{scn} AS sort
|
||||
FROM {tn};
|
||||
|
||||
'''.format(tn=table_name, cn=column_name,
|
||||
@ -340,11 +340,11 @@ class SchemaUpgrade(object):
|
||||
(SELECT COUNT(id) FROM {lt} WHERE value={table}.id) count,
|
||||
(SELECT AVG(r.rating)
|
||||
FROM {lt},
|
||||
books_ratings_link as bl,
|
||||
ratings as r
|
||||
WHERE {lt}.value={table}.id and bl.book={lt}.book and
|
||||
r.id = bl.rating and r.rating <> 0) avg_rating,
|
||||
value as sort
|
||||
books_ratings_link AS bl,
|
||||
ratings AS r
|
||||
WHERE {lt}.value={table}.id AND bl.book={lt}.book AND
|
||||
r.id = bl.rating AND r.rating <> 0) avg_rating,
|
||||
value AS sort
|
||||
FROM {table};
|
||||
|
||||
DROP VIEW IF EXISTS tag_browser_filtered_{table};
|
||||
@ -355,12 +355,12 @@ class SchemaUpgrade(object):
|
||||
books_list_filter(book)) count,
|
||||
(SELECT AVG(r.rating)
|
||||
FROM {lt},
|
||||
books_ratings_link as bl,
|
||||
ratings as r
|
||||
books_ratings_link AS bl,
|
||||
ratings AS r
|
||||
WHERE {lt}.value={table}.id AND bl.book={lt}.book AND
|
||||
r.id = bl.rating AND r.rating <> 0 AND
|
||||
books_list_filter(bl.book)) avg_rating,
|
||||
value as sort
|
||||
value AS sort
|
||||
FROM {table};
|
||||
'''.format(lt=link_table_name, table=table_name)
|
||||
self.conn.executescript(script)
|
||||
@ -396,15 +396,17 @@ class SchemaUpgrade(object):
|
||||
(author_to_author_sort(author.replace('|', ',')).strip(), id))
|
||||
self.conn.commit()
|
||||
self.conn.executescript('''
|
||||
DROP TRIGGER IF EXISTS author_insert_trg;
|
||||
CREATE TRIGGER author_insert_trg
|
||||
AFTER INSERT ON authors
|
||||
BEGIN
|
||||
UPDATE authors SET sort=author_to_author_sort(NEW.name) WHERE id=NEW.id;
|
||||
END;
|
||||
DROP TRIGGER IF EXISTS author_update_trg;
|
||||
CREATE TRIGGER author_update_trg
|
||||
BEFORE UPDATE ON authors
|
||||
BEGIN
|
||||
UPDATE authors SET sort=author_to_author_sort(NEW.name)
|
||||
WHERE id=NEW.id and name <> NEW.name;
|
||||
WHERE id=NEW.id AND name <> NEW.name;
|
||||
END;
|
||||
''')
|
||||
''')
|
||||
|
Loading…
x
Reference in New Issue
Block a user