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