Pull from trunk
@ -4,6 +4,65 @@
|
||||
# for important features/bug fixes.
|
||||
# Also, each release can have new and improved recipes.
|
||||
|
||||
- version: 0.7.2
|
||||
date: 2010-06-11
|
||||
|
||||
new features:
|
||||
- title: "The Cover Browser can now be freely resized."
|
||||
description: >
|
||||
"You can now resize the Cover Browser just like the other areas of the user interface by dragging the edge. The Cover Browser now
|
||||
also emphasizes the cetral book cover, making it larger than the others. Also on widescreen monitors the cover browser is now automatically placed
|
||||
to the side of the book list instead of below it."
|
||||
|
||||
- title: "Added tweak to control how titles and series names are sorted"
|
||||
|
||||
- title: "Clicking on row numbers no longer open the viewer. Instead you have to double click"
|
||||
|
||||
bug fixes:
|
||||
- title: "SONY driver: The regression causing slow perfomance has been corrected. Various bug fixes to deal with corner cases"
|
||||
|
||||
- title: "iPad driver: Various bugfixes, should now work much more seamlessly."
|
||||
|
||||
- title: "Fix regression causing calibre to not start if the library path is invalid, because say a drive has been removed"
|
||||
tickets: [5787]
|
||||
|
||||
- title: "Fix regression in 0.7.1 that broke searching in the e-book viewers and for news sources"
|
||||
|
||||
- title: "Fix regressions that caused the Publisher to change when updating Series and floating point custom columns to be rounded to integers."
|
||||
tickets: [5788]
|
||||
|
||||
- title: "Fix regression that broke check database integrity in the presence of custom coulmns or user categories"
|
||||
tickets: [5779]
|
||||
|
||||
- title: "Fix regresison that broke the Email to submenu in the send to device menu"
|
||||
|
||||
- title: "Fix Tag browser re-opening closed tree after editing metadata"
|
||||
tickets: [5744]
|
||||
|
||||
- title: "Conversion pipeline: Handle missing/obsolete input/output profiles gracefully"
|
||||
|
||||
- title: "Fix Adding/Deleting Search does not refresh Left Pane Correctly"
|
||||
tickets: [5751]
|
||||
|
||||
- title: "Content server: Fix serving of CBZ/CBR files to stanza"
|
||||
|
||||
new recipes:
|
||||
- title: Repantes, Haaretz
|
||||
author: Darko Miletic
|
||||
|
||||
- title: CBC Canada
|
||||
author: rty
|
||||
|
||||
|
||||
improved recipes:
|
||||
- The Sun
|
||||
- The Economist
|
||||
- Boston Globe
|
||||
- Honolulu Star Advertiser
|
||||
- SMH
|
||||
- Sueddeutsche
|
||||
- Our Daily Bread
|
||||
|
||||
- version: 0.7.1
|
||||
date: 2010-06-04
|
||||
|
||||
|
@ -61,3 +61,15 @@ sort_columns_at_startup = None
|
||||
# default if not set: MMM yyyy
|
||||
gui_pubdate_display_format = 'MMM yyyy'
|
||||
|
||||
# Control title and series sorting in the library view.
|
||||
# If set to 'library_order', Leading articles such as The and A will be ignored.
|
||||
# If set to 'strictly_alphabetic', the titles will be sorted without processing
|
||||
# For example, with library_order, The Client will sort under 'C'. With
|
||||
# strictly_alphabetic, the book will sort under 'T'.
|
||||
# This flag affects Calibre's library display. It has no effect on devices. In
|
||||
# addition, titles for books added before changing the flag will retain their
|
||||
# order until the title is edited. Double-clicking on a title and hitting return
|
||||
# without changing anything is sufficient to change the sort.
|
||||
title_series_sorting = 'library_order'
|
||||
|
||||
|
||||
|
@ -1,7 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
||||
<svg
|
||||
xmlns:i="http://ns.adobe.com/AdobeIllustrator/10.0/"
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:cc="http://web.resource.org/cc/"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
@ -10,446 +9,238 @@
|
||||
xmlns:xlink="http://www.w3.org/1999/xlink"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
width="128"
|
||||
height="128"
|
||||
width="48"
|
||||
height="48"
|
||||
id="svg2"
|
||||
sodipodi:version="0.32"
|
||||
inkscape:version="0.44.1"
|
||||
inkscape:version="0.45"
|
||||
version="1.0"
|
||||
sodipodi:docbase="/Users/david/Progetti/oxygen-svn/theme/svg/actions"
|
||||
sodipodi:docname="bookmark.svg">
|
||||
sodipodi:docbase="/home/dobey/Projects/gnome-icon-theme/scalable/apps"
|
||||
sodipodi:docname="accessories-dictionary.svg"
|
||||
inkscape:export-filename="/home/ulisse/Desktop/accessories-dictionary.png"
|
||||
inkscape:export-xdpi="90"
|
||||
inkscape:export-ydpi="90"
|
||||
inkscape:output_extension="org.inkscape.output.svg.inkscape">
|
||||
<defs
|
||||
id="defs4">
|
||||
<linearGradient
|
||||
id="linearGradient26907"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
x1="-84.002403"
|
||||
y1="-383.9971"
|
||||
x2="-12.0029"
|
||||
y2="-383.9971"
|
||||
gradientTransform="matrix(0,1,-1,0,-39.9985,140.0029)">
|
||||
<stop
|
||||
offset="0"
|
||||
style="stop-color:#888a85;stop-opacity:1;"
|
||||
id="stop26909" />
|
||||
<stop
|
||||
offset="1"
|
||||
style="stop-color:#2e3436;stop-opacity:1;"
|
||||
id="stop26911" />
|
||||
</linearGradient>
|
||||
<linearGradient
|
||||
gradientTransform="matrix(0,1,-1,0,-39.9985,140.0029)"
|
||||
y2="-383.9975"
|
||||
x2="-23.516129"
|
||||
y1="-383.9971"
|
||||
x1="-84.002403"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
id="linearGradient3711">
|
||||
<stop
|
||||
id="stop3713"
|
||||
style="stop-color:white;stop-opacity:1;"
|
||||
offset="0" />
|
||||
<stop
|
||||
id="stop3715"
|
||||
style="stop-color:white;stop-opacity:0;"
|
||||
offset="1" />
|
||||
</linearGradient>
|
||||
<linearGradient
|
||||
id="linearGradient3081">
|
||||
<stop
|
||||
id="stop3083"
|
||||
offset="0"
|
||||
style="stop-color:#28691f;stop-opacity:1;" />
|
||||
<stop
|
||||
id="stop3085"
|
||||
offset="1"
|
||||
style="stop-color:#00bf00;stop-opacity:1;" />
|
||||
</linearGradient>
|
||||
<linearGradient
|
||||
id="linearGradient3290">
|
||||
<stop
|
||||
style="stop-color:yellow;stop-opacity:1;"
|
||||
offset="0"
|
||||
id="stop3292" />
|
||||
<stop
|
||||
style="stop-color:#ffb66d;stop-opacity:1;"
|
||||
offset="1"
|
||||
id="stop3294" />
|
||||
</linearGradient>
|
||||
<linearGradient
|
||||
inkscape:collect="always"
|
||||
id="linearGradient3765">
|
||||
id="linearGradient2309">
|
||||
<stop
|
||||
style="stop-color:#ffffff;stop-opacity:1;"
|
||||
offset="0"
|
||||
id="stop3767" />
|
||||
id="stop2311" />
|
||||
<stop
|
||||
style="stop-color:#ffffff;stop-opacity:0;"
|
||||
offset="1"
|
||||
id="stop3769" />
|
||||
id="stop2313" />
|
||||
</linearGradient>
|
||||
<linearGradient
|
||||
inkscape:collect="always"
|
||||
id="linearGradient3747">
|
||||
id="linearGradient2301">
|
||||
<stop
|
||||
style="stop-color:#ffffff;stop-opacity:1;"
|
||||
style="stop-color:#790000;stop-opacity:1"
|
||||
offset="0"
|
||||
id="stop3749" />
|
||||
id="stop2303" />
|
||||
<stop
|
||||
style="stop-color:#ffffff;stop-opacity:0;"
|
||||
style="stop-color:#b03636;stop-opacity:1"
|
||||
offset="1"
|
||||
id="stop3751" />
|
||||
id="stop2305" />
|
||||
</linearGradient>
|
||||
<linearGradient
|
||||
id="linearGradient3638">
|
||||
inkscape:collect="always"
|
||||
id="linearGradient2286">
|
||||
<stop
|
||||
style="stop-color:#ffffff;stop-opacity:0;"
|
||||
style="stop-color:#555753"
|
||||
offset="0"
|
||||
id="stop3640" />
|
||||
id="stop2288" />
|
||||
<stop
|
||||
id="stop3661"
|
||||
offset="0.06868132"
|
||||
style="stop-color:#ffffff;stop-opacity:1;" />
|
||||
<stop
|
||||
id="stop3659"
|
||||
offset="0.5"
|
||||
style="stop-color:#ffffff;stop-opacity:1;" />
|
||||
<stop
|
||||
style="stop-color:#ffffff;stop-opacity:0;"
|
||||
style="stop-color:#555753;stop-opacity:0"
|
||||
offset="1"
|
||||
id="stop3642" />
|
||||
id="stop2290" />
|
||||
</linearGradient>
|
||||
<linearGradient
|
||||
id="linearGradient1563">
|
||||
inkscape:collect="always"
|
||||
id="linearGradient2276">
|
||||
<stop
|
||||
id="stop1565"
|
||||
style="stop-color:#babdb6;stop-opacity:1;"
|
||||
offset="0"
|
||||
style="stop-color:#ffffff;stop-opacity:1;" />
|
||||
id="stop2278" />
|
||||
<stop
|
||||
id="stop1567"
|
||||
style="stop-color:#8f9488;stop-opacity:1"
|
||||
offset="1"
|
||||
style="stop-color:white;stop-opacity:0;" />
|
||||
id="stop2280" />
|
||||
</linearGradient>
|
||||
<linearGradient
|
||||
id="linearGradient3273">
|
||||
inkscape:collect="always"
|
||||
id="linearGradient2258">
|
||||
<stop
|
||||
id="stop3275"
|
||||
style="stop-color:#ffa4a4;stop-opacity:1"
|
||||
offset="0"
|
||||
style="stop-color:#ffffff;stop-opacity:0.55035973;" />
|
||||
id="stop2260" />
|
||||
<stop
|
||||
id="stop3277"
|
||||
style="stop-color:#a40000"
|
||||
offset="1"
|
||||
style="stop-color:#ffffff;stop-opacity:0;" />
|
||||
id="stop2262" />
|
||||
</linearGradient>
|
||||
<linearGradient
|
||||
id="linearGradient3291"
|
||||
inkscape:collect="always"
|
||||
id="linearGradient2235">
|
||||
<stop
|
||||
style="stop-color:#cccccc;stop-opacity:1"
|
||||
offset="0"
|
||||
id="stop2237" />
|
||||
<stop
|
||||
style="stop-color:#9b9b9b;stop-opacity:1"
|
||||
offset="1"
|
||||
id="stop2239" />
|
||||
</linearGradient>
|
||||
<linearGradient
|
||||
inkscape:collect="always"
|
||||
id="linearGradient2229">
|
||||
<stop
|
||||
style="stop-color:#888a85"
|
||||
offset="0"
|
||||
id="stop2231" />
|
||||
<stop
|
||||
style="stop-color:#d3d7cf;stop-opacity:0;"
|
||||
offset="1"
|
||||
id="stop2233" />
|
||||
</linearGradient>
|
||||
<linearGradient
|
||||
id="linearGradient2221"
|
||||
inkscape:collect="always">
|
||||
<stop
|
||||
id="stop3293"
|
||||
id="stop2223"
|
||||
offset="0"
|
||||
style="stop-color:#000000;stop-opacity:1;" />
|
||||
style="stop-color:#babdb6" />
|
||||
<stop
|
||||
id="stop3295"
|
||||
id="stop2225"
|
||||
offset="1"
|
||||
style="stop-color:#000000;stop-opacity:0;" />
|
||||
style="stop-color:#d3d7cf;stop-opacity:0;" />
|
||||
</linearGradient>
|
||||
<linearGradient
|
||||
id="linearGradient12948">
|
||||
inkscape:collect="always"
|
||||
id="linearGradient2184">
|
||||
<stop
|
||||
style="stop-color:#ffffff;stop-opacity:1;"
|
||||
offset="0"
|
||||
id="stop12950" />
|
||||
id="stop2186" />
|
||||
<stop
|
||||
style="stop-color:#c0c0c0;stop-opacity:0;"
|
||||
style="stop-color:#e3e3e3;stop-opacity:1"
|
||||
offset="1"
|
||||
id="stop12952" />
|
||||
id="stop2188" />
|
||||
</linearGradient>
|
||||
<linearGradient
|
||||
inkscape:collect="always"
|
||||
xlink:href="#linearGradient3273"
|
||||
id="linearGradient3605"
|
||||
x1="80.100487"
|
||||
y1="44.807674"
|
||||
x2="77.714729"
|
||||
y2="101.4734"
|
||||
xlink:href="#linearGradient2229"
|
||||
id="linearGradient2211"
|
||||
x1="24"
|
||||
y1="19.505583"
|
||||
x2="19.982143"
|
||||
y2="19.550226"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
gradientTransform="matrix(0.959962,0,0,0.959962,2.35549,3.275418)"
|
||||
spreadMethod="reflect" />
|
||||
gradientTransform="matrix(-1,0,0,1,48,0)" />
|
||||
<linearGradient
|
||||
inkscape:collect="always"
|
||||
xlink:href="#linearGradient3638"
|
||||
id="linearGradient3644"
|
||||
x1="57.287113"
|
||||
y1="1.1597457"
|
||||
x2="144.2531"
|
||||
y2="16.876789"
|
||||
xlink:href="#linearGradient2221"
|
||||
id="linearGradient2219"
|
||||
x1="24"
|
||||
y1="19.996655"
|
||||
x2="32"
|
||||
y2="19.90625"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
gradientTransform="matrix(-1,0,0,1,48,0)" />
|
||||
<linearGradient
|
||||
inkscape:collect="always"
|
||||
xlink:href="#linearGradient2184"
|
||||
id="linearGradient2245"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
x1="15.714286"
|
||||
y1="16.82852"
|
||||
x2="36.482143"
|
||||
y2="20.667807" />
|
||||
<linearGradient
|
||||
inkscape:collect="always"
|
||||
xlink:href="#linearGradient2235"
|
||||
id="linearGradient2247"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
x1="19.940901"
|
||||
y1="10.918805"
|
||||
x2="24"
|
||||
y2="22.750927" />
|
||||
<linearGradient
|
||||
inkscape:collect="always"
|
||||
xlink:href="#linearGradient2258"
|
||||
id="linearGradient2264"
|
||||
x1="32.794643"
|
||||
y1="21.696428"
|
||||
x2="34.79464"
|
||||
y2="32.321426"
|
||||
gradientUnits="userSpaceOnUse" />
|
||||
<linearGradient
|
||||
inkscape:collect="always"
|
||||
xlink:href="#linearGradient3638"
|
||||
id="linearGradient3646"
|
||||
x1="57.287113"
|
||||
y1="1.1597457"
|
||||
x2="144.2531"
|
||||
y2="16.876789"
|
||||
gradientUnits="userSpaceOnUse" />
|
||||
<linearGradient
|
||||
inkscape:collect="always"
|
||||
xlink:href="#linearGradient3638"
|
||||
id="linearGradient3648"
|
||||
x1="57.287113"
|
||||
y1="1.1597457"
|
||||
x2="144.2531"
|
||||
y2="16.876789"
|
||||
xlink:href="#linearGradient2276"
|
||||
id="linearGradient2282"
|
||||
x1="37.535713"
|
||||
y1="34.196426"
|
||||
x2="9.9285688"
|
||||
y2="20.089285"
|
||||
gradientUnits="userSpaceOnUse" />
|
||||
<radialGradient
|
||||
inkscape:collect="always"
|
||||
xlink:href="#linearGradient12948"
|
||||
id="radialGradient3716"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
gradientTransform="matrix(1,-7.045514e-15,1.946707e-15,0.941176,2.788953e-13,3.492906)"
|
||||
cx="23.190451"
|
||||
cy="59.379417"
|
||||
fx="22.471308"
|
||||
fy="59.354759"
|
||||
r="2.1082227" />
|
||||
<linearGradient
|
||||
inkscape:collect="always"
|
||||
xlink:href="#linearGradient1563"
|
||||
id="linearGradient3732"
|
||||
x1="98.291809"
|
||||
y1="-126.7503"
|
||||
x2="44.242641"
|
||||
y2="101.45739"
|
||||
xlink:href="#linearGradient2286"
|
||||
id="radialGradient2292"
|
||||
cx="24"
|
||||
cy="36.75"
|
||||
fx="24"
|
||||
fy="36.75"
|
||||
r="22.5"
|
||||
gradientTransform="matrix(1,0,0,0.3,-3.16587e-17,25.725)"
|
||||
gradientUnits="userSpaceOnUse" />
|
||||
<linearGradient
|
||||
inkscape:collect="always"
|
||||
xlink:href="#linearGradient1563"
|
||||
id="linearGradient3739"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
x1="98.291809"
|
||||
y1="-44.01474"
|
||||
x2="44.242641"
|
||||
y2="101.45739" />
|
||||
<radialGradient
|
||||
inkscape:collect="always"
|
||||
xlink:href="#linearGradient3291"
|
||||
id="radialGradient3743"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
gradientTransform="matrix(1,0,0,0.197802,0,92.82166)"
|
||||
cx="63.912209"
|
||||
cy="115.70919"
|
||||
fx="63.975182"
|
||||
fy="116.88514"
|
||||
r="63.912209" />
|
||||
<radialGradient
|
||||
inkscape:collect="always"
|
||||
xlink:href="#linearGradient3747"
|
||||
id="radialGradient3753"
|
||||
cx="5.7531347"
|
||||
cy="-45.41592"
|
||||
fx="74.816956"
|
||||
fy="-43.169445"
|
||||
r="124.10334"
|
||||
gradientTransform="matrix(1,-5.290907e-17,-3.962245e-18,9.492274e-2,9.333694e-14,-41.10492)"
|
||||
gradientUnits="userSpaceOnUse" />
|
||||
<radialGradient
|
||||
inkscape:collect="always"
|
||||
xlink:href="#linearGradient3747"
|
||||
id="radialGradient3757"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
gradientTransform="matrix(1,-1.087455e-16,-5.565153e-18,9.492274e-2,-1.420331e-15,-41.10492)"
|
||||
cx="5.7531347"
|
||||
cy="-45.41592"
|
||||
fx="74.816956"
|
||||
fy="-43.169445"
|
||||
r="124.10334" />
|
||||
<radialGradient
|
||||
inkscape:collect="always"
|
||||
xlink:href="#linearGradient3747"
|
||||
id="radialGradient3761"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
gradientTransform="matrix(1,-1.302059e-16,-7.897474e-18,9.492274e-2,1.345372e-13,-41.10492)"
|
||||
cx="5.7531347"
|
||||
cy="-45.41592"
|
||||
fx="74.816956"
|
||||
fy="-43.169445"
|
||||
r="124.10334" />
|
||||
<radialGradient
|
||||
inkscape:collect="always"
|
||||
xlink:href="#linearGradient3765"
|
||||
id="radialGradient3771"
|
||||
cx="23.662739"
|
||||
cy="95.898506"
|
||||
fx="24.26058"
|
||||
fy="96.778763"
|
||||
r="2.793914"
|
||||
gradientTransform="matrix(1.484142,0.129521,-0.489782,5.61225,35.51325,-445.3727)"
|
||||
xlink:href="#linearGradient2301"
|
||||
id="linearGradient2307"
|
||||
x1="23.955357"
|
||||
y1="10.008928"
|
||||
x2="29.214285"
|
||||
y2="30.276785"
|
||||
gradientUnits="userSpaceOnUse" />
|
||||
<linearGradient
|
||||
inkscape:collect="always"
|
||||
xlink:href="#linearGradient3290"
|
||||
id="linearGradient3106"
|
||||
x1="84.634949"
|
||||
y1="116.10083"
|
||||
x2="89.72541"
|
||||
y2="-15.33666"
|
||||
xlink:href="#linearGradient2309"
|
||||
id="linearGradient2315"
|
||||
x1="6.7230334"
|
||||
y1="37.683041"
|
||||
x2="37.804565"
|
||||
y2="29.096745"
|
||||
gradientUnits="userSpaceOnUse" />
|
||||
<radialGradient
|
||||
gradientUnits="userSpaceOnUse"
|
||||
gradientTransform="matrix(1,0,0,0.111111,0,138.1081)"
|
||||
r="64.796692"
|
||||
fy="177.29686"
|
||||
fx="80.738739"
|
||||
cy="155.37218"
|
||||
cx="80.738739"
|
||||
id="radialGradient5079"
|
||||
xlink:href="#linearGradient5073"
|
||||
inkscape:collect="always" />
|
||||
<linearGradient
|
||||
id="linearGradient5073"
|
||||
inkscape:collect="always">
|
||||
<stop
|
||||
id="stop5075"
|
||||
offset="0"
|
||||
style="stop-color:#000000;stop-opacity:1;" />
|
||||
<stop
|
||||
id="stop5077"
|
||||
offset="1"
|
||||
style="stop-color:#000000;stop-opacity:0;" />
|
||||
</linearGradient>
|
||||
<foreignObject
|
||||
id="foreignObject7221"
|
||||
height="1"
|
||||
width="1"
|
||||
y="0"
|
||||
x="0"
|
||||
requiredExtensions="http://ns.adobe.com/AdobeIllustrator/10.0/">
|
||||
<i:pgfRef
|
||||
xlink:href="#adobe_illustrator_pgf" />
|
||||
</foreignObject>
|
||||
<linearGradient
|
||||
id="XMLID_1_"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
x1="95.693398"
|
||||
y1="141.1738"
|
||||
x2="32.308601"
|
||||
y2="77.789001">
|
||||
<stop
|
||||
offset="0"
|
||||
style="stop-color:#75511A"
|
||||
id="stop7227" />
|
||||
<stop
|
||||
offset="0.3988"
|
||||
style="stop-color:#563A11"
|
||||
id="stop7229" />
|
||||
<stop
|
||||
offset="0.7642"
|
||||
style="stop-color:#402B0B"
|
||||
id="stop7231" />
|
||||
<stop
|
||||
offset="1"
|
||||
style="stop-color:#382509"
|
||||
id="stop7233" />
|
||||
</linearGradient>
|
||||
<linearGradient
|
||||
id="XMLID_3_"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
x1="63.9995"
|
||||
y1="92.865196"
|
||||
x2="63.9995"
|
||||
y2="120.8652"
|
||||
gradientTransform="translate(175.0067,11.74752)">
|
||||
<stop
|
||||
offset="0"
|
||||
style="stop-color:#888A85"
|
||||
id="stop7261" />
|
||||
<stop
|
||||
offset="0.3226"
|
||||
style="stop-color:#A6A7A3"
|
||||
id="stop7263" />
|
||||
<stop
|
||||
offset="1"
|
||||
style="stop-color:#EEEEEC"
|
||||
id="stop7265" />
|
||||
</linearGradient>
|
||||
<linearGradient
|
||||
id="XMLID_4_"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
x1="64.000504"
|
||||
y1="108.8652"
|
||||
x2="64.000504"
|
||||
y2="92.865196">
|
||||
<stop
|
||||
offset="0"
|
||||
style="stop-color:#EEEEEC"
|
||||
id="stop7270" />
|
||||
<stop
|
||||
offset="1"
|
||||
style="stop-color:#FFFFFF"
|
||||
id="stop7272" />
|
||||
</linearGradient>
|
||||
<linearGradient
|
||||
inkscape:collect="always"
|
||||
xlink:href="#linearGradient3081"
|
||||
id="linearGradient2149"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
x1="62.112335"
|
||||
y1="90.513916"
|
||||
x2="67.887672"
|
||||
y2="39.095695" />
|
||||
<linearGradient
|
||||
inkscape:collect="always"
|
||||
xlink:href="#linearGradient26907"
|
||||
id="linearGradient3226"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
gradientTransform="matrix(0,1,-1,0,-39.9985,140.0029)"
|
||||
x1="-70.002899"
|
||||
y1="-383.9971"
|
||||
x2="-11.91648"
|
||||
y2="-383.9971" />
|
||||
<radialGradient
|
||||
inkscape:collect="always"
|
||||
xlink:href="#linearGradient3711"
|
||||
id="radialGradient3228"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
cx="343.99899"
|
||||
cy="92"
|
||||
fx="343.99899"
|
||||
fy="92"
|
||||
r="36" />
|
||||
<linearGradient
|
||||
inkscape:collect="always"
|
||||
xlink:href="#linearGradient3711"
|
||||
id="linearGradient3230"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
gradientTransform="matrix(0,1.022977,-1.022977,0,111.9686,137.8125)"
|
||||
x1="-88.058083"
|
||||
y1="-131.93112"
|
||||
x2="-45.096584"
|
||||
y2="-131.93112" />
|
||||
</defs>
|
||||
<sodipodi:namedview
|
||||
id="base"
|
||||
pagecolor="#ffffff"
|
||||
bordercolor="#666666"
|
||||
borderopacity="1.0"
|
||||
bordercolor="#a8a8a8"
|
||||
borderopacity="1"
|
||||
inkscape:pageopacity="0.0"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:zoom="4.8203125"
|
||||
inkscape:cx="64"
|
||||
inkscape:cy="64"
|
||||
inkscape:zoom="7.919596"
|
||||
inkscape:cx="41.482905"
|
||||
inkscape:cy="24.425816"
|
||||
inkscape:document-units="px"
|
||||
inkscape:current-layer="layer1"
|
||||
inkscape:window-width="1247"
|
||||
inkscape:window-height="816"
|
||||
inkscape:window-x="388"
|
||||
inkscape:window-y="110"
|
||||
inkscape:showpageshadow="false"
|
||||
inkscape:grid-bbox="true"
|
||||
showgrid="true"
|
||||
gridspacingx="4px"
|
||||
gridspacingy="4px"
|
||||
gridempspacing="0"
|
||||
inkscape:grid-points="true" />
|
||||
inkscape:grid-points="true"
|
||||
gridspacingx="0.5px"
|
||||
gridspacingy="0.5px"
|
||||
gridempspacing="2"
|
||||
inkscape:window-width="872"
|
||||
inkscape:window-height="694"
|
||||
inkscape:window-x="0"
|
||||
inkscape:window-y="25"
|
||||
fill="#75507b" />
|
||||
<metadata
|
||||
id="metadata7">
|
||||
<rdf:RDF>
|
||||
@ -458,133 +249,108 @@
|
||||
<dc:format>image/svg+xml</dc:format>
|
||||
<dc:type
|
||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||
<dc:creator>
|
||||
<cc:Agent>
|
||||
<dc:title>Ulisse Perusin</dc:title>
|
||||
</cc:Agent>
|
||||
</dc:creator>
|
||||
<dc:title>Dictionary</dc:title>
|
||||
<dc:subject>
|
||||
<rdf:Bag>
|
||||
<rdf:li>dictionary</rdf:li>
|
||||
<rdf:li>translation</rdf:li>
|
||||
</rdf:Bag>
|
||||
</dc:subject>
|
||||
<cc:license
|
||||
rdf:resource="http://creativecommons.org/licenses/GPL/2.0/" />
|
||||
</cc:Work>
|
||||
<cc:License
|
||||
rdf:about="http://creativecommons.org/licenses/GPL/2.0/">
|
||||
<cc:permits
|
||||
rdf:resource="http://web.resource.org/cc/Reproduction" />
|
||||
<cc:permits
|
||||
rdf:resource="http://web.resource.org/cc/Distribution" />
|
||||
<cc:requires
|
||||
rdf:resource="http://web.resource.org/cc/Notice" />
|
||||
<cc:permits
|
||||
rdf:resource="http://web.resource.org/cc/DerivativeWorks" />
|
||||
<cc:requires
|
||||
rdf:resource="http://web.resource.org/cc/ShareAlike" />
|
||||
<cc:requires
|
||||
rdf:resource="http://web.resource.org/cc/SourceCode" />
|
||||
</cc:License>
|
||||
</rdf:RDF>
|
||||
</metadata>
|
||||
<g
|
||||
inkscape:label="Layer 1"
|
||||
inkscape:label="Livello 1"
|
||||
inkscape:groupmode="layer"
|
||||
id="layer1">
|
||||
<path
|
||||
transform="matrix(0.511285,0.187762,-0.187762,0.511285,41.72321,44.08266)"
|
||||
d="M 153.09403,94.713757 C 144.53658,107.09689 92.616372,93.013297 78.414631,98.001518 C 64.21289,102.98974 32.50348,146.4474 18.082028,142.13539 C 3.6605746,137.82337 1.0106378,84.092245 -8.1220219,72.127031 C -17.254681,60.161818 -68.384124,43.433534 -68.739625,28.385431 C -69.095125,13.337327 -18.812666,-5.7867426 -10.255219,-18.169872 C -1.697772,-30.553002 -1.5880954,-84.349316 12.613645,-89.337536 C 26.815387,-94.325757 60.541592,-52.41396 74.963045,-48.101941 C 89.384498,-43.789923 140.58172,-60.30959 149.71438,-48.344376 C 158.84704,-36.379162 129.40853,8.6478227 129.76403,23.695927 C 130.11953,38.74403 161.65148,82.330628 153.09403,94.713757 z "
|
||||
inkscape:randomized="0"
|
||||
inkscape:rounded="0.20136392"
|
||||
inkscape:flatsided="false"
|
||||
sodipodi:arg2="1.2330172"
|
||||
sodipodi:arg1="0.60469864"
|
||||
sodipodi:r2="76.832565"
|
||||
sodipodi:r1="121.72647"
|
||||
sodipodi:cy="25.510532"
|
||||
sodipodi:cx="52.952892"
|
||||
sodipodi:sides="5"
|
||||
id="path3574"
|
||||
style="opacity:1;fill:#e3ad00;fill-opacity:1.0;fill-rule:nonzero;stroke:none;stroke-width:14.80892919;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:4;stroke-opacity:1"
|
||||
sodipodi:type="star" />
|
||||
<path
|
||||
style="opacity:1;fill:url(#linearGradient3106);fill-opacity:1.0;fill-rule:nonzero;stroke:url(#linearGradient3605);stroke-width:6.803;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:4;stroke-opacity:1"
|
||||
d="M 64.817613,10.159328 C 64.581604,10.317484 63.312654,10.957094 61.843149,12.708869 C 60.101516,14.785047 58.138879,17.917081 56.177505,21.235666 C 54.216128,24.55425 52.251443,28.092247 50.341888,31.150546 C 48.432331,34.208845 46.806952,36.762169 44.279648,38.544213 C 41.752344,40.326257 38.764915,41.002069 35.242943,41.773631 C 31.720971,42.545192 27.75285,43.193621 23.968308,43.926576 C 20.183765,44.659533 16.5656,45.476237 14.025101,46.419462 C 11.841858,47.230044 10.829167,48.201295 10.625712,48.345781 C 10.626839,48.347738 10.624524,48.371367 10.625712,48.374108 C 10.696321,48.571093 10.870285,49.989399 12.127109,52.000123 C 13.563478,54.298089 15.950898,57.154462 18.50096,60.045339 C 21.051023,62.936217 23.774397,65.867627 26.092925,68.628793 C 28.411454,71.389955 30.363146,73.748045 31.27699,76.702337 C 32.190833,79.656627 31.914822,82.68926 31.560274,86.277278 C 31.205724,89.8653 30.616267,93.839413 30.143862,97.665227 C 30.113483,97.911252 30.08362,98.156728 30.054361,98.401429 C 29.628627,101.96194 29.330856,105.3582 29.435657,107.89172 C 29.533657,110.26089 30.173974,111.54076 30.228847,111.74436 C 30.438123,111.73798 31.837454,111.97838 34.138142,111.40442 C 36.7675,110.74847 40.20401,109.39531 43.741411,107.86339 C 47.278812,106.33148 50.937026,104.62602 54.279513,103.27421 C 57.621999,101.9224 60.450754,100.79418 63.542844,100.838 C 66.634933,100.8818 69.418339,102.08321 72.721189,103.52916 C 76.024038,104.97512 79.653393,106.79843 83.145977,108.42996 C 86.638561,110.06147 90.026215,111.49575 92.635935,112.22595 C 94.919441,112.86485 96.334003,112.66799 96.54523,112.67918 C 96.605258,112.47676 97.286649,111.22034 97.451733,108.85487 C 97.640395,106.1515 97.418963,102.46604 97.055137,98.628384 C 96.691312,94.790732 96.174767,90.780408 95.922008,87.183781 C 95.669251,83.587159 95.491404,80.56438 96.488573,77.637169 C 97.485753,74.709955 99.503438,72.399636 101.89927,69.705264 C 104.29508,67.010894 107.11524,64.16591 109.74619,61.348436 C 112.37711,58.530963 114.78913,55.729544 116.29001,53.47319 C 117.57984,51.534136 117.84976,50.137859 117.93304,49.903833 C 117.93436,49.901119 117.93183,49.877435 117.93304,49.875506 C 117.7318,49.725835 116.72138,48.73631 114.56198,47.864201 C 112.04922,46.849382 108.49434,45.927914 104.73209,45.088035 C 100.96983,44.248155 97.012813,43.466178 93.514108,42.595149 C 90.015409,41.724119 87.038194,40.992031 84.562389,39.139105 C 82.086586,37.286179 80.548923,34.65831 78.726774,31.54714 C 76.904626,28.435971 75.041014,24.863438 73.174441,21.49062 C 71.307869,18.117801 69.417536,14.946869 67.735421,12.822182 C 66.263569,10.963081 64.982527,10.293346 64.817613,10.159328 z "
|
||||
id="path3580"
|
||||
sodipodi:nodetypes="cssssssssssssssssscssssssscssssssssssssssssc" />
|
||||
<path
|
||||
sodipodi:nodetypes="ccc"
|
||||
id="path2276"
|
||||
d="M -106.3852,44.124126 L -106.3852,41.329417 L -106.3852,44.124126 z "
|
||||
style="fill:#ffffff;fill-opacity:0.75688076;fill-rule:nonzero;stroke:none;stroke-width:0.5;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:4;stroke-opacity:1" />
|
||||
<path
|
||||
sodipodi:type="arc"
|
||||
style="opacity:0.38139535;fill:url(#radialGradient3743);fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:4;stroke-opacity:1"
|
||||
id="path3289"
|
||||
sodipodi:cx="63.912209"
|
||||
sodipodi:cy="115.70919"
|
||||
sodipodi:rx="63.912209"
|
||||
sodipodi:ry="12.641975"
|
||||
d="M 127.82442 115.70919 A 63.912209 12.641975 0 1 1 0,115.70919 A 63.912209 12.641975 0 1 1 127.82442 115.70919 z"
|
||||
transform="matrix(-1.001374,0,0,0.410379,128,75.32738)" />
|
||||
style="opacity:0.50196078;color:#000000;fill:url(#radialGradient2292);fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1;stroke-linecap:round;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:17.85;stroke-opacity:1;visibility:visible;display:block;overflow:visible"
|
||||
id="path2284"
|
||||
sodipodi:cx="24"
|
||||
sodipodi:cy="36.75"
|
||||
sodipodi:rx="22.5"
|
||||
sodipodi:ry="6.75"
|
||||
d="M 46.5 36.75 A 22.5 6.75 0 1 1 1.5,36.75 A 22.5 6.75 0 1 1 46.5 36.75 z"
|
||||
transform="matrix(1.066667,0,0,0.962963,-1.600001,1.111111)" />
|
||||
<path
|
||||
style="fill:none;fill-opacity:1.0;fill-rule:evenodd;stroke:url(#linearGradient3648);stroke-width:0.50672567;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:0.5813008"
|
||||
d="M 55.266721,10.739701 C 56.520212,8.5685899 61.220699,1.3579337 65.008418,1.4134271 C 71.889436,1.5172832 83.511202,31.129589 88.946059,34.460427 C 95.635958,38.560436 119.92387,41.46414 124.34296,44.969282"
|
||||
id="path3632"
|
||||
sodipodi:nodetypes="csss" />
|
||||
style="color:#000000;fill:#523856;fill-opacity:1;fill-rule:nonzero;stroke:#3e263b;stroke-width:1;stroke-linecap:round;stroke-linejoin:round;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:17.85;stroke-opacity:1;visibility:visible;display:block;overflow:visible"
|
||||
d="M 4.5,11.5 L 43.5,11.5 L 47.5,38.5 L 29,38.5 L 28,37.5 C 26,39 22,39 20,37.5 L 19,38.5 L 0.5,38.5 L 4.5,11.5 z "
|
||||
id="rect1304"
|
||||
sodipodi:nodetypes="ccccccccc" />
|
||||
<path
|
||||
sodipodi:nodetypes="csss"
|
||||
id="path3634"
|
||||
d="M 55.236135,11.274949 C 56.489626,9.1038383 61.236542,1.57297 65.023711,1.6581121 C 71.830955,1.8111507 83.271335,31.483209 88.869595,34.705112 C 95.670099,38.618929 119.98852,41.765855 124.40761,45.270997"
|
||||
style="fill:none;fill-opacity:1.0;fill-rule:evenodd;stroke:url(#linearGradient3646);stroke-width:1;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:0.43089432" />
|
||||
sodipodi:type="inkscape:offset"
|
||||
inkscape:radius="-0.91809106"
|
||||
inkscape:original="M 4.5 11.5 L 0.5 38.5 L 19 38.5 L 20 37.5 C 22 39 26 39 28 37.5 L 29 38.5 L 47.5 38.5 L 43.5 11.5 L 4.5 11.5 z "
|
||||
xlink:href="#rect1304"
|
||||
style="opacity:0.13333333;color:#000000;fill:none;fill-opacity:1;fill-rule:nonzero;stroke:#ffffff;stroke-width:1;stroke-linecap:round;stroke-linejoin:round;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:17.85;stroke-opacity:1;visibility:visible;display:block;overflow:visible"
|
||||
id="path2274"
|
||||
inkscape:href="#rect1304"
|
||||
d="M 5.28125,12.40625 L 1.5625,37.59375 L 18.59375,37.59375 L 19.34375,36.84375 C 19.667151,36.507336 20.191452,36.467006 20.5625,36.75 C 21.327469,37.323727 22.653015,37.71875 24,37.71875 C 25.346985,37.71875 26.672531,37.323727 27.4375,36.75 C 27.808548,36.467006 28.332849,36.507336 28.65625,36.84375 L 29.40625,37.59375 L 46.4375,37.59375 L 42.71875,12.40625 L 5.28125,12.40625 z " />
|
||||
<path
|
||||
style="fill:none;fill-opacity:1.0;fill-rule:evenodd;stroke:url(#linearGradient3644);stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:0.43089432"
|
||||
d="M 55.205632,12.312054 C 56.459123,10.140944 61.420826,2.0361374 65.023711,2.1461616 C 71.282863,2.3391656 83.42385,32.459308 88.778086,35.193162 C 95.766183,38.761259 121.08663,42.680948 124.71264,46.094581"
|
||||
id="path3636"
|
||||
sodipodi:nodetypes="csss" />
|
||||
style="fill:url(#linearGradient2282);fill-opacity:1.0;fill-rule:evenodd;stroke:#888a85;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||
d="M 2,36.5 C 7.6666667,36.5 16,35 19,36.5 C 22,34 26,34 29,36.5 C 32,35 41,36.5 46,36.5 L 45.5,34 C 38.5,31.5 29,28.5 24,33 C 19,28.5 9.5,31.5 2.5,34 L 2,36.5 z "
|
||||
id="path2180"
|
||||
sodipodi:nodetypes="cccccccc" />
|
||||
<path
|
||||
sodipodi:type="arc"
|
||||
style="opacity:0.70232556;fill:url(#radialGradient3716);fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.89999998;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:4;stroke-opacity:1"
|
||||
id="path11160"
|
||||
sodipodi:cx="23.190451"
|
||||
sodipodi:cy="59.379417"
|
||||
sodipodi:rx="2.1082227"
|
||||
sodipodi:ry="1.9842097"
|
||||
d="M 25.298673 59.379417 A 2.1082227 1.9842097 0 1 1 21.082228,59.379417 A 2.1082227 1.9842097 0 1 1 25.298673 59.379417 z"
|
||||
transform="matrix(-1.742936,-1.063485,-0.470527,1.244278,191.1539,-3.699137)" />
|
||||
sodipodi:type="inkscape:offset"
|
||||
inkscape:radius="-1.0582203"
|
||||
inkscape:original="M 14 30.875 C 10.125 31.375 6 32.75 2.5 34 L 2 36.5 C 7.6666667 36.5 16 35 19 36.5 C 22 34 26 34 29 36.5 C 32 35 41 36.5 46 36.5 L 45.5 34 C 38.5 31.5 29 28.5 24 33 C 21.5 30.75 17.875 30.375 14 30.875 z "
|
||||
xlink:href="#path2180"
|
||||
style="opacity:0.30196078;fill:none;fill-opacity:1;fill-rule:evenodd;stroke:url(#linearGradient2315);stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||
id="path2266"
|
||||
inkscape:href="#path2180"
|
||||
d="M 14.375,31.9375 C 10.963293,32.392394 7.260823,33.622273 3.90625,34.8125 L 3.8125,35.34375 C 6.2979599,35.262594 9.0476285,35.037732 11.6875,34.875 C 14.462294,34.703951 16.881256,34.711661 18.78125,35.40625 C 20.133116,34.409774 21.661646,33.894157 23.21875,33.75 C 21.042747,31.830616 17.941674,31.461944 14.375,31.9375 z M 28.625,31.9375 C 27.145571,32.213473 25.86037,32.798142 24.78125,33.75 C 26.338354,33.894157 27.866884,34.409774 29.21875,35.40625 C 31.163554,34.697135 33.704549,34.703523 36.5625,34.875 C 39.261382,35.036933 41.920385,35.260963 44.1875,35.34375 L 44.09375,34.8125 C 40.739177,33.622273 37.036707,32.392394 33.625,31.9375 C 31.827105,31.697781 30.128781,31.656984 28.625,31.9375 z " />
|
||||
<path
|
||||
style="opacity:1;fill:url(#linearGradient3732);fill-opacity:1.0;fill-rule:nonzero;stroke:none;stroke-width:6.803;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:4;stroke-opacity:1"
|
||||
d="M 64.8125 10.15625 C 64.576492 10.314406 63.313255 10.966975 61.84375 12.71875 C 60.102119 14.794928 58.148874 17.931415 56.1875 21.25 C 54.226123 24.568584 52.253305 28.097951 50.34375 31.15625 C 48.434193 34.21455 46.808554 36.749206 44.28125 38.53125 C 41.753946 40.313295 38.771972 41.009688 35.25 41.78125 C 31.728028 42.55281 27.753292 43.204545 23.96875 43.9375 C 20.184208 44.670458 16.571749 45.463025 14.03125 46.40625 C 11.848007 47.216834 10.828455 48.199264 10.625 48.34375 C 10.62496 48.346283 10.625145 48.371753 10.625 48.375 C 10.695609 48.571986 10.868176 49.989276 12.125 52 C 13.561369 54.297967 15.949938 57.140373 18.5 60.03125 C 20.422509 62.210702 22.440722 64.427292 24.3125 66.5625 C 47.187815 68.967477 71.532076 77.450485 95.75 81.53125 C 95.830132 80.186335 96.067405 78.894893 96.5 77.625 C 97.497182 74.697786 99.510418 72.413122 101.90625 69.71875 C 104.30206 67.024383 107.11905 64.161224 109.75 61.34375 C 112.38092 58.526279 114.78037 55.725104 116.28125 53.46875 C 117.57108 51.529696 117.85422 50.140276 117.9375 49.90625 C 117.93747 49.903618 117.93766 49.878251 117.9375 49.875 C 117.73626 49.725328 116.7219 48.747109 114.5625 47.875 C 112.04974 46.860181 108.481 45.933629 104.71875 45.09375 C 100.95649 44.253869 96.998705 43.464779 93.5 42.59375 C 90.001302 41.722719 87.038305 40.977926 84.5625 39.125 C 82.0867 37.272072 80.540899 34.67367 78.71875 31.5625 C 76.8966 28.451331 75.054073 24.872818 73.1875 21.5 C 71.320931 18.127181 69.432115 14.937187 67.75 12.8125 C 66.278149 10.953399 64.977414 10.290268 64.8125 10.15625 z "
|
||||
id="path3718" />
|
||||
style="fill:url(#linearGradient2245);fill-opacity:1;fill-rule:evenodd;stroke:url(#linearGradient2247);stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||
d="M 2.5,34 C 9,31.5 20,29 24,33 C 28,29 39,31.5 45.5,34 L 42.5,10.5 C 37,8 27.5,6 24,9 C 20,6 12,8 5.5,10.5 L 2.5,34 z "
|
||||
id="path2182"
|
||||
sodipodi:nodetypes="ccccccc" />
|
||||
<path
|
||||
style="opacity:0.41393443;fill:url(#linearGradient3739);fill-opacity:1.0;fill-rule:nonzero;stroke:none;stroke-width:6.803;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:4;stroke-opacity:1"
|
||||
d="M 64.8125 10.15625 C 64.576492 10.314406 63.313255 10.966975 61.84375 12.71875 C 60.102119 14.794928 58.148874 17.931415 56.1875 21.25 C 54.226123 24.568584 52.253305 28.097951 50.34375 31.15625 C 48.434193 34.21455 46.808554 36.749206 44.28125 38.53125 C 41.753946 40.313295 38.771972 41.009688 35.25 41.78125 C 31.728028 42.55281 27.753292 43.204545 23.96875 43.9375 C 20.184208 44.670458 16.571749 45.463025 14.03125 46.40625 C 11.848007 47.216834 10.828455 48.199264 10.625 48.34375 C 10.62496 48.346283 10.625145 48.371753 10.625 48.375 C 10.695609 48.571986 10.868176 49.989276 12.125 52 C 13.561369 54.297967 15.949938 57.140373 18.5 60.03125 C 20.422509 62.210702 22.440722 64.427292 24.3125 66.5625 C 25.752576 66.713901 27.204929 66.896788 28.65625 67.09375 C 42.328845 56.623879 60.733777 43.188439 78.53125 31.25 C 76.771363 28.21678 74.98888 24.755017 73.1875 21.5 C 71.320931 18.127181 69.432115 14.937187 67.75 12.8125 C 66.278149 10.953399 64.977414 10.290268 64.8125 10.15625 z M 99.34375 43.90625 C 86.79565 53.381359 75.792347 63.914843 66.25 75.09375 C 76.032927 77.504442 85.901575 79.871772 95.75 81.53125 C 95.830132 80.186335 96.067405 78.894893 96.5 77.625 C 97.497182 74.697786 99.510418 72.413122 101.90625 69.71875 C 104.30206 67.024383 107.11905 64.161224 109.75 61.34375 C 112.38092 58.526279 114.78037 55.725104 116.28125 53.46875 C 117.57108 51.529696 117.85422 50.140276 117.9375 49.90625 C 117.93747 49.903618 117.93766 49.878251 117.9375 49.875 C 117.73626 49.725328 116.7219 48.747109 114.5625 47.875 C 112.04974 46.860181 108.481 45.933629 104.71875 45.09375 C 102.94925 44.698729 101.13165 44.292609 99.34375 43.90625 z "
|
||||
id="path3736" />
|
||||
<path
|
||||
id="path3741"
|
||||
d="M 64.8125,10.15625 C 64.576492,10.314406 63.313255,10.966975 61.84375,12.71875 C 60.102119,14.794928 58.148874,17.931415 56.1875,21.25 C 54.226123,24.568584 52.253305,28.097951 50.34375,31.15625 C 48.434193,34.21455 46.808554,36.749206 44.28125,38.53125 C 41.753946,40.313295 38.771972,41.009688 35.25,41.78125 C 31.728028,42.55281 27.753292,43.204545 23.96875,43.9375 C 20.184208,44.670458 16.571749,45.463025 14.03125,46.40625 C 11.848007,47.216834 10.828455,48.199264 10.625,48.34375 C 10.62496,48.346283 10.625145,48.371753 10.625,48.375 C 10.695609,48.571986 10.868176,49.989276 12.125,52 C 13.561369,54.297967 60.733777,43.188439 78.53125,31.25 C 76.771363,28.21678 74.98888,24.755017 73.1875,21.5 C 71.320931,18.127181 69.432115,14.937187 67.75,12.8125 C 66.278149,10.953399 64.977414,10.290268 64.8125,10.15625 z M 99.34375,43.90625 C 68.470207,67.487324 85.901575,79.871772 95.75,81.53125 C 95.830132,80.186335 96.067405,78.894893 96.5,77.625 C 97.497182,74.697786 99.510418,72.413122 101.90625,69.71875 C 104.30206,67.024383 107.11905,64.161224 109.75,61.34375 C 112.38092,58.526279 114.78037,55.725104 116.28125,53.46875 C 117.57108,51.529696 117.85422,50.140276 117.9375,49.90625 C 117.93747,49.903618 117.93766,49.878251 117.9375,49.875 C 117.73626,49.725328 116.7219,48.747109 114.5625,47.875 C 112.04974,46.860181 108.481,45.933629 104.71875,45.09375 C 102.94925,44.698729 101.13165,44.292609 99.34375,43.90625 z "
|
||||
style="opacity:0.34836066;fill:url(#linearGradient3739);fill-opacity:1.0;fill-rule:nonzero;stroke:none;stroke-width:6.803;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:4;stroke-opacity:1"
|
||||
sodipodi:nodetypes="csssssssssscsscccssssssssc" />
|
||||
<path
|
||||
sodipodi:type="arc"
|
||||
style="opacity:0.35655739;fill:url(#radialGradient3753);fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:4;stroke-opacity:0.43089432"
|
||||
id="path3745"
|
||||
sodipodi:cx="5.7531347"
|
||||
sodipodi:cy="-45.41592"
|
||||
sodipodi:rx="124.10334"
|
||||
sodipodi:ry="11.780229"
|
||||
d="M 129.85647 -45.41592 A 124.10334 11.780229 0 1 1 -118.35021,-45.41592 A 124.10334 11.780229 0 1 1 129.85647 -45.41592 z"
|
||||
transform="matrix(0.126835,-5.623734e-2,-3.870485e-2,-9.211943e-2,44.81196,106.2565)" />
|
||||
<path
|
||||
transform="matrix(-0.126834,-5.702883e-2,3.870485e-2,-9.341592e-2,81.95911,106.3126)"
|
||||
d="M 129.85647 -45.41592 A 124.10334 11.780229 0 1 1 -118.35021,-45.41592 A 124.10334 11.780229 0 1 1 129.85647 -45.41592 z"
|
||||
sodipodi:ry="11.780229"
|
||||
sodipodi:rx="124.10334"
|
||||
sodipodi:cy="-45.41592"
|
||||
sodipodi:cx="5.7531347"
|
||||
id="path3755"
|
||||
style="opacity:0.49590164;fill:url(#radialGradient3757);fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:4;stroke-opacity:0.43089432"
|
||||
sodipodi:type="arc" />
|
||||
<path
|
||||
transform="matrix(-6.548665e-3,-0.135343,-9.988208e-2,2.696531e-3,91.9485,98.93228)"
|
||||
d="M 129.85647 -45.41592 A 124.10334 11.780229 0 1 1 -118.35021,-45.41592 A 124.10334 11.780229 0 1 1 129.85647 -45.41592 z"
|
||||
sodipodi:ry="11.780229"
|
||||
sodipodi:rx="124.10334"
|
||||
sodipodi:cy="-45.41592"
|
||||
sodipodi:cx="5.7531347"
|
||||
id="path3759"
|
||||
style="opacity:0.27459016;fill:url(#radialGradient3761);fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:4;stroke-opacity:0.43089432"
|
||||
sodipodi:type="arc" />
|
||||
<path
|
||||
style="opacity:0.17;fill:#2e3436;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:14.80892944;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:4;stroke-opacity:1"
|
||||
d="M 126.314,45.945281 C 127.57715,54.014451 105.05512,70.888621 102.47025,78.476531 C 99.826558,86.237151 107.76438,114.43949 101.06401,119.16403 C 94.363618,123.88859 70.449248,106.96767 62.251508,106.85153 C 54.053768,106.73539 29.690348,122.98275 23.126508,118.07028 C 22.815738,117.8377 22.558998,117.52665 22.314008,117.19528 C 22.708398,118.50348 23.279848,119.53038 24.126508,120.16403 C 30.690348,125.0765 55.053768,108.82913 63.251508,108.94528 C 71.449248,109.06142 95.363618,126.01358 102.064,121.28903 C 108.76438,116.56449 100.82656,88.362141 103.47025,80.601531 C 106.11395,72.840911 129.61178,55.340191 127.189,47.507781 C 127.02007,46.961651 126.72727,46.430131 126.314,45.945281 z M 1.5015079,49.851531 C 4.5831579,57.838661 18.613888,70.110761 22.845258,77.320281 C 20.896748,71.159061 6.3960679,58.682221 1.5015079,49.851531 z "
|
||||
id="path3308" />
|
||||
<path
|
||||
style="opacity:0.17;fill:#2e3436;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:14.80892944;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:4;stroke-opacity:1"
|
||||
d="M 127.1265,47.382781 C 127.77543,55.569451 105.80307,72.111371 103.2515,79.601531 C 100.60781,87.362151 108.54563,115.56449 101.84525,120.28903 C 95.144868,125.01357 71.261748,108.06142 63.064008,107.94528 C 54.866278,107.82913 30.471598,124.10775 23.907758,119.19528 C 22.913828,118.45141 22.292008,117.15904 21.907758,115.50778 C 22.250148,117.65334 22.937778,119.30561 24.126508,120.19528 C 30.690348,125.10775 55.053778,108.82913 63.251508,108.94528 C 71.449248,109.06142 95.363638,126.01357 102.064,121.28903 C 108.76438,116.56449 100.82655,88.362151 103.47025,80.601531 C 106.11395,72.840911 129.61177,55.340181 127.189,47.507781 C 127.17552,47.464201 127.14164,47.425951 127.1265,47.382781 z M 0.93900787,47.757781 C 1.9815279,56.300511 21.645828,72.265141 23.876508,79.476531 C 23.903658,79.564291 23.914628,79.665031 23.939008,79.757781 C 23.870988,79.288551 23.775168,78.856101 23.657758,78.476531 C 21.511968,71.539581 3.2557579,56.495971 0.93900787,47.757781 z "
|
||||
id="path3303" />
|
||||
<path
|
||||
style="fill:url(#radialGradient3771);fill-opacity:1.0;fill-rule:evenodd;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;opacity:0.55327869"
|
||||
d="M 25.088207,80.21837 C 25.534474,90.747814 22.054583,105.95279 22.237274,111.46459 L 24.632057,111.69267 C 26.600057,101.69251 28.017156,91.508728 28.167214,80.902594 L 25.088207,80.21837 z "
|
||||
id="path3763"
|
||||
style="color:#000000;fill:url(#linearGradient2219);fill-opacity:1.0;fill-rule:nonzero;stroke:none;stroke-width:1;stroke-linecap:round;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dashoffset:17.85;stroke-opacity:1;visibility:visible;display:block;overflow:visible"
|
||||
d="M 24,9.5 C 22,8 19.5,7.5 16,8 L 16,30.5 C 18,29.5 22,30.5 24,32.5 L 24,9.5 z "
|
||||
id="rect2192"
|
||||
sodipodi:nodetypes="ccccc" />
|
||||
<path
|
||||
style="opacity:0.62;fill:#2e3436;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:14.80892944;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:4;stroke-opacity:1"
|
||||
d="M 0.89521787,47.070281 C 0.89114787,55.417331 21.603498,72.067851 23.895208,79.476531 C 24.122348,80.210811 24.248638,81.111361 24.301458,82.164031 C 24.258118,80.995191 24.141798,79.961201 23.895208,79.164031 C 21.629398,71.839061 1.3489179,55.506151 0.89521787,47.070281 z M 127.36395,48.789031 C 126.76815,57.193121 105.96742,73.013441 103.48895,80.289031 C 103.13757,81.320501 102.96318,82.732101 102.92645,84.382781 C 102.97549,82.859581 103.15849,81.571601 103.48895,80.601531 C 105.99802,73.236121 127.27213,57.108781 127.36395,48.789031 z M 63.270208,108.63278 C 55.072468,108.51664 30.709048,124.79525 24.145208,119.88278 C 22.709368,118.80818 21.987678,116.61813 21.738958,113.78903 C 21.963318,116.76637 22.658218,119.08239 24.145208,120.19528 C 30.709048,125.10775 55.072468,108.82913 63.270208,108.94528 C 71.467938,109.06142 95.382328,126.01357 102.0827,121.28903 C 103.80587,120.07399 104.52313,117.30046 104.73895,113.72653 C 104.49958,117.15646 103.75779,119.79539 102.0827,120.97653 C 95.382328,125.70107 71.467938,108.74892 63.270208,108.63278 z "
|
||||
id="path3296" />
|
||||
style="color:#000000;fill:url(#linearGradient2211);fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1;stroke-linecap:round;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dashoffset:17.85;stroke-opacity:1;visibility:visible;display:block;overflow:visible"
|
||||
d="M 24,9.5 C 25.221264,8.803878 26.327771,7.9069322 28,8 L 29,30.5 C 27.5,30 25.5,31.5 24,32.5 L 24,9.5 z "
|
||||
id="path2195"
|
||||
sodipodi:nodetypes="ccccc" />
|
||||
<path
|
||||
sodipodi:type="inkscape:offset"
|
||||
inkscape:radius="-0.92850536"
|
||||
inkscape:original="M 20.34375 7.625 C 16.101562 7.0390625 10.375 8.625 5.5 10.5 L 2.5 34 C 9 31.5 20 29 24 33 C 28 29 39 31.5 45.5 34 L 42.5 10.5 C 37 8 27.5 6 24 9 C 23 8.25 21.757812 7.8203125 20.34375 7.625 z "
|
||||
xlink:href="#path2182"
|
||||
style="opacity:0.65098039;fill:none;fill-opacity:1;fill-rule:evenodd;stroke:#ffffff;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||
id="path2243"
|
||||
inkscape:href="#path2182"
|
||||
d="M 17.03125,8.375 C 14.611845,8.6563261 11.827815,9.5624782 8.78125,10.71875 L 4.25,32.59375 C 7.5567067,31.338728 11.345145,30.271354 14.90625,29.9375 C 16.969491,29.744071 18.927893,29.768608 20.625,30.125 C 21.963283,30.406039 23.09173,31.003906 24,31.8125 C 24.90827,31.003906 26.036717,30.406039 27.375,30.125 C 29.072107,29.768608 31.030509,29.744071 33.09375,29.9375 C 36.654855,30.271354 40.443293,31.338728 43.75,32.59375 L 39.1875,10.6875 C 36.612085,9.5579242 33.750698,8.6570052 31.15625,8.375 C 28.420939,8.0776836 26.053467,8.4675643 24.59375,9.71875 C 24.262671,9.9972426 23.783138,10.010203 23.4375,9.75 C 21.660341,8.417131 19.571761,8.0795918 17.03125,8.375 z " />
|
||||
<path
|
||||
style="fill:url(#linearGradient2264);fill-opacity:1.0;fill-rule:evenodd;stroke:url(#linearGradient2307);stroke-width:1;stroke-linecap:square;stroke-linejoin:miter;stroke-opacity:1;stroke-miterlimit:4;stroke-dasharray:none"
|
||||
d="M 24.455357,8.7321429 C 24.5,20.5 34,20 33.5,30.5 L 32.5,34.5 L 34,34 L 35,35 L 35.5,31 C 36,20 24.544643,19.089286 24.5,8.5 L 24.455357,8.7321429 z "
|
||||
id="path2227"
|
||||
sodipodi:nodetypes="cccccccc" />
|
||||
</g>
|
||||
</svg>
|
||||
|
Before Width: | Height: | Size: 32 KiB After Width: | Height: | Size: 15 KiB |
BIN
resources/images/news/ourdailybread.png
Normal file
After Width: | Height: | Size: 739 B |
Before Width: | Height: | Size: 983 B After Width: | Height: | Size: 983 B |
Before Width: | Height: | Size: 50 KiB After Width: | Height: | Size: 47 KiB |
Before Width: | Height: | Size: 156 KiB After Width: | Height: | Size: 14 KiB |
63
resources/recipes/auto.recipe
Normal file
@ -0,0 +1,63 @@
|
||||
#!/usr/bin/env python
|
||||
__license__ = 'GPL v3'
|
||||
__author__ = 'GabrieleMarini, based on Darko Miletic'
|
||||
__copyright__ = '2009, Darko Miletic <darko.miletic at gmail.com>, Gabriele Marini'
|
||||
__version__ = 'v1.02 Marini Gabriele '
|
||||
__date__ = '14062010'
|
||||
__description__ = 'Italian daily newspaper'
|
||||
|
||||
'''
|
||||
http://www.corrieredellosport.it/
|
||||
'''
|
||||
from calibre.web.feeds.news import BasicNewsRecipe
|
||||
|
||||
class Auto(BasicNewsRecipe):
|
||||
__author__ = 'Gabriele Marini'
|
||||
description = 'Auto and Formula 1'
|
||||
|
||||
cover_url = 'http://www.auto.it/res/imgs/logo_Auto.png'
|
||||
|
||||
|
||||
title = u'Auto'
|
||||
publisher = 'CONTE Editore'
|
||||
category = 'Sport'
|
||||
|
||||
language = 'it'
|
||||
timefmt = '[%a, %d %b, %Y]'
|
||||
|
||||
oldest_article = 60
|
||||
max_articles_per_feed = 30
|
||||
use_embedded_content = False
|
||||
recursion = 10
|
||||
|
||||
remove_javascript = True
|
||||
no_stylesheets = True
|
||||
|
||||
html2lrf_options = [
|
||||
'--comment', description
|
||||
, '--category', category
|
||||
, '--publisher', publisher
|
||||
, '--ignore-tables'
|
||||
]
|
||||
|
||||
html2epub_options = 'publisher="' + publisher + '"\ncomments="' + description + '"\ntags="' + category + '"\nlinearize_tables=True'
|
||||
|
||||
keep_only_tags = [
|
||||
dict(name='h2', attrs={'class':['tit_Article y_Txt']}),
|
||||
dict(name='h2', attrs={'class':['tit_Article']}),
|
||||
dict(name='div', attrs={'class':['box_Img newsdet_new ']}),
|
||||
dict(name='div', attrs={'class':['box_Img newsdet_as ']}),
|
||||
dict(name='table', attrs={'class':['table_A']}),
|
||||
dict(name='div', attrs={'class':['txt_Article txtBox_cms']}),
|
||||
dict(name='testoscheda')]
|
||||
|
||||
|
||||
feeds = [
|
||||
(u'Tutte le News' , u'http://www.auto.it/rss/articoli.xml' ),
|
||||
(u'Prove su Strada' , u'http://www.auto.it/rss/prove+6.xml'),
|
||||
(u'Novit\xe0' , u'http://www.auto.it/rss/novita+3.xml')
|
||||
]
|
||||
|
||||
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
__license__ = 'GPL v3'
|
||||
__copyright__ = '2009, Darko Miletic <darko.miletic at gmail.com>'
|
||||
__copyright__ = '2009-2010, Darko Miletic <darko.miletic at gmail.com>'
|
||||
'''
|
||||
www.boston.com
|
||||
'''
|
||||
@ -7,10 +7,10 @@ www.boston.com
|
||||
from calibre.web.feeds.recipes import BasicNewsRecipe
|
||||
|
||||
class BusinessStandard(BasicNewsRecipe):
|
||||
title = 'Boston'
|
||||
title = 'The Boston Globe'
|
||||
__author__ = 'Darko Miletic'
|
||||
description = 'News from Boston'
|
||||
oldest_article = 7
|
||||
oldest_article = 2
|
||||
max_articles_per_feed = 100
|
||||
no_stylesheets = True
|
||||
delay = 1
|
||||
@ -19,6 +19,9 @@ class BusinessStandard(BasicNewsRecipe):
|
||||
publisher = 'Boston'
|
||||
category = 'news, boston, usa, world'
|
||||
language = 'en'
|
||||
publication_type = 'newspaper'
|
||||
masthead_url = 'http://cache.boston.com/images/globe/grslider/the_boston_globe.gif'
|
||||
extra_css = ' body{font-family: Georgia, serif} div#articleBodyTop{display:block} '
|
||||
|
||||
conversion_options = {
|
||||
'comments' : description
|
||||
@ -27,8 +30,11 @@ class BusinessStandard(BasicNewsRecipe):
|
||||
,'publisher' : publisher
|
||||
}
|
||||
|
||||
keep_only_tags = [dict(name='div', attrs={'class':'story'})]
|
||||
remove_tags = [dict(name=['object','link','script','iframe'])]
|
||||
keep_only_tags = [dict(attrs={'id':['INDblogEntry','blogEntry','articleHeader','articleGraphs','galleryShell']})]
|
||||
remove_tags = [
|
||||
dict(name=['object','link','script','iframe'])
|
||||
,dict(attrs={'id':['blogheadTools','bdc_emailWidget','tools','relatedContent']})
|
||||
]
|
||||
|
||||
feeds = [
|
||||
(u'Top Stories' , u'http://feeds.boston.com/boston/topstories' )
|
||||
@ -38,12 +44,9 @@ class BusinessStandard(BasicNewsRecipe):
|
||||
]
|
||||
|
||||
def print_version(self, url):
|
||||
return url + '?mode=PF'
|
||||
return url + '?page=full'
|
||||
|
||||
def get_article_url(self, article):
|
||||
rawarticle = article.get('pheedo_origlink', None)
|
||||
artls, sep, rsep = rawarticle.rpartition('/?')
|
||||
if artls == '':
|
||||
artls = rawarticle.rpartition('?')[0]
|
||||
return artls
|
||||
rawarticle = article.get('guid', None)
|
||||
return rawarticle.rpartition('?')[0]
|
||||
|
||||
|
60
resources/recipes/corriere_dello_sport.recipe
Normal file
@ -0,0 +1,60 @@
|
||||
#!/usr/bin/env python
|
||||
__license__ = 'GPL v3'
|
||||
__author__ = 'GabrieleMarini, based on Darko Miletic'
|
||||
__copyright__ = '2009, Darko Miletic <darko.miletic at gmail.com>, Gabriele Marini'
|
||||
__version__ = ' '
|
||||
__date__ = '14-06-2010'
|
||||
__description__ = 'Italian daily newspaper'
|
||||
|
||||
'''
|
||||
http://www.corrieredellosport.it/
|
||||
'''
|
||||
from calibre.web.feeds.news import BasicNewsRecipe
|
||||
|
||||
class ilCorrieredelloSport(BasicNewsRecipe):
|
||||
__author__ = 'Gabriele Marini'
|
||||
description = 'Italian daily newspaper'
|
||||
|
||||
cover_url = 'http://edicola.corrieredellosport.it/newsmem/corsport/prima/nazionale_prima.jpg'
|
||||
|
||||
|
||||
title = u'Il Corriere dello Sport'
|
||||
publisher = 'CORRIERE DELLO SPORT s.r.l. '
|
||||
category = 'Sport'
|
||||
|
||||
language = 'it'
|
||||
timefmt = '[%a, %d %b, %Y]'
|
||||
|
||||
oldest_article = 10
|
||||
max_articles_per_feed = 100
|
||||
use_embedded_content = False
|
||||
recursion = 10
|
||||
|
||||
remove_javascript = True
|
||||
no_stylesheets = True
|
||||
|
||||
html2lrf_options = [
|
||||
'--comment', description
|
||||
, '--category', category
|
||||
, '--publisher', publisher
|
||||
, '--ignore-tables'
|
||||
]
|
||||
|
||||
html2epub_options = 'publisher="' + publisher + '"\ncomments="' + description + '"\ntags="' + category + '"\nlinearize_tables=True'
|
||||
|
||||
keep_only_tags = [
|
||||
dict(name='h1', attrs={'class':['tit_Article']}),
|
||||
dict(name='h1', attrs={'class':['tit_Article_mondiali']}),
|
||||
dict(name='div', attrs={'class':['box_Img']}),
|
||||
dict(name='p', attrs={'class':['summary','text']})]
|
||||
|
||||
|
||||
|
||||
|
||||
feeds = [
|
||||
(u'Primo Piano' , u'http://www.corrieredellosport.it/rss/primo_piano.xml' ),
|
||||
(u'Calcio' , u'http://www.corrieredellosport.it/rss/Calcio-3.xml'),
|
||||
(u'Formula 1' , u'http://www.corrieredellosport.it/rss/Formula-1-7.xml'),
|
||||
(u'Moto' , u'http://www.corrieredellosport.it/rss/Moto-8.xml'),
|
||||
(u'Piu visti' , u'http://www.corrieredellosport.it/rss/piu_visti.xml')
|
||||
]
|
@ -1,4 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
__license__ = 'GPL v3'
|
||||
__copyright__ = '2008-2010, Darko Miletic <darko.miletic at gmail.com>'
|
||||
'''
|
||||
@ -23,7 +22,14 @@ class Danas(BasicNewsRecipe):
|
||||
language = 'sr'
|
||||
publication_type = 'newspaper'
|
||||
remove_empty_feeds = True
|
||||
extra_css = '@font-face {font-family: "serif1";src:url(res:///opt/sony/ebook/FONT/tt0011m_.ttf)} @font-face {font-family: "sans1";src:url(res:///opt/sony/ebook/FONT/tt0003m_.ttf)} .article_description,body,.lokacija{font-family: Tahoma,Arial,Helvetica,sans1,sans-serif} .nadNaslov,h1,.preamble{font-family: Georgia,"Times New Roman",Times,serif1,serif} .antrfileText{border-left: 2px solid #999999; margin-left: 0.8em; padding-left: 1.2em; margin-bottom: 0; margin-top: 0} h2,.datum,.lokacija,.autor{font-size: small} .antrfileNaslov{border-left: 2px solid #999999; margin-left: 0.8em; padding-left: 1.2em; font-weight:bold; margin-bottom: 0; margin-top: 0} img{margin-bottom: 0.8em} '
|
||||
extra_css = """ @font-face {font-family: "serif1";src:url(res:///opt/sony/ebook/FONT/tt0011m_.ttf)}
|
||||
@font-face {font-family: "sans1";src:url(res:///opt/sony/ebook/FONT/tt0003m_.ttf)}
|
||||
.article_description,body,.lokacija{font-family: Tahoma,Arial,Helvetica,sans1,sans-serif}
|
||||
.nadNaslov,h1,.preamble{font-family: Georgia,"Times New Roman",Times,serif1,serif}
|
||||
.antrfileText{border-left: 2px solid #999999; margin-left: 0.8em; padding-left: 1.2em;
|
||||
margin-bottom: 0; margin-top: 0} h2,.datum,.lokacija,.autor{font-size: small}
|
||||
.antrfileNaslov{border-left: 2px solid #999999; margin-left: 0.8em; padding-left: 1.2em;
|
||||
font-weight:bold; margin-bottom: 0; margin-top: 0} img{margin-bottom: 0.8em} """
|
||||
|
||||
conversion_options = {
|
||||
'comment' : description
|
||||
@ -42,19 +48,32 @@ class Danas(BasicNewsRecipe):
|
||||
]
|
||||
|
||||
feeds = [
|
||||
(u'Politika' , u'http://www.danas.rs/rss/rss.asp?column_id=27')
|
||||
,(u'Hronika' , u'http://www.danas.rs/rss/rss.asp?column_id=2' )
|
||||
,(u'Dru\xc5\xa1tvo', u'http://www.danas.rs/rss/rss.asp?column_id=24')
|
||||
,(u'Dijalog' , u'http://www.danas.rs/rss/rss.asp?column_id=1' )
|
||||
,(u'Ekonomija', u'http://www.danas.rs/rss/rss.asp?column_id=6' )
|
||||
,(u'Svet' , u'http://www.danas.rs/rss/rss.asp?column_id=25')
|
||||
,(u'Srbija' , u'http://www.danas.rs/rss/rss.asp?column_id=28')
|
||||
,(u'Kultura' , u'http://www.danas.rs/rss/rss.asp?column_id=5' )
|
||||
,(u'Sport' , u'http://www.danas.rs/rss/rss.asp?column_id=13')
|
||||
,(u'Scena' , u'http://www.danas.rs/rss/rss.asp?column_id=42')
|
||||
,(u'Feljton' , u'http://www.danas.rs/rss/rss.asp?column_id=19')
|
||||
,(u'Periskop' , u'http://www.danas.rs/rss/rss.asp?column_id=4' )
|
||||
,(u'Famozno' , u'http://www.danas.rs/rss/rss.asp?column_id=47')
|
||||
(u'Politika' , u'http://www.danas.rs/rss/rss.asp?column_id=27')
|
||||
,(u'Hronika' , u'http://www.danas.rs/rss/rss.asp?column_id=2' )
|
||||
,(u'Drustvo' , u'http://www.danas.rs/rss/rss.asp?column_id=24')
|
||||
,(u'Dijalog' , u'http://www.danas.rs/rss/rss.asp?column_id=1' )
|
||||
,(u'Ekonomija' , u'http://www.danas.rs/rss/rss.asp?column_id=6' )
|
||||
,(u'Svet' , u'http://www.danas.rs/rss/rss.asp?column_id=25')
|
||||
,(u'Srbija' , u'http://www.danas.rs/rss/rss.asp?column_id=28')
|
||||
,(u'Kultura' , u'http://www.danas.rs/rss/rss.asp?column_id=5' )
|
||||
,(u'Sport' , u'http://www.danas.rs/rss/rss.asp?column_id=13')
|
||||
,(u'Scena' , u'http://www.danas.rs/rss/rss.asp?column_id=42')
|
||||
,(u'Feljton' , u'http://www.danas.rs/rss/rss.asp?column_id=19')
|
||||
,(u'Periskop' , u'http://www.danas.rs/rss/rss.asp?column_id=4' )
|
||||
,(u'Famozno' , u'http://www.danas.rs/rss/rss.asp?column_id=47')
|
||||
,(u'Sluzbena beleska' , u'http://www.danas.rs/rss/rss.asp?column_id=48')
|
||||
,(u'Suocavanja' , u'http://www.danas.rs/rss/rss.asp?column_id=49')
|
||||
,(u'Moj Izbor' , u'http://www.danas.rs/rss/rss.asp?column_id=50')
|
||||
,(u'Direktno' , u'http://www.danas.rs/rss/rss.asp?column_id=51')
|
||||
,(u'I tome slicno' , u'http://www.danas.rs/rss/rss.asp?column_id=52')
|
||||
,(u'No longer and not yet', u'http://www.danas.rs/rss/rss.asp?column_id=53')
|
||||
,(u'Resetovanje' , u'http://www.danas.rs/rss/rss.asp?column_id=54')
|
||||
,(u'Iza scene' , u'http://www.danas.rs/rss/rss.asp?column_id=60')
|
||||
,(u'Drustvoslovlje' , u'http://www.danas.rs/rss/rss.asp?column_id=55')
|
||||
,(u'Zvaka u pepeljari' , u'http://www.danas.rs/rss/rss.asp?column_id=56')
|
||||
,(u'Vostani Serbie' , u'http://www.danas.rs/rss/rss.asp?column_id=57')
|
||||
,(u'Med&Jad-a' , u'http://www.danas.rs/rss/rss.asp?column_id=58')
|
||||
,(u'Svetlosti pozornice' , u'http://www.danas.rs/rss/rss.asp?column_id=59')
|
||||
]
|
||||
|
||||
def preprocess_html(self, soup):
|
||||
@ -65,3 +84,10 @@ class Danas(BasicNewsRecipe):
|
||||
def print_version(self, url):
|
||||
return url + '&action=print'
|
||||
|
||||
def get_cover_url(self):
|
||||
cover_url = None
|
||||
soup = self.index_to_soup('http://www.danas.rs/')
|
||||
for citem in soup.findAll('img'):
|
||||
if citem['src'].endswith('naslovna.jpg'):
|
||||
return 'http://www.danas.rs' + citem['src']
|
||||
return cover_url
|
||||
|
@ -24,9 +24,10 @@ class Economist(BasicNewsRecipe):
|
||||
oldest_article = 7.0
|
||||
cover_url = 'http://www.economist.com/images/covers/currentcoverus_large.jpg'
|
||||
remove_tags = [dict(name=['script', 'noscript', 'title', 'iframe', 'cf_floatingcontent']),
|
||||
dict(attrs={'class':['dblClkTrk']})]
|
||||
remove_tags_before = dict(name=lambda tag: tag.name=='title' and tag.parent.name=='body')
|
||||
dict(attrs={'class':['dblClkTrk', 'ec-article-info']})]
|
||||
keep_only_tags = [dict(id='ec-article-body')]
|
||||
needs_subscription = True
|
||||
no_stylesheets = True
|
||||
preprocess_regexps = [(re.compile('</html>.*', re.DOTALL),
|
||||
lambda x:'</html>')]
|
||||
|
||||
@ -87,7 +88,9 @@ class Economist(BasicNewsRecipe):
|
||||
continue
|
||||
a = tag.find('a', href=True)
|
||||
if a is not None:
|
||||
url=a['href'].replace('displaystory', 'PrinterFriendly').strip()
|
||||
url=a['href']
|
||||
id_ = re.search(r'story_id=(\d+)', url).group(1)
|
||||
url = 'http://www.economist.com/node/%s/print'%id_
|
||||
if url.startswith('Printer'):
|
||||
url = '/'+url
|
||||
if url.startswith('/'):
|
||||
|
@ -17,8 +17,9 @@ class Economist(BasicNewsRecipe):
|
||||
oldest_article = 7.0
|
||||
cover_url = 'http://www.economist.com/images/covers/currentcoverus_large.jpg'
|
||||
remove_tags = [dict(name=['script', 'noscript', 'title', 'iframe', 'cf_floatingcontent']),
|
||||
dict(attrs={'class':['dblClkTrk']})]
|
||||
remove_tags_before = dict(name=lambda tag: tag.name=='title' and tag.parent.name=='body')
|
||||
dict(attrs={'class':['dblClkTrk', 'ec-article-info']})]
|
||||
keep_only_tags = [dict(id='ec-article-body')]
|
||||
no_stylesheets = True
|
||||
preprocess_regexps = [(re.compile('</html>.*', re.DOTALL),
|
||||
lambda x:'</html>')]
|
||||
|
||||
@ -88,19 +89,20 @@ class Economist(BasicNewsRecipe):
|
||||
br = browser()
|
||||
ret = br.open(url)
|
||||
raw = ret.read()
|
||||
url = br.geturl().replace('displaystory', 'PrinterFriendly').strip()
|
||||
url = br.geturl().split('?')[0]+'/print'
|
||||
root = html.fromstring(raw)
|
||||
matches = root.xpath('//*[@class = "article-section"]')
|
||||
matches = root.xpath('//*[@class = "ec-article-info"]')
|
||||
feedtitle = 'Miscellaneous'
|
||||
if matches:
|
||||
feedtitle = string.capwords(html.tostring(matches[0], method='text',
|
||||
encoding=unicode))
|
||||
feedtitle = string.capwords(html.tostring(matches[-1], method='text',
|
||||
encoding=unicode).split('|')[-1].strip())
|
||||
return (i, feedtitle, url, title, description, author, published)
|
||||
|
||||
def eco_article_found(self, req, result):
|
||||
from calibre.web.feeds import Article
|
||||
i, feedtitle, link, title, description, author, published = result
|
||||
self.log('Found print version for article:', title)
|
||||
self.log('Found print version for article:', title, 'in', feedtitle,
|
||||
'at', link)
|
||||
|
||||
a = Article(i, title, link, author, description, published, '')
|
||||
|
||||
|
@ -1,96 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: cp1252 -*-
|
||||
|
||||
__license__ = 'GPL v3'
|
||||
__copyright__ = '2009, Darko Miletic <darko.miletic at gmail.com>'
|
||||
'''
|
||||
honoluluadvertiser.com
|
||||
'''
|
||||
|
||||
from calibre.web.feeds.news import BasicNewsRecipe
|
||||
|
||||
class Honoluluadvertiser(BasicNewsRecipe):
|
||||
title = 'Honolulu Advertiser'
|
||||
__author__ = 'Darko Miletic and Sujata Raman'
|
||||
description = "Latest national and local Hawaii sports news from The Honolulu Advertiser."
|
||||
publisher = 'Honolulu Advertiser'
|
||||
category = 'news, Honolulu, Hawaii'
|
||||
oldest_article = 2
|
||||
language = 'en'
|
||||
|
||||
max_articles_per_feed = 100
|
||||
no_stylesheets = True
|
||||
use_embedded_content = False
|
||||
encoding = 'cp1252'
|
||||
remove_javascript = True
|
||||
cover_url = 'http://www.honoluluadvertiser.com/graphics/frontpage/frontpage.jpg'
|
||||
|
||||
html2lrf_options = [
|
||||
'--comment' , description
|
||||
, '--category' , category
|
||||
, '--publisher' , publisher
|
||||
]
|
||||
|
||||
html2epub_options = 'publisher="' + publisher + '"\ncomments="' + description + '"\ntags="' + category + '"'
|
||||
|
||||
keep_only_tags = [dict(name='div', attrs={'class':["hon_article_top","article-bodytext","hon_article_photo","storyphoto","article"]}),
|
||||
dict(name='div', attrs={'id':["storycontentleft","article"]})
|
||||
]
|
||||
|
||||
remove_tags = [dict(name=['object','link','embed']),
|
||||
dict(name='div', attrs={'class':["article-tools","titleBar","invisiblespacer","articleflex-container","hon_newslist","categoryheader","columnframe","subHeadline","poster-container"]}),
|
||||
dict(name='div', attrs={'align':["right"]}),
|
||||
dict(name='div', attrs={'id':["pluckcomments"]}),
|
||||
dict(name='td', attrs={'class':["prepsfacts"]}),
|
||||
dict(name='img', attrs={'height':["1"]}),
|
||||
dict(name='img', attrs={'alt':["Advertisement"]}),
|
||||
dict(name='img', attrs={'src':["/gcicommonfiles/sr/graphics/common/adlabel_horz.gif","/gcicommonfiles/sr/graphics/common/icon_whatsthis.gif",]}),
|
||||
]
|
||||
|
||||
extra_css = '''
|
||||
h1{font-family:Arial,Helvetica,sans-serif; font-size:large; color:#000000; }
|
||||
.hon_article_timestamp{font-family:Arial,Helvetica,sans-serif; font-size:70%; }
|
||||
.postedStoryDate{font-family:Arial,Helvetica,sans-serif; font-size:30%; }
|
||||
.postedDate{font-family:Arial,Helvetica,sans-serif; font-size:30%; }
|
||||
.credit{font-family:Arial,Helvetica,sans-serif; font-size:30%; }
|
||||
.hon_article_top{font-family:Arial,Helvetica,sans-serif; color:#666666; font-size:30%; font-weight:bold;}
|
||||
.grayBackground{font-family:Arial,Helvetica,sans-serif; color:#666666; font-size:30%;}
|
||||
.hon_photocaption{font-family:Arial,Helvetica,sans-serif; font-size:30%; }
|
||||
.photoCaption{font-family:Arial,Helvetica,sans-serif; font-size:30%; }
|
||||
.hon_photocredit{font-family:Arial,Helvetica,sans-serif; font-size:30%; color:#666666;}
|
||||
.storyphoto{font-family:Arial,Helvetica,sans-serif; font-size:30%; color:#666666;}
|
||||
.article-bodytext{font-family:Arial,Helvetica,sans-serif; font-size:xx-small; }
|
||||
.storycontentleft{font-family:Arial,Helvetica,sans-serif; font-size:xx-small; }
|
||||
#article{font-family:Arial,Helvetica,sans-serif; font-size:xx-small; }
|
||||
.contentarea{font-family:Arial,Helvetica,sans-serif; font-size:xx-small; }
|
||||
.storytext{font-family:Verdana,Arial,Helvetica,sans-serif; font-size:xx-small;}
|
||||
.storyHeadline{font-family:Arial,Helvetica,sans-serif; font-size:large; color:#000000; font-weight:bold;}
|
||||
.source{font-family:Arial,Helvetica,sans-serif; color:#333333; font-style: italic; font-weight:bold; }
|
||||
'''
|
||||
|
||||
feeds = [
|
||||
(u'Breaking news', u'http://www.honoluluadvertiser.com/apps/pbcs.dll/section?Category=RSS01&MIME=XML' )
|
||||
,(u'Local news', u'http://www.honoluluadvertiser.com/apps/pbcs.dll/section?Category=RSS02&MIME=XML' )
|
||||
,(u'Sports', u'http://www.honoluluadvertiser.com/apps/pbcs.dll/section?Category=RSS03&MIME=XML' )
|
||||
,(u'Island life', u'http://www.honoluluadvertiser.com/apps/pbcs.dll/section?Category=RSS05&MIME=XML' )
|
||||
,(u'Entertainment', u'http://www.honoluluadvertiser.com/apps/pbcs.dll/section?Category=RSS06&MIME=XML' )
|
||||
,(u'Business', u'http://www.honoluluadvertiser.com/apps/pbcs.dll/section?Category=RSS04&MIME=XML' )
|
||||
]
|
||||
|
||||
def preprocess_html(self, soup):
|
||||
for item in soup.findAll(style=True):
|
||||
del item['style']
|
||||
mtag = '\n<meta http-equiv="Content-Language" content="en"/>\n'
|
||||
soup.head.insert(0,mtag)
|
||||
|
||||
for tag in soup.findAll(name=['span','table','font']):
|
||||
tag.name = 'div'
|
||||
|
||||
return soup
|
||||
|
||||
|
||||
# def print_version(self, url):
|
||||
# ubody, sep, rest = url.rpartition('/-1/')
|
||||
# root, sep2, article_id = ubody.partition('/article/')
|
||||
# return u'http://www.honoluluadvertiser.com/apps/pbcs.dll/article?AID=/' + article_id + '&template=printart'
|
||||
|
@ -51,6 +51,7 @@ class LeMondeDiplomatiqueEn(BasicNewsRecipe):
|
||||
, dict(name='div',attrs={'class':'notes surlignable'})
|
||||
]
|
||||
remove_tags = [dict(name=['object','link','script','iframe','base'])]
|
||||
remove_attributes = ['height','width']
|
||||
|
||||
def parse_index(self):
|
||||
articles = []
|
||||
@ -72,5 +73,5 @@ class LeMondeDiplomatiqueEn(BasicNewsRecipe):
|
||||
,'url' :url
|
||||
,'description':description
|
||||
})
|
||||
return [(soup.head.title.string, articles)]
|
||||
return [(self.title, articles)]
|
||||
|
||||
|
@ -11,11 +11,11 @@ http://www.libero-news.it/
|
||||
from calibre.web.feeds.news import BasicNewsRecipe
|
||||
|
||||
class LiberoNews(BasicNewsRecipe):
|
||||
__author__ = 'Marini Gabriele'
|
||||
description = 'Italian daily newspaper'
|
||||
__author__ = 'Marini Gabriele'
|
||||
description = 'Italian daily newspaper'
|
||||
|
||||
cover_url = 'http://www.ilgiornale.it/img_v1/logo.gif'
|
||||
title = u'Libero'
|
||||
cover_url = 'http://www.libero-news.it/images/logo.png'
|
||||
title = u'Libero '
|
||||
publisher = 'EDITORIALE LIBERO s.r.l 2006'
|
||||
category = 'News, politics, culture, economy, general interest'
|
||||
|
||||
|
@ -16,7 +16,7 @@ class NYTimes(BasicNewsRecipe):
|
||||
|
||||
title = 'New York Times Top Stories'
|
||||
__author__ = 'GRiker'
|
||||
language = _('English')
|
||||
language = 'en'
|
||||
description = 'Top Stories from the New York Times'
|
||||
|
||||
# List of sections typically included in Top Stories. Use a keyword from the
|
||||
|
@ -1,9 +1,7 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
__license__ = 'GPL v3'
|
||||
__copyright__ = '2009, Darko Miletic <darko.miletic at gmail.com>'
|
||||
__copyright__ = '2009-2010, Darko Miletic <darko.miletic at gmail.com>'
|
||||
'''
|
||||
rbc.org
|
||||
odb.org
|
||||
'''
|
||||
|
||||
from calibre.web.feeds.news import BasicNewsRecipe
|
||||
@ -11,27 +9,29 @@ from calibre.web.feeds.news import BasicNewsRecipe
|
||||
class OurDailyBread(BasicNewsRecipe):
|
||||
title = 'Our Daily Bread'
|
||||
__author__ = 'Darko Miletic and Sujata Raman'
|
||||
description = 'Religion'
|
||||
description = "Our Daily Bread is a daily devotional from RBC Ministries which helps readers spend time each day in God's Word."
|
||||
oldest_article = 15
|
||||
language = 'en'
|
||||
lang = 'en'
|
||||
|
||||
language = 'en'
|
||||
max_articles_per_feed = 100
|
||||
no_stylesheets = True
|
||||
use_embedded_content = False
|
||||
category = 'religion'
|
||||
category = 'ODB, Daily Devotional, Bible, Christian Devotional, Devotional, RBC Ministries, Our Daily Bread, Devotionals, Daily Devotionals, Christian Devotionals, Faith, Bible Study, Bible Studies, Scripture, RBC, religion'
|
||||
encoding = 'utf-8'
|
||||
|
||||
|
||||
conversion_options = {
|
||||
'comments' : description
|
||||
,'tags' : category
|
||||
,'language' : 'en'
|
||||
'comments' : description
|
||||
,'tags' : category
|
||||
,'language' : language
|
||||
,'linearize_tables' : True
|
||||
}
|
||||
|
||||
keep_only_tags = [dict(name='div', attrs={'class':['altbg','text']})]
|
||||
keep_only_tags = [dict(attrs={'class':'module-content'})]
|
||||
remove_tags = [
|
||||
dict(attrs={'id':'article-zoom'})
|
||||
,dict(attrs={'class':'listen-now-box'})
|
||||
]
|
||||
remove_tags_after = dict(attrs={'class':'readable-area'})
|
||||
|
||||
remove_tags = [dict(name='div', attrs={'id':['ctl00_cphPrimary_pnlBookCover']}),
|
||||
]
|
||||
extra_css = '''
|
||||
.text{font-family:Arial,Helvetica,sans-serif;font-size:x-small;}
|
||||
.devotionalTitle{font-family:Arial,Helvetica,sans-serif; font-size:large; font-weight: bold;}
|
||||
@ -40,14 +40,9 @@ class OurDailyBread(BasicNewsRecipe):
|
||||
a{color:#000000;font-family:Arial,Helvetica,sans-serif; font-size:x-small;}
|
||||
'''
|
||||
|
||||
feeds = [(u'Our Daily Bread', u'http://www.rbc.org/rss.ashx?id=50398')]
|
||||
feeds = [(u'Our Daily Bread', u'http://odb.org/feed/')]
|
||||
|
||||
def preprocess_html(self, soup):
|
||||
soup.html['xml:lang'] = self.lang
|
||||
soup.html['lang'] = self.lang
|
||||
mtag = '<meta http-equiv="Content-Type" content="text/html; charset=' + self.encoding + '">'
|
||||
soup.head.insert(0,mtag)
|
||||
|
||||
return self.adeify_images(soup)
|
||||
|
||||
def get_cover_url(self):
|
||||
@ -61,3 +56,4 @@ class OurDailyBread(BasicNewsRecipe):
|
||||
cover_url = a.img['src']
|
||||
|
||||
return cover_url
|
||||
|
||||
|
43
resources/recipes/reptantes.recipe
Normal file
@ -0,0 +1,43 @@
|
||||
|
||||
__license__ = 'GPL v3'
|
||||
__copyright__ = '2010, Darko Miletic <darko.miletic at gmail.com>'
|
||||
'''
|
||||
www.reptantes.com.ar
|
||||
'''
|
||||
|
||||
from calibre.web.feeds.news import BasicNewsRecipe
|
||||
|
||||
class Reptantes(BasicNewsRecipe):
|
||||
title = 'Reptantes'
|
||||
__author__ = 'Darko Miletic'
|
||||
description = u"cada vez que te haces acupuntura, tu muñeco vudú sufre en algún lado"
|
||||
oldest_article = 130
|
||||
max_articles_per_feed = 100
|
||||
language = 'es'
|
||||
encoding = 'utf-8'
|
||||
no_stylesheets = True
|
||||
use_embedded_content = False
|
||||
publication_type = 'blog'
|
||||
extra_css = ' body{font-family: "Palatino Linotype",serif} h2{text-align: center; color:#BE7F8D} img{margin-bottom: 2em} '
|
||||
|
||||
conversion_options = {
|
||||
'comment' : description
|
||||
, 'tags' : 'literatura'
|
||||
, 'publisher': 'Hernan Racnati'
|
||||
, 'language' : language
|
||||
}
|
||||
|
||||
feeds = [(u'Posts', u'http://www.reptantes.com.ar/?feed=rss2')]
|
||||
|
||||
keep_only_tags = [dict(attrs={'id':'content'})]
|
||||
remove_tags = [dict(attrs={'class':'iLikeThis'})]
|
||||
remove_tags_before = dict(name='h2')
|
||||
remove_tags_after = dict(attrs={'class':'iLikeThis'})
|
||||
|
||||
|
||||
def preprocess_html(self, soup):
|
||||
for item in soup.findAll(style=True):
|
||||
del item['style']
|
||||
return self.adeify_images(soup)
|
||||
|
||||
|
@ -21,7 +21,7 @@ class Smh_au(BasicNewsRecipe):
|
||||
language = 'en_AU'
|
||||
remove_empty_feeds = True
|
||||
masthead_url = 'http://images.smh.com.au/2010/02/02/1087188/smh-620.jpg'
|
||||
publication_type = 'newspaper'
|
||||
publication_type = 'newspaper'
|
||||
extra_css = ' h1{font-family: Georgia,"Times New Roman",Times,serif } body{font-family: Arial,Helvetica,sans-serif} .cT-imageLandscape{font-size: x-small} '
|
||||
|
||||
conversion_options = {
|
||||
@ -47,7 +47,7 @@ class Smh_au(BasicNewsRecipe):
|
||||
for itimg in soup.findAll('img',src=True):
|
||||
if itimg['src'].endswith('frontpage.jpg'):
|
||||
self.cover_url = itimg['src']
|
||||
|
||||
|
||||
for item in soup.findAll(attrs={'class':'cN-storyHeadlineLead cfix'}):
|
||||
description = ''
|
||||
title_prefix = ''
|
||||
@ -65,4 +65,4 @@ class Smh_au(BasicNewsRecipe):
|
||||
,'url' :url
|
||||
,'description':description
|
||||
})
|
||||
return [(soup.head.title.string, articles)]
|
||||
return [(self.tag_to_string(soup.find('title')), articles)]
|
||||
|
47
resources/recipes/staradvertiser.recipe
Normal file
@ -0,0 +1,47 @@
|
||||
__license__ = 'GPL v3'
|
||||
__copyright__ = '2009-2010, Darko Miletic <darko.miletic at gmail.com>'
|
||||
'''
|
||||
staradvertiser.com
|
||||
'''
|
||||
|
||||
from calibre.web.feeds.news import BasicNewsRecipe
|
||||
|
||||
class Starbulletin(BasicNewsRecipe):
|
||||
title = 'Honolulu Star Advertiser'
|
||||
__author__ = 'Darko Miletic'
|
||||
description = "Latest national and local Hawaii sports news"
|
||||
publisher = 'Honolulu Star-Advertiser'
|
||||
category = 'news, Honolulu, Hawaii'
|
||||
oldest_article = 2
|
||||
max_articles_per_feed = 100
|
||||
language = 'en'
|
||||
no_stylesheets = True
|
||||
use_embedded_content = False
|
||||
encoding = 'utf8'
|
||||
publication_type = 'newspaper'
|
||||
extra_css = ' body{font-family: Verdana,Arial,Helvetica,sans-serif} h1,.brown,.postCredit{color: #663300} .storyDeck{font-size: 1.2em; font-weight: bold} '
|
||||
|
||||
conversion_options = {
|
||||
'comment' : description
|
||||
, 'tags' : category
|
||||
, 'publisher' : publisher
|
||||
, 'language' : language
|
||||
, 'linearize_tables' : True
|
||||
}
|
||||
|
||||
remove_tags_before = dict(attrs={'id':'storyTitle'})
|
||||
remove_tags_after = dict(name='div', attrs={'class':'storytext'})
|
||||
remove_tags = [
|
||||
dict(name=['object','link'])
|
||||
,dict(attrs={'class':'insideStoryImage'})
|
||||
]
|
||||
|
||||
feeds = [
|
||||
(u'Headlines' , u'http://www.staradvertiser.com/staradvertiser_headlines.rss' )
|
||||
,(u'News' , u'http://www.staradvertiser.com/news/index.rss' )
|
||||
,(u'Sports' , u'http://www.staradvertiser.com/sports/index.rss' )
|
||||
,(u'Features' , u'http://www.staradvertiser.com/features/index.rss' )
|
||||
,(u'Editorials', u'http://www.staradvertiser.com/editorials/index.rss' )
|
||||
,(u'Business' , u'http://www.staradvertiser.com/business/index.rss' )
|
||||
,(u'Travel' , u'http://www.staradvertiser.com/travel/index.rss' )
|
||||
]
|
@ -1,60 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
__license__ = 'GPL v3'
|
||||
__copyright__ = '2009, Darko Miletic <darko.miletic at gmail.com>'
|
||||
'''
|
||||
starbulletin.com
|
||||
'''
|
||||
|
||||
from calibre.web.feeds.news import BasicNewsRecipe
|
||||
|
||||
class Starbulletin(BasicNewsRecipe):
|
||||
title = 'Honolulu Star-Bulletin'
|
||||
__author__ = 'Darko Miletic'
|
||||
description = "Latest national and local Hawaii sports news"
|
||||
publisher = 'Honolulu Star-Bulletin'
|
||||
category = 'news, Honolulu, Hawaii'
|
||||
oldest_article = 2
|
||||
max_articles_per_feed = 100
|
||||
language = 'en'
|
||||
|
||||
no_stylesheets = True
|
||||
use_embedded_content = False
|
||||
encoding = 'utf8'
|
||||
remove_javascript = True
|
||||
cover_url = 'http://media.starbulletin.com/designimages/spacer.gif'
|
||||
|
||||
html2lrf_options = [
|
||||
'--comment' , description
|
||||
, '--category' , category
|
||||
, '--publisher' , publisher
|
||||
]
|
||||
|
||||
html2epub_options = 'publisher="' + publisher + '"\ncomments="' + description + '"\ntags="' + category + '"'
|
||||
|
||||
keep_only_tags = [ dict(name='div', attrs={'id':'storyColoumn'}) ]
|
||||
|
||||
remove_tags = [
|
||||
dict(name=['object','link'])
|
||||
,dict(name='span', attrs={'id':'printdesc'})
|
||||
,dict(name='div' , attrs={'class':'lightGreyBox storyTools clearAll'})
|
||||
,dict(name='div' , attrs={'id':'breadcrumbs'})
|
||||
]
|
||||
|
||||
feeds = [
|
||||
(u'Headlines', u'http://www.starbulletin.com/starbulletin_headlines.rss' )
|
||||
,(u'News', u'http://www.starbulletin.com/news/index.rss' )
|
||||
,(u'Sports', u'http://www.starbulletin.com/sports/index.rss' )
|
||||
,(u'Features', u'http://www.starbulletin.com/features/index.rss' )
|
||||
,(u'Editorials', u'http://www.starbulletin.com/editorials/index.rss' )
|
||||
,(u'Business', u'http://www.starbulletin.com/business/index.rss' )
|
||||
,(u'Travel', u'http://www.starbulletin.com/travel/index.rss' )
|
||||
]
|
||||
|
||||
def preprocess_html(self, soup):
|
||||
for item in soup.findAll(style=True):
|
||||
del item['style']
|
||||
mtag = '\n<meta http-equiv="Content-Language" content="en"/>\n'
|
||||
soup.head.insert(0,mtag)
|
||||
return soup
|
||||
|
@ -19,10 +19,10 @@ class Sueddeutsche(BasicNewsRecipe):
|
||||
no_stylesheets = True
|
||||
language = 'de'
|
||||
|
||||
encoding = 'iso-8859-15'
|
||||
encoding = 'utf-8'
|
||||
remove_javascript = True
|
||||
|
||||
|
||||
|
||||
remove_tags = [ dict(name='link'), dict(name='iframe'),
|
||||
dict(name='div', attrs={'id':["bookmarking","themenbox","artikelfoot","CAD_AD",
|
||||
"SKY_AD","NT1_AD","navbar1","sdesiteheader"]}),
|
||||
|
58
resources/recipes/thairath.recipe
Normal file
@ -0,0 +1,58 @@
|
||||
from calibre.web.feeds.news import BasicNewsRecipe
|
||||
|
||||
class AdvancedUserRecipe1271637235(BasicNewsRecipe):
|
||||
|
||||
title = u'Thairath'
|
||||
__author__ = 'Anat R.'
|
||||
language = 'th'
|
||||
|
||||
oldest_article = 7
|
||||
|
||||
max_articles_per_feed = 100
|
||||
no_stylesheets = True
|
||||
|
||||
remove_javascript = True
|
||||
|
||||
use_embedded_content = False
|
||||
feeds = [(u'News',
|
||||
u'http://www.thairath.co.th/rss/news.xml'), (u'Politics',
|
||||
u'http://www.thairath.co.th/rss/pol.xml'), (u'Economy',
|
||||
u'http://www.thairath.co.th/rss/eco.xml'), (u'International',
|
||||
u'http://www.thairath.co.th/rss/oversea.xml'), (u'Sports',
|
||||
u'http://www.thairath.co.th/rss/sport.xml'), (u'Life',
|
||||
u'http://www.thairath.co.th/rss/life.xml'), (u'Education',
|
||||
u'http://www.thairath.co.th/rss/edu.xml'), (u'Tech',
|
||||
u'http://www.thairath.co..th/rss/tech.xml'), (u'Entertainment',
|
||||
u'http://www.thairath.co.th/rss/ent.xml')]
|
||||
keep_only_tags = []
|
||||
|
||||
keep_only_tags.append(dict(name = 'h1', attrs = {'id' : 'title'}))
|
||||
|
||||
keep_only_tags.append(dict(name = 'ul', attrs = {'class' :
|
||||
'detail-info'}))
|
||||
|
||||
keep_only_tags.append(dict(name = 'img', attrs = {'class' :
|
||||
'detail-image'}))
|
||||
|
||||
keep_only_tags.append(dict(name = 'div', attrs = {'class' :
|
||||
'entry'}))
|
||||
remove_tags = []
|
||||
remove_tags.append(dict(name = 'div', attrs = {'id':
|
||||
'menu-holder'}))
|
||||
|
||||
remove_tags.append(dict(name = 'div', attrs = {'class':
|
||||
'addthis_toolbox addthis_default_style'}))
|
||||
|
||||
remove_tags.append(dict(name = 'div', attrs = {'class': 'box top-item'}))
|
||||
|
||||
remove_tags.append(dict(name = 'div', attrs = {'class': 'column-200 column-margin-430'}))
|
||||
|
||||
remove_tags.append(dict(name = 'div', attrs = {'id':
|
||||
'detail-related'}))
|
||||
|
||||
remove_tags.append(dict(name = 'div', attrs = {'id': 'related'}))
|
||||
|
||||
remove_tags.append(dict(name = 'id', attrs = {'class': 'footer'}))
|
||||
|
||||
remove_tags.append(dict(name = "ul",attrs =
|
||||
{'id':'banner-highlights-images'}))
|
44
resources/recipes/the_nation_thai.recipe
Normal file
@ -0,0 +1,44 @@
|
||||
|
||||
from calibre.web.feeds.news import BasicNewsRecipe
|
||||
|
||||
class AdvancedUserRecipe1271596863(BasicNewsRecipe):
|
||||
|
||||
title = u'The Nation'
|
||||
__author__ = 'Anat R.'
|
||||
language = 'en_TH'
|
||||
|
||||
oldest_article = 7
|
||||
|
||||
max_articles_per_feed = 100
|
||||
no_stylesheets = True
|
||||
|
||||
remove_javascript = True
|
||||
|
||||
use_embedded_content = False
|
||||
feeds = [(u'Topstory',
|
||||
u'http://www.nationmultimedia.com/home/rss/topstories.rss'),
|
||||
(u'National', u'http://www.nationmultimedia.com/home/rss/national.rss'),
|
||||
(u'Politics',
|
||||
u'http://www.nationmultimedia.com/home/rss/politics.rss'), (u'Business',
|
||||
u'http://www.nationmultimedia.com/home/rss/business.rss'),
|
||||
(u'Regional', u'http://www.nationmultimedia.com/home/rss/regional.rss'),
|
||||
(u'Sports', u'http://www.nationmultimedia.com/home/rss/sport.rss'),
|
||||
(u'Travel', u'http://www.nationmultimedia.com/home/rss/travel.rss'),
|
||||
(u'Life', u'http://www.nationmultimedia.com/home/rss/life.rss')]
|
||||
keep_only_tags = []
|
||||
|
||||
keep_only_tags.append(dict(name = 'div', attrs = {'class' :
|
||||
'pd10'}))
|
||||
remove_tags = []
|
||||
|
||||
remove_tags.append(dict(name = 'div', attrs = {'class':
|
||||
'WrapperHeaderCol2-2'}))
|
||||
|
||||
remove_tags.append(dict(name = 'div', attrs = {'class':
|
||||
'LayoutMenu2'}))
|
||||
|
||||
remove_tags.append(dict(name = 'div', attrs = {'class':
|
||||
'TextHeaderRight'}))
|
||||
|
||||
remove_tags.append(dict(name = "ul",attrs = {'id':'toolZoom'}))
|
||||
|
@ -16,7 +16,7 @@ class DailyTelegraph(BasicNewsRecipe):
|
||||
language = 'en_AU'
|
||||
|
||||
oldest_article = 2
|
||||
max_articles_per_feed = 10
|
||||
max_articles_per_feed = 20
|
||||
remove_javascript = True
|
||||
no_stylesheets = True
|
||||
encoding = 'utf8'
|
||||
|
@ -1,5 +1,6 @@
|
||||
import re
|
||||
from calibre.web.feeds.news import BasicNewsRecipe
|
||||
from calibre.ebooks.BeautifulSoup import Tag
|
||||
|
||||
class AdvancedUserRecipe1268409464(BasicNewsRecipe):
|
||||
title = u'The Sun'
|
||||
@ -14,24 +15,27 @@ class AdvancedUserRecipe1268409464(BasicNewsRecipe):
|
||||
remove_javascript = True
|
||||
|
||||
keep_only_tags = [
|
||||
dict(name='div', attrs={'class':'medium-centered'})
|
||||
,dict(name='div', attrs={'class':'article'})
|
||||
,dict(name='div', attrs={'class':'clear-left'})
|
||||
,dict(name='div', attrs={'class':'text-center'})
|
||||
dict(id='column-print')
|
||||
]
|
||||
|
||||
remove_tags = [
|
||||
dict(name='div', attrs={'class':'slideshow'})
|
||||
,dict(name='div', attrs={'class':'float-left'})
|
||||
,dict(name='div', attrs={'class':'ltbx-slideshow ltbx-btn-ss'})
|
||||
,dict(name='a', attrs={'class':'add_a_comment'})
|
||||
,dict(name='div', attrs={'id':'vxFlashPlayerContent'})
|
||||
,dict(name='div', attrs={'id':'k1006094r1c1t5w380h529'})
|
||||
,dict(name='div', attrs={'id':'tum_login_form_container'})
|
||||
,dict(name='div', attrs={'class':'discHeader'})
|
||||
,dict(name='div', attrs={'class':'margin-bottom-neg-2'})
|
||||
dict(name='div', attrs={'class':[
|
||||
'clear text-center small padding-left-right-5 text-999 padding-top-5 padding-bottom-10 grey-solid-line',
|
||||
'clear width-625 bg-fff padding-top-10'
|
||||
]}),
|
||||
dict(name='video'),
|
||||
]
|
||||
|
||||
def preprocess_html(self, soup):
|
||||
h1 = soup.find('h1')
|
||||
if h1 is not None:
|
||||
text = self.tag_to_string(h1)
|
||||
nh = Tag(soup, 'h1')
|
||||
nh.insert(0, text)
|
||||
h1.replaceWith(nh)
|
||||
|
||||
return soup
|
||||
|
||||
|
||||
feeds = [(u'News', u'http://www.thesun.co.uk/sol/homepage/feeds/rss/article312900.ece')
|
||||
,(u'Sport', u'http://www.thesun.co.uk/sol/homepage/feeds/rss/article247732.ece')
|
||||
|
@ -2,7 +2,7 @@ __license__ = 'GPL v3'
|
||||
__copyright__ = '2008, Kovid Goyal kovid@kovidgoyal.net'
|
||||
__docformat__ = 'restructuredtext en'
|
||||
__appname__ = 'calibre'
|
||||
__version__ = '0.7.1'
|
||||
__version__ = '0.7.2'
|
||||
__author__ = "Kovid Goyal <kovid@kovidgoyal.net>"
|
||||
|
||||
import re
|
||||
|
@ -445,7 +445,7 @@ from calibre.devices.nook.driver import NOOK
|
||||
from calibre.devices.prs505.driver import PRS505
|
||||
from calibre.devices.android.driver import ANDROID, S60
|
||||
from calibre.devices.nokia.driver import N770, N810, E71X
|
||||
from calibre.devices.eslick.driver import ESLICK
|
||||
from calibre.devices.eslick.driver import ESLICK, EBK52
|
||||
from calibre.devices.nuut2.driver import NUUT2
|
||||
from calibre.devices.iriver.driver import IRIVER_STORY
|
||||
from calibre.devices.binatone.driver import README
|
||||
@ -519,6 +519,7 @@ plugins += [
|
||||
N810,
|
||||
COOL_ER,
|
||||
ESLICK,
|
||||
EBK52,
|
||||
NUUT2,
|
||||
IRIVER_STORY,
|
||||
GER2,
|
||||
|
@ -30,7 +30,7 @@ class ANDROID(USBMS):
|
||||
0x18d1 : { 0x4e11 : [0x0100, 0x226], 0x4e12: [0x0100, 0x226]},
|
||||
|
||||
# Samsung
|
||||
0x04e8 : { 0x681d : [0x0222], 0x681c : [0x0222, 0x0224]},
|
||||
0x04e8 : { 0x681d : [0x0222, 0x0400], 0x681c : [0x0222, 0x0224]},
|
||||
|
||||
# Acer
|
||||
0x502 : { 0x3203 : [0x0100]},
|
||||
@ -41,10 +41,12 @@ class ANDROID(USBMS):
|
||||
'be used')
|
||||
EXTRA_CUSTOMIZATION_DEFAULT = ', '.join(EBOOK_DIR_MAIN)
|
||||
|
||||
VENDOR_NAME = ['HTC', 'MOTOROLA', 'GOOGLE_', 'ANDROID', 'ACER', 'GT-I5700']
|
||||
VENDOR_NAME = ['HTC', 'MOTOROLA', 'GOOGLE_', 'ANDROID', 'ACER',
|
||||
'GT-I5700', 'SAMSUNG']
|
||||
WINDOWS_MAIN_MEM = ['ANDROID_PHONE', 'A855', 'A853', 'INC.NEXUS_ONE',
|
||||
'__UMS_COMPOSITE', '_MB200', 'MASS_STORAGE', '_-_CARD']
|
||||
WINDOWS_CARD_A_MEM = ['ANDROID_PHONE']
|
||||
'__UMS_COMPOSITE', '_MB200', 'MASS_STORAGE', '_-_CARD',
|
||||
'PROD_GT-I9000']
|
||||
WINDOWS_CARD_A_MEM = ['ANDROID_PHONE', 'PROD_GT-I9000_CARD']
|
||||
|
||||
OSX_MAIN_MEM = 'HTC Android Phone Media'
|
||||
|
||||
|
@ -36,4 +36,29 @@ class ESLICK(USBMS):
|
||||
|
||||
SUPPORTS_SUB_DIRS = True
|
||||
|
||||
@classmethod
|
||||
def can_handle(cls, dev, debug=False):
|
||||
return (dev[3], dev[4]) != ('philips', 'Philips d')
|
||||
|
||||
|
||||
|
||||
class EBK52(ESLICK):
|
||||
|
||||
name = 'EBK-52 Device Interface'
|
||||
gui_name = 'Sigmatek EBK'
|
||||
description = _('Communicate with the Sigmatek eBook reader.')
|
||||
|
||||
FORMATS = ['epub', 'fb2', 'pdf', 'txt']
|
||||
|
||||
VENDOR_NAME = ''
|
||||
WINDOWS_MAIN_MEM = WINDOWS_CARD_A_MEM = 'EBOOK_READER'
|
||||
|
||||
MAIN_MEMORY_VOLUME_LABEL = 'Sigmatek Main Memory'
|
||||
STORAGE_CARD_VOLUME_LABEL = 'Sigmatek Storage Card'
|
||||
|
||||
|
||||
@classmethod
|
||||
def can_handle(cls, dev, debug=False):
|
||||
return (dev[3], dev[4]) == ('philips', 'Philips d')
|
||||
|
||||
|
||||
|
@ -123,5 +123,12 @@ class BOOX(HANLINV3):
|
||||
EBOOK_DIR_MAIN = 'MyBooks'
|
||||
EBOOK_DIR_CARD_A = 'MyBooks'
|
||||
|
||||
def windows_sort_drives(self, drives):
|
||||
return drives
|
||||
|
||||
def osx_sort_names(self, names):
|
||||
return names
|
||||
|
||||
def linux_swap_drives(self, drives):
|
||||
return drives
|
||||
|
||||
|
@ -287,7 +287,12 @@ class DevicePlugin(Plugin):
|
||||
This method should raise a L{FreeSpaceError} if there is not enough
|
||||
free space on the device. The text of the FreeSpaceError must contain the
|
||||
word "card" if C{on_card} is not None otherwise it must contain the word "memory".
|
||||
:files: A list of paths and/or file-like objects.
|
||||
:files: A list of paths and/or file-like objects. If they are paths and
|
||||
the paths point to temporary files, they may have an additional
|
||||
attribute, original_file_path pointing to the originals. They may have
|
||||
another optional attribute, deleted_after_upload which if True means
|
||||
that the file pointed to by original_file_path will be deleted after
|
||||
being uploaded to the device.
|
||||
:names: A list of file names that the books should have
|
||||
once uploaded to the device. len(names) == len(files)
|
||||
:return: A list of 3-element tuples. The list is meant to be passed
|
||||
|
@ -7,12 +7,33 @@ __docformat__ = 'restructuredtext en'
|
||||
'''
|
||||
Device driver for Amazon's Kindle
|
||||
'''
|
||||
import datetime, os, re, sys
|
||||
import datetime, os, re, sys, json, hashlib
|
||||
from cStringIO import StringIO
|
||||
from struct import unpack
|
||||
|
||||
from calibre.devices.usbms.driver import USBMS
|
||||
|
||||
'''
|
||||
Notes on collections:
|
||||
|
||||
A collections cache is stored at system/collections.json
|
||||
The cache is read only, changes made to it are overwritten (it is regenerated)
|
||||
on device disconnect
|
||||
|
||||
A log of collection creation/manipulation is available at
|
||||
system/userannotationlog
|
||||
|
||||
collections.json refers to books via a SHA1 hash of the absolute path to the
|
||||
book (prefix is /mnt/us on my Kindle). The SHA1 hash may or may not be prefixed
|
||||
by some characters, use the last 40 characters.
|
||||
|
||||
Changing the metadata and resending the file doesn't seem to affect collections
|
||||
|
||||
Adding a book to a collection on the Kindle does not change the book file at all
|
||||
(i.e. it is binary identical). Therefore collection information is not stored in
|
||||
file metadata.
|
||||
'''
|
||||
|
||||
class KINDLE(USBMS):
|
||||
|
||||
name = 'Kindle Device Interface'
|
||||
@ -60,6 +81,7 @@ class KINDLE(USBMS):
|
||||
'replace')
|
||||
return mi
|
||||
|
||||
|
||||
def get_annotations(self, path_map):
|
||||
MBP_FORMATS = [u'azw', u'mobi', u'prc', u'txt']
|
||||
mbp_formats = set(MBP_FORMATS)
|
||||
@ -150,6 +172,37 @@ class KINDLE2(KINDLE):
|
||||
PRODUCT_ID = [0x0002]
|
||||
BCD = [0x0100]
|
||||
|
||||
def books(self, oncard=None, end_session=True):
|
||||
bl = USBMS.books(self, oncard=oncard, end_session=end_session)
|
||||
# Read collections information
|
||||
collections = os.path.join(self._main_prefix, 'system', 'collections.json')
|
||||
if os.access(collections, os.R_OK):
|
||||
try:
|
||||
self.kindle_update_booklist(bl, collections)
|
||||
except:
|
||||
import traceback
|
||||
traceback.print_exc()
|
||||
return bl
|
||||
|
||||
def kindle_update_booklist(self, bl, collections):
|
||||
with open(collections, 'rb') as f:
|
||||
collections = f.read()
|
||||
collections = json.loads(collections)
|
||||
path_map = {}
|
||||
for name, val in collections.items():
|
||||
col = name.split('@')[0]
|
||||
items = val.get('items', [])
|
||||
for x in items:
|
||||
x = x[-40:]
|
||||
if x not in path_map:
|
||||
path_map[x] = set([])
|
||||
path_map[x].add(col)
|
||||
if path_map:
|
||||
for book in bl:
|
||||
path = '/mnt/us/'+book.lpath
|
||||
h = hashlib.sha1(path).hexdigest()
|
||||
if h in path_map:
|
||||
book.device_collections = list(sorted(path_map[h]))
|
||||
|
||||
class KINDLE_DX(KINDLE2):
|
||||
|
||||
|
@ -337,7 +337,7 @@ def main():
|
||||
dev.touch(args[0])
|
||||
elif command == 'test_file':
|
||||
parser = OptionParser(usage=("usage: %prog test_file path\n"
|
||||
'Open device, copy file psecified by path to device and '
|
||||
'Open device, copy file specified by path to device and '
|
||||
'then eject device.'))
|
||||
options, args = parser.parse_args(args)
|
||||
if len(args) != 1:
|
||||
|
@ -8,7 +8,7 @@ Device driver for the SONY devices
|
||||
|
||||
import os, time, re
|
||||
|
||||
from calibre.devices.usbms.driver import USBMS
|
||||
from calibre.devices.usbms.driver import USBMS, debug_print
|
||||
from calibre.devices.prs505 import MEDIA_XML
|
||||
from calibre.devices.prs505 import CACHE_XML
|
||||
from calibre.devices.prs505.sony_cache import XMLCache
|
||||
@ -128,26 +128,31 @@ class PRS505(USBMS):
|
||||
return XMLCache(paths, prefixes)
|
||||
|
||||
def books(self, oncard=None, end_session=True):
|
||||
debug_print('PRS505: starting fetching books for card', oncard)
|
||||
bl = USBMS.books(self, oncard=oncard, end_session=end_session)
|
||||
c = self.initialize_XML_cache()
|
||||
c.update_booklist(bl, {'carda':1, 'cardb':2}.get(oncard, 0))
|
||||
debug_print('PRS505: finished fetching books for card', oncard)
|
||||
return bl
|
||||
|
||||
def sync_booklists(self, booklists, end_session=True):
|
||||
debug_print('PRS505: started sync_booklists')
|
||||
c = self.initialize_XML_cache()
|
||||
blists = {}
|
||||
for i in c.paths:
|
||||
if booklists[i] is not None:
|
||||
blists[i] = booklists[i]
|
||||
opts = self.settings()
|
||||
collections = ['series', 'tags']
|
||||
if opts.extra_customization:
|
||||
collections = [x.strip() for x in
|
||||
opts.extra_customization.split(',')]
|
||||
|
||||
else:
|
||||
collections = []
|
||||
debug_print('PRS505: collection fields:', collections)
|
||||
c.update(blists, collections)
|
||||
c.write()
|
||||
|
||||
USBMS.sync_booklists(self, booklists, end_session=end_session)
|
||||
debug_print('PRS505: finished sync_booklists')
|
||||
|
||||
|
||||
|
@ -14,6 +14,7 @@ from lxml import etree
|
||||
|
||||
from calibre import prints, guess_type
|
||||
from calibre.devices.errors import DeviceError
|
||||
from calibre.devices.usbms.driver import debug_print
|
||||
from calibre.constants import DEBUG
|
||||
from calibre.ebooks.chardet import xml_to_unicode
|
||||
from calibre.ebooks.metadata import authors_to_string, title_sort
|
||||
@ -46,7 +47,7 @@ def strptime(src):
|
||||
src[2] = str(MONTH_MAP[src[2]])
|
||||
return time.strptime(' '.join(src), '%w, %d %m %Y %H:%M:%S %Z')
|
||||
|
||||
def strftime(epoch, zone=time.gmtime):
|
||||
def strftime(epoch, zone=time.localtime):
|
||||
src = time.strftime("%w, %d %m %Y %H:%M:%S GMT", zone(epoch)).split()
|
||||
src[0] = INVERSE_DAY_MAP[int(src[0][:-1])]+','
|
||||
src[2] = INVERSE_MONTH_MAP[int(src[2])]
|
||||
@ -61,7 +62,7 @@ class XMLCache(object):
|
||||
|
||||
def __init__(self, paths, prefixes):
|
||||
if DEBUG:
|
||||
prints('Building XMLCache...')
|
||||
debug_print('Building XMLCache...')
|
||||
pprint(paths)
|
||||
self.paths = paths
|
||||
self.prefixes = prefixes
|
||||
@ -97,16 +98,17 @@ class XMLCache(object):
|
||||
self.record_roots[0] = recs[0]
|
||||
|
||||
self.detect_namespaces()
|
||||
debug_print('Done building XMLCache...')
|
||||
|
||||
|
||||
# Playlist management {{{
|
||||
def purge_broken_playlist_items(self, root):
|
||||
id_map = self.build_id_map(root)
|
||||
for pl in root.xpath('//*[local-name()="playlist"]'):
|
||||
seen = set([])
|
||||
for item in list(pl):
|
||||
id_ = item.get('id', None)
|
||||
if id_ is None or id_ in seen or not root.xpath(
|
||||
'//*[local-name()!="item" and @id="%s"]'%id_):
|
||||
if id_ is None or id_ in seen or id_map.get(id_, None) is None:
|
||||
if DEBUG:
|
||||
if id_ is None:
|
||||
cause = 'invalid id'
|
||||
@ -127,7 +129,7 @@ class XMLCache(object):
|
||||
for playlist in root.xpath('//*[local-name()="playlist"]'):
|
||||
if len(playlist) == 0 or not playlist.get('title', None):
|
||||
if DEBUG:
|
||||
prints('Removing playlist id:', playlist.get('id', None),
|
||||
debug_print('Removing playlist id:', playlist.get('id', None),
|
||||
playlist.get('title', None))
|
||||
playlist.getparent().remove(playlist)
|
||||
|
||||
@ -149,20 +151,25 @@ class XMLCache(object):
|
||||
seen.add(title)
|
||||
|
||||
def get_playlist_map(self):
|
||||
debug_print('Start get_playlist_map')
|
||||
ans = {}
|
||||
self.ensure_unique_playlist_titles()
|
||||
debug_print('after ensure_unique_playlist_titles')
|
||||
self.prune_empty_playlists()
|
||||
debug_print('get_playlist_map loop')
|
||||
for i, root in self.record_roots.items():
|
||||
debug_print('get_playlist_map loop', i)
|
||||
id_map = self.build_id_map(root)
|
||||
ans[i] = []
|
||||
for playlist in root.xpath('//*[local-name()="playlist"]'):
|
||||
items = []
|
||||
for item in playlist:
|
||||
id_ = item.get('id', None)
|
||||
records = root.xpath(
|
||||
'//*[local-name()="text" and @id="%s"]'%id_)
|
||||
if records:
|
||||
items.append(records[0])
|
||||
record = id_map.get(id_, None)
|
||||
if record is not None:
|
||||
items.append(record)
|
||||
ans[i].append((playlist.get('title'), items))
|
||||
debug_print('end get_playlist_map')
|
||||
return ans
|
||||
|
||||
def get_or_create_playlist(self, bl_idx, title):
|
||||
@ -171,7 +178,7 @@ class XMLCache(object):
|
||||
if playlist.get('title', None) == title:
|
||||
return playlist
|
||||
if DEBUG:
|
||||
prints('Creating playlist:', title)
|
||||
debug_print('Creating playlist:', title)
|
||||
ans = root.makeelement('{%s}playlist'%self.namespaces[bl_idx],
|
||||
nsmap=root.nsmap, attrib={
|
||||
'uuid' : uuid(),
|
||||
@ -185,7 +192,7 @@ class XMLCache(object):
|
||||
|
||||
def fix_ids(self): # {{{
|
||||
if DEBUG:
|
||||
prints('Running fix_ids()')
|
||||
debug_print('Running fix_ids()')
|
||||
|
||||
def ensure_numeric_ids(root):
|
||||
idmap = {}
|
||||
@ -198,8 +205,8 @@ class XMLCache(object):
|
||||
idmap[id_] = '-1'
|
||||
|
||||
if DEBUG and idmap:
|
||||
prints('Found non numeric ids:')
|
||||
prints(list(idmap.keys()))
|
||||
debug_print('Found non numeric ids:')
|
||||
debug_print(list(idmap.keys()))
|
||||
return idmap
|
||||
|
||||
def remap_playlist_references(root, idmap):
|
||||
@ -210,7 +217,7 @@ class XMLCache(object):
|
||||
if id_ in idmap:
|
||||
item.set('id', idmap[id_])
|
||||
if DEBUG:
|
||||
prints('Remapping id %s to %s'%(id_, idmap[id_]))
|
||||
debug_print('Remapping id %s to %s'%(id_, idmap[id_]))
|
||||
|
||||
def ensure_media_xml_base_ids(root):
|
||||
for num, tag in enumerate(('library', 'watchSpecial')):
|
||||
@ -260,6 +267,8 @@ class XMLCache(object):
|
||||
last_bl = max(self.roots.keys())
|
||||
max_id = self.max_id(self.roots[last_bl])
|
||||
self.roots[0].set('nextID', str(max_id+1))
|
||||
debug_print('Finished running fix_ids()')
|
||||
|
||||
# }}}
|
||||
|
||||
# Update JSON from XML {{{
|
||||
@ -267,7 +276,7 @@ class XMLCache(object):
|
||||
if bl_index not in self.record_roots:
|
||||
return
|
||||
if DEBUG:
|
||||
prints('Updating JSON cache:', bl_index)
|
||||
debug_print('Updating JSON cache:', bl_index)
|
||||
root = self.record_roots[bl_index]
|
||||
pmap = self.get_playlist_map()[bl_index]
|
||||
playlist_map = {}
|
||||
@ -279,13 +288,14 @@ class XMLCache(object):
|
||||
playlist_map[path] = []
|
||||
playlist_map[path].append(title)
|
||||
|
||||
lpath_map = self.build_lpath_map(root)
|
||||
for book in bl:
|
||||
record = self.book_by_lpath(book.lpath, root)
|
||||
record = lpath_map.get(book.lpath, None)
|
||||
if record is not None:
|
||||
title = record.get('title', None)
|
||||
if title is not None and title != book.title:
|
||||
if DEBUG:
|
||||
prints('Renaming title', book.title, 'to', title)
|
||||
debug_print('Renaming title', book.title, 'to', title)
|
||||
book.title = title
|
||||
# We shouldn't do this for Sonys, because the reader strips
|
||||
# all but the first author.
|
||||
@ -310,20 +320,24 @@ class XMLCache(object):
|
||||
if book.lpath in playlist_map:
|
||||
tags = playlist_map[book.lpath]
|
||||
book.device_collections = tags
|
||||
debug_print('Finished updating JSON cache:', bl_index)
|
||||
|
||||
# }}}
|
||||
|
||||
# Update XML from JSON {{{
|
||||
def update(self, booklists, collections_attributes):
|
||||
debug_print('Starting update XML from JSON')
|
||||
playlist_map = self.get_playlist_map()
|
||||
|
||||
for i, booklist in booklists.items():
|
||||
if DEBUG:
|
||||
prints('Updating XML Cache:', i)
|
||||
debug_print('Updating XML Cache:', i)
|
||||
root = self.record_roots[i]
|
||||
lpath_map = self.build_lpath_map(root)
|
||||
for book in booklist:
|
||||
path = os.path.join(self.prefixes[i], *(book.lpath.split('/')))
|
||||
record = self.book_by_lpath(book.lpath, root)
|
||||
# record = self.book_by_lpath(book.lpath, root)
|
||||
record = lpath_map.get(book.lpath, None)
|
||||
if record is None:
|
||||
record = self.create_text_record(root, i, book.lpath)
|
||||
self.update_text_record(record, book, path, i)
|
||||
@ -337,16 +351,19 @@ class XMLCache(object):
|
||||
# This is needed to update device_collections
|
||||
for i, booklist in booklists.items():
|
||||
self.update_booklist(booklist, i)
|
||||
debug_print('Finished update XML from JSON')
|
||||
|
||||
def update_playlists(self, bl_index, root, booklist, playlist_map,
|
||||
collections_attributes):
|
||||
debug_print('Starting update_playlists')
|
||||
collections = booklist.get_collections(collections_attributes)
|
||||
lpath_map = self.build_lpath_map(root)
|
||||
for category, books in collections.items():
|
||||
records = [self.book_by_lpath(b.lpath, root) for b in books]
|
||||
records = [lpath_map.get(b.lpath, None) for b in books]
|
||||
# Remove any books that were not found, although this
|
||||
# *should* never happen
|
||||
if DEBUG and None in records:
|
||||
prints('WARNING: Some elements in the JSON cache were not'
|
||||
debug_print('WARNING: Some elements in the JSON cache were not'
|
||||
' found in the XML cache')
|
||||
records = [x for x in records if x is not None]
|
||||
for rec in records:
|
||||
@ -355,7 +372,7 @@ class XMLCache(object):
|
||||
ids = [x.get('id', None) for x in records]
|
||||
if None in ids:
|
||||
if DEBUG:
|
||||
prints('WARNING: Some <text> elements do not have ids')
|
||||
debug_print('WARNING: Some <text> elements do not have ids')
|
||||
ids = [x for x in ids if x is not None]
|
||||
|
||||
playlist = self.get_or_create_playlist(bl_index, category)
|
||||
@ -379,20 +396,21 @@ class XMLCache(object):
|
||||
title = playlist.get('title', None)
|
||||
if title not in collections:
|
||||
if DEBUG:
|
||||
prints('Deleting playlist:', playlist.get('title', ''))
|
||||
debug_print('Deleting playlist:', playlist.get('title', ''))
|
||||
playlist.getparent().remove(playlist)
|
||||
continue
|
||||
books = collections[title]
|
||||
records = [self.book_by_lpath(b.lpath, root) for b in books]
|
||||
records = [lpath_map.get(b.lpath, None) for b in books]
|
||||
records = [x for x in records if x is not None]
|
||||
ids = [x.get('id', None) for x in records]
|
||||
ids = [x for x in ids if x is not None]
|
||||
for item in list(playlist):
|
||||
if item.get('id', None) not in ids:
|
||||
if DEBUG:
|
||||
prints('Deleting item:', item.get('id', ''),
|
||||
debug_print('Deleting item:', item.get('id', ''),
|
||||
'from playlist:', playlist.get('title', ''))
|
||||
playlist.remove(item)
|
||||
debug_print('Finishing update_playlists')
|
||||
|
||||
def create_text_record(self, root, bl_id, lpath):
|
||||
namespace = self.namespaces[bl_id]
|
||||
@ -405,14 +423,9 @@ class XMLCache(object):
|
||||
return ans
|
||||
|
||||
def update_text_record(self, record, book, path, bl_index):
|
||||
timestamp = os.path.getctime(path)
|
||||
timestamp = os.path.getmtime(path)
|
||||
date = strftime(timestamp)
|
||||
if date != record.get('date', None):
|
||||
if DEBUG:
|
||||
prints('Changing date of', path, 'from',
|
||||
record.get('date', ''), 'to', date)
|
||||
prints('\tctime', strftime(os.path.getctime(path)))
|
||||
prints('\tmtime', strftime(os.path.getmtime(path)))
|
||||
record.set('date', date)
|
||||
record.set('size', str(os.stat(path).st_size))
|
||||
title = book.title if book.title else _('Unknown')
|
||||
@ -475,12 +488,24 @@ class XMLCache(object):
|
||||
# }}}
|
||||
|
||||
# Utility methods {{{
|
||||
|
||||
def build_lpath_map(self, root):
|
||||
m = {}
|
||||
for bk in root.xpath('//*[local-name()="text"]'):
|
||||
m[bk.get('path')] = bk
|
||||
return m
|
||||
|
||||
def build_id_map(self, root):
|
||||
m = {}
|
||||
for bk in root.xpath('//*[local-name()="text"]'):
|
||||
m[bk.get('id')] = bk
|
||||
return m
|
||||
|
||||
def book_by_lpath(self, lpath, root):
|
||||
matches = root.xpath(u'//*[local-name()="text" and @path="%s"]'%lpath)
|
||||
if matches:
|
||||
return matches[0]
|
||||
|
||||
|
||||
def max_id(self, root):
|
||||
ans = -1
|
||||
for x in root.xpath('//*[@id]'):
|
||||
@ -515,10 +540,10 @@ class XMLCache(object):
|
||||
break
|
||||
self.namespaces[i] = ns
|
||||
|
||||
if DEBUG:
|
||||
prints('Found nsmaps:')
|
||||
pprint(self.nsmaps)
|
||||
prints('Found namespaces:')
|
||||
pprint(self.namespaces)
|
||||
# if DEBUG:
|
||||
# debug_print('Found nsmaps:')
|
||||
# pprint(self.nsmaps)
|
||||
# debug_print('Found namespaces:')
|
||||
# pprint(self.namespaces)
|
||||
# }}}
|
||||
|
||||
|
@ -46,7 +46,8 @@ class Book(MetaInformation):
|
||||
self.smart_update(other)
|
||||
|
||||
def __eq__(self, other):
|
||||
return self.path == getattr(other, 'path', None)
|
||||
# use lpath because the prefix can change, changing path
|
||||
return self.lpath == getattr(other, 'lpath', None)
|
||||
|
||||
@dynamic_property
|
||||
def db_id(self):
|
||||
@ -97,13 +98,24 @@ class Book(MetaInformation):
|
||||
|
||||
class BookList(_BookList):
|
||||
|
||||
def __init__(self, oncard, prefix, settings):
|
||||
_BookList.__init__(self, oncard, prefix, settings)
|
||||
self._bookmap = {}
|
||||
|
||||
def supports_collections(self):
|
||||
return False
|
||||
|
||||
def add_book(self, book, replace_metadata):
|
||||
if book not in self:
|
||||
try:
|
||||
b = self.index(book)
|
||||
except (ValueError, IndexError):
|
||||
b = None
|
||||
if b is None:
|
||||
self.append(book)
|
||||
return True
|
||||
if replace_metadata:
|
||||
self[b].smart_update(book)
|
||||
return True
|
||||
return False
|
||||
|
||||
def remove_book(self, book):
|
||||
@ -112,7 +124,6 @@ class BookList(_BookList):
|
||||
def get_collections(self):
|
||||
return {}
|
||||
|
||||
|
||||
class CollectionsBookList(BookList):
|
||||
|
||||
def supports_collections(self):
|
||||
|
@ -765,12 +765,8 @@ class Device(DeviceConfig, DevicePlugin):
|
||||
path = existing[0]
|
||||
|
||||
def get_size(obj):
|
||||
if hasattr(obj, 'seek'):
|
||||
obj.seek(0, os.SEEK_END)
|
||||
size = obj.tell()
|
||||
obj.seek(0)
|
||||
return size
|
||||
return os.path.getsize(obj)
|
||||
path = getattr(obj, 'name', obj)
|
||||
return os.path.getsize(path)
|
||||
|
||||
sizes = [get_size(f) for f in files]
|
||||
size = sum(sizes)
|
||||
|
@ -12,15 +12,24 @@ for a particular device.
|
||||
|
||||
import os
|
||||
import re
|
||||
import time
|
||||
import json
|
||||
from itertools import cycle
|
||||
|
||||
from calibre import prints, isbytestring
|
||||
from calibre.constants import filesystem_encoding
|
||||
from calibre.constants import filesystem_encoding, DEBUG
|
||||
from calibre.devices.usbms.cli import CLI
|
||||
from calibre.devices.usbms.device import Device
|
||||
from calibre.devices.usbms.books import BookList, Book
|
||||
|
||||
BASE_TIME = None
|
||||
def debug_print(*args):
|
||||
global BASE_TIME
|
||||
if BASE_TIME is None:
|
||||
BASE_TIME = time.time()
|
||||
if DEBUG:
|
||||
prints('DEBUG: %6.1f'%(time.time()-BASE_TIME), *args)
|
||||
|
||||
# CLI must come before Device as it implements the CLI functions that
|
||||
# are inherited from the device interface in Device.
|
||||
class USBMS(CLI, Device):
|
||||
@ -47,6 +56,8 @@ class USBMS(CLI, Device):
|
||||
def books(self, oncard=None, end_session=True):
|
||||
from calibre.ebooks.metadata.meta import path_to_ext
|
||||
|
||||
debug_print ('USBMS: Fetching list of books from device. oncard=', oncard)
|
||||
|
||||
dummy_bl = BookList(None, None, None)
|
||||
|
||||
if oncard == 'carda' and not self._card_a_prefix:
|
||||
@ -136,8 +147,8 @@ class USBMS(CLI, Device):
|
||||
need_sync = True
|
||||
del bl[idx]
|
||||
|
||||
#print "count found in cache: %d, count of files in metadata: %d, need_sync: %s" % \
|
||||
# (len(bl_cache), len(bl), need_sync)
|
||||
debug_print('USBMS: count found in cache: %d, count of files in metadata: %d, need_sync: %s' % \
|
||||
(len(bl_cache), len(bl), need_sync))
|
||||
if need_sync: #self.count_found_in_bl != len(bl) or need_sync:
|
||||
if oncard == 'cardb':
|
||||
self.sync_booklists((None, None, bl))
|
||||
@ -147,10 +158,13 @@ class USBMS(CLI, Device):
|
||||
self.sync_booklists((bl, None, None))
|
||||
|
||||
self.report_progress(1.0, _('Getting list of books on device...'))
|
||||
debug_print('USBMS: Finished fetching list of books from device. oncard=', oncard)
|
||||
return bl
|
||||
|
||||
def upload_books(self, files, names, on_card=None, end_session=True,
|
||||
metadata=None):
|
||||
debug_print('USBMS: uploading %d books'%(len(files)))
|
||||
|
||||
path = self._sanity_check(on_card, files)
|
||||
|
||||
paths = []
|
||||
@ -174,6 +188,7 @@ class USBMS(CLI, Device):
|
||||
self.report_progress((i+1) / float(len(files)), _('Transferring books to device...'))
|
||||
|
||||
self.report_progress(1.0, _('Transferring books to device...'))
|
||||
debug_print('USBMS: finished uploading %d books'%(len(files)))
|
||||
return zip(paths, cycle([on_card]))
|
||||
|
||||
def upload_cover(self, path, filename, metadata):
|
||||
@ -186,6 +201,8 @@ class USBMS(CLI, Device):
|
||||
pass
|
||||
|
||||
def add_books_to_metadata(self, locations, metadata, booklists):
|
||||
debug_print('USBMS: adding metadata for %d books'%(len(metadata)))
|
||||
|
||||
metadata = iter(metadata)
|
||||
for i, location in enumerate(locations):
|
||||
self.report_progress((i+1) / float(len(locations)), _('Adding books to device metadata listing...'))
|
||||
@ -218,8 +235,10 @@ class USBMS(CLI, Device):
|
||||
book.size = os.stat(self.normalize_path(path)).st_size
|
||||
booklists[blist].add_book(book, replace_metadata=True)
|
||||
self.report_progress(1.0, _('Adding books to device metadata listing...'))
|
||||
debug_print('USBMS: finished adding metadata')
|
||||
|
||||
def delete_books(self, paths, end_session=True):
|
||||
debug_print('USBMS: deleting %d books'%(len(paths)))
|
||||
for i, path in enumerate(paths):
|
||||
self.report_progress((i+1) / float(len(paths)), _('Removing books from device...'))
|
||||
path = self.normalize_path(path)
|
||||
@ -240,8 +259,11 @@ class USBMS(CLI, Device):
|
||||
except:
|
||||
pass
|
||||
self.report_progress(1.0, _('Removing books from device...'))
|
||||
debug_print('USBMS: finished deleting %d books'%(len(paths)))
|
||||
|
||||
def remove_books_from_metadata(self, paths, booklists):
|
||||
debug_print('USBMS: removing metadata for %d books'%(len(paths)))
|
||||
|
||||
for i, path in enumerate(paths):
|
||||
self.report_progress((i+1) / float(len(paths)), _('Removing books from device metadata listing...'))
|
||||
for bl in booklists:
|
||||
@ -249,8 +271,11 @@ class USBMS(CLI, Device):
|
||||
if path.endswith(book.path):
|
||||
bl.remove_book(book)
|
||||
self.report_progress(1.0, _('Removing books from device metadata listing...'))
|
||||
debug_print('USBMS: finished removing metadata for %d books'%(len(paths)))
|
||||
|
||||
def sync_booklists(self, booklists, end_session=True):
|
||||
debug_print('USBMS: starting sync_booklists')
|
||||
|
||||
if not os.path.exists(self.normalize_path(self._main_prefix)):
|
||||
os.makedirs(self.normalize_path(self._main_prefix))
|
||||
|
||||
@ -267,6 +292,19 @@ class USBMS(CLI, Device):
|
||||
write_prefix(self._card_b_prefix, 2)
|
||||
|
||||
self.report_progress(1.0, _('Sending metadata to device...'))
|
||||
debug_print('USBMS: finished sync_booklists')
|
||||
|
||||
@classmethod
|
||||
def build_template_regexp(cls):
|
||||
def replfunc(match):
|
||||
if match.group(1) in ['title', 'series', 'series_index', 'isbn']:
|
||||
return '(?P<' + match.group(1) + '>.+?)'
|
||||
elif match.group(1) == 'authors':
|
||||
return '(?P<author>.+?)'
|
||||
else:
|
||||
return '(.+?)'
|
||||
template = cls.save_template().rpartition('/')[2]
|
||||
return re.compile(re.sub('{([^}]*)}', replfunc, template) + '([_\d]*$)')
|
||||
|
||||
@classmethod
|
||||
def path_to_unicode(cls, path):
|
||||
@ -329,22 +367,22 @@ class USBMS(CLI, Device):
|
||||
from calibre.ebooks.metadata.meta import metadata_from_formats
|
||||
from calibre.customize.ui import quick_metadata
|
||||
with quick_metadata:
|
||||
return metadata_from_formats(fmts)
|
||||
return metadata_from_formats(fmts, force_read_metadata=True,
|
||||
pattern=cls.build_template_regexp())
|
||||
|
||||
@classmethod
|
||||
def book_from_path(cls, prefix, path):
|
||||
def book_from_path(cls, prefix, lpath):
|
||||
from calibre.ebooks.metadata import MetaInformation
|
||||
|
||||
if cls.settings().read_metadata or cls.MUST_READ_METADATA:
|
||||
mi = cls.metadata_from_path(cls.normalize_path(os.path.join(prefix, path)))
|
||||
mi = cls.metadata_from_path(cls.normalize_path(os.path.join(prefix, lpath)))
|
||||
else:
|
||||
from calibre.ebooks.metadata.meta import metadata_from_filename
|
||||
mi = metadata_from_filename(cls.normalize_path(os.path.basename(path)),
|
||||
re.compile(r'^(?P<title>[ \S]+?)[ _]-[ _](?P<author>[ \S]+?)_+\d+'))
|
||||
|
||||
mi = metadata_from_filename(cls.normalize_path(os.path.basename(lpath)),
|
||||
cls.build_template_regexp())
|
||||
if mi is None:
|
||||
mi = MetaInformation(os.path.splitext(os.path.basename(path))[0],
|
||||
mi = MetaInformation(os.path.splitext(os.path.basename(lpath))[0],
|
||||
[_('Unknown')])
|
||||
size = os.stat(cls.normalize_path(os.path.join(prefix, path))).st_size
|
||||
book = cls.book_class(prefix, path, other=mi, size=size)
|
||||
size = os.stat(cls.normalize_path(os.path.join(prefix, lpath))).st_size
|
||||
book = cls.book_class(prefix, lpath, other=mi, size=size)
|
||||
return book
|
||||
|
@ -706,15 +706,22 @@ OptionRecommendation(name='timestamp',
|
||||
for rec in group:
|
||||
setattr(self.opts, rec.option.name, rec.recommended_value)
|
||||
|
||||
for x in input_profiles():
|
||||
if x.short_name == self.opts.input_profile:
|
||||
self.opts.input_profile = x
|
||||
break
|
||||
def set_profile(profiles, which):
|
||||
attr = which + '_profile'
|
||||
sval = getattr(self.opts, attr)
|
||||
for x in profiles():
|
||||
if x.short_name == sval:
|
||||
setattr(self.opts, attr, x)
|
||||
return
|
||||
self.log.warn(
|
||||
'Profile (%s) %r is no longer available, using default'%(which, sval))
|
||||
for x in profiles():
|
||||
if x.short_name == 'default':
|
||||
setattr(self.opts, attr, x)
|
||||
break
|
||||
|
||||
for x in output_profiles():
|
||||
if x.short_name == self.opts.output_profile:
|
||||
self.opts.output_profile = x
|
||||
break
|
||||
set_profile(input_profiles, 'input')
|
||||
set_profile(output_profiles, 'output')
|
||||
|
||||
self.read_user_metadata()
|
||||
self.opts.no_inline_navbars = self.opts.output_profile.supports_mobi_indexing \
|
||||
|
@ -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]
|
||||
@ -223,6 +223,7 @@ class MetaInformation(object):
|
||||
'isbn', 'tags', 'cover_data', 'application_id', 'guide',
|
||||
'manifest', 'spine', 'toc', 'cover', 'language',
|
||||
'book_producer', 'timestamp', 'lccn', 'lcc', 'ddc',
|
||||
'author_sort_map',
|
||||
'pubdate', 'rights', 'publication_type', 'uuid'):
|
||||
if hasattr(mi, attr):
|
||||
setattr(ans, attr, getattr(mi, attr))
|
||||
@ -244,6 +245,7 @@ class MetaInformation(object):
|
||||
self.tags = getattr(mi, 'tags', [])
|
||||
#: mi.cover_data = (ext, data)
|
||||
self.cover_data = getattr(mi, 'cover_data', (None, None))
|
||||
self.author_sort_map = getattr(mi, 'author_sort_map', {})
|
||||
|
||||
for x in ('author_sort', 'title_sort', 'comments', 'category', 'publisher',
|
||||
'series', 'series_index', 'rating', 'isbn', 'language',
|
||||
@ -258,7 +260,7 @@ class MetaInformation(object):
|
||||
'series', 'series_index', 'tags', 'rating', 'isbn', 'language',
|
||||
'application_id', 'manifest', 'toc', 'spine', 'guide', 'cover',
|
||||
'book_producer', 'timestamp', 'lccn', 'lcc', 'ddc', 'pubdate',
|
||||
'rights', 'publication_type', 'uuid'
|
||||
'rights', 'publication_type', 'uuid', 'author_sort_map'
|
||||
):
|
||||
prints(x, getattr(self, x, 'None'))
|
||||
|
||||
@ -288,6 +290,9 @@ class MetaInformation(object):
|
||||
self.tags += mi.tags
|
||||
self.tags = list(set(self.tags))
|
||||
|
||||
if mi.author_sort_map:
|
||||
self.author_sort_map.update(mi.author_sort_map)
|
||||
|
||||
if getattr(mi, 'cover_data', False):
|
||||
other_cover = mi.cover_data[-1]
|
||||
self_cover = self.cover_data[-1] if self.cover_data else ''
|
||||
|
@ -10,12 +10,31 @@ import os
|
||||
from contextlib import closing
|
||||
|
||||
from calibre.customize import FileTypePlugin
|
||||
from calibre.utils.zipfile import ZipFile, stringFileHeader
|
||||
|
||||
def is_comic(list_of_names):
|
||||
extensions = set([x.rpartition('.')[-1].lower() for x in list_of_names])
|
||||
comic_extensions = set(['jpg', 'jpeg', 'png'])
|
||||
return len(extensions - comic_extensions) == 0
|
||||
|
||||
def archive_type(stream):
|
||||
try:
|
||||
pos = stream.tell()
|
||||
except:
|
||||
pos = 0
|
||||
id_ = stream.read(4)
|
||||
ans = None
|
||||
if id_ == stringFileHeader:
|
||||
ans = 'zip'
|
||||
elif id_.startswith('Rar'):
|
||||
ans = 'rar'
|
||||
try:
|
||||
stream.seek(pos)
|
||||
except:
|
||||
pass
|
||||
return ans
|
||||
|
||||
|
||||
class ArchiveExtract(FileTypePlugin):
|
||||
name = 'Archive Extract'
|
||||
author = 'Kovid Goyal'
|
||||
@ -31,7 +50,6 @@ class ArchiveExtract(FileTypePlugin):
|
||||
if is_rar:
|
||||
from calibre.libunrar import extract_member, names
|
||||
else:
|
||||
from calibre.utils.zipfile import ZipFile
|
||||
zf = ZipFile(archive, 'r')
|
||||
|
||||
if is_rar:
|
||||
|
@ -35,6 +35,8 @@ PUBLICATION_METADATA_FIELDS = frozenset([
|
||||
'title_sort',
|
||||
# Ordered list of authors. Must never be None, can be [_('Unknown')]
|
||||
'authors',
|
||||
# Map of sort strings for each author
|
||||
'author_sort_map',
|
||||
# Pseudo field that can be set, but if not set is auto generated
|
||||
# from authors and languages
|
||||
'author_sort',
|
||||
|
@ -16,6 +16,7 @@ NULL_VALUES = {
|
||||
'classifiers' : {},
|
||||
'languages' : [],
|
||||
'device_collections': [],
|
||||
'author_sort_map': {},
|
||||
'authors' : [_('Unknown')],
|
||||
'title' : _('Unknown'),
|
||||
}
|
||||
|
@ -27,16 +27,16 @@ for i, ext in enumerate(_METADATA_PRIORITIES):
|
||||
def path_to_ext(path):
|
||||
return os.path.splitext(path)[1][1:].lower()
|
||||
|
||||
def metadata_from_formats(formats):
|
||||
def metadata_from_formats(formats, force_read_metadata=False, pattern=None):
|
||||
try:
|
||||
return _metadata_from_formats(formats)
|
||||
return _metadata_from_formats(formats, force_read_metadata, pattern)
|
||||
except:
|
||||
mi = metadata_from_filename(list(iter(formats))[0])
|
||||
mi = metadata_from_filename(list(iter(formats), pattern)[0])
|
||||
if not mi.authors:
|
||||
mi.authors = [_('Unknown')]
|
||||
return mi
|
||||
|
||||
def _metadata_from_formats(formats):
|
||||
def _metadata_from_formats(formats, force_read_metadata=False, pattern=None):
|
||||
mi = MetaInformation(None, None)
|
||||
formats.sort(cmp=lambda x,y: cmp(METADATA_PRIORITIES[path_to_ext(x)],
|
||||
METADATA_PRIORITIES[path_to_ext(y)]))
|
||||
@ -51,7 +51,9 @@ def _metadata_from_formats(formats):
|
||||
with open(path, 'rb') as stream:
|
||||
try:
|
||||
newmi = get_metadata(stream, stream_type=ext,
|
||||
use_libprs_metadata=True)
|
||||
use_libprs_metadata=True,
|
||||
force_read_metadata=force_read_metadata,
|
||||
pattern=pattern)
|
||||
mi.smart_update(newmi)
|
||||
except:
|
||||
continue
|
||||
@ -69,18 +71,21 @@ def is_recipe(filename):
|
||||
return filename.startswith('calibre') and \
|
||||
filename.rpartition('.')[0].endswith('_recipe_out')
|
||||
|
||||
def get_metadata(stream, stream_type='lrf', use_libprs_metadata=False):
|
||||
def get_metadata(stream, stream_type='lrf', use_libprs_metadata=False,
|
||||
force_read_metadata=False, pattern=None):
|
||||
pos = 0
|
||||
if hasattr(stream, 'tell'):
|
||||
pos = stream.tell()
|
||||
try:
|
||||
return _get_metadata(stream, stream_type, use_libprs_metadata)
|
||||
return _get_metadata(stream, stream_type, use_libprs_metadata,
|
||||
force_read_metadata, pattern)
|
||||
finally:
|
||||
if hasattr(stream, 'seek'):
|
||||
stream.seek(pos)
|
||||
|
||||
|
||||
def _get_metadata(stream, stream_type, use_libprs_metadata):
|
||||
def _get_metadata(stream, stream_type, use_libprs_metadata,
|
||||
force_read_metadata=False, pattern=None):
|
||||
if stream_type: stream_type = stream_type.lower()
|
||||
if stream_type in ('html', 'html', 'xhtml', 'xhtm', 'xml'):
|
||||
stream_type = 'html'
|
||||
@ -100,8 +105,8 @@ def _get_metadata(stream, stream_type, use_libprs_metadata):
|
||||
|
||||
mi = MetaInformation(None, None)
|
||||
name = os.path.basename(getattr(stream, 'name', ''))
|
||||
base = metadata_from_filename(name)
|
||||
if is_recipe(name) or prefs['read_file_metadata']:
|
||||
base = metadata_from_filename(name, pat=pattern)
|
||||
if force_read_metadata or is_recipe(name) or prefs['read_file_metadata']:
|
||||
mi = get_file_type_metadata(stream, stream_type)
|
||||
if base.title == os.path.splitext(name)[0] and base.authors is None:
|
||||
# Assume that there was no metadata in the file and the user set pattern
|
||||
@ -139,7 +144,7 @@ def metadata_from_filename(name, pat=None):
|
||||
pat = re.compile(prefs.get('filename_pattern'))
|
||||
name = name.replace('_', ' ')
|
||||
match = pat.search(name)
|
||||
if match:
|
||||
if match is not None:
|
||||
try:
|
||||
mi.title = match.group('title')
|
||||
except IndexError:
|
||||
|
@ -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))
|
||||
|
@ -103,8 +103,8 @@ class CoverManager(object):
|
||||
32)]
|
||||
img_data = create_cover_page(lines, I('library.png'))
|
||||
id, href = self.oeb.manifest.generate('cover_image',
|
||||
'cover_image.png')
|
||||
item = self.oeb.manifest.add(id, href, guess_type('t.png')[0],
|
||||
'cover_image.jpg')
|
||||
item = self.oeb.manifest.add(id, href, guess_type('t.jpg')[0],
|
||||
data=img_data)
|
||||
m.clear('cover')
|
||||
m.add('cover', item.id)
|
||||
|
@ -43,8 +43,8 @@ def _config():
|
||||
help=_('Notify when a new version is available'))
|
||||
c.add_opt('use_roman_numerals_for_series_number', default=True,
|
||||
help=_('Use Roman numerals for series number'))
|
||||
c.add_opt('sort_by_popularity', default=False,
|
||||
help=_('Sort tags list by popularity'))
|
||||
c.add_opt('sort_tags_by', default='name',
|
||||
help=_('Sort tags list by name, popularity, or rating'))
|
||||
c.add_opt('cover_flow_queue_length', default=6,
|
||||
help=_('Number of covers to show in the cover browsing mode'))
|
||||
c.add_opt('LRF_conversion_defaults', default=[],
|
||||
@ -99,6 +99,10 @@ def _config():
|
||||
help=_('Limit max simultaneous jobs to number of CPUs'))
|
||||
c.add_opt('tag_browser_hidden_categories', default=set(),
|
||||
help=_('tag browser categories not to display'))
|
||||
c.add_opt('gui_layout', choices=['wide', 'narrow'],
|
||||
help=_('The layout of the user interface'), default='wide')
|
||||
c.add_opt('show_avg_rating', default=True,
|
||||
help=_('Show the average rating per item indication in the tag browser'))
|
||||
return ConfigProxy(c)
|
||||
|
||||
config = _config()
|
||||
@ -125,6 +129,17 @@ def available_width():
|
||||
desktop = QCoreApplication.instance().desktop()
|
||||
return desktop.availableGeometry().width()
|
||||
|
||||
_is_widescreen = None
|
||||
|
||||
def is_widescreen():
|
||||
global _is_widescreen
|
||||
if _is_widescreen is None:
|
||||
try:
|
||||
_is_widescreen = float(available_width())/available_height() > 1.4
|
||||
except:
|
||||
_is_widescreen = False
|
||||
return _is_widescreen
|
||||
|
||||
def extension(path):
|
||||
return os.path.splitext(path)[1][1:].lower()
|
||||
|
||||
|
1209
src/calibre/gui2/actions.py
Normal file
281
src/calibre/gui2/book_details.py
Normal file
@ -0,0 +1,281 @@
|
||||
#!/usr/bin/env python
|
||||
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:ai
|
||||
|
||||
__license__ = 'GPL v3'
|
||||
__copyright__ = '2010, Kovid Goyal <kovid@kovidgoyal.net>'
|
||||
__docformat__ = 'restructuredtext en'
|
||||
|
||||
import os, collections
|
||||
|
||||
from PyQt4.Qt import QLabel, QPixmap, QSize, QWidget, Qt, pyqtSignal, \
|
||||
QVBoxLayout, QScrollArea, QPropertyAnimation, QEasingCurve, \
|
||||
QSizePolicy, QPainter, QRect, pyqtProperty, QDesktopServices, QUrl
|
||||
|
||||
from calibre import fit_image, prepare_string_for_xml
|
||||
from calibre.gui2.widgets import IMAGE_EXTENSIONS
|
||||
from calibre.ebooks import BOOK_EXTENSIONS
|
||||
from calibre.constants import preferred_encoding
|
||||
from calibre.library.comments import comments_to_html
|
||||
|
||||
# render_rows(data) {{{
|
||||
WEIGHTS = collections.defaultdict(lambda : 100)
|
||||
WEIGHTS[_('Path')] = 5
|
||||
WEIGHTS[_('Formats')] = 1
|
||||
WEIGHTS[_('Collections')] = 2
|
||||
WEIGHTS[_('Series')] = 3
|
||||
WEIGHTS[_('Tags')] = 4
|
||||
|
||||
def render_rows(data):
|
||||
keys = data.keys()
|
||||
keys.sort(cmp=lambda x, y: cmp(WEIGHTS[x], WEIGHTS[y]))
|
||||
rows = []
|
||||
for key in keys:
|
||||
txt = data[key]
|
||||
if key in ('id', _('Comments')) or not hasattr(txt, 'strip') or not txt.strip() or \
|
||||
txt == 'None':
|
||||
continue
|
||||
if isinstance(key, str):
|
||||
key = key.decode(preferred_encoding, 'replace')
|
||||
if isinstance(txt, str):
|
||||
txt = txt.decode(preferred_encoding, 'replace')
|
||||
if '</font>' not in txt:
|
||||
txt = prepare_string_for_xml(txt)
|
||||
if 'id' in data:
|
||||
if key == _('Path'):
|
||||
txt = u'<a href="path:%s" title="%s">%s</a>'%(data['id'],
|
||||
txt, _('Click to open'))
|
||||
if key == _('Formats') and txt and txt != _('None'):
|
||||
fmts = [x.strip() for x in txt.split(',')]
|
||||
fmts = [u'<a href="format:%s:%s">%s</a>' % (data['id'], x, x) for x
|
||||
in fmts]
|
||||
txt = ', '.join(fmts)
|
||||
else:
|
||||
if key == _('Path'):
|
||||
txt = u'<a href="devpath:%s">%s</a>'%(txt,
|
||||
_('Click to open'))
|
||||
|
||||
rows.append((key, txt))
|
||||
return rows
|
||||
|
||||
# }}}
|
||||
|
||||
class CoverView(QWidget): # {{{
|
||||
|
||||
|
||||
def __init__(self, parent=None):
|
||||
QWidget.__init__(self, parent)
|
||||
self.setMaximumSize(QSize(120, 120))
|
||||
self.setMinimumSize(QSize(120, 1))
|
||||
self._current_pixmap_size = self.maximumSize()
|
||||
|
||||
self.animation = QPropertyAnimation(self, 'current_pixmap_size', self)
|
||||
self.animation.setEasingCurve(QEasingCurve(QEasingCurve.OutExpo))
|
||||
self.animation.setDuration(1000)
|
||||
self.animation.setStartValue(QSize(0, 0))
|
||||
self.animation.valueChanged.connect(self.value_changed)
|
||||
|
||||
self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
|
||||
|
||||
self.default_pixmap = QPixmap(I('book.svg'))
|
||||
self.pixmap = self.default_pixmap
|
||||
self.pwidth = self.pheight = None
|
||||
self.data = {}
|
||||
|
||||
self.do_layout()
|
||||
|
||||
def value_changed(self, val):
|
||||
self.update()
|
||||
|
||||
def setCurrentPixmapSize(self, val):
|
||||
self._current_pixmap_size = val
|
||||
|
||||
def do_layout(self):
|
||||
pixmap = self.pixmap
|
||||
pwidth, pheight = pixmap.width(), pixmap.height()
|
||||
self.pwidth, self.pheight = fit_image(pwidth, pheight,
|
||||
self.rect().width(), self.rect().height())[1:]
|
||||
self.current_pixmap_size = QSize(self.pwidth, self.pheight)
|
||||
self.animation.setEndValue(self.current_pixmap_size)
|
||||
|
||||
def relayout(self, parent_size):
|
||||
self.setMaximumSize(parent_size.width(),
|
||||
min(int(parent_size.height()/2.),int(4/3. * parent_size.width())+1))
|
||||
self.resize(self.maximumSize())
|
||||
self.animation.stop()
|
||||
self.do_layout()
|
||||
|
||||
def sizeHint(self):
|
||||
return self.maximumSize()
|
||||
|
||||
def show_data(self, data):
|
||||
self.animation.stop()
|
||||
if data.get('id', True) == self.data.get('id', False):
|
||||
return
|
||||
self.data = {'id':data.get('id', None)}
|
||||
if data.has_key('cover'):
|
||||
self.pixmap = QPixmap.fromImage(data.pop('cover'))
|
||||
if self.pixmap.isNull():
|
||||
self.pixmap = self.default_pixmap
|
||||
else:
|
||||
self.pixmap = self.default_pixmap
|
||||
self.do_layout()
|
||||
self.update()
|
||||
self.animation.start()
|
||||
|
||||
def paintEvent(self, event):
|
||||
canvas_size = self.rect()
|
||||
width = self.current_pixmap_size.width()
|
||||
extrax = canvas_size.width() - width
|
||||
if extrax < 0: extrax = 0
|
||||
x = int(extrax/2.)
|
||||
height = self.current_pixmap_size.height()
|
||||
extray = canvas_size.height() - height
|
||||
if extray < 0: extray = 0
|
||||
y = int(extray/2.)
|
||||
target = QRect(x, y, width, height)
|
||||
p = QPainter(self)
|
||||
p.setRenderHints(QPainter.Antialiasing | QPainter.SmoothPixmapTransform)
|
||||
p.drawPixmap(target, self.pixmap.scaled(target.size(),
|
||||
Qt.KeepAspectRatio, Qt.SmoothTransformation))
|
||||
p.end()
|
||||
|
||||
current_pixmap_size = pyqtProperty('QSize',
|
||||
fget=lambda self: self._current_pixmap_size,
|
||||
fset=setCurrentPixmapSize
|
||||
)
|
||||
|
||||
|
||||
# }}}
|
||||
|
||||
class Label(QLabel):
|
||||
|
||||
mr = pyqtSignal(object)
|
||||
link_clicked = pyqtSignal(object)
|
||||
|
||||
def __init__(self):
|
||||
QLabel.__init__(self)
|
||||
self.setTextFormat(Qt.RichText)
|
||||
self.setText('')
|
||||
self.setWordWrap(True)
|
||||
self.linkActivated.connect(self.link_activated)
|
||||
self._link_clicked = False
|
||||
self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
|
||||
|
||||
def link_activated(self, link):
|
||||
self._link_clicked = True
|
||||
link = unicode(link)
|
||||
self.link_clicked.emit(link)
|
||||
|
||||
def mouseReleaseEvent(self, ev):
|
||||
QLabel.mouseReleaseEvent(self, ev)
|
||||
if not self._link_clicked:
|
||||
self.mr.emit(ev)
|
||||
self._link_clicked = False
|
||||
|
||||
class BookInfo(QScrollArea):
|
||||
|
||||
def __init__(self, parent=None):
|
||||
QScrollArea.__init__(self, parent)
|
||||
self.setWidgetResizable(True)
|
||||
self.label = Label()
|
||||
self.setWidget(self.label)
|
||||
self.link_clicked = self.label.link_clicked
|
||||
self.mr = self.label.mr
|
||||
self.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
|
||||
|
||||
def show_data(self, data):
|
||||
self.label.setText('')
|
||||
rows = render_rows(data)
|
||||
rows = u'\n'.join([u'<tr><td valign="top"><b>%s:</b></td><td valign="top">%s</td></tr>'%(k,t) for
|
||||
k, t in rows])
|
||||
if _('Comments') in data and data[_('Comments')]:
|
||||
comments = comments_to_html(data[_('Comments')])
|
||||
rows += u'<tr><td colspan="2">%s</td></tr>'%comments
|
||||
|
||||
self.label.setText(u'<table>%s</table>'%rows)
|
||||
|
||||
class BookDetails(QWidget):
|
||||
|
||||
resized = pyqtSignal(object)
|
||||
show_book_info = pyqtSignal()
|
||||
open_containing_folder = pyqtSignal(int)
|
||||
view_specific_format = pyqtSignal(int, object)
|
||||
|
||||
# Drag 'n drop {{{
|
||||
DROPABBLE_EXTENSIONS = IMAGE_EXTENSIONS+BOOK_EXTENSIONS
|
||||
files_dropped = pyqtSignal(object, object)
|
||||
|
||||
@classmethod
|
||||
def paths_from_event(cls, event):
|
||||
'''
|
||||
Accept a drop event and return a list of paths that can be read from
|
||||
and represent files with extensions.
|
||||
'''
|
||||
if event.mimeData().hasFormat('text/uri-list'):
|
||||
urls = [unicode(u.toLocalFile()) for u in event.mimeData().urls()]
|
||||
urls = [u for u in urls if os.path.splitext(u)[1] and os.access(u, os.R_OK)]
|
||||
return [u for u in urls if os.path.splitext(u)[1][1:].lower() in cls.DROPABBLE_EXTENSIONS]
|
||||
|
||||
def dragEnterEvent(self, event):
|
||||
if int(event.possibleActions() & Qt.CopyAction) + \
|
||||
int(event.possibleActions() & Qt.MoveAction) == 0:
|
||||
return
|
||||
paths = self.paths_from_event(event)
|
||||
if paths:
|
||||
event.acceptProposedAction()
|
||||
|
||||
def dropEvent(self, event):
|
||||
paths = self.paths_from_event(event)
|
||||
event.setDropAction(Qt.CopyAction)
|
||||
self.files_dropped.emit(event, paths)
|
||||
|
||||
def dragMoveEvent(self, event):
|
||||
event.acceptProposedAction()
|
||||
|
||||
# }}}
|
||||
|
||||
def __init__(self, parent=None):
|
||||
QWidget.__init__(self, parent)
|
||||
self._layout = QVBoxLayout()
|
||||
|
||||
self.setLayout(self._layout)
|
||||
self.cover_view = CoverView(self)
|
||||
self.cover_view.relayout(self.size())
|
||||
self.resized.connect(self.cover_view.relayout, type=Qt.QueuedConnection)
|
||||
self._layout.addWidget(self.cover_view, alignment=Qt.AlignHCenter)
|
||||
self.book_info = BookInfo(self)
|
||||
self._layout.addWidget(self.book_info)
|
||||
self.book_info.link_clicked.connect(self._link_clicked)
|
||||
self.book_info.mr.connect(self.mouseReleaseEvent)
|
||||
self.setMinimumSize(QSize(190, 200))
|
||||
self.setCursor(Qt.PointingHandCursor)
|
||||
|
||||
def _link_clicked(self, link):
|
||||
typ, _, val = link.partition(':')
|
||||
if typ == 'path':
|
||||
self.open_containing_folder.emit(int(val))
|
||||
elif typ == 'format':
|
||||
id_, fmt = val.split(':')
|
||||
self.view_specific_format.emit(int(id_), fmt)
|
||||
elif typ == 'devpath':
|
||||
QDesktopServices.openUrl(QUrl.fromLocalFile(val))
|
||||
|
||||
|
||||
def mouseReleaseEvent(self, ev):
|
||||
ev.accept()
|
||||
self.show_book_info.emit()
|
||||
|
||||
def resizeEvent(self, ev):
|
||||
self.resized.emit(self.size())
|
||||
|
||||
def show_data(self, data):
|
||||
self.cover_view.show_data(data)
|
||||
self.book_info.show_data(data)
|
||||
self.setToolTip('<p>'+_('Click to open Book Details window') +
|
||||
'<br><br>' + _('Path') + ': ' + data.get(_('Path'), ''))
|
||||
|
||||
def reset_info(self):
|
||||
self.show_data({})
|
||||
|
||||
|
||||
|
@ -13,7 +13,7 @@ from PyQt4.Qt import QPixmap, SIGNAL
|
||||
from calibre.gui2 import choose_images, error_dialog
|
||||
from calibre.gui2.convert.metadata_ui import Ui_Form
|
||||
from calibre.ebooks.metadata import authors_to_string, string_to_authors, \
|
||||
MetaInformation, authors_to_sort_string
|
||||
MetaInformation
|
||||
from calibre.ebooks.metadata.opf2 import metadata_to_opf
|
||||
from calibre.ptempfile import PersistentTemporaryFile
|
||||
from calibre.gui2.convert import Widget
|
||||
@ -57,7 +57,7 @@ class MetadataWidget(Widget, Ui_Form):
|
||||
au = unicode(self.author.currentText())
|
||||
au = re.sub(r'\s+et al\.$', '', au)
|
||||
authors = string_to_authors(au)
|
||||
self.author_sort.setText(authors_to_sort_string(authors))
|
||||
self.author_sort.setText(self.db.author_sort_from_authors(authors))
|
||||
|
||||
|
||||
def initialize_metadata_options(self):
|
||||
|
@ -7,16 +7,18 @@ __docformat__ = 'restructuredtext en'
|
||||
Module to implement the Cover Flow feature
|
||||
'''
|
||||
|
||||
import sys, os
|
||||
import sys, os, time
|
||||
|
||||
from PyQt4.QtGui import QImage, QSizePolicy
|
||||
from PyQt4.QtCore import Qt, QSize, SIGNAL, QObject
|
||||
from PyQt4.Qt import QImage, QSizePolicy, QTimer, QDialog, Qt, QSize, \
|
||||
QStackedLayout, QLabel
|
||||
|
||||
from calibre import plugins
|
||||
from calibre.gui2 import config
|
||||
from calibre.gui2 import config, available_height, available_width
|
||||
|
||||
pictureflow, pictureflowerror = plugins['pictureflow']
|
||||
|
||||
if pictureflow is not None:
|
||||
|
||||
class EmptyImageList(pictureflow.FlowImages):
|
||||
def __init__(self):
|
||||
pictureflow.FlowImages.__init__(self)
|
||||
@ -51,7 +53,7 @@ if pictureflow is not None:
|
||||
def __init__(self, model, buffer=20):
|
||||
pictureflow.FlowImages.__init__(self)
|
||||
self.model = model
|
||||
QObject.connect(self.model, SIGNAL('modelReset()'), self.reset)
|
||||
self.model.modelReset.connect(self.reset)
|
||||
|
||||
def count(self):
|
||||
return self.model.count()
|
||||
@ -66,7 +68,7 @@ if pictureflow is not None:
|
||||
return ans
|
||||
|
||||
def reset(self):
|
||||
self.emit(SIGNAL('dataChanged()'))
|
||||
self.dataChanged.emit()
|
||||
|
||||
def image(self, index):
|
||||
return self.model.cover(index)
|
||||
@ -74,13 +76,16 @@ if pictureflow is not None:
|
||||
|
||||
class CoverFlow(pictureflow.PictureFlow):
|
||||
|
||||
def __init__(self, height=300, parent=None, text_height=25):
|
||||
def __init__(self, parent=None):
|
||||
pictureflow.PictureFlow.__init__(self, parent,
|
||||
config['cover_flow_queue_length']+1)
|
||||
self.setSlideSize(QSize(int(2/3. * height), height))
|
||||
self.setMinimumSize(QSize(int(2.35*0.67*height), (5/3.)*height+text_height))
|
||||
self.setMinimumSize(QSize(300, 150))
|
||||
self.setFocusPolicy(Qt.WheelFocus)
|
||||
self.setSizePolicy(QSizePolicy(QSizePolicy.Minimum, QSizePolicy.Minimum))
|
||||
self.setSizePolicy(QSizePolicy(QSizePolicy.Expanding,
|
||||
QSizePolicy.Expanding))
|
||||
|
||||
def sizeHint(self):
|
||||
return self.minimumSize()
|
||||
|
||||
def wheelEvent(self, ev):
|
||||
ev.accept()
|
||||
@ -95,6 +100,118 @@ else:
|
||||
DatabaseImages = None
|
||||
FileSystemImages = None
|
||||
|
||||
class CoverFlowMixin(object):
|
||||
|
||||
def __init__(self):
|
||||
self.cover_flow = None
|
||||
if CoverFlow is not None:
|
||||
self.cf_last_updated_at = None
|
||||
self.cover_flow_sync_timer = QTimer(self)
|
||||
self.cover_flow_sync_timer.timeout.connect(self.cover_flow_do_sync)
|
||||
self.cover_flow_sync_flag = True
|
||||
self.cover_flow = CoverFlow(parent=self)
|
||||
self.cover_flow.currentChanged.connect(self.sync_listview_to_cf)
|
||||
self.library_view.selectionModel().currentRowChanged.connect(
|
||||
self.sync_cf_to_listview)
|
||||
self.db_images = DatabaseImages(self.library_view.model())
|
||||
self.cover_flow.setImages(self.db_images)
|
||||
else:
|
||||
self.cover_flow = QLabel('<p>'+_('Cover browser could not be loaded')
|
||||
+'<br>'+pictureflowerror)
|
||||
self.cover_flow.setWordWrap(True)
|
||||
if config['separate_cover_flow']:
|
||||
self.cb_splitter.button.clicked.connect(self.toggle_cover_browser)
|
||||
if CoverFlow is not None:
|
||||
self.cover_flow.stop.connect(self.hide_cover_browser)
|
||||
else:
|
||||
self.cb_splitter.insertWidget(self.cb_splitter.side_index, self.cover_flow)
|
||||
if CoverFlow is not None:
|
||||
self.cover_flow.stop.connect(self.cb_splitter.hide_side_pane)
|
||||
self.cb_splitter.button.toggled.connect(self.cover_browser_toggled)
|
||||
|
||||
def toggle_cover_browser(self):
|
||||
cbd = getattr(self, 'cb_dialog', None)
|
||||
if cbd is not None:
|
||||
self.hide_cover_browser()
|
||||
else:
|
||||
self.show_cover_browser()
|
||||
|
||||
def cover_browser_toggled(self, *args):
|
||||
if self.cb_splitter.button.isChecked():
|
||||
self.cover_browser_shown()
|
||||
else:
|
||||
self.cover_browser_hidden()
|
||||
|
||||
def cover_browser_shown(self):
|
||||
self.cover_flow.setFocus(Qt.OtherFocusReason)
|
||||
if CoverFlow is not None:
|
||||
self.cover_flow.setCurrentSlide(self.library_view.currentIndex().row())
|
||||
self.cover_flow_sync_timer.start(500)
|
||||
self.library_view.setCurrentIndex(
|
||||
self.library_view.currentIndex())
|
||||
self.library_view.scroll_to_row(self.library_view.currentIndex().row())
|
||||
|
||||
def cover_browser_hidden(self):
|
||||
if CoverFlow is not None:
|
||||
self.cover_flow_sync_timer.stop()
|
||||
idx = self.library_view.model().index(self.cover_flow.currentSlide(), 0)
|
||||
if idx.isValid():
|
||||
sm = self.library_view.selectionModel()
|
||||
sm.select(idx, sm.ClearAndSelect|sm.Rows)
|
||||
self.library_view.setCurrentIndex(idx)
|
||||
self.library_view.scroll_to_row(idx.row())
|
||||
|
||||
|
||||
def show_cover_browser(self):
|
||||
d = QDialog(self)
|
||||
ah, aw = available_height(), available_width()
|
||||
d.resize(int(aw/1.5), ah-60)
|
||||
d._layout = QStackedLayout()
|
||||
d.setLayout(d._layout)
|
||||
d.setWindowTitle(_('Browse by covers'))
|
||||
d.layout().addWidget(self.cover_flow)
|
||||
self.cover_flow.setVisible(True)
|
||||
self.cover_flow.setFocus(Qt.OtherFocusReason)
|
||||
d.show()
|
||||
self.cb_splitter.button.set_state_to_hide()
|
||||
d.finished.connect(self.cb_splitter.button.set_state_to_show)
|
||||
self.cb_dialog = d
|
||||
|
||||
def hide_cover_browser(self):
|
||||
cbd = getattr(self, 'cb_dialog', None)
|
||||
if cbd is not None:
|
||||
cbd.accept()
|
||||
self.cb_dialog = None
|
||||
|
||||
def sync_cf_to_listview(self, current, previous):
|
||||
if self.cover_flow_sync_flag and self.cover_flow.isVisible() and \
|
||||
self.cover_flow.currentSlide() != current.row():
|
||||
self.cover_flow.setCurrentSlide(current.row())
|
||||
self.cover_flow_sync_flag = True
|
||||
|
||||
def cover_flow_do_sync(self):
|
||||
self.cover_flow_sync_flag = True
|
||||
try:
|
||||
if self.cover_flow.isVisible() and self.cf_last_updated_at is not None and \
|
||||
time.time() - self.cf_last_updated_at > 0.5:
|
||||
self.cf_last_updated_at = None
|
||||
row = self.cover_flow.currentSlide()
|
||||
m = self.library_view.model()
|
||||
index = m.index(row, 0)
|
||||
if self.library_view.currentIndex().row() != row and index.isValid():
|
||||
self.cover_flow_sync_flag = False
|
||||
self.library_view.scroll_to_row(index.row())
|
||||
sm = self.library_view.selectionModel()
|
||||
sm.select(index, sm.ClearAndSelect|sm.Rows)
|
||||
self.library_view.setCurrentIndex(index)
|
||||
except:
|
||||
pass
|
||||
|
||||
|
||||
def sync_listview_to_cf(self, row):
|
||||
self.cf_last_updated_at = time.time()
|
||||
|
||||
|
||||
def main(args=sys.argv):
|
||||
return 0
|
||||
|
||||
@ -103,12 +220,12 @@ if __name__ == '__main__':
|
||||
app = QApplication([])
|
||||
w = QMainWindow()
|
||||
cf = CoverFlow()
|
||||
cf.resize(cf.minimumSize())
|
||||
w.resize(cf.minimumSize()+QSize(30, 20))
|
||||
cf.resize(int(available_width()/1.5), available_height()-60)
|
||||
w.resize(cf.size()+QSize(30, 20))
|
||||
path = sys.argv[1]
|
||||
model = FileSystemImages(sys.argv[1])
|
||||
cf.currentChanged[int].connect(model.currentChanged)
|
||||
cf.setImages(model)
|
||||
cf.connect(cf, SIGNAL('currentChanged(int)'), model.currentChanged)
|
||||
w.setCentralWidget(cf)
|
||||
|
||||
w.show()
|
||||
|
@ -101,6 +101,11 @@ class Float(Int):
|
||||
w.setSpecialValueText(_('Undefined'))
|
||||
w.setSingleStep(1)
|
||||
|
||||
def setter(self, val):
|
||||
if val is None:
|
||||
val = self.widgets[1].minimum()
|
||||
self.widgets[1].setValue(val)
|
||||
|
||||
class Rating(Int):
|
||||
|
||||
def setup_ui(self, parent):
|
||||
|
@ -1,25 +1,29 @@
|
||||
from __future__ import with_statement
|
||||
__license__ = 'GPL v3'
|
||||
__copyright__ = '2008, Kovid Goyal <kovid at kovidgoyal.net>'
|
||||
import os, traceback, Queue, time, socket, cStringIO, re
|
||||
|
||||
# Imports {{{
|
||||
import os, traceback, Queue, time, socket, cStringIO, re, sys
|
||||
from threading import Thread, RLock
|
||||
from itertools import repeat
|
||||
from functools import partial
|
||||
from binascii import unhexlify
|
||||
|
||||
from PyQt4.Qt import QMenu, QAction, QActionGroup, QIcon, SIGNAL, QPixmap, \
|
||||
Qt, pyqtSignal
|
||||
Qt, pyqtSignal, QColor, QPainter
|
||||
from PyQt4.QtSvg import QSvgRenderer
|
||||
|
||||
from calibre.customize.ui import available_input_formats, available_output_formats, \
|
||||
device_plugins
|
||||
from calibre.devices.interface import DevicePlugin
|
||||
from calibre.devices.errors import UserFeedback
|
||||
from calibre.gui2.dialogs.choose_format import ChooseFormatDialog
|
||||
from calibre.utils.ipc.job import BaseJob
|
||||
from calibre.devices.scanner import DeviceScanner
|
||||
from calibre.gui2 import config, error_dialog, Dispatcher, dynamic, \
|
||||
pixmap_to_data, warning_dialog, \
|
||||
question_dialog
|
||||
from calibre.ebooks.metadata import authors_to_string, authors_to_sort_string
|
||||
pixmap_to_data, warning_dialog, \
|
||||
question_dialog, info_dialog, choose_dir
|
||||
from calibre.ebooks.metadata import authors_to_string
|
||||
from calibre import preferred_encoding, prints
|
||||
from calibre.utils.filenames import ascii_filename
|
||||
from calibre.devices.errors import FreeSpaceError
|
||||
@ -27,7 +31,9 @@ from calibre.utils.smtp import compose_mail, sendmail, extract_email_address, \
|
||||
config as email_config
|
||||
from calibre.devices.folder_device.driver import FOLDER_DEVICE
|
||||
|
||||
class DeviceJob(BaseJob):
|
||||
# }}}
|
||||
|
||||
class DeviceJob(BaseJob): # {{{
|
||||
|
||||
def __init__(self, func, done, job_manager, args=[], kwargs={},
|
||||
description=''):
|
||||
@ -78,8 +84,9 @@ class DeviceJob(BaseJob):
|
||||
def log_file(self):
|
||||
return cStringIO.StringIO(self._details.encode('utf-8'))
|
||||
|
||||
# }}}
|
||||
|
||||
class DeviceManager(Thread):
|
||||
class DeviceManager(Thread): # {{{
|
||||
|
||||
def __init__(self, connected_slot, job_manager, open_feedback_slot, sleep_time=2):
|
||||
'''
|
||||
@ -122,7 +129,7 @@ class DeviceManager(Thread):
|
||||
try:
|
||||
dev.open()
|
||||
except:
|
||||
print 'Unable to open device', dev
|
||||
prints('Unable to open device', str(dev))
|
||||
traceback.print_exc()
|
||||
continue
|
||||
self.connected_device = dev
|
||||
@ -168,11 +175,11 @@ class DeviceManager(Thread):
|
||||
if possibly_connected_devices:
|
||||
if not self.do_connect(possibly_connected_devices,
|
||||
is_folder_device=False):
|
||||
print 'Connect to device failed, retrying in 5 seconds...'
|
||||
prints('Connect to device failed, retrying in 5 seconds...')
|
||||
time.sleep(5)
|
||||
if not self.do_connect(possibly_connected_devices,
|
||||
is_folder_device=False):
|
||||
print 'Device connect failed again, giving up'
|
||||
prints('Device connect failed again, giving up')
|
||||
|
||||
def umount_device(self, *args):
|
||||
if self.is_device_connected and not self.job_manager.has_device_jobs():
|
||||
@ -317,7 +324,7 @@ class DeviceManager(Thread):
|
||||
def _save_books(self, paths, target):
|
||||
'''Copy books from device to disk'''
|
||||
for path in paths:
|
||||
name = path.rpartition(getattr(self.device, 'path_sep', '/'))[2]
|
||||
name = path.rpartition(os.sep)[2]
|
||||
dest = os.path.join(target, name)
|
||||
if os.path.abspath(dest) != os.path.abspath(path):
|
||||
f = open(dest, 'wb')
|
||||
@ -338,8 +345,9 @@ class DeviceManager(Thread):
|
||||
return self.create_job(self._view_book, done, args=[path, target],
|
||||
description=_('View book on device'))
|
||||
|
||||
# }}}
|
||||
|
||||
class DeviceAction(QAction):
|
||||
class DeviceAction(QAction): # {{{
|
||||
|
||||
a_s = pyqtSignal(object)
|
||||
|
||||
@ -356,9 +364,9 @@ class DeviceAction(QAction):
|
||||
def __repr__(self):
|
||||
return self.__class__.__name__ + ':%s:%s:%s'%(self.dest, self.delete,
|
||||
self.specific)
|
||||
# }}}
|
||||
|
||||
|
||||
class DeviceMenu(QMenu):
|
||||
class DeviceMenu(QMenu): # {{{
|
||||
|
||||
fetch_annotations = pyqtSignal()
|
||||
connect_to_folder = pyqtSignal()
|
||||
@ -385,16 +393,14 @@ class DeviceMenu(QMenu):
|
||||
default_account = (dest, False, False, I('mail.svg'),
|
||||
_('Email to')+' '+account)
|
||||
action1 = DeviceAction(dest, False, False, I('mail.svg'),
|
||||
_('Email to')+' '+account, self)
|
||||
_('Email to')+' '+account)
|
||||
action2 = DeviceAction(dest, True, False, I('mail.svg'),
|
||||
_('Email to')+' '+account, self)
|
||||
_('Email to')+' '+account+ _(' and delete from library'))
|
||||
map(self.email_to_menu.addAction, (action1, action2))
|
||||
map(self._memory.append, (action1, action2))
|
||||
self.email_to_menu.addSeparator()
|
||||
self.connect(action1, SIGNAL('a_s(QAction)'),
|
||||
self.action_triggered)
|
||||
self.connect(action2, SIGNAL('a_s(QAction)'),
|
||||
self.action_triggered)
|
||||
action1.a_s.connect(self.action_triggered)
|
||||
action2.a_s.connect(self.action_triggered)
|
||||
|
||||
basic_actions = [
|
||||
('main:', False, False, I('reader.svg'),
|
||||
@ -532,8 +538,9 @@ class DeviceMenu(QMenu):
|
||||
annot_enable = enable and getattr(device, 'SUPPORTS_ANNOTATIONS', False)
|
||||
self.annotation_action.setEnabled(annot_enable)
|
||||
|
||||
# }}}
|
||||
|
||||
class Emailer(Thread):
|
||||
class Emailer(Thread): # {{{
|
||||
|
||||
def __init__(self, timeout=60):
|
||||
Thread.__init__(self)
|
||||
@ -590,8 +597,206 @@ class Emailer(Thread):
|
||||
results.append([jobname, e, traceback.format_exc()])
|
||||
callback(results)
|
||||
|
||||
# }}}
|
||||
|
||||
class DeviceMixin(object): # {{{
|
||||
|
||||
def __init__(self):
|
||||
self.db_book_uuid_cache = set()
|
||||
self.device_error_dialog = error_dialog(self, _('Error'),
|
||||
_('Error communicating with device'), ' ')
|
||||
self.device_error_dialog.setModal(Qt.NonModal)
|
||||
self.device_connected = None
|
||||
self.emailer = Emailer()
|
||||
self.emailer.start()
|
||||
self.device_manager = DeviceManager(Dispatcher(self.device_detected),
|
||||
self.job_manager, Dispatcher(self.status_bar.show_message))
|
||||
self.device_manager.start()
|
||||
|
||||
def set_default_thumbnail(self, height):
|
||||
r = QSvgRenderer(I('book.svg'))
|
||||
pixmap = QPixmap(height, height)
|
||||
pixmap.fill(QColor(255,255,255))
|
||||
p = QPainter(pixmap)
|
||||
r.render(p)
|
||||
p.end()
|
||||
self.default_thumbnail = (pixmap.width(), pixmap.height(),
|
||||
pixmap_to_data(pixmap))
|
||||
|
||||
def connect_to_folder(self):
|
||||
dir = choose_dir(self, 'Select Device Folder',
|
||||
_('Select folder to open as device'))
|
||||
if dir is not None:
|
||||
self.device_manager.connect_to_folder(dir)
|
||||
|
||||
def disconnect_from_folder(self):
|
||||
self.device_manager.disconnect_folder()
|
||||
|
||||
def _sync_action_triggered(self, *args):
|
||||
m = getattr(self, '_sync_menu', None)
|
||||
if m is not None:
|
||||
m.trigger_default()
|
||||
|
||||
def create_device_menu(self):
|
||||
self._sync_menu = DeviceMenu(self)
|
||||
self.action_sync.setMenu(self._sync_menu)
|
||||
self.connect(self._sync_menu,
|
||||
SIGNAL('sync(PyQt_PyObject, PyQt_PyObject, PyQt_PyObject)'),
|
||||
self.dispatch_sync_event)
|
||||
self._sync_menu.fetch_annotations.connect(self.fetch_annotations)
|
||||
self._sync_menu.connect_to_folder.connect(self.connect_to_folder)
|
||||
self._sync_menu.disconnect_from_folder.connect(self.disconnect_from_folder)
|
||||
if self.device_connected:
|
||||
self._sync_menu.connect_to_folder_action.setEnabled(False)
|
||||
if self.device_connected == 'folder':
|
||||
self._sync_menu.disconnect_from_folder_action.setEnabled(True)
|
||||
else:
|
||||
self._sync_menu.disconnect_from_folder_action.setEnabled(False)
|
||||
else:
|
||||
self._sync_menu.connect_to_folder_action.setEnabled(True)
|
||||
self._sync_menu.disconnect_from_folder_action.setEnabled(False)
|
||||
|
||||
|
||||
|
||||
def device_job_exception(self, job):
|
||||
'''
|
||||
Handle exceptions in threaded device jobs.
|
||||
'''
|
||||
if isinstance(getattr(job, 'exception', None), UserFeedback):
|
||||
ex = job.exception
|
||||
func = {UserFeedback.ERROR:error_dialog,
|
||||
UserFeedback.WARNING:warning_dialog,
|
||||
UserFeedback.INFO:info_dialog}[ex.level]
|
||||
return func(self, _('Failed'), ex.msg, det_msg=ex.details if
|
||||
ex.details else '', show=True)
|
||||
|
||||
try:
|
||||
if 'Could not read 32 bytes on the control bus.' in \
|
||||
unicode(job.details):
|
||||
error_dialog(self, _('Error talking to device'),
|
||||
_('There was a temporary error talking to the '
|
||||
'device. Please unplug and reconnect the device '
|
||||
'and or reboot.')).show()
|
||||
return
|
||||
except:
|
||||
pass
|
||||
try:
|
||||
prints(job.details, file=sys.stderr)
|
||||
except:
|
||||
pass
|
||||
if not self.device_error_dialog.isVisible():
|
||||
self.device_error_dialog.setDetailedText(job.details)
|
||||
self.device_error_dialog.show()
|
||||
|
||||
# Device connected {{{
|
||||
def device_detected(self, connected, is_folder_device):
|
||||
'''
|
||||
Called when a device is connected to the computer.
|
||||
'''
|
||||
if connected:
|
||||
self._sync_menu.connect_to_folder_action.setEnabled(False)
|
||||
if is_folder_device:
|
||||
self._sync_menu.disconnect_from_folder_action.setEnabled(True)
|
||||
self.device_manager.get_device_information(\
|
||||
Dispatcher(self.info_read))
|
||||
self.set_default_thumbnail(\
|
||||
self.device_manager.device.THUMBNAIL_HEIGHT)
|
||||
self.status_bar.show_message(_('Device: ')+\
|
||||
self.device_manager.device.__class__.get_gui_name()+\
|
||||
_(' detected.'), 3000)
|
||||
self.device_connected = 'device' if not is_folder_device else 'folder'
|
||||
self._sync_menu.enable_device_actions(True,
|
||||
self.device_manager.device.card_prefix(),
|
||||
self.device_manager.device)
|
||||
self.location_view.model().device_connected(self.device_manager.device)
|
||||
self.eject_action.setEnabled(True)
|
||||
self.refresh_ondevice_info (device_connected = True, reset_only = True)
|
||||
else:
|
||||
self._sync_menu.connect_to_folder_action.setEnabled(True)
|
||||
self._sync_menu.disconnect_from_folder_action.setEnabled(False)
|
||||
self.device_connected = None
|
||||
self._sync_menu.enable_device_actions(False)
|
||||
self.location_view.model().update_devices()
|
||||
self.vanity.setText(self.vanity_template%\
|
||||
dict(version=self.latest_version, device=' '))
|
||||
self.device_info = ' '
|
||||
if self.current_view() != self.library_view:
|
||||
self.book_details.reset_info()
|
||||
self.location_view.setCurrentIndex(self.location_view.model().index(0))
|
||||
self.eject_action.setEnabled(False)
|
||||
self.refresh_ondevice_info (device_connected = False)
|
||||
|
||||
def info_read(self, job):
|
||||
'''
|
||||
Called once device information has been read.
|
||||
'''
|
||||
if job.failed:
|
||||
return self.device_job_exception(job)
|
||||
info, cp, fs = job.result
|
||||
self.location_view.model().update_devices(cp, fs)
|
||||
self.device_info = _('Connected ')+info[0]
|
||||
self.vanity.setText(self.vanity_template%\
|
||||
dict(version=self.latest_version, device=self.device_info))
|
||||
|
||||
self.device_manager.books(Dispatcher(self.metadata_downloaded))
|
||||
|
||||
def metadata_downloaded(self, job):
|
||||
'''
|
||||
Called once metadata has been read for all books on the device.
|
||||
'''
|
||||
if job.failed:
|
||||
self.device_job_exception(job)
|
||||
return
|
||||
self.set_books_in_library(job.result, reset=True)
|
||||
mainlist, cardalist, cardblist = job.result
|
||||
self.memory_view.set_database(mainlist)
|
||||
self.memory_view.set_editable(self.device_manager.device.CAN_SET_METADATA)
|
||||
self.card_a_view.set_database(cardalist)
|
||||
self.card_a_view.set_editable(self.device_manager.device.CAN_SET_METADATA)
|
||||
self.card_b_view.set_database(cardblist)
|
||||
self.card_b_view.set_editable(self.device_manager.device.CAN_SET_METADATA)
|
||||
self.sync_news()
|
||||
self.sync_catalogs()
|
||||
self.refresh_ondevice_info(device_connected = True)
|
||||
|
||||
def refresh_ondevice_info(self, device_connected, reset_only = False):
|
||||
'''
|
||||
Force the library view to refresh, taking into consideration
|
||||
books information
|
||||
'''
|
||||
self.book_on_device(None, reset=True)
|
||||
if reset_only:
|
||||
return
|
||||
self.library_view.set_device_connected(device_connected)
|
||||
|
||||
# }}}
|
||||
|
||||
def remove_paths(self, paths):
|
||||
return self.device_manager.delete_books(
|
||||
Dispatcher(self.books_deleted), paths)
|
||||
|
||||
def books_deleted(self, job):
|
||||
'''
|
||||
Called once deletion is done on the device
|
||||
'''
|
||||
for view in (self.memory_view, self.card_a_view, self.card_b_view):
|
||||
view.model().deletion_done(job, job.failed)
|
||||
if job.failed:
|
||||
self.device_job_exception(job)
|
||||
return
|
||||
|
||||
if self.delete_memory.has_key(job):
|
||||
paths, model = self.delete_memory.pop(job)
|
||||
self.device_manager.remove_books_from_metadata(paths,
|
||||
self.booklists())
|
||||
model.paths_deleted(paths)
|
||||
self.upload_booklists()
|
||||
# Clear the ondevice info so it will be recomputed
|
||||
self.book_on_device(None, None, reset=True)
|
||||
# We want to reset all the ondevice flags in the library. Use a big
|
||||
# hammer, so we don't need to worry about whether some succeeded or not
|
||||
self.library_view.model().refresh()
|
||||
|
||||
class DeviceGUI(object):
|
||||
|
||||
def dispatch_sync_event(self, dest, delete, specific):
|
||||
rows = self.library_view.selectionModel().selectedRows()
|
||||
@ -637,7 +842,7 @@ class DeviceGUI(object):
|
||||
if not ids or len(ids) == 0:
|
||||
return
|
||||
files, _auto_ids = self.library_view.model().get_preferred_formats_from_ids(ids,
|
||||
fmts, paths=True, set_metadata=True,
|
||||
fmts, set_metadata=True,
|
||||
specific_format=specific_format,
|
||||
exclude_auto=do_auto_convert)
|
||||
if do_auto_convert:
|
||||
@ -647,7 +852,6 @@ class DeviceGUI(object):
|
||||
_auto_ids = []
|
||||
|
||||
full_metadata = self.library_view.model().metadata_for(ids)
|
||||
files = [getattr(f, 'name', None) for f in files]
|
||||
|
||||
bad, remove_ids, jobnames = [], [], []
|
||||
texts, subjects, attachments, attachment_names = [], [], [], []
|
||||
@ -679,7 +883,7 @@ class DeviceGUI(object):
|
||||
self.emailer.send_mails(jobnames,
|
||||
Dispatcher(partial(self.emails_sent, remove=remove)),
|
||||
attachments, to_s, subjects, texts, attachment_names)
|
||||
self.status_bar.showMessage(_('Sending email to')+' '+to, 3000)
|
||||
self.status_bar.show_message(_('Sending email to')+' '+to, 3000)
|
||||
|
||||
auto = []
|
||||
if _auto_ids != []:
|
||||
@ -740,7 +944,7 @@ class DeviceGUI(object):
|
||||
'%s'%errors, show=True
|
||||
)
|
||||
else:
|
||||
self.status_bar.showMessage(_('Sent by email:') + ', '.join(good),
|
||||
self.status_bar.show_message(_('Sent by email:') + ', '.join(good),
|
||||
5000)
|
||||
|
||||
def cover_to_thumbnail(self, data):
|
||||
@ -760,7 +964,7 @@ class DeviceGUI(object):
|
||||
for account, fmts in accounts:
|
||||
files, auto = self.library_view.model().\
|
||||
get_preferred_formats_from_ids([id], fmts)
|
||||
files = [f.name for f in files if f is not None]
|
||||
files = [f for f in files if f is not None]
|
||||
if not files:
|
||||
continue
|
||||
attachment = files[0]
|
||||
@ -779,7 +983,7 @@ class DeviceGUI(object):
|
||||
attachments, to_s, subjects, texts, attachment_names)
|
||||
sent_mails.append(to_s[0])
|
||||
if sent_mails:
|
||||
self.status_bar.showMessage(_('Sent news to')+' '+\
|
||||
self.status_bar.show_message(_('Sent news to')+' '+\
|
||||
', '.join(sent_mails), 3000)
|
||||
|
||||
def sync_catalogs(self, send_ids=None, do_auto_convert=True):
|
||||
@ -824,7 +1028,7 @@ class DeviceGUI(object):
|
||||
prefix = prefix.decode(preferred_encoding, 'replace')
|
||||
prefix = ascii_filename(prefix)
|
||||
names.append('%s_%d%s'%(prefix, id,
|
||||
os.path.splitext(f.name)[1]))
|
||||
os.path.splitext(f)[1]))
|
||||
if mi.cover and os.access(mi.cover, os.R_OK):
|
||||
mi.thumbnail = self.cover_to_thumbnail(open(mi.cover,
|
||||
'rb').read())
|
||||
@ -837,13 +1041,14 @@ class DeviceGUI(object):
|
||||
on_card = space.get(sorted(space.keys(), reverse=True)[0], None)
|
||||
self.upload_books(files, names, metadata,
|
||||
on_card=on_card,
|
||||
memory=[[f.name for f in files], remove])
|
||||
self.status_bar.showMessage(_('Sending catalogs to device.'), 5000)
|
||||
memory=[files, remove])
|
||||
self.status_bar.show_message(_('Sending catalogs to device.'), 5000)
|
||||
|
||||
|
||||
|
||||
def sync_news(self, send_ids=None, do_auto_convert=True):
|
||||
if self.device_connected:
|
||||
del_on_upload = config['delete_news_from_library_on_upload']
|
||||
settings = self.device_manager.device.settings()
|
||||
ids = list(dynamic.get('news_to_be_synced', set([]))) if send_ids is None else send_ids
|
||||
ids = [id for id in ids if self.library_view.model().db.has_id(id)]
|
||||
@ -873,6 +1078,8 @@ class DeviceGUI(object):
|
||||
'the device?'), det_msg=autos):
|
||||
self.auto_convert_news(auto, format)
|
||||
files = [f for f in files if f is not None]
|
||||
for f in files:
|
||||
f.deleted_after_upload = del_on_upload
|
||||
if not files:
|
||||
dynamic.set('news_to_be_synced', set([]))
|
||||
return
|
||||
@ -884,22 +1091,21 @@ class DeviceGUI(object):
|
||||
prefix = prefix.decode(preferred_encoding, 'replace')
|
||||
prefix = ascii_filename(prefix)
|
||||
names.append('%s_%d%s'%(prefix, id,
|
||||
os.path.splitext(f.name)[1]))
|
||||
os.path.splitext(f)[1]))
|
||||
if mi.cover and os.access(mi.cover, os.R_OK):
|
||||
mi.thumbnail = self.cover_to_thumbnail(open(mi.cover,
|
||||
'rb').read())
|
||||
dynamic.set('news_to_be_synced', set([]))
|
||||
if config['upload_news_to_device'] and files:
|
||||
remove = ids if \
|
||||
config['delete_news_from_library_on_upload'] else []
|
||||
remove = ids if del_on_upload else []
|
||||
space = { self.location_view.model().free[0] : None,
|
||||
self.location_view.model().free[1] : 'carda',
|
||||
self.location_view.model().free[2] : 'cardb' }
|
||||
on_card = space.get(sorted(space.keys(), reverse=True)[0], None)
|
||||
self.upload_books(files, names, metadata,
|
||||
on_card=on_card,
|
||||
memory=[[f.name for f in files], remove])
|
||||
self.status_bar.showMessage(_('Sending news to device.'), 5000)
|
||||
memory=[files, remove])
|
||||
self.status_bar.show_message(_('Sending news to device.'), 5000)
|
||||
|
||||
|
||||
def sync_to_device(self, on_card, delete_from_library,
|
||||
@ -914,7 +1120,7 @@ class DeviceGUI(object):
|
||||
|
||||
_files, _auto_ids = self.library_view.model().get_preferred_formats_from_ids(ids,
|
||||
settings.format_map,
|
||||
paths=True, set_metadata=True,
|
||||
set_metadata=True,
|
||||
specific_format=specific_format,
|
||||
exclude_auto=do_auto_convert)
|
||||
if do_auto_convert:
|
||||
@ -930,9 +1136,8 @@ class DeviceGUI(object):
|
||||
mi.thumbnail = self.cover_to_thumbnail(open(mi.cover, 'rb').read())
|
||||
imetadata = iter(metadata)
|
||||
|
||||
files = [getattr(f, 'name', None) for f in _files]
|
||||
bad, good, gf, names, remove_ids = [], [], [], [], []
|
||||
for f in files:
|
||||
for f in _files:
|
||||
mi = imetadata.next()
|
||||
id = ids.next()
|
||||
if f is None:
|
||||
@ -954,7 +1159,7 @@ class DeviceGUI(object):
|
||||
names.append('%s_%d%s'%(prefix, id, os.path.splitext(f)[1]))
|
||||
remove = remove_ids if delete_from_library else []
|
||||
self.upload_books(gf, names, good, on_card, memory=(_files, remove))
|
||||
self.status_bar.showMessage(_('Sending books to device.'), 5000)
|
||||
self.status_bar.show_message(_('Sending books to device.'), 5000)
|
||||
|
||||
auto = []
|
||||
if _auto_ids != []:
|
||||
@ -1129,6 +1334,13 @@ class DeviceGUI(object):
|
||||
in cache['authors']:
|
||||
loc[i] = True
|
||||
continue
|
||||
# Also check author sort, because it can be used as author in
|
||||
# some formats
|
||||
if mi.author_sort and \
|
||||
re.sub('(?u)\W|[_]', '', mi.author_sort.lower()) \
|
||||
in cache['authors']:
|
||||
loc[i] = True
|
||||
continue
|
||||
return loc
|
||||
|
||||
def set_books_in_library(self, booklists, reset=False):
|
||||
@ -1141,10 +1353,16 @@ class DeviceGUI(object):
|
||||
mi = db.get_metadata(id, index_is_id=True)
|
||||
title = re.sub('(?u)\W|[_]', '', mi.title.lower())
|
||||
if title not in self.db_book_title_cache:
|
||||
self.db_book_title_cache[title] = {'authors':{}, 'db_ids':{}}
|
||||
authors = authors_to_string(mi.authors).lower() if mi.authors else ''
|
||||
authors = re.sub('(?u)\W|[_]', '', authors)
|
||||
self.db_book_title_cache[title]['authors'][authors] = mi
|
||||
self.db_book_title_cache[title] = \
|
||||
{'authors':{}, 'author_sort':{}, 'db_ids':{}}
|
||||
if mi.authors:
|
||||
authors = authors_to_string(mi.authors).lower()
|
||||
authors = re.sub('(?u)\W|[_]', '', authors)
|
||||
self.db_book_title_cache[title]['authors'][authors] = mi
|
||||
if mi.author_sort:
|
||||
aus = mi.author_sort.lower()
|
||||
aus = re.sub('(?u)\W|[_]', '', aus)
|
||||
self.db_book_title_cache[title]['author_sort'][aus] = mi
|
||||
self.db_book_title_cache[title]['db_ids'][mi.application_id] = mi
|
||||
self.db_book_uuid_cache.add(mi.uuid)
|
||||
|
||||
@ -1175,19 +1393,29 @@ class DeviceGUI(object):
|
||||
book.smart_update(d['db_ids'][book.db_id])
|
||||
resend_metadata = True
|
||||
continue
|
||||
book_authors = authors_to_string(book.authors).lower() if book.authors else ''
|
||||
book_authors = re.sub('(?u)\W|[_]', '', book_authors)
|
||||
if book_authors in d['authors']:
|
||||
book.in_library = True
|
||||
book.smart_update(d['authors'][book_authors])
|
||||
resend_metadata = True
|
||||
if book.authors:
|
||||
# Compare against both author and author sort, because
|
||||
# either can appear as the author
|
||||
book_authors = authors_to_string(book.authors).lower()
|
||||
book_authors = re.sub('(?u)\W|[_]', '', book_authors)
|
||||
if book_authors in d['authors']:
|
||||
book.in_library = True
|
||||
book.smart_update(d['authors'][book_authors])
|
||||
resend_metadata = True
|
||||
elif book_authors in d['author_sort']:
|
||||
book.in_library = True
|
||||
book.smart_update(d['author_sort'][book_authors])
|
||||
resend_metadata = True
|
||||
# Set author_sort if it isn't already
|
||||
asort = getattr(book, 'author_sort', None)
|
||||
if not asort and book.authors:
|
||||
book.author_sort = authors_to_sort_string(book.authors)
|
||||
book.author_sort = self.library_view.model().db.author_sort_from_authors(book.authors)
|
||||
resend_metadata = True
|
||||
|
||||
if resend_metadata:
|
||||
# Correct the metadata cache on device.
|
||||
if self.device_manager.is_device_connected:
|
||||
self.device_manager.sync_booklists(None, booklists)
|
||||
|
||||
# }}}
|
||||
|
||||
|
@ -38,9 +38,10 @@ class ConfigWidget(QWidget, Ui_ConfigWidget):
|
||||
self.opt_read_metadata.setChecked(self.settings.read_metadata)
|
||||
else:
|
||||
self.opt_read_metadata.hide()
|
||||
if extra_customization_message and settings.extra_customization:
|
||||
if extra_customization_message:
|
||||
self.extra_customization_label.setText(extra_customization_message)
|
||||
self.opt_extra_customization.setText(settings.extra_customization)
|
||||
if settings.extra_customization:
|
||||
self.opt_extra_customization.setText(settings.extra_customization)
|
||||
else:
|
||||
self.extra_customization_label.setVisible(False)
|
||||
self.opt_extra_customization.setVisible(False)
|
||||
|
@ -49,12 +49,12 @@ class BookInfo(QDialog, Ui_BookInfo):
|
||||
|
||||
def open_book_path(self, path):
|
||||
if os.sep in unicode(path):
|
||||
QDesktopServices.openUrl(QUrl('file:'+path))
|
||||
QDesktopServices.openUrl(QUrl.fromLocalFile(path))
|
||||
else:
|
||||
format = unicode(path)
|
||||
path = self.view.model().db.format_abspath(self.current_row, format)
|
||||
if path is not None:
|
||||
QDesktopServices.openUrl(QUrl('file:'+path))
|
||||
QDesktopServices.openUrl(QUrl.fromLocalFile(path))
|
||||
|
||||
|
||||
def next(self):
|
||||
@ -121,6 +121,7 @@ class BookInfo(QDialog, Ui_BookInfo):
|
||||
f = f.strip()
|
||||
info[_('Formats')] += '<a href="%s">%s</a>, '%(f,f)
|
||||
for key in info.keys():
|
||||
if key == 'id': continue
|
||||
txt = info[key]
|
||||
txt = u'<br />\n'.join(textwrap.wrap(txt, 120))
|
||||
rows += u'<tr><td><b>%s:</b></td><td>%s</td></tr>'%(key, txt)
|
||||
|
@ -481,8 +481,18 @@ class ConfigDialog(ResizableDialog, Ui_Dialog):
|
||||
self.opt_enforce_cpu_limit.setChecked(config['enforce_cpu_limit'])
|
||||
self.device_detection_button.clicked.connect(self.debug_device_detection)
|
||||
self.port.editingFinished.connect(self.check_port_value)
|
||||
self.search_as_you_type.setChecked(config['search_as_you_type'])
|
||||
self.show_avg_rating.setChecked(config['show_avg_rating'])
|
||||
self.show_splash_screen.setChecked(gprefs.get('show_splash_screen',
|
||||
True))
|
||||
li = None
|
||||
for i, z in enumerate([('wide', _('Wide')),
|
||||
('narrow', _('Narrow'))]):
|
||||
x, y = z
|
||||
self.opt_gui_layout.addItem(y, QVariant(x))
|
||||
if x == config['gui_layout']:
|
||||
li = i
|
||||
self.opt_gui_layout.setCurrentIndex(li)
|
||||
|
||||
def check_port_value(self, *args):
|
||||
port = self.port.value()
|
||||
@ -854,6 +864,7 @@ class ConfigDialog(ResizableDialog, Ui_Dialog):
|
||||
config['delete_news_from_library_on_upload'] = self.delete_news.isChecked()
|
||||
config['upload_news_to_device'] = self.sync_news.isChecked()
|
||||
config['search_as_you_type'] = self.search_as_you_type.isChecked()
|
||||
config['show_avg_rating'] = self.show_avg_rating.isChecked()
|
||||
config['get_social_metadata'] = self.opt_get_social_metadata.isChecked()
|
||||
config['overwrite_author_title_metadata'] = self.opt_overwrite_author_title_metadata.isChecked()
|
||||
config['enforce_cpu_limit'] = bool(self.opt_enforce_cpu_limit.isChecked())
|
||||
@ -863,6 +874,8 @@ class ConfigDialog(ResizableDialog, Ui_Dialog):
|
||||
if self.viewer.item(i).checkState() == Qt.Checked:
|
||||
fmts.append(str(self.viewer.item(i).text()))
|
||||
config['internally_viewed_formats'] = fmts
|
||||
val = self.opt_gui_layout.itemData(self.opt_gui_layout.currentIndex()).toString()
|
||||
config['gui_layout'] = unicode(val)
|
||||
|
||||
if not path or not os.path.exists(path) or not os.path.isdir(path):
|
||||
d = error_dialog(self, _('Invalid database location'),
|
||||
|
@ -89,8 +89,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>608</width>
|
||||
<height>683</height>
|
||||
<width>604</width>
|
||||
<height>679</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_7">
|
||||
@ -332,7 +332,7 @@
|
||||
</widget>
|
||||
<widget class="QWidget" name="page">
|
||||
<layout class="QGridLayout" name="gridLayout_8">
|
||||
<item row="0" column="0">
|
||||
<item row="1" column="0">
|
||||
<widget class="QCheckBox" name="roman_numerals">
|
||||
<property name="text">
|
||||
<string>Use &Roman numerals for series number</string>
|
||||
@ -342,35 +342,45 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<item row="2" column="0">
|
||||
<widget class="QCheckBox" name="systray_icon">
|
||||
<property name="text">
|
||||
<string>Enable system &tray icon (needs restart)</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<item row="2" column="1">
|
||||
<widget class="QCheckBox" name="systray_notifications">
|
||||
<property name="text">
|
||||
<string>Show &notifications in system tray</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0" colspan="2">
|
||||
<item row="3" column="0" colspan="2">
|
||||
<widget class="QCheckBox" name="show_splash_screen">
|
||||
<property name="text">
|
||||
<string>Show &splash screen at startup</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0" colspan="2">
|
||||
<item row="4" column="0" colspan="2">
|
||||
<widget class="QCheckBox" name="separate_cover_flow">
|
||||
<property name="text">
|
||||
<string>Show cover &browser in a separate window (needs restart)</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<item row="5" column="0">
|
||||
<widget class="QCheckBox" name="show_avg_rating">
|
||||
<property name="text">
|
||||
<string>Show &average ratings in the tags browser</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="0">
|
||||
<widget class="QCheckBox" name="search_as_you_type">
|
||||
<property name="text">
|
||||
<string>Search as you type</string>
|
||||
@ -380,21 +390,21 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0" colspan="2">
|
||||
<item row="7" column="0" colspan="2">
|
||||
<widget class="QCheckBox" name="sync_news">
|
||||
<property name="text">
|
||||
<string>Automatically send downloaded &news to ebook reader</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="0" colspan="2">
|
||||
<item row="8" column="0" colspan="2">
|
||||
<widget class="QCheckBox" name="delete_news">
|
||||
<property name="text">
|
||||
<string>&Delete news from library when it is automatically sent to reader</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="0" colspan="2">
|
||||
<item row="9" column="0" colspan="2">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_6">
|
||||
@ -411,7 +421,7 @@
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="8" column="0" colspan="2">
|
||||
<item row="10" column="0" colspan="2">
|
||||
<widget class="QGroupBox" name="groupBox_2">
|
||||
<property name="title">
|
||||
<string>Toolbar</string>
|
||||
@ -459,7 +469,7 @@
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="9" column="0" colspan="2">
|
||||
<item row="11" column="0" colspan="2">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_7">
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
@ -625,6 +635,26 @@
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_17">
|
||||
<property name="text">
|
||||
<string>User Interface &layout (needs restart):</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>opt_gui_layout</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QComboBox" name="opt_gui_layout">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>250</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="page_6">
|
||||
|
@ -3,6 +3,7 @@ __copyright__ = '2010, Kovid Goyal <kovid at kovidgoyal.net>'
|
||||
|
||||
'''Dialog to create a new custom column'''
|
||||
|
||||
import re
|
||||
from functools import partial
|
||||
|
||||
from PyQt4.QtCore import SIGNAL
|
||||
@ -94,8 +95,8 @@ class CreateCustomColumn(QDialog, Ui_QCreateCustomColumn):
|
||||
col = unicode(self.column_name_box.text()).lower()
|
||||
if not col:
|
||||
return self.simple_error('', _('No lookup name was provided'))
|
||||
if not col.isalnum() or not col[0].isalpha():
|
||||
return self.simple_error('', _('The label must contain only letters and digits, and start with a letter'))
|
||||
if re.match('^\w*$', col) is None or not col[0].isalpha():
|
||||
return self.simple_error('', _('The label must contain only letters, digits and underscores, and start with a letter'))
|
||||
col_heading = unicode(self.column_heading_box.text())
|
||||
col_type = self.column_types[self.column_type_box.currentIndex()]['datatype']
|
||||
if col_type == '*text':
|
||||
|
82
src/calibre/gui2/dialogs/edit_authors_dialog.py
Normal file
@ -0,0 +1,82 @@
|
||||
#!/usr/bin/env python
|
||||
__copyright__ = '2008, Kovid Goyal kovid@kovidgoyal.net'
|
||||
__docformat__ = 'restructuredtext en'
|
||||
__license__ = 'GPL v3'
|
||||
|
||||
from PyQt4.Qt import Qt, QDialog, QTableWidgetItem, QAbstractItemView
|
||||
|
||||
from calibre.ebooks.metadata import author_to_author_sort
|
||||
from calibre.gui2.dialogs.edit_authors_dialog_ui import Ui_EditAuthorsDialog
|
||||
|
||||
class tableItem(QTableWidgetItem):
|
||||
def __ge__(self, other):
|
||||
return unicode(self.text()).lower() >= unicode(other.text()).lower()
|
||||
|
||||
def __lt__(self, other):
|
||||
return unicode(self.text()).lower() < unicode(other.text()).lower()
|
||||
|
||||
class EditAuthorsDialog(QDialog, Ui_EditAuthorsDialog):
|
||||
|
||||
def __init__(self, parent, db, id_to_select):
|
||||
QDialog.__init__(self, parent)
|
||||
Ui_EditAuthorsDialog.__init__(self)
|
||||
self.setupUi(self)
|
||||
|
||||
self.buttonBox.accepted.connect(self.accepted)
|
||||
|
||||
self.table.setSelectionMode(QAbstractItemView.SingleSelection)
|
||||
self.table.setColumnCount(2)
|
||||
self.table.setHorizontalHeaderLabels([_('Author'), _('Author sort')])
|
||||
|
||||
self.authors = {}
|
||||
auts = db.get_authors_with_ids()
|
||||
self.table.setRowCount(len(auts))
|
||||
select_item = None
|
||||
for row, (id, author, sort) in enumerate(auts):
|
||||
author = author.replace('|', ',')
|
||||
self.authors[id] = (author, sort)
|
||||
aut = tableItem(author)
|
||||
aut.setData(Qt.UserRole, id)
|
||||
sort = tableItem(sort)
|
||||
self.table.setItem(row, 0, aut)
|
||||
self.table.setItem(row, 1, sort)
|
||||
if id == id_to_select:
|
||||
select_item = sort
|
||||
self.table.resizeColumnsToContents()
|
||||
|
||||
# set up the signal after the table is filled
|
||||
self.table.cellChanged.connect(self.cell_changed)
|
||||
|
||||
self.table.setSortingEnabled(True)
|
||||
self.table.sortByColumn(1, Qt.AscendingOrder)
|
||||
if select_item is not None:
|
||||
self.table.setCurrentItem(select_item)
|
||||
self.table.editItem(select_item)
|
||||
else:
|
||||
self.table.setCurrentCell(0, 0)
|
||||
|
||||
def accepted(self):
|
||||
self.result = []
|
||||
for row in range(0,self.table.rowCount()):
|
||||
id = self.table.item(row, 0).data(Qt.UserRole).toInt()[0]
|
||||
aut = unicode(self.table.item(row, 0).text()).strip()
|
||||
sort = unicode(self.table.item(row, 1).text()).strip()
|
||||
orig_aut,orig_sort = self.authors[id]
|
||||
if orig_aut != aut or orig_sort != sort:
|
||||
self.result.append((id, orig_aut, aut, sort))
|
||||
|
||||
def cell_changed(self, row, col):
|
||||
if col == 0:
|
||||
item = self.table.item(row, 0)
|
||||
aut = unicode(item.text()).strip()
|
||||
c = self.table.item(row, 1)
|
||||
c.setText(author_to_author_sort(aut))
|
||||
item = c
|
||||
else:
|
||||
item = self.table.item(row, 1)
|
||||
self.table.setCurrentItem(item)
|
||||
# disable and reenable sorting to force the sort now, so we can scroll
|
||||
# to the item after it moves
|
||||
self.table.setSortingEnabled(False)
|
||||
self.table.setSortingEnabled(True)
|
||||
self.table.scrollToItem(item)
|
86
src/calibre/gui2/dialogs/edit_authors_dialog.ui
Normal file
@ -0,0 +1,86 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>EditAuthorsDialog</class>
|
||||
<widget class="QDialog" name="EditAuthorsDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>730</width>
|
||||
<height>342</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="MinimumExpanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Manage authors</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QTableWidget" name="table">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="columnCount">
|
||||
<number>0</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
<property name="centerButtons">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>EditAuthorsDialog</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>229</x>
|
||||
<y>211</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>157</x>
|
||||
<y>234</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>EditAuthorsDialog</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>297</x>
|
||||
<y>217</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>286</x>
|
||||
<y>234</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
@ -8,7 +8,7 @@ from PyQt4.QtGui import QDialog, QGridLayout
|
||||
|
||||
from calibre.gui2.dialogs.metadata_bulk_ui import Ui_MetadataBulkDialog
|
||||
from calibre.gui2.dialogs.tag_editor import TagEditor
|
||||
from calibre.ebooks.metadata import string_to_authors, authors_to_sort_string, \
|
||||
from calibre.ebooks.metadata import string_to_authors, \
|
||||
authors_to_string
|
||||
from calibre.gui2.custom_column_widgets import populate_bulk_metadata_page
|
||||
|
||||
@ -110,10 +110,7 @@ class MetadataBulkDialog(QDialog, Ui_MetadataBulkDialog):
|
||||
au = string_to_authors(au)
|
||||
self.db.set_authors(id, au, notify=False)
|
||||
if self.auto_author_sort.isChecked():
|
||||
aut = self.db.authors(id, index_is_id=True)
|
||||
aut = aut if aut else ''
|
||||
aut = [a.strip().replace('|', ',') for a in aut.strip().split(',')]
|
||||
x = authors_to_sort_string(aut)
|
||||
x = self.db.author_sort_from_book(id, index_is_id=True)
|
||||
if x:
|
||||
self.db.set_author_sort(id, x, notify=False)
|
||||
aus = unicode(self.author_sort.text())
|
||||
|
@ -23,7 +23,7 @@ from calibre.gui2.dialogs.fetch_metadata import FetchMetadata
|
||||
from calibre.gui2.dialogs.tag_editor import TagEditor
|
||||
from calibre.gui2.widgets import ProgressIndicator
|
||||
from calibre.ebooks import BOOK_EXTENSIONS
|
||||
from calibre.ebooks.metadata import authors_to_sort_string, string_to_authors, \
|
||||
from calibre.ebooks.metadata import string_to_authors, \
|
||||
authors_to_string, check_isbn
|
||||
from calibre.ebooks.metadata.library_thing import cover_from_isbn
|
||||
from calibre import islinux, isfreebsd
|
||||
@ -357,7 +357,8 @@ class MetadataSingleDialog(ResizableDialog, Ui_MetadataSingleDialog):
|
||||
aus = self.db.author_sort(row)
|
||||
self.author_sort.setText(aus if aus else '')
|
||||
tags = self.db.tags(row)
|
||||
self.tags.setText(', '.join(tags.split(',')) if tags else '')
|
||||
self.original_tags = ', '.join(tags.split(',')) if tags else ''
|
||||
self.tags.setText(self.original_tags)
|
||||
self.tags.update_tags_cache(self.db.all_tags())
|
||||
rating = self.db.rating(row)
|
||||
if rating > 0:
|
||||
@ -403,12 +404,14 @@ class MetadataSingleDialog(ResizableDialog, Ui_MetadataSingleDialog):
|
||||
ag = QCoreApplication.instance().desktop().availableGeometry(self)
|
||||
self.cover.MAX_HEIGHT = ag.height()-(25 if (islinux or isfreebsd) else 0)-height_of_rest
|
||||
self.cover.MAX_WIDTH = ag.width()-(25 if (islinux or isfreebsd) else 0)-width_of_rest
|
||||
pm = QPixmap()
|
||||
if cover:
|
||||
pm = QPixmap()
|
||||
pm.loadFromData(cover)
|
||||
if not pm.isNull():
|
||||
self.cover.setPixmap(pm)
|
||||
if pm.isNull():
|
||||
pm = QPixmap(I('book.svg'))
|
||||
else:
|
||||
self.cover_data = cover
|
||||
self.cover.setPixmap(pm)
|
||||
self.original_series_name = unicode(self.series.text()).strip()
|
||||
if len(db.custom_column_label_map) == 0:
|
||||
self.central_widget.tabBar().setVisible(False)
|
||||
@ -457,7 +460,7 @@ class MetadataSingleDialog(ResizableDialog, Ui_MetadataSingleDialog):
|
||||
au = unicode(self.authors.text())
|
||||
au = re.sub(r'\s+et al\.$', '', au)
|
||||
authors = string_to_authors(au)
|
||||
self.author_sort.setText(authors_to_sort_string(authors))
|
||||
self.author_sort.setText(self.db.author_sort_from_authors(authors))
|
||||
|
||||
def swap_title_author(self):
|
||||
title = self.title.text()
|
||||
@ -525,6 +528,10 @@ class MetadataSingleDialog(ResizableDialog, Ui_MetadataSingleDialog):
|
||||
self.publisher.setCurrentIndex(idx)
|
||||
|
||||
def edit_tags(self):
|
||||
if self.tags.text() != self.original_tags:
|
||||
error_dialog(self, _('Cannot use tag editor'),
|
||||
_('The tags editor cannot be used if you have modified the tags')).exec_()
|
||||
return
|
||||
d = TagEditor(self, self.db, self.row)
|
||||
d.exec_()
|
||||
if d.result() == QDialog.Accepted:
|
||||
|
@ -121,6 +121,9 @@
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
<property name="centerButtons">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
|
424
src/calibre/gui2/init.py
Normal file
@ -0,0 +1,424 @@
|
||||
#!/usr/bin/env python
|
||||
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:ai
|
||||
|
||||
__license__ = 'GPL v3'
|
||||
__copyright__ = '2010, Kovid Goyal <kovid@kovidgoyal.net>'
|
||||
__docformat__ = 'restructuredtext en'
|
||||
|
||||
import functools
|
||||
|
||||
from PyQt4.Qt import QMenu, Qt, pyqtSignal, QToolButton, QIcon, QStackedWidget, \
|
||||
QWidget, QHBoxLayout, QToolBar, QSize, QSizePolicy
|
||||
|
||||
from calibre.utils.config import prefs
|
||||
from calibre.ebooks import BOOK_EXTENSIONS
|
||||
from calibre.constants import isosx, __appname__
|
||||
from calibre.gui2 import config, is_widescreen
|
||||
from calibre.gui2.library.views import BooksView, DeviceBooksView
|
||||
from calibre.gui2.widgets import Splitter
|
||||
from calibre.gui2.tag_view import TagBrowserWidget
|
||||
from calibre.gui2.status import StatusBar, HStatusBar
|
||||
from calibre.gui2.book_details import BookDetails
|
||||
|
||||
_keep_refs = []
|
||||
|
||||
def partial(*args, **kwargs):
|
||||
ans = functools.partial(*args, **kwargs)
|
||||
_keep_refs.append(ans)
|
||||
return ans
|
||||
|
||||
class SaveMenu(QMenu): # {{{
|
||||
|
||||
save_fmt = pyqtSignal(object)
|
||||
|
||||
def __init__(self, parent):
|
||||
QMenu.__init__(self, _('Save single format to disk...'), parent)
|
||||
for ext in sorted(BOOK_EXTENSIONS):
|
||||
action = self.addAction(ext.upper())
|
||||
setattr(self, 'do_'+ext, partial(self.do, ext))
|
||||
action.triggered.connect(
|
||||
getattr(self, 'do_'+ext))
|
||||
|
||||
def do(self, ext, *args):
|
||||
self.save_fmt.emit(ext)
|
||||
|
||||
# }}}
|
||||
|
||||
class ToolbarMixin(object): # {{{
|
||||
|
||||
def __init__(self):
|
||||
md = QMenu()
|
||||
md.addAction(_('Edit metadata individually'),
|
||||
partial(self.edit_metadata, False, bulk=False))
|
||||
md.addSeparator()
|
||||
md.addAction(_('Edit metadata in bulk'),
|
||||
partial(self.edit_metadata, False, bulk=True))
|
||||
md.addSeparator()
|
||||
md.addAction(_('Download metadata and covers'),
|
||||
partial(self.download_metadata, False, covers=True))
|
||||
md.addAction(_('Download only metadata'),
|
||||
partial(self.download_metadata, False, covers=False))
|
||||
md.addAction(_('Download only covers'),
|
||||
partial(self.download_metadata, False, covers=True,
|
||||
set_metadata=False, set_social_metadata=False))
|
||||
md.addAction(_('Download only social metadata'),
|
||||
partial(self.download_metadata, False, covers=False,
|
||||
set_metadata=False, set_social_metadata=True))
|
||||
self.metadata_menu = md
|
||||
|
||||
mb = QMenu()
|
||||
mb.addAction(_('Merge into first selected book - delete others'),
|
||||
self.merge_books)
|
||||
mb.addSeparator()
|
||||
mb.addAction(_('Merge into first selected book - keep others'),
|
||||
partial(self.merge_books, safe_merge=True))
|
||||
self.merge_menu = mb
|
||||
self.action_merge.setMenu(mb)
|
||||
md.addSeparator()
|
||||
md.addAction(self.action_merge)
|
||||
|
||||
self.add_menu = QMenu()
|
||||
self.add_menu.addAction(_('Add books from a single directory'),
|
||||
self.add_books)
|
||||
self.add_menu.addAction(_('Add books from directories, including '
|
||||
'sub-directories (One book per directory, assumes every ebook '
|
||||
'file is the same book in a different format)'),
|
||||
self.add_recursive_single)
|
||||
self.add_menu.addAction(_('Add books from directories, including '
|
||||
'sub directories (Multiple books per directory, assumes every '
|
||||
'ebook file is a different book)'), self.add_recursive_multiple)
|
||||
self.add_menu.addAction(_('Add Empty book. (Book entry with no '
|
||||
'formats)'), self.add_empty)
|
||||
self.action_add.setMenu(self.add_menu)
|
||||
self.action_add.triggered.connect(self.add_books)
|
||||
self.action_del.triggered.connect(self.delete_books)
|
||||
self.action_edit.triggered.connect(self.edit_metadata)
|
||||
self.action_merge.triggered.connect(self.merge_books)
|
||||
|
||||
self.action_save.triggered.connect(self.save_to_disk)
|
||||
self.save_menu = QMenu()
|
||||
self.save_menu.addAction(_('Save to disk'), partial(self.save_to_disk,
|
||||
False))
|
||||
self.save_menu.addAction(_('Save to disk in a single directory'),
|
||||
partial(self.save_to_single_dir, False))
|
||||
self.save_menu.addAction(_('Save only %s format to disk')%
|
||||
prefs['output_format'].upper(),
|
||||
partial(self.save_single_format_to_disk, False))
|
||||
self.save_menu.addAction(
|
||||
_('Save only %s format to disk in a single directory')%
|
||||
prefs['output_format'].upper(),
|
||||
partial(self.save_single_fmt_to_single_dir, False))
|
||||
self.save_sub_menu = SaveMenu(self)
|
||||
self.save_menu.addMenu(self.save_sub_menu)
|
||||
self.save_sub_menu.save_fmt.connect(self.save_specific_format_disk)
|
||||
|
||||
self.action_view.triggered.connect(self.view_book)
|
||||
self.view_menu = QMenu()
|
||||
self.view_menu.addAction(_('View'), partial(self.view_book, False))
|
||||
ac = self.view_menu.addAction(_('View specific format'))
|
||||
ac.setShortcut((Qt.ControlModifier if isosx else Qt.AltModifier)+Qt.Key_V)
|
||||
self.action_view.setMenu(self.view_menu)
|
||||
ac.triggered.connect(self.view_specific_format, type=Qt.QueuedConnection)
|
||||
|
||||
self.delete_menu = QMenu()
|
||||
self.delete_menu.addAction(_('Remove selected books'), self.delete_books)
|
||||
self.delete_menu.addAction(
|
||||
_('Remove files of a specific format from selected books..'),
|
||||
self.delete_selected_formats)
|
||||
self.delete_menu.addAction(
|
||||
_('Remove all formats from selected books, except...'),
|
||||
self.delete_all_but_selected_formats)
|
||||
self.delete_menu.addAction(
|
||||
_('Remove covers from selected books'), self.delete_covers)
|
||||
self.action_del.setMenu(self.delete_menu)
|
||||
|
||||
self.action_open_containing_folder.setShortcut(Qt.Key_O)
|
||||
self.addAction(self.action_open_containing_folder)
|
||||
self.action_open_containing_folder.triggered.connect(self.view_folder)
|
||||
self.action_sync.setShortcut(Qt.Key_D)
|
||||
self.action_sync.setEnabled(True)
|
||||
self.create_device_menu()
|
||||
self.action_sync.triggered.connect(
|
||||
self._sync_action_triggered)
|
||||
|
||||
self.action_edit.setMenu(md)
|
||||
self.action_save.setMenu(self.save_menu)
|
||||
|
||||
cm = QMenu()
|
||||
cm.addAction(_('Convert individually'), partial(self.convert_ebook,
|
||||
False, bulk=False))
|
||||
cm.addAction(_('Bulk convert'),
|
||||
partial(self.convert_ebook, False, bulk=True))
|
||||
cm.addSeparator()
|
||||
ac = cm.addAction(
|
||||
_('Create catalog of books in your calibre library'))
|
||||
ac.triggered.connect(self.generate_catalog)
|
||||
self.action_convert.setMenu(cm)
|
||||
self.action_convert.triggered.connect(self.convert_ebook)
|
||||
self.convert_menu = cm
|
||||
|
||||
pm = QMenu()
|
||||
ap = self.action_preferences
|
||||
pm.addAction(ap)
|
||||
pm.addAction(QIcon(I('wizard.svg')), _('Run welcome wizard'),
|
||||
self.run_wizard)
|
||||
self.action_preferences.setMenu(pm)
|
||||
self.preferences_menu = pm
|
||||
for x in (self.preferences_action, self.action_preferences):
|
||||
x.triggered.connect(self.do_config)
|
||||
|
||||
for x in ('news', 'edit', 'sync', 'convert', 'save', 'add', 'view',
|
||||
'del', 'preferences'):
|
||||
w = self.tool_bar.widgetForAction(getattr(self, 'action_'+x))
|
||||
w.setPopupMode(w.MenuButtonPopup)
|
||||
|
||||
self.tool_bar.setContextMenuPolicy(Qt.PreventContextMenu)
|
||||
|
||||
for ch in self.tool_bar.children():
|
||||
if isinstance(ch, QToolButton):
|
||||
ch.setCursor(Qt.PointingHandCursor)
|
||||
|
||||
self.tool_bar.contextMenuEvent = self.no_op
|
||||
|
||||
def read_toolbar_settings(self):
|
||||
self.tool_bar.setIconSize(config['toolbar_icon_size'])
|
||||
self.tool_bar.setToolButtonStyle(
|
||||
Qt.ToolButtonTextUnderIcon if \
|
||||
config['show_text_in_toolbar'] else \
|
||||
Qt.ToolButtonIconOnly)
|
||||
|
||||
# }}}
|
||||
|
||||
class LibraryViewMixin(object): # {{{
|
||||
|
||||
def __init__(self, db):
|
||||
similar_menu = QMenu(_('Similar books...'))
|
||||
similar_menu.addAction(self.action_books_by_same_author)
|
||||
similar_menu.addAction(self.action_books_in_this_series)
|
||||
similar_menu.addAction(self.action_books_with_the_same_tags)
|
||||
similar_menu.addAction(self.action_books_by_this_publisher)
|
||||
self.action_books_by_same_author.setShortcut(Qt.ALT + Qt.Key_A)
|
||||
self.action_books_in_this_series.setShortcut(Qt.ALT + Qt.Key_S)
|
||||
self.action_books_by_this_publisher.setShortcut(Qt.ALT + Qt.Key_P)
|
||||
self.action_books_with_the_same_tags.setShortcut(Qt.ALT+Qt.Key_T)
|
||||
self.addAction(self.action_books_by_same_author)
|
||||
self.addAction(self.action_books_by_this_publisher)
|
||||
self.addAction(self.action_books_in_this_series)
|
||||
self.addAction(self.action_books_with_the_same_tags)
|
||||
self.similar_menu = similar_menu
|
||||
self.action_books_by_same_author.triggered.connect(
|
||||
partial(self.show_similar_books, 'authors'))
|
||||
self.action_books_in_this_series.triggered.connect(
|
||||
partial(self.show_similar_books, 'series'))
|
||||
self.action_books_with_the_same_tags.triggered.connect(
|
||||
partial(self.show_similar_books, 'tag'))
|
||||
self.action_books_by_this_publisher.triggered.connect(
|
||||
partial(self.show_similar_books, 'publisher'))
|
||||
self.library_view.set_context_menu(self.action_edit, self.action_sync,
|
||||
self.action_convert, self.action_view,
|
||||
self.action_save,
|
||||
self.action_open_containing_folder,
|
||||
self.action_show_book_details,
|
||||
self.action_del,
|
||||
similar_menu=similar_menu)
|
||||
|
||||
self.memory_view.set_context_menu(None, None, None,
|
||||
self.action_view, self.action_save, None, None, self.action_del)
|
||||
self.card_a_view.set_context_menu(None, None, None,
|
||||
self.action_view, self.action_save, None, None, self.action_del)
|
||||
self.card_b_view.set_context_menu(None, None, None,
|
||||
self.action_view, self.action_save, None, None, self.action_del)
|
||||
|
||||
self.library_view.files_dropped.connect(self.files_dropped, type=Qt.QueuedConnection)
|
||||
for func, args in [
|
||||
('connect_to_search_box', (self.search,
|
||||
self.search_done)),
|
||||
('connect_to_book_display',
|
||||
(self.book_details.show_data,)),
|
||||
]:
|
||||
for view in (self.library_view, self.memory_view, self.card_a_view, self.card_b_view):
|
||||
getattr(view, func)(*args)
|
||||
|
||||
self.memory_view.connect_dirtied_signal(self.upload_booklists)
|
||||
self.card_a_view.connect_dirtied_signal(self.upload_booklists)
|
||||
self.card_b_view.connect_dirtied_signal(self.upload_booklists)
|
||||
|
||||
self.book_on_device(None, reset=True)
|
||||
db.set_book_on_device_func(self.book_on_device)
|
||||
self.library_view.set_database(db)
|
||||
self.library_view.model().set_book_on_device_func(self.book_on_device)
|
||||
prefs['library_path'] = self.library_path
|
||||
|
||||
for view in ('library', 'memory', 'card_a', 'card_b'):
|
||||
view = getattr(self, view+'_view')
|
||||
view.verticalHeader().sectionDoubleClicked.connect(self.view_specific_book)
|
||||
|
||||
|
||||
|
||||
def show_similar_books(self, type, *args):
|
||||
search, join = [], ' '
|
||||
idx = self.library_view.currentIndex()
|
||||
if not idx.isValid():
|
||||
return
|
||||
row = idx.row()
|
||||
if type == 'series':
|
||||
series = idx.model().db.series(row)
|
||||
if series:
|
||||
search = ['series:"'+series+'"']
|
||||
elif type == 'publisher':
|
||||
publisher = idx.model().db.publisher(row)
|
||||
if publisher:
|
||||
search = ['publisher:"'+publisher+'"']
|
||||
elif type == 'tag':
|
||||
tags = idx.model().db.tags(row)
|
||||
if tags:
|
||||
search = ['tag:"='+t+'"' for t in tags.split(',')]
|
||||
elif type in ('author', 'authors'):
|
||||
authors = idx.model().db.authors(row)
|
||||
if authors:
|
||||
search = ['author:"='+a.strip().replace('|', ',')+'"' \
|
||||
for a in authors.split(',')]
|
||||
join = ' or '
|
||||
if search:
|
||||
self.search.set_search_string(join.join(search))
|
||||
|
||||
def search_done(self, view, ok):
|
||||
if view is self.current_view():
|
||||
self.search.search_done(ok)
|
||||
self.set_number_of_books_shown()
|
||||
|
||||
# }}}
|
||||
|
||||
class LibraryWidget(Splitter): # {{{
|
||||
|
||||
def __init__(self, parent):
|
||||
orientation = Qt.Vertical
|
||||
if config['gui_layout'] == 'narrow':
|
||||
orientation = Qt.Horizontal if is_widescreen() else Qt.Vertical
|
||||
idx = 0 if orientation == Qt.Vertical else 1
|
||||
size = 300 if orientation == Qt.Vertical else 550
|
||||
Splitter.__init__(self, 'cover_browser_splitter', _('Cover Browser'),
|
||||
I('cover_flow.svg'),
|
||||
orientation=orientation, parent=parent,
|
||||
connect_button=not config['separate_cover_flow'],
|
||||
side_index=idx, initial_side_size=size, initial_show=False)
|
||||
parent.library_view = BooksView(parent)
|
||||
parent.library_view.setObjectName('library_view')
|
||||
self.addWidget(parent.library_view)
|
||||
# }}}
|
||||
|
||||
class Stack(QStackedWidget): # {{{
|
||||
|
||||
def __init__(self, parent):
|
||||
QStackedWidget.__init__(self, parent)
|
||||
|
||||
parent.cb_splitter = LibraryWidget(parent)
|
||||
self.tb_widget = TagBrowserWidget(parent)
|
||||
parent.tb_splitter = Splitter('tag_browser_splitter',
|
||||
_('Tag Browser'), I('tags.svg'),
|
||||
parent=parent, side_index=0, initial_side_size=200)
|
||||
parent.tb_splitter.addWidget(self.tb_widget)
|
||||
parent.tb_splitter.addWidget(parent.cb_splitter)
|
||||
parent.tb_splitter.setCollapsible(parent.tb_splitter.other_index, False)
|
||||
|
||||
self.addWidget(parent.tb_splitter)
|
||||
for x in ('memory', 'card_a', 'card_b'):
|
||||
name = x+'_view'
|
||||
w = DeviceBooksView(parent)
|
||||
setattr(parent, name, w)
|
||||
self.addWidget(w)
|
||||
w.setObjectName(name)
|
||||
|
||||
|
||||
# }}}
|
||||
|
||||
class SideBar(QToolBar): # {{{
|
||||
|
||||
|
||||
def __init__(self, splitters, jobs_button, parent=None):
|
||||
QToolBar.__init__(self, _('Side bar'), parent)
|
||||
self.setOrientation(Qt.Vertical)
|
||||
self.setMovable(False)
|
||||
self.setFloatable(False)
|
||||
self.setToolButtonStyle(Qt.ToolButtonIconOnly)
|
||||
self.setIconSize(QSize(48, 48))
|
||||
self.spacer = QWidget(self)
|
||||
self.spacer.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Expanding)
|
||||
for s in splitters:
|
||||
self.addWidget(s.button)
|
||||
self.addWidget(self.spacer)
|
||||
self.addWidget(jobs_button)
|
||||
|
||||
for ch in self.children():
|
||||
if isinstance(ch, QToolButton):
|
||||
ch.setCursor(Qt.PointingHandCursor)
|
||||
|
||||
# }}}
|
||||
|
||||
class LayoutMixin(object): # {{{
|
||||
|
||||
def __init__(self):
|
||||
self.setupUi(self)
|
||||
self.setWindowTitle(__appname__)
|
||||
|
||||
if config['gui_layout'] == 'narrow':
|
||||
self.status_bar = self.book_details = StatusBar(self)
|
||||
self.stack = Stack(self)
|
||||
self.bd_splitter = Splitter('book_details_splitter',
|
||||
_('Book Details'), I('book.svg'),
|
||||
orientation=Qt.Vertical, parent=self, side_index=1)
|
||||
self._layout_mem = [QWidget(self), QHBoxLayout()]
|
||||
self._layout_mem[0].setLayout(self._layout_mem[1])
|
||||
l = self._layout_mem[1]
|
||||
l.addWidget(self.stack)
|
||||
self.sidebar = SideBar([getattr(self, x+'_splitter')
|
||||
for x in ('bd', 'tb', 'cb')], self.jobs_button, parent=self)
|
||||
l.addWidget(self.sidebar)
|
||||
self.bd_splitter.addWidget(self._layout_mem[0])
|
||||
self.bd_splitter.addWidget(self.status_bar)
|
||||
self.bd_splitter.setCollapsible(self.bd_splitter.other_index, False)
|
||||
self.centralwidget.layout().addWidget(self.bd_splitter)
|
||||
else:
|
||||
self.status_bar = HStatusBar(self)
|
||||
self.setStatusBar(self.status_bar)
|
||||
self.bd_splitter = Splitter('book_details_splitter',
|
||||
_('Book Details'), I('book.svg'), initial_side_size=200,
|
||||
orientation=Qt.Horizontal, parent=self, side_index=1)
|
||||
self.stack = Stack(self)
|
||||
self.bd_splitter.addWidget(self.stack)
|
||||
self.book_details = BookDetails(self)
|
||||
self.bd_splitter.addWidget(self.book_details)
|
||||
self.bd_splitter.setCollapsible(self.bd_splitter.other_index, False)
|
||||
self.bd_splitter.setSizePolicy(QSizePolicy(QSizePolicy.Expanding,
|
||||
QSizePolicy.Expanding))
|
||||
self.centralwidget.layout().addWidget(self.bd_splitter)
|
||||
|
||||
for x in ('cb', 'tb', 'bd'):
|
||||
button = getattr(self, x+'_splitter').button
|
||||
button.setIconSize(QSize(22, 22))
|
||||
self.status_bar.addPermanentWidget(button)
|
||||
self.status_bar.addPermanentWidget(self.jobs_button)
|
||||
|
||||
def finalize_layout(self):
|
||||
m = self.library_view.model()
|
||||
if m.rowCount(None) > 0:
|
||||
self.library_view.set_current_row(0)
|
||||
m.current_changed(self.library_view.currentIndex(),
|
||||
self.library_view.currentIndex())
|
||||
|
||||
|
||||
def save_layout_state(self):
|
||||
for x in ('library', 'memory', 'card_a', 'card_b'):
|
||||
getattr(self, x+'_view').save_state()
|
||||
|
||||
for x in ('cb', 'tb', 'bd'):
|
||||
getattr(self, x+'_splitter').save_state()
|
||||
|
||||
def read_layout_settings(self):
|
||||
# View states are restored automatically when set_database is called
|
||||
|
||||
for x in ('cb', 'tb', 'bd'):
|
||||
getattr(self, x+'_splitter').restore_state()
|
||||
|
||||
# }}}
|
||||
|
@ -7,11 +7,14 @@ __docformat__ = 'restructuredtext en'
|
||||
Job management.
|
||||
'''
|
||||
|
||||
import re
|
||||
|
||||
from Queue import Empty, Queue
|
||||
|
||||
from PyQt4.Qt import QAbstractTableModel, QVariant, QModelIndex, Qt, \
|
||||
QTimer, SIGNAL, QIcon, QDialog, QAbstractItemDelegate, QApplication, \
|
||||
QSize, QStyleOptionProgressBarV2, QString, QStyle, QToolTip
|
||||
QTimer, pyqtSignal, QIcon, QDialog, QAbstractItemDelegate, QApplication, \
|
||||
QSize, QStyleOptionProgressBarV2, QString, QStyle, QToolTip, QFrame, \
|
||||
QHBoxLayout, QVBoxLayout, QSizePolicy, QLabel, QCoreApplication
|
||||
|
||||
from calibre.utils.ipc.server import Server
|
||||
from calibre.utils.ipc.job import ParallelJob
|
||||
@ -20,9 +23,13 @@ from calibre.gui2.device import DeviceJob
|
||||
from calibre.gui2.dialogs.jobs_ui import Ui_JobsDialog
|
||||
from calibre import __appname__
|
||||
from calibre.gui2.dialogs.job_view_ui import Ui_Dialog
|
||||
from calibre.gui2.progress_indicator import ProgressIndicator
|
||||
|
||||
class JobManager(QAbstractTableModel):
|
||||
|
||||
job_added = pyqtSignal(int)
|
||||
job_done = pyqtSignal(int)
|
||||
|
||||
def __init__(self):
|
||||
QAbstractTableModel.__init__(self)
|
||||
self.wait_icon = QVariant(QIcon(I('jobs.svg')))
|
||||
@ -37,8 +44,7 @@ class JobManager(QAbstractTableModel):
|
||||
self.changed_queue = Queue()
|
||||
|
||||
self.timer = QTimer(self)
|
||||
self.connect(self.timer, SIGNAL('timeout()'), self.update,
|
||||
Qt.QueuedConnection)
|
||||
self.timer.timeout.connect(self.update, type=Qt.QueuedConnection)
|
||||
self.timer.start(1000)
|
||||
|
||||
def columnCount(self, parent=QModelIndex()):
|
||||
@ -130,8 +136,7 @@ class JobManager(QAbstractTableModel):
|
||||
for i, j in enumerate(self.jobs):
|
||||
if j.run_state == j.RUNNING:
|
||||
idx = self.index(i, 3)
|
||||
self.emit(SIGNAL('dataChanged(QModelIndex,QModelIndex)'),
|
||||
idx, idx)
|
||||
self.dataChanged.emit(idx, idx)
|
||||
|
||||
# Update parallel jobs
|
||||
jobs = set([])
|
||||
@ -157,20 +162,19 @@ class JobManager(QAbstractTableModel):
|
||||
self.jobs.sort()
|
||||
self.reset()
|
||||
if job.is_finished:
|
||||
self.emit(SIGNAL('job_done(int)'), len(self.unfinished_jobs()))
|
||||
self.job_done.emit(len(self.unfinished_jobs()))
|
||||
else:
|
||||
for job in jobs:
|
||||
idx = self.jobs.index(job)
|
||||
self.emit(SIGNAL('dataChanged(QModelIndex,QModelIndex)'),
|
||||
self.dataChanged.emit(
|
||||
self.index(idx, 0), self.index(idx, 3))
|
||||
|
||||
|
||||
def _add_job(self, job):
|
||||
self.emit(SIGNAL('layoutAboutToBeChanged()'))
|
||||
self.layoutAboutToBeChanged.emit()
|
||||
self.jobs.append(job)
|
||||
self.jobs.sort()
|
||||
self.emit(SIGNAL('job_added(int)'), len(self.unfinished_jobs()))
|
||||
self.emit(SIGNAL('layoutChanged()'))
|
||||
self.job_added.emit(len(self.unfinished_jobs()))
|
||||
|
||||
def done_jobs(self):
|
||||
return [j for j in self.jobs if j.is_finished]
|
||||
@ -266,6 +270,80 @@ class DetailView(QDialog, Ui_Dialog):
|
||||
if more:
|
||||
self.log.appendPlainText(more.decode('utf-8', 'replace'))
|
||||
|
||||
class JobsButton(QFrame):
|
||||
|
||||
def __init__(self, horizontal=False, size=48, parent=None):
|
||||
QFrame.__init__(self, parent)
|
||||
if horizontal:
|
||||
size = 24
|
||||
self.pi = ProgressIndicator(self, size)
|
||||
self._jobs = QLabel('<b>'+_('Jobs:')+' 0')
|
||||
self._jobs.mouseReleaseEvent = self.mouseReleaseEvent
|
||||
|
||||
if horizontal:
|
||||
self.setLayout(QHBoxLayout())
|
||||
self.layout().setDirection(self.layout().RightToLeft)
|
||||
else:
|
||||
self.setLayout(QVBoxLayout())
|
||||
self._jobs.setAlignment(Qt.AlignHCenter|Qt.AlignBottom)
|
||||
|
||||
self.layout().addWidget(self.pi)
|
||||
self.layout().addWidget(self._jobs)
|
||||
if not horizontal:
|
||||
self.layout().setAlignment(self._jobs, Qt.AlignHCenter)
|
||||
self._jobs.setMargin(0)
|
||||
self.layout().setMargin(0)
|
||||
self._jobs.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Minimum)
|
||||
self.setCursor(Qt.PointingHandCursor)
|
||||
self.setToolTip(_('Click to see list of active jobs.'))
|
||||
|
||||
def initialize(self, jobs_dialog, job_manager):
|
||||
self.jobs_dialog = jobs_dialog
|
||||
job_manager.job_added.connect(self.job_added)
|
||||
job_manager.job_done.connect(self.job_done)
|
||||
|
||||
|
||||
def mouseReleaseEvent(self, event):
|
||||
if self.jobs_dialog.isVisible():
|
||||
self.jobs_dialog.hide()
|
||||
else:
|
||||
self.jobs_dialog.show()
|
||||
|
||||
@property
|
||||
def is_running(self):
|
||||
return self.pi.isAnimated()
|
||||
|
||||
def start(self):
|
||||
self.pi.startAnimation()
|
||||
|
||||
def stop(self):
|
||||
self.pi.stopAnimation()
|
||||
|
||||
def jobs(self):
|
||||
src = unicode(self._jobs.text())
|
||||
return int(re.search(r'\d+', src).group())
|
||||
|
||||
def job_added(self, nnum):
|
||||
jobs = self._jobs
|
||||
src = unicode(jobs.text())
|
||||
num = self.jobs()
|
||||
text = src.replace(str(num), str(nnum))
|
||||
jobs.setText(text)
|
||||
self.start()
|
||||
|
||||
def job_done(self, nnum):
|
||||
jobs = self._jobs
|
||||
src = unicode(jobs.text())
|
||||
num = self.jobs()
|
||||
text = src.replace(str(num), str(nnum))
|
||||
jobs.setText(text)
|
||||
if nnum == 0:
|
||||
self.no_more_jobs()
|
||||
|
||||
def no_more_jobs(self):
|
||||
if self.is_running:
|
||||
self.stop()
|
||||
QCoreApplication.instance().alert(self, 5000)
|
||||
|
||||
|
||||
class JobsDialog(QDialog, Ui_JobsDialog):
|
||||
@ -278,14 +356,9 @@ class JobsDialog(QDialog, Ui_JobsDialog):
|
||||
self.model = model
|
||||
self.setWindowModality(Qt.NonModal)
|
||||
self.setWindowTitle(__appname__ + _(' - Jobs'))
|
||||
self.connect(self.kill_button, SIGNAL('clicked()'),
|
||||
self.kill_job)
|
||||
self.connect(self.details_button, SIGNAL('clicked()'),
|
||||
self.show_details)
|
||||
self.connect(self.stop_all_jobs_button, SIGNAL('clicked()'),
|
||||
self.kill_all_jobs)
|
||||
self.connect(self, SIGNAL('kill_job(int, PyQt_PyObject)'),
|
||||
self.jobs_view.model().kill_job)
|
||||
self.kill_button.clicked.connect(self.kill_job)
|
||||
self.details_button.clicked.connect(self.show_details)
|
||||
self.stop_all_jobs_button.clicked.connect(self.kill_all_jobs)
|
||||
self.pb_delegate = ProgressBarDelegate(self)
|
||||
self.jobs_view.setItemDelegateForColumn(2, self.pb_delegate)
|
||||
self.jobs_view.doubleClicked.connect(self.show_job_details)
|
||||
@ -304,18 +377,18 @@ class JobsDialog(QDialog, Ui_JobsDialog):
|
||||
d.exec_()
|
||||
d.timer.stop()
|
||||
|
||||
def kill_job(self):
|
||||
def kill_job(self, *args):
|
||||
for index in self.jobs_view.selectedIndexes():
|
||||
row = index.row()
|
||||
self.model.kill_job(row, self)
|
||||
return
|
||||
|
||||
def show_details(self):
|
||||
def show_details(self, *args):
|
||||
for index in self.jobs_view.selectedIndexes():
|
||||
self.show_job_details(index)
|
||||
return
|
||||
|
||||
def kill_all_jobs(self):
|
||||
def kill_all_jobs(self, *args):
|
||||
self.model.kill_all_jobs()
|
||||
|
||||
def closeEvent(self, e):
|
||||
|
@ -21,7 +21,8 @@ from calibre.utils.date import dt_factory, qt_to_dt, isoformat
|
||||
from calibre.ebooks.metadata.meta import set_metadata as _set_metadata
|
||||
from calibre.utils.search_query_parser import SearchQueryParser
|
||||
from calibre.library.caches import _match, CONTAINS_MATCH, EQUALS_MATCH, REGEXP_MATCH
|
||||
from calibre import strftime
|
||||
from calibre import strftime, isbytestring, prepare_string_for_xml
|
||||
from calibre.constants import filesystem_encoding
|
||||
from calibre.gui2.library import DEFAULT_SORT
|
||||
|
||||
def human_readable(size, precision=1):
|
||||
@ -33,6 +34,14 @@ TIME_FMT = '%d %b %Y'
|
||||
ALIGNMENT_MAP = {'left': Qt.AlignLeft, 'right': Qt.AlignRight, 'center':
|
||||
Qt.AlignHCenter}
|
||||
|
||||
class FormatPath(unicode):
|
||||
|
||||
def __new__(cls, path, orig_file_path):
|
||||
ans = unicode.__new__(cls, path)
|
||||
ans.orig_file_path = orig_file_path
|
||||
ans.deleted_after_upload = False
|
||||
return ans
|
||||
|
||||
class BooksModel(QAbstractTableModel): # {{{
|
||||
|
||||
about_to_be_sorted = pyqtSignal(object, name='aboutToBeSorted')
|
||||
@ -191,7 +200,7 @@ class BooksModel(QAbstractTableModel): # {{{
|
||||
self.count_changed()
|
||||
self.clear_caches()
|
||||
self.reset()
|
||||
|
||||
return ids
|
||||
|
||||
def delete_books_by_id(self, ids):
|
||||
for id in ids:
|
||||
@ -291,6 +300,7 @@ class BooksModel(QAbstractTableModel): # {{{
|
||||
formats = _('None')
|
||||
data[_('Formats')] = formats
|
||||
data[_('Path')] = self.db.abspath(idx)
|
||||
data['id'] = self.id(idx)
|
||||
comments = self.db.comments(idx)
|
||||
if not comments:
|
||||
comments = _('None')
|
||||
@ -299,7 +309,9 @@ class BooksModel(QAbstractTableModel): # {{{
|
||||
if series:
|
||||
sidx = self.db.series_index(idx)
|
||||
sidx = fmt_sidx(sidx, use_roman = self.use_roman_numbers)
|
||||
data[_('Series')] = _('Book <font face="serif">%s</font> of %s.')%(sidx, series)
|
||||
data[_('Series')] = \
|
||||
_('Book <font face="serif">%s</font> of %s.')%\
|
||||
(sidx, prepare_string_for_xml(series))
|
||||
|
||||
return data
|
||||
|
||||
@ -379,7 +391,7 @@ class BooksModel(QAbstractTableModel): # {{{
|
||||
else:
|
||||
return metadata
|
||||
|
||||
def get_preferred_formats_from_ids(self, ids, formats, paths=False,
|
||||
def get_preferred_formats_from_ids(self, ids, formats,
|
||||
set_metadata=False, specific_format=None,
|
||||
exclude_auto=False, mode='r+b'):
|
||||
ans = []
|
||||
@ -404,12 +416,23 @@ class BooksModel(QAbstractTableModel): # {{{
|
||||
as_file=True)) as src:
|
||||
shutil.copyfileobj(src, pt)
|
||||
pt.flush()
|
||||
if getattr(src, 'name', None):
|
||||
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)
|
||||
pt.close() if paths else pt.seek(0)
|
||||
ans.append(pt)
|
||||
except:
|
||||
traceback.print_exc()
|
||||
pt.close()
|
||||
def to_uni(x):
|
||||
if isbytestring(x):
|
||||
x = x.decode(filesystem_encoding)
|
||||
return x
|
||||
name, op = map(to_uni, map(os.path.abspath, (pt.name,
|
||||
pt.orig_file_path)))
|
||||
ans.append(FormatPath(name, op))
|
||||
else:
|
||||
need_auto.append(id)
|
||||
if not exclude_auto:
|
||||
@ -865,6 +888,15 @@ class DeviceBooksModel(BooksModel): # {{{
|
||||
ans.extend(v)
|
||||
return ans
|
||||
|
||||
def clear_ondevice(self, db_ids):
|
||||
for data in self.db:
|
||||
if data is None:
|
||||
continue
|
||||
app_id = getattr(data, 'application_id', None)
|
||||
if app_id is not None and app_id in db_ids:
|
||||
data.in_library = False
|
||||
self.reset()
|
||||
|
||||
def flags(self, index):
|
||||
if self.map[index.row()] in self.indices_to_be_deleted():
|
||||
return Qt.ItemIsUserCheckable # Can't figure out how to get the disabled flag in python
|
||||
|
@ -26,6 +26,15 @@ class BooksView(QTableView): # {{{
|
||||
|
||||
def __init__(self, parent, modelcls=BooksModel):
|
||||
QTableView.__init__(self, parent)
|
||||
|
||||
self.setDragEnabled(True)
|
||||
self.setDragDropOverwriteMode(False)
|
||||
self.setDragDropMode(self.DragDrop)
|
||||
self.setAlternatingRowColors(True)
|
||||
self.setSelectionBehavior(self.SelectRows)
|
||||
self.setShowGrid(False)
|
||||
self.setWordWrap(False)
|
||||
|
||||
self.rating_delegate = RatingDelegate(self)
|
||||
self.timestamp_delegate = DateDelegate(self)
|
||||
self.pubdate_delegate = PubDateDelegate(self)
|
||||
@ -283,7 +292,8 @@ class BooksView(QTableView): # {{{
|
||||
old_state['column_positions'][name] = i
|
||||
if name != 'ondevice':
|
||||
old_state['column_sizes'][name] = \
|
||||
max(self.sizeHintForColumn(i), h.sectionSizeHint(i))
|
||||
min(350, max(self.sizeHintForColumn(i),
|
||||
h.sectionSizeHint(i)))
|
||||
if name == 'timestamp':
|
||||
old_state['column_sizes'][name] += 12
|
||||
return old_state
|
||||
@ -426,6 +436,26 @@ class BooksView(QTableView): # {{{
|
||||
if dy != 0:
|
||||
self.column_header.update()
|
||||
|
||||
def scroll_to_row(self, row):
|
||||
if row > -1:
|
||||
h = self.horizontalHeader()
|
||||
for i in range(h.count()):
|
||||
if not h.isSectionHidden(i):
|
||||
self.scrollTo(self.model().index(row, i))
|
||||
break
|
||||
|
||||
def set_current_row(self, row, select=True):
|
||||
if row > -1:
|
||||
h = self.horizontalHeader()
|
||||
for i in range(h.count()):
|
||||
if not h.isSectionHidden(i):
|
||||
index = self.model().index(row, i)
|
||||
self.setCurrentIndex(index)
|
||||
if select:
|
||||
sm = self.selectionModel()
|
||||
sm.select(index, sm.ClearAndSelect|sm.Rows)
|
||||
break
|
||||
|
||||
def close(self):
|
||||
self._model.close()
|
||||
|
||||
|
@ -53,7 +53,24 @@ def init_qt(args):
|
||||
app.setWindowIcon(QIcon(I('library.png')))
|
||||
return app, opts, args, actions
|
||||
|
||||
def get_library_path():
|
||||
|
||||
def get_default_library_path():
|
||||
fname = _('Calibre Library')
|
||||
if isinstance(fname, unicode):
|
||||
try:
|
||||
fname = fname.encode(filesystem_encoding)
|
||||
except:
|
||||
fname = 'Calibre Library'
|
||||
x = os.path.expanduser('~'+os.sep+fname)
|
||||
if not os.path.exists(x):
|
||||
try:
|
||||
os.makedirs(x)
|
||||
except:
|
||||
x = os.path.expanduser('~')
|
||||
return x
|
||||
|
||||
|
||||
def get_library_path(parent=None):
|
||||
library_path = prefs['library_path']
|
||||
if library_path is None: # Need to migrate to new database layout
|
||||
base = os.path.expanduser('~')
|
||||
@ -73,10 +90,12 @@ def get_library_path():
|
||||
try:
|
||||
os.makedirs(library_path)
|
||||
except:
|
||||
error_dialog(None, _('Failed to create library'),
|
||||
_('Failed to create calibre library at: %r. Aborting.')%library_path,
|
||||
error_dialog(parent, _('Failed to create library'),
|
||||
_('Failed to create calibre library at: %r.')%library_path,
|
||||
det_msg=traceback.format_exc(), show=True)
|
||||
library_path = None
|
||||
library_path = choose_dir(parent, 'choose calibre library',
|
||||
_('Choose a location for your new calibre e-book library'),
|
||||
default_dir=get_default_library_path())
|
||||
return library_path
|
||||
|
||||
class DBRepair(QThread):
|
||||
@ -159,22 +178,9 @@ class GuiRunner(QObject):
|
||||
'a new empty library.'),
|
||||
det_msg=tb, show=True)
|
||||
if db is None:
|
||||
fname = _('Calibre Library')
|
||||
if isinstance(fname, unicode):
|
||||
try:
|
||||
fname = fname.encode(filesystem_encoding)
|
||||
except:
|
||||
fname = 'Calibre Library'
|
||||
x = os.path.expanduser('~'+os.sep+fname)
|
||||
if not os.path.exists(x):
|
||||
try:
|
||||
os.makedirs(x)
|
||||
except:
|
||||
x = os.path.expanduser('~')
|
||||
candidate = choose_dir(self.splash_screen, 'choose calibre library',
|
||||
_('Choose a location for your new calibre e-book library'),
|
||||
default_dir=x)
|
||||
|
||||
default_dir=get_default_library_path())
|
||||
if not candidate:
|
||||
self.initialization_failed()
|
||||
|
||||
@ -236,8 +242,8 @@ class GuiRunner(QObject):
|
||||
if gprefs.get('show_splash_screen', True):
|
||||
self.show_splash_screen()
|
||||
|
||||
self.library_path = get_library_path()
|
||||
if self.library_path is None:
|
||||
self.library_path = get_library_path(parent=self.splash_screen)
|
||||
if not self.library_path:
|
||||
self.initialization_failed()
|
||||
|
||||
self.initialize_db()
|
||||
|
@ -169,6 +169,12 @@
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="search_restriction">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>150</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Books display will be restricted to those matching the selected saved search</string>
|
||||
</property>
|
||||
@ -304,264 +310,6 @@
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="Splitter" name="vertical_splitter">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>100</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<widget class="QWidget" name="layoutWidget">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QStackedWidget" name="stack">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>100</horstretch>
|
||||
<verstretch>100</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="currentIndex">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="library">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="Splitter" name="horizontal_splitter">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<widget class="QWidget" name="layoutWidget">
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="TagsView" name="tags_view">
|
||||
<property name="tabKeyNavigation">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="alternatingRowColors">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="animated">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="headerHidden">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="popularity">
|
||||
<property name="text">
|
||||
<string>Sort by &popularity</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="tag_match">
|
||||
<property name="currentIndex">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Match any</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Match all</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="edit_categories">
|
||||
<property name="toolTip">
|
||||
<string>Create, edit, and delete user categories</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Manage &user categories</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="BooksView" name="library_view">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>100</horstretch>
|
||||
<verstretch>10</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="acceptDrops">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="dragEnabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="dragDropOverwriteMode">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="dragDropMode">
|
||||
<enum>QAbstractItemView::DragDrop</enum>
|
||||
</property>
|
||||
<property name="alternatingRowColors">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="selectionBehavior">
|
||||
<enum>QAbstractItemView::SelectRows</enum>
|
||||
</property>
|
||||
<property name="showGrid">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="main_memory">
|
||||
<layout class="QGridLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="DeviceBooksView" name="memory_view">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>100</horstretch>
|
||||
<verstretch>10</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="acceptDrops">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="dragEnabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="dragDropOverwriteMode">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="dragDropMode">
|
||||
<enum>QAbstractItemView::DragDrop</enum>
|
||||
</property>
|
||||
<property name="alternatingRowColors">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="selectionBehavior">
|
||||
<enum>QAbstractItemView::SelectRows</enum>
|
||||
</property>
|
||||
<property name="showGrid">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="card_a_memory">
|
||||
<layout class="QGridLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="DeviceBooksView" name="card_a_view">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
|
||||
<horstretch>10</horstretch>
|
||||
<verstretch>10</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="acceptDrops">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="dragEnabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="dragDropOverwriteMode">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="dragDropMode">
|
||||
<enum>QAbstractItemView::DragDrop</enum>
|
||||
</property>
|
||||
<property name="alternatingRowColors">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="selectionBehavior">
|
||||
<enum>QAbstractItemView::SelectRows</enum>
|
||||
</property>
|
||||
<property name="showGrid">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="card_b_memory">
|
||||
<layout class="QGridLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="DeviceBooksView" name="card_b_view">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
|
||||
<horstretch>10</horstretch>
|
||||
<verstretch>10</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="acceptDrops">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="dragEnabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="dragDropOverwriteMode">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="dragDropMode">
|
||||
<enum>QAbstractItemView::DragDrop</enum>
|
||||
</property>
|
||||
<property name="alternatingRowColors">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="selectionBehavior">
|
||||
<enum>QAbstractItemView::SelectRows</enum>
|
||||
</property>
|
||||
<property name="showGrid">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="SideBar" name="sidebar" native="true">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>30</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="StatusBar" name="status_bar" native="true"/>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QToolBar" name="tool_bar">
|
||||
@ -798,26 +546,11 @@
|
||||
</action>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>BooksView</class>
|
||||
<extends>QTableView</extends>
|
||||
<header>calibre/gui2/library/views.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>LocationView</class>
|
||||
<extends>QListView</extends>
|
||||
<header>widgets.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>DeviceBooksView</class>
|
||||
<extends>QTableView</extends>
|
||||
<header>calibre/gui2/library/views.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>TagsView</class>
|
||||
<extends>QTreeView</extends>
|
||||
<header>calibre/gui2/tag_view.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>SearchBox2</class>
|
||||
<extends>QComboBox</extends>
|
||||
@ -828,24 +561,6 @@
|
||||
<extends>QComboBox</extends>
|
||||
<header>calibre.gui2.search_box</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>StatusBar</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>calibre/gui2/status.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>Splitter</class>
|
||||
<extends>QSplitter</extends>
|
||||
<header>calibre/gui2/widgets.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>SideBar</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>calibre/gui2/sidebar.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources>
|
||||
<include location="../../../resources/images.qrc"/>
|
||||
|
@ -85,6 +85,10 @@ typedef long PFreal;
|
||||
|
||||
typedef unsigned short QRgb565;
|
||||
|
||||
#define REFLECTION_FACTOR 1.5
|
||||
|
||||
#define MAX(x, y) ((x > y) ? x : y)
|
||||
|
||||
#define RGB565_RED_MASK 0xF800
|
||||
#define RGB565_GREEN_MASK 0x07E0
|
||||
#define RGB565_BLUE_MASK 0x001F
|
||||
@ -122,6 +126,7 @@ inline PFreal floatToFixed(float val)
|
||||
return (PFreal)(val*PFREAL_ONE);
|
||||
}
|
||||
|
||||
// sinTable {{{
|
||||
#define IANGLE_MAX 1024
|
||||
#define IANGLE_MASK 1023
|
||||
|
||||
@ -291,6 +296,7 @@ int main(int, char**)
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
// }}}
|
||||
|
||||
inline PFreal fsin(int iangle)
|
||||
{
|
||||
@ -313,6 +319,8 @@ struct SlideInfo
|
||||
PFreal cy;
|
||||
};
|
||||
|
||||
// PicturePlowPrivate {{{
|
||||
|
||||
class PictureFlowPrivate
|
||||
{
|
||||
public:
|
||||
@ -367,6 +375,7 @@ private:
|
||||
|
||||
int slideWidth;
|
||||
int slideHeight;
|
||||
int fontSize;
|
||||
int zoom;
|
||||
int queueLength;
|
||||
|
||||
@ -404,6 +413,7 @@ PictureFlowPrivate::PictureFlowPrivate(PictureFlow* w, int queueLength_)
|
||||
|
||||
slideWidth = 200;
|
||||
slideHeight = 200;
|
||||
fontSize = 10;
|
||||
zoom = 100;
|
||||
|
||||
centerIndex = 0;
|
||||
@ -540,6 +550,11 @@ void PictureFlowPrivate::showSlide(int index)
|
||||
|
||||
void PictureFlowPrivate::resize(int w, int h)
|
||||
{
|
||||
if (w < 10) w = 10;
|
||||
if (h < 10) h = 10;
|
||||
slideHeight = int(float(h)/REFLECTION_FACTOR);
|
||||
slideWidth = int(float(slideHeight) * 2/3.);
|
||||
fontSize = MAX(int(h/15.), 12);
|
||||
recalc(w, h);
|
||||
resetSlides();
|
||||
triggerRender();
|
||||
@ -588,8 +603,8 @@ static QImage prepareSurface(QImage img, int w, int h)
|
||||
img = img.scaled(w, h, Qt::IgnoreAspectRatio, mode);
|
||||
|
||||
// slightly larger, to accomodate for the reflection
|
||||
int hs = h * 2;
|
||||
int hofs = h / 3;
|
||||
int hs = int(h * REFLECTION_FACTOR);
|
||||
int hofs = 0;
|
||||
|
||||
// offscreen buffer: black is sweet
|
||||
QImage result(hs, w, QImage::Format_RGB16);
|
||||
@ -709,14 +724,15 @@ void PictureFlowPrivate::render()
|
||||
QPainter painter;
|
||||
painter.begin(&buffer);
|
||||
|
||||
QFont font("Arial", 14);
|
||||
QFont font = QFont();
|
||||
font.setBold(true);
|
||||
font.setPixelSize(fontSize);
|
||||
painter.setFont(font);
|
||||
painter.setPen(Qt::white);
|
||||
//painter.setPen(QColor(255,255,255,127));
|
||||
|
||||
if (centerIndex < slideCount() && centerIndex > -1)
|
||||
painter.drawText( QRect(0,0, buffer.width(), (buffer.height() - slideSize().height())/2),
|
||||
painter.drawText( QRect(0,0, buffer.width(), buffer.height()*2-fontSize*3),
|
||||
Qt::AlignCenter, slideImages->caption(centerIndex));
|
||||
|
||||
painter.end();
|
||||
@ -759,8 +775,9 @@ void PictureFlowPrivate::render()
|
||||
QPainter painter;
|
||||
painter.begin(&buffer);
|
||||
|
||||
QFont font("Arial", 14);
|
||||
QFont font = QFont();
|
||||
font.setBold(true);
|
||||
font.setPixelSize(fontSize);
|
||||
painter.setFont(font);
|
||||
|
||||
int leftTextIndex = (step>0) ? centerIndex : centerIndex-1;
|
||||
@ -768,12 +785,12 @@ void PictureFlowPrivate::render()
|
||||
|
||||
painter.setPen(QColor(255,255,255, (255-fade) ));
|
||||
if (leftTextIndex < sc && leftTextIndex > -1)
|
||||
painter.drawText( QRect(0,0, buffer.width(), (buffer.height() - slideSize().height())/2),
|
||||
painter.drawText( QRect(0,0, buffer.width(), buffer.height()*2 - fontSize*3),
|
||||
Qt::AlignCenter, slideImages->caption(leftTextIndex));
|
||||
|
||||
painter.setPen(QColor(255,255,255, fade));
|
||||
if (leftTextIndex+1 < sc && leftTextIndex > -2)
|
||||
painter.drawText( QRect(0,0, buffer.width(), (buffer.height() - slideSize().height())/2),
|
||||
painter.drawText( QRect(0,0, buffer.width(), buffer.height()*2 - fontSize*3),
|
||||
Qt::AlignCenter, slideImages->caption(leftTextIndex+1));
|
||||
|
||||
|
||||
@ -887,7 +904,7 @@ int col1, int col2)
|
||||
int center = (sh*BILINEAR_STRETCH_VER/2);
|
||||
int dy = dist*BILINEAR_STRETCH_VER / h;
|
||||
#else
|
||||
int center = (sh/2);
|
||||
int center = sh/2;
|
||||
int dy = dist / h;
|
||||
#endif
|
||||
int p1 = center*PFREAL_ONE - dy/2;
|
||||
@ -1104,8 +1121,9 @@ void PictureFlowPrivate::clearSurfaceCache()
|
||||
surfaceCache.clear();
|
||||
}
|
||||
|
||||
// -----------------------------------------
|
||||
// }}}
|
||||
|
||||
// PictureFlow {{{
|
||||
PictureFlow::PictureFlow(QWidget* parent, int queueLength): QWidget(parent)
|
||||
{
|
||||
d = new PictureFlowPrivate(this, queueLength);
|
||||
@ -1381,3 +1399,5 @@ void PictureFlow::emitcurrentChanged(int index) { emit currentChanged(index); }
|
||||
int FlowImages::count() { return 0; }
|
||||
QImage FlowImages::image(int index) { index=0; return QImage(); }
|
||||
QString FlowImages::caption(int index) {index=0; return QString(); }
|
||||
|
||||
// }}}
|
||||
|
@ -115,7 +115,8 @@ public:
|
||||
QSize slideSize() const;
|
||||
|
||||
/*!
|
||||
Sets the dimension of each slide (in pixels).
|
||||
Sets the dimension of each slide (in pixels). Do not use this method directly
|
||||
instead use resize which automatically sets an appropriate slide size.
|
||||
*/
|
||||
void setSlideSize(QSize size);
|
||||
|
||||
|
@ -16,6 +16,10 @@ public:
|
||||
virtual int count();
|
||||
virtual QImage image(int index);
|
||||
virtual QString caption(int index);
|
||||
|
||||
signals:
|
||||
void dataChanged();
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
@ -7,11 +7,15 @@ __copyright__ = '2009, Kovid Goyal <kovid@kovidgoyal.net>'
|
||||
__docformat__ = 'restructuredtext en'
|
||||
|
||||
from PyQt4.Qt import QComboBox, Qt, QLineEdit, QStringList, pyqtSlot, \
|
||||
pyqtSignal, SIGNAL
|
||||
from PyQt4.QtGui import QCompleter
|
||||
pyqtSignal, SIGNAL, QObject, QDialog, QCompleter, \
|
||||
QAction, QKeySequence
|
||||
|
||||
from calibre.gui2 import config
|
||||
from calibre.gui2.dialogs.confirm_delete import confirm
|
||||
from calibre.gui2.dialogs.saved_search_editor import SavedSearchEditor
|
||||
from calibre.gui2.dialogs.search import SearchDialog
|
||||
from calibre.utils.config import prefs
|
||||
from calibre.utils.search_query_parser import saved_searches
|
||||
|
||||
class SearchLineEdit(QLineEdit):
|
||||
|
||||
@ -69,7 +73,7 @@ class SearchBox2(QComboBox):
|
||||
self.connect(self.line_edit, SIGNAL('mouse_released(PyQt_PyObject)'),
|
||||
self.mouse_released, Qt.DirectConnection)
|
||||
self.setEditable(True)
|
||||
self.help_state = True
|
||||
self.help_state = False
|
||||
self.as_you_type = True
|
||||
self.prev_search = ''
|
||||
self.timer = None
|
||||
@ -79,8 +83,7 @@ class SearchBox2(QComboBox):
|
||||
self.setMinimumContentsLength(25)
|
||||
self._in_a_search = False
|
||||
|
||||
def initialize(self, opt_name, colorize=False,
|
||||
help_text=_('Search')):
|
||||
def initialize(self, opt_name, colorize=False, help_text=_('Search')):
|
||||
self.as_you_type = config['search_as_you_type']
|
||||
self.opt_name = opt_name
|
||||
self.addItems(QStringList(list(set(config[opt_name]))))
|
||||
@ -97,6 +100,9 @@ class SearchBox2(QComboBox):
|
||||
self.help_state = False
|
||||
|
||||
def clear_to_help(self):
|
||||
if self.help_state:
|
||||
return
|
||||
self.help_state = True
|
||||
self.search.emit('')
|
||||
self._in_a_search = False
|
||||
self.setEditText(self.help_text)
|
||||
@ -104,7 +110,6 @@ class SearchBox2(QComboBox):
|
||||
self.killTimer(self.timer)
|
||||
self.timer = None
|
||||
self.line_edit.home(False)
|
||||
self.help_state = True
|
||||
self.line_edit.setStyleSheet(
|
||||
'QLineEdit { color: gray; background-color: %s; }' %
|
||||
self.normal_background)
|
||||
@ -239,9 +244,9 @@ class SavedSearchBox(QComboBox):
|
||||
self.setInsertPolicy(self.NoInsert)
|
||||
self.setSizeAdjustPolicy(self.AdjustToMinimumContentsLengthWithIcon)
|
||||
self.setMinimumContentsLength(10)
|
||||
self.tool_tip_text = self.toolTip()
|
||||
|
||||
def initialize(self, _saved_searches, _search_box, colorize=False, help_text=_('Search')):
|
||||
self.tool_tip_text = self.toolTip()
|
||||
self.saved_searches = _saved_searches
|
||||
self.search_box = _search_box
|
||||
self.help_text = help_text
|
||||
@ -331,3 +336,75 @@ class SavedSearchBox(QComboBox):
|
||||
if idx < 0:
|
||||
return
|
||||
self.search_box.set_search_string(self.saved_searches.lookup(unicode(self.currentText())))
|
||||
|
||||
class SearchBoxMixin(object):
|
||||
|
||||
def __init__(self):
|
||||
self.search.initialize('main_search_history', colorize=True,
|
||||
help_text=_('Search (For Advanced Search click the button to the left)'))
|
||||
self.connect(self.search, SIGNAL('cleared()'), self.search_box_cleared)
|
||||
self.connect(self.clear_button, SIGNAL('clicked()'), self.search.clear)
|
||||
QObject.connect(self.advanced_search_button, SIGNAL('clicked(bool)'),
|
||||
self.do_advanced_search)
|
||||
|
||||
self.search.clear()
|
||||
self.search.setMaximumWidth(self.width()-150)
|
||||
self.action_focus_search = QAction(self)
|
||||
shortcuts = QKeySequence.keyBindings(QKeySequence.Find)
|
||||
shortcuts = list(shortcuts) + [QKeySequence('/')]
|
||||
self.action_focus_search.setShortcuts(shortcuts)
|
||||
self.action_focus_search.triggered.connect(lambda x:
|
||||
self.search.setFocus(Qt.OtherFocusReason))
|
||||
self.addAction(self.action_focus_search)
|
||||
|
||||
def search_box_cleared(self):
|
||||
self.tags_view.clear()
|
||||
self.saved_search.clear_to_help()
|
||||
self.set_number_of_books_shown()
|
||||
|
||||
def do_advanced_search(self, *args):
|
||||
d = SearchDialog(self)
|
||||
if d.exec_() == QDialog.Accepted:
|
||||
self.search.set_search_string(d.search_string())
|
||||
|
||||
class SavedSearchBoxMixin(object):
|
||||
|
||||
def __init__(self):
|
||||
self.connect(self.saved_search, SIGNAL('changed()'), self.saved_searches_changed)
|
||||
self.saved_searches_changed()
|
||||
self.connect(self.clear_button, SIGNAL('clicked()'), self.saved_search.clear_to_help)
|
||||
self.saved_search.initialize(saved_searches, self.search, colorize=True,
|
||||
help_text=_('Saved Searches'))
|
||||
self.connect(self.save_search_button, SIGNAL('clicked()'),
|
||||
self.saved_search.save_search_button_clicked)
|
||||
self.connect(self.delete_search_button, SIGNAL('clicked()'),
|
||||
self.saved_search.delete_search_button_clicked)
|
||||
self.connect(self.copy_search_button, SIGNAL('clicked()'),
|
||||
self.saved_search.copy_search_button_clicked)
|
||||
|
||||
|
||||
def saved_searches_changed(self):
|
||||
p = prefs['saved_searches'].keys()
|
||||
p.sort()
|
||||
t = unicode(self.search_restriction.currentText())
|
||||
self.search_restriction.clear() # rebuild the restrictions combobox using current saved searches
|
||||
self.search_restriction.addItem('')
|
||||
self.tags_view.recount()
|
||||
for s in p:
|
||||
self.search_restriction.addItem(s)
|
||||
if t:
|
||||
if t in p: # redo the current restriction, if there was one
|
||||
self.search_restriction.setCurrentIndex(self.search_restriction.findText(t))
|
||||
# self.tags_view.set_search_restriction(t)
|
||||
else:
|
||||
self.search_restriction.setCurrentIndex(0)
|
||||
self.apply_search_restriction('')
|
||||
|
||||
def do_saved_search_edit(self, search):
|
||||
d = SavedSearchEditor(self, search)
|
||||
d.exec_()
|
||||
if d.result() == d.Accepted:
|
||||
self.saved_searches_changed()
|
||||
self.saved_search.clear_to_help()
|
||||
|
||||
|
||||
|
57
src/calibre/gui2/search_restriction_mixin.py
Normal file
@ -0,0 +1,57 @@
|
||||
'''
|
||||
Created on 10 Jun 2010
|
||||
|
||||
@author: charles
|
||||
'''
|
||||
|
||||
class SearchRestrictionMixin(object):
|
||||
|
||||
def __init__(self):
|
||||
self.search_restriction.activated[str].connect(self.apply_search_restriction)
|
||||
self.library_view.model().count_changed_signal.connect(self.restriction_count_changed)
|
||||
self.search_restriction.setSizeAdjustPolicy(self.search_restriction.AdjustToMinimumContentsLengthWithIcon)
|
||||
self.search_restriction.setMinimumContentsLength(10)
|
||||
|
||||
'''
|
||||
Adding and deleting books while restricted creates a complexity. When added,
|
||||
they are displayed regardless of whether they match a search restriction.
|
||||
However, if they do not, they are removed at the next search. The counts
|
||||
must take this behavior into effect.
|
||||
'''
|
||||
|
||||
def restriction_count_changed(self, c):
|
||||
self.restriction_count_of_books_in_view += \
|
||||
c - self.restriction_count_of_books_in_library
|
||||
self.restriction_count_of_books_in_library = c
|
||||
if self.restriction_in_effect:
|
||||
self.set_number_of_books_shown()
|
||||
|
||||
def apply_search_restriction(self, r):
|
||||
r = unicode(r)
|
||||
if r is not None and r != '':
|
||||
self.restriction_in_effect = True
|
||||
restriction = 'search:"%s"'%(r)
|
||||
else:
|
||||
self.restriction_in_effect = False
|
||||
restriction = ''
|
||||
self.restriction_count_of_books_in_view = \
|
||||
self.library_view.model().set_search_restriction(restriction)
|
||||
self.search.clear_to_help()
|
||||
self.saved_search.clear_to_help()
|
||||
self.tags_view.set_search_restriction(restriction)
|
||||
self.set_number_of_books_shown()
|
||||
|
||||
def set_number_of_books_shown(self):
|
||||
if self.current_view() == self.library_view and self.restriction_in_effect:
|
||||
t = _("({0} of {1})").format(self.current_view().row_count(),
|
||||
self.restriction_count_of_books_in_view)
|
||||
self.search_count.setStyleSheet \
|
||||
('QLabel { border-radius: 8px; background-color: yellow; }')
|
||||
else: # No restriction or not library view
|
||||
if not self.search.in_a_search():
|
||||
t = _("(all books)")
|
||||
else:
|
||||
t = _("({0} of all)").format(self.current_view().row_count())
|
||||
self.search_count.setStyleSheet(
|
||||
'QLabel { background-color: transparent; }')
|
||||
self.search_count.setText(t)
|
@ -1,240 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:ai
|
||||
|
||||
__license__ = 'GPL v3'
|
||||
__copyright__ = '2010, Kovid Goyal <kovid@kovidgoyal.net>'
|
||||
__docformat__ = 'restructuredtext en'
|
||||
|
||||
import re
|
||||
from functools import partial
|
||||
|
||||
from PyQt4.Qt import QToolBar, Qt, QIcon, QSizePolicy, QWidget, \
|
||||
QFrame, QVBoxLayout, QLabel, QSize, QCoreApplication, QToolButton
|
||||
|
||||
from calibre.gui2.progress_indicator import ProgressIndicator
|
||||
from calibre.gui2 import dynamic
|
||||
|
||||
class JobsButton(QFrame):
|
||||
|
||||
def __init__(self, parent):
|
||||
QFrame.__init__(self, parent)
|
||||
self.setLayout(QVBoxLayout())
|
||||
self.pi = ProgressIndicator(self)
|
||||
self.layout().addWidget(self.pi)
|
||||
self.jobs = QLabel('<b>'+_('Jobs:')+' 0')
|
||||
self.jobs.setAlignment(Qt.AlignHCenter|Qt.AlignBottom)
|
||||
self.layout().addWidget(self.jobs)
|
||||
self.layout().setAlignment(self.jobs, Qt.AlignHCenter)
|
||||
self.jobs.setMargin(0)
|
||||
self.layout().setMargin(0)
|
||||
self.jobs.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Minimum)
|
||||
self.setCursor(Qt.PointingHandCursor)
|
||||
self.setToolTip(_('Click to see list of active jobs.'))
|
||||
|
||||
def initialize(self, jobs_dialog):
|
||||
self.jobs_dialog = jobs_dialog
|
||||
|
||||
def mouseReleaseEvent(self, event):
|
||||
if self.jobs_dialog.isVisible():
|
||||
self.jobs_dialog.hide()
|
||||
else:
|
||||
self.jobs_dialog.show()
|
||||
|
||||
@property
|
||||
def is_running(self):
|
||||
return self.pi.isAnimated()
|
||||
|
||||
def start(self):
|
||||
self.pi.startAnimation()
|
||||
|
||||
def stop(self):
|
||||
self.pi.stopAnimation()
|
||||
|
||||
|
||||
class Jobs(ProgressIndicator):
|
||||
|
||||
def initialize(self, jobs_dialog):
|
||||
self.jobs_dialog = jobs_dialog
|
||||
|
||||
def mouseClickEvent(self, event):
|
||||
if self.jobs_dialog.isVisible():
|
||||
self.jobs_dialog.jobs_view.write_settings()
|
||||
self.jobs_dialog.hide()
|
||||
else:
|
||||
self.jobs_dialog.jobs_view.read_settings()
|
||||
self.jobs_dialog.show()
|
||||
self.jobs_dialog.jobs_view.restore_column_widths()
|
||||
|
||||
@property
|
||||
def is_running(self):
|
||||
return self.isAnimated()
|
||||
|
||||
def start(self):
|
||||
self.startAnimation()
|
||||
|
||||
def stop(self):
|
||||
self.stopAnimation()
|
||||
|
||||
|
||||
|
||||
class SideBar(QToolBar):
|
||||
|
||||
toggle_texts = {
|
||||
'book_info' : (_('Show Book Details'), _('Hide Book Details')),
|
||||
'tag_browser' : (_('Show Tag Browser'), _('Hide Tag Browser')),
|
||||
'cover_browser': (_('Show Cover Browser'), _('Hide Cover Browser')),
|
||||
}
|
||||
toggle_icons = {
|
||||
'book_info' : 'book.svg',
|
||||
'tag_browser' : 'tags.svg',
|
||||
'cover_browser': 'cover_flow.svg',
|
||||
}
|
||||
|
||||
|
||||
def __init__(self, parent=None):
|
||||
QToolBar.__init__(self, _('Side bar'), parent)
|
||||
self.setOrientation(Qt.Vertical)
|
||||
self.setMovable(False)
|
||||
self.setFloatable(False)
|
||||
self.setToolButtonStyle(Qt.ToolButtonIconOnly)
|
||||
self.setIconSize(QSize(48, 48))
|
||||
|
||||
for ac in ('book_info', 'tag_browser', 'cover_browser'):
|
||||
action = self.addAction(QIcon(I(self.toggle_icons[ac])),
|
||||
self.toggle_texts[ac][1], getattr(self, '_toggle_'+ac))
|
||||
setattr(self, 'action_toggle_'+ac, action)
|
||||
w = self.widgetForAction(action)
|
||||
w.setCheckable(True)
|
||||
setattr(self, 'show_'+ac, partial(getattr(self, '_toggle_'+ac),
|
||||
show=True))
|
||||
setattr(self, 'hide_'+ac, partial(getattr(self, '_toggle_'+ac),
|
||||
show=False))
|
||||
|
||||
|
||||
self.spacer = QWidget(self)
|
||||
self.spacer.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Expanding)
|
||||
self.addWidget(self.spacer)
|
||||
self.jobs_button = JobsButton(self)
|
||||
self.addWidget(self.jobs_button)
|
||||
|
||||
self.show_cover_browser = partial(self._toggle_cover_browser, show=True)
|
||||
self.hide_cover_browser = partial(self._toggle_cover_browser,
|
||||
show=False)
|
||||
for ch in self.children():
|
||||
if isinstance(ch, QToolButton):
|
||||
ch.setCursor(Qt.PointingHandCursor)
|
||||
|
||||
def initialize(self, jobs_dialog, cover_browser, toggle_cover_browser,
|
||||
cover_browser_error, vertical_splitter, horizontal_splitter):
|
||||
self.jobs_button.initialize(jobs_dialog)
|
||||
self.cover_browser, self.do_toggle_cover_browser = cover_browser, \
|
||||
toggle_cover_browser
|
||||
if self.cover_browser is None:
|
||||
self.action_toggle_cover_browser.setEnabled(False)
|
||||
self.action_toggle_cover_browser.setText(
|
||||
_('Cover browser could not be loaded: ') + cover_browser_error)
|
||||
else:
|
||||
self.cover_browser.stop.connect(self.hide_cover_browser)
|
||||
self._toggle_cover_browser(dynamic.get('cover_flow_visible', False))
|
||||
|
||||
self.horizontal_splitter = horizontal_splitter
|
||||
self.vertical_splitter = vertical_splitter
|
||||
|
||||
tb_state = dynamic.get('tag_browser_state', None)
|
||||
if tb_state is not None:
|
||||
self.horizontal_splitter.restoreState(tb_state)
|
||||
tb_last_open_state = dynamic.get('tag_browser_last_open_state', None)
|
||||
if tb_last_open_state is not None and \
|
||||
not self.horizontal_splitter.is_side_index_hidden:
|
||||
self.horizontal_splitter.restoreState(tb_last_open_state)
|
||||
|
||||
bi_state = dynamic.get('book_info_state', None)
|
||||
if bi_state is not None:
|
||||
self.vertical_splitter.restoreState(bi_state)
|
||||
bi_last_open_state = dynamic.get('book_info_last_open_state', None)
|
||||
if bi_last_open_state is not None and \
|
||||
not self.vertical_splitter.is_side_index_hidden:
|
||||
self.vertical_splitter.restoreState(bi_last_open_state)
|
||||
|
||||
self.horizontal_splitter.initialize(name='tag_browser')
|
||||
self.vertical_splitter.initialize(name='book_info')
|
||||
self.view_status_changed('book_info', not
|
||||
self.vertical_splitter.is_side_index_hidden)
|
||||
self.view_status_changed('tag_browser', not
|
||||
self.horizontal_splitter.is_side_index_hidden)
|
||||
self.vertical_splitter.state_changed.connect(partial(self.view_status_changed,
|
||||
'book_info'), type=Qt.QueuedConnection)
|
||||
self.horizontal_splitter.state_changed.connect(partial(self.view_status_changed,
|
||||
'tag_browser'), type=Qt.QueuedConnection)
|
||||
|
||||
|
||||
|
||||
def view_status_changed(self, name, visible):
|
||||
action = getattr(self, 'action_toggle_'+name)
|
||||
texts = self.toggle_texts[name]
|
||||
action.setText(texts[int(visible)])
|
||||
w = self.widgetForAction(action)
|
||||
w.setCheckable(True)
|
||||
w.setChecked(visible)
|
||||
|
||||
def location_changed(self, location):
|
||||
is_lib = location == 'library'
|
||||
for ac in ('cover_browser', 'tag_browser'):
|
||||
ac = getattr(self, 'action_toggle_'+ac)
|
||||
ac.setEnabled(is_lib)
|
||||
self.widgetForAction(ac).setVisible(is_lib)
|
||||
|
||||
def save_state(self):
|
||||
dynamic.set('cover_flow_visible', self.is_cover_browser_visible)
|
||||
dynamic.set('tag_browser_state',
|
||||
str(self.horizontal_splitter.saveState()))
|
||||
dynamic.set('book_info_state',
|
||||
str(self.vertical_splitter.saveState()))
|
||||
|
||||
|
||||
@property
|
||||
def is_cover_browser_visible(self):
|
||||
return self.cover_browser is not None and self.cover_browser.isVisible()
|
||||
|
||||
def _toggle_cover_browser(self, show=None):
|
||||
if show is None:
|
||||
show = not self.is_cover_browser_visible
|
||||
self.do_toggle_cover_browser(show)
|
||||
self.view_status_changed('cover_browser', show)
|
||||
|
||||
def external_cover_flow_finished(self, *args):
|
||||
self.view_status_changed('cover_browser', False)
|
||||
|
||||
def _toggle_tag_browser(self, show=None):
|
||||
self.horizontal_splitter.toggle_side_index()
|
||||
|
||||
def _toggle_book_info(self, show=None):
|
||||
self.vertical_splitter.toggle_side_index()
|
||||
|
||||
def jobs(self):
|
||||
src = unicode(self.jobs_button.jobs.text())
|
||||
return int(re.search(r'\d+', src).group())
|
||||
|
||||
def job_added(self, nnum):
|
||||
jobs = self.jobs_button.jobs
|
||||
src = unicode(jobs.text())
|
||||
num = self.jobs()
|
||||
text = src.replace(str(num), str(nnum))
|
||||
jobs.setText(text)
|
||||
self.jobs_button.start()
|
||||
|
||||
def job_done(self, nnum):
|
||||
jobs = self.jobs_button.jobs
|
||||
src = unicode(jobs.text())
|
||||
num = self.jobs()
|
||||
text = src.replace(str(num), str(nnum))
|
||||
jobs.setText(text)
|
||||
if nnum == 0:
|
||||
self.no_more_jobs()
|
||||
|
||||
def no_more_jobs(self):
|
||||
if self.jobs_button.is_running:
|
||||
self.jobs_button.stop()
|
||||
QCoreApplication.instance().alert(self, 5000)
|
||||
|
||||
|
@ -1,10 +1,12 @@
|
||||
__license__ = 'GPL v3'
|
||||
__copyright__ = '2008, Kovid Goyal <kovid at kovidgoyal.net>'
|
||||
import os, collections
|
||||
|
||||
from PyQt4.QtGui import QStatusBar, QLabel, QWidget, QHBoxLayout, QPixmap, \
|
||||
QSizePolicy, QScrollArea
|
||||
from PyQt4.QtCore import Qt, QSize, pyqtSignal
|
||||
import os
|
||||
|
||||
from PyQt4.Qt import QStatusBar, QLabel, QWidget, QHBoxLayout, QPixmap, \
|
||||
QSizePolicy, QScrollArea, Qt, QSize, pyqtSignal, \
|
||||
QPropertyAnimation, QEasingCurve, QDesktopServices, QUrl
|
||||
|
||||
|
||||
from calibre import fit_image, preferred_encoding, isosx
|
||||
from calibre.gui2 import config
|
||||
@ -12,6 +14,7 @@ from calibre.gui2.widgets import IMAGE_EXTENSIONS
|
||||
from calibre.gui2.notify import get_notifier
|
||||
from calibre.ebooks import BOOK_EXTENSIONS
|
||||
from calibre.library.comments import comments_to_html
|
||||
from calibre.gui2.book_details import render_rows
|
||||
|
||||
class BookInfoDisplay(QWidget):
|
||||
|
||||
@ -46,36 +49,39 @@ class BookInfoDisplay(QWidget):
|
||||
event.acceptProposedAction()
|
||||
|
||||
|
||||
class BookCoverDisplay(QLabel):
|
||||
class BookCoverDisplay(QLabel): # {{{
|
||||
|
||||
def __init__(self, coverpath=I('book.svg')):
|
||||
QLabel.__init__(self)
|
||||
self.animation = QPropertyAnimation(self, 'size', self)
|
||||
self.animation.setEasingCurve(QEasingCurve(QEasingCurve.OutExpo))
|
||||
self.animation.setDuration(1000)
|
||||
self.animation.setStartValue(QSize(0, 0))
|
||||
self.setMaximumWidth(81)
|
||||
self.setMaximumHeight(108)
|
||||
self.default_pixmap = QPixmap(coverpath).scaled(self.maximumWidth(),
|
||||
self.maximumHeight(),
|
||||
Qt.IgnoreAspectRatio,
|
||||
Qt.SmoothTransformation)
|
||||
self.default_pixmap = QPixmap(coverpath)
|
||||
self.setScaledContents(True)
|
||||
self.statusbar_height = 120
|
||||
self.setPixmap(self.default_pixmap)
|
||||
|
||||
def do_layout(self):
|
||||
self.animation.stop()
|
||||
pixmap = self.pixmap()
|
||||
pwidth, pheight = pixmap.width(), pixmap.height()
|
||||
width, height = fit_image(pwidth, pheight,
|
||||
pwidth, self.statusbar_height-12)[1:]
|
||||
pwidth, self.statusbar_height-20)[1:]
|
||||
self.setMaximumHeight(height)
|
||||
try:
|
||||
aspect_ratio = pwidth/float(pheight)
|
||||
except ZeroDivisionError:
|
||||
aspect_ratio = 1
|
||||
self.setMaximumWidth(int(aspect_ratio*self.maximumHeight()))
|
||||
self.animation.setEndValue(self.maximumSize())
|
||||
|
||||
def setPixmap(self, pixmap):
|
||||
QLabel.setPixmap(self, pixmap)
|
||||
self.do_layout()
|
||||
|
||||
self.animation.start()
|
||||
|
||||
def sizeHint(self):
|
||||
return QSize(self.maximumWidth(), self.maximumHeight())
|
||||
@ -84,27 +90,31 @@ class BookInfoDisplay(QWidget):
|
||||
self.statusbar_height = statusbar_size.height()
|
||||
self.do_layout()
|
||||
|
||||
# }}}
|
||||
|
||||
class BookDataDisplay(QLabel):
|
||||
|
||||
mr = pyqtSignal(int)
|
||||
mr = pyqtSignal(object)
|
||||
link_clicked = pyqtSignal(object)
|
||||
|
||||
def __init__(self):
|
||||
QLabel.__init__(self)
|
||||
self.setText('')
|
||||
self.setWordWrap(True)
|
||||
self.setSizePolicy(QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding))
|
||||
self.linkActivated.connect(self.link_activated)
|
||||
self._link_clicked = False
|
||||
|
||||
def mouseReleaseEvent(self, ev):
|
||||
self.mr.emit(1)
|
||||
QLabel.mouseReleaseEvent(self, ev)
|
||||
if not self._link_clicked:
|
||||
self.mr.emit(ev)
|
||||
self._link_clicked = False
|
||||
|
||||
WEIGHTS = collections.defaultdict(lambda : 100)
|
||||
WEIGHTS[_('Path')] = 0
|
||||
WEIGHTS[_('Formats')] = 1
|
||||
WEIGHTS[_('Collections')] = 2
|
||||
WEIGHTS[_('Series')] = 3
|
||||
WEIGHTS[_('Tags')] = 4
|
||||
WEIGHTS[_('Comments')] = 5
|
||||
def link_activated(self, link):
|
||||
self._link_clicked = True
|
||||
link = unicode(link)
|
||||
self.link_clicked.emit(link)
|
||||
|
||||
show_book_info = pyqtSignal()
|
||||
|
||||
@ -125,6 +135,7 @@ class BookInfoDisplay(QWidget):
|
||||
self._layout.setAlignment(self.cover_display, Qt.AlignTop|Qt.AlignLeft)
|
||||
|
||||
def mouseReleaseEvent(self, ev):
|
||||
ev.accept()
|
||||
self.show_book_info.emit()
|
||||
|
||||
def show_data(self, data):
|
||||
@ -136,24 +147,12 @@ class BookInfoDisplay(QWidget):
|
||||
rows, comments = [], ''
|
||||
self.book_data.setText('')
|
||||
self.data = data.copy()
|
||||
keys = data.keys()
|
||||
keys.sort(cmp=lambda x, y: cmp(self.WEIGHTS[x], self.WEIGHTS[y]))
|
||||
for key in keys:
|
||||
txt = data[key]
|
||||
if not txt or not txt.strip() or txt == 'None':
|
||||
continue
|
||||
if isinstance(key, str):
|
||||
key = key.decode(preferred_encoding, 'replace')
|
||||
if isinstance(txt, str):
|
||||
txt = txt.decode(preferred_encoding, 'replace')
|
||||
if key == _('Comments'):
|
||||
comments = comments_to_html(txt)
|
||||
else:
|
||||
rows.append((key, txt))
|
||||
rows = render_rows(self.data)
|
||||
rows = '\n'.join([u'<tr><td valign="top"><b>%s:</b></td><td valign="top">%s</td></tr>'%(k,t) for
|
||||
k, t in rows])
|
||||
if comments:
|
||||
comments = '<b>Comments:</b>'+comments
|
||||
if _('Comments') in self.data:
|
||||
comments = comments_to_html(self.data[_('Comments')])
|
||||
comments = ('<b>%s:</b>'%_('Comments'))+comments
|
||||
left_pane = u'<table>%s</table>'%rows
|
||||
right_pane = u'<div>%s</div>'%comments
|
||||
self.book_data.setText(u'<table><tr><td valign="top" '
|
||||
@ -164,18 +163,59 @@ class BookInfoDisplay(QWidget):
|
||||
self.book_data.updateGeometry()
|
||||
self.updateGeometry()
|
||||
self.setVisible(True)
|
||||
self.setToolTip('<p>'+_('Click to open Book Details window') +
|
||||
'<br><br>' + _('Path') + ': ' + data.get(_('Path'), ''))
|
||||
|
||||
|
||||
class StatusBar(QStatusBar):
|
||||
|
||||
resized = pyqtSignal(object)
|
||||
files_dropped = pyqtSignal(object, object)
|
||||
show_book_info = pyqtSignal()
|
||||
class StatusBarInterface(object):
|
||||
|
||||
def initialize(self, systray=None):
|
||||
self.systray = systray
|
||||
self.notifier = get_notifier(systray)
|
||||
self.book_info = BookInfoDisplay(self.clearMessage)
|
||||
|
||||
def show_message(self, msg, timeout=0):
|
||||
QStatusBar.showMessage(self, msg, timeout)
|
||||
if self.notifier is not None and not config['disable_tray_notification']:
|
||||
if isosx and isinstance(msg, unicode):
|
||||
try:
|
||||
msg = msg.encode(preferred_encoding)
|
||||
except UnicodeEncodeError:
|
||||
msg = msg.encode('utf-8')
|
||||
self.notifier(msg)
|
||||
|
||||
def clear_message(self):
|
||||
QStatusBar.clearMessage(self)
|
||||
|
||||
class BookDetailsInterface(object):
|
||||
|
||||
# These signals must be defined in the class implementing this interface
|
||||
files_dropped = None
|
||||
show_book_info = None
|
||||
open_containing_folder = None
|
||||
view_specific_format = None
|
||||
|
||||
def reset_info(self):
|
||||
raise NotImplementedError()
|
||||
|
||||
def show_data(self, data):
|
||||
raise NotImplementedError()
|
||||
|
||||
class HStatusBar(QStatusBar, StatusBarInterface):
|
||||
pass
|
||||
|
||||
class StatusBar(QStatusBar, StatusBarInterface, BookDetailsInterface):
|
||||
|
||||
files_dropped = pyqtSignal(object, object)
|
||||
show_book_info = pyqtSignal()
|
||||
open_containing_folder = pyqtSignal(int)
|
||||
view_specific_format = pyqtSignal(int, object)
|
||||
|
||||
resized = pyqtSignal(object)
|
||||
|
||||
def initialize(self, systray=None):
|
||||
StatusBarInterface.initialize(self, systray=systray)
|
||||
self.book_info = BookInfoDisplay(self.clear_message)
|
||||
self.book_info.setAcceptDrops(True)
|
||||
self.scroll_area = QScrollArea()
|
||||
self.scroll_area.setWidget(self.book_info)
|
||||
@ -184,26 +224,30 @@ class StatusBar(QStatusBar):
|
||||
type=Qt.QueuedConnection)
|
||||
self.book_info.files_dropped.connect(self.files_dropped.emit,
|
||||
type=Qt.QueuedConnection)
|
||||
self.book_info.book_data.link_clicked.connect(self._link_clicked)
|
||||
self.addWidget(self.scroll_area, 100)
|
||||
self.setMinimumHeight(120)
|
||||
self.resized.connect(self.book_info.cover_display.relayout)
|
||||
self.book_info.cover_display.relayout(self.size())
|
||||
|
||||
|
||||
def _link_clicked(self, link):
|
||||
typ, _, val = link.partition(':')
|
||||
if typ == 'path':
|
||||
self.open_containing_folder.emit(int(val))
|
||||
elif typ == 'format':
|
||||
id_, fmt = val.split(':')
|
||||
self.view_specific_format.emit(int(id_), fmt)
|
||||
elif typ == 'devpath':
|
||||
QDesktopServices.openUrl(QUrl.fromLocalFile(val))
|
||||
|
||||
|
||||
def resizeEvent(self, ev):
|
||||
self.resized.emit(self.size())
|
||||
|
||||
def reset_info(self):
|
||||
self.book_info.show_data({})
|
||||
|
||||
def showMessage(self, msg, timeout=0):
|
||||
ret = QStatusBar.showMessage(self, msg, timeout)
|
||||
if self.notifier is not None and not config['disable_tray_notification']:
|
||||
if isosx and isinstance(msg, unicode):
|
||||
try:
|
||||
msg = msg.encode(preferred_encoding)
|
||||
except UnicodeEncodeError:
|
||||
msg = msg.encode('utf-8')
|
||||
self.notifier(msg)
|
||||
return ret
|
||||
|
||||
def show_data(self, data):
|
||||
self.book_info.show_data(data)
|
||||
|
||||
|
@ -11,13 +11,50 @@ from itertools import izip
|
||||
from functools import partial
|
||||
|
||||
from PyQt4.Qt import Qt, QTreeView, QApplication, pyqtSignal, \
|
||||
QFont, QSize, QIcon, QPoint, \
|
||||
QAbstractItemModel, QVariant, QModelIndex, QMenu
|
||||
QFont, QSize, QIcon, QPoint, QVBoxLayout, QComboBox, \
|
||||
QAbstractItemModel, QVariant, QModelIndex, QMenu, \
|
||||
QPushButton, QWidget, QItemDelegate
|
||||
|
||||
from calibre.gui2 import config, NONE
|
||||
from calibre.utils.config import prefs
|
||||
from calibre.library.field_metadata import TagsIcons
|
||||
from calibre.utils.search_query_parser import saved_searches
|
||||
from calibre.gui2 import error_dialog
|
||||
from calibre.gui2.dialogs.tag_categories import TagCategories
|
||||
from calibre.gui2.dialogs.tag_list_editor import TagListEditor
|
||||
from calibre.gui2.dialogs.edit_authors_dialog import EditAuthorsDialog
|
||||
|
||||
class TagDelegate(QItemDelegate): # {{{
|
||||
|
||||
def paint(self, painter, option, index):
|
||||
item = index.internalPointer()
|
||||
if item.type != TagTreeItem.TAG:
|
||||
QItemDelegate.paint(self, painter, option, index)
|
||||
return
|
||||
r = option.rect
|
||||
model = self.parent().model()
|
||||
icon = model.data(index, Qt.DecorationRole).toPyObject()
|
||||
painter.save()
|
||||
if item.tag.state != 0 or not config['show_avg_rating'] or \
|
||||
item.tag.avg_rating is None:
|
||||
icon.paint(painter, r, Qt.AlignLeft)
|
||||
else:
|
||||
painter.setOpacity(0.3)
|
||||
icon.paint(painter, r, Qt.AlignLeft)
|
||||
painter.setOpacity(1)
|
||||
rating = item.tag.avg_rating
|
||||
painter.setClipRect(r.left(), r.bottom()-int(r.height()*(rating/5.0)),
|
||||
r.width(), r.height())
|
||||
icon.paint(painter, r, Qt.AlignLeft)
|
||||
painter.setClipRect(r)
|
||||
|
||||
# Paint the text
|
||||
r.setLeft(r.left()+r.height()+3)
|
||||
painter.drawText(r, Qt.AlignLeft|Qt.AlignVCenter,
|
||||
model.data(index, Qt.DisplayRole).toString())
|
||||
painter.restore()
|
||||
|
||||
# }}}
|
||||
|
||||
class TagsView(QTreeView): # {{{
|
||||
|
||||
@ -26,22 +63,28 @@ class TagsView(QTreeView): # {{{
|
||||
user_category_edit = pyqtSignal(object)
|
||||
tag_list_edit = pyqtSignal(object, object)
|
||||
saved_search_edit = pyqtSignal(object)
|
||||
author_sort_edit = pyqtSignal(object, object)
|
||||
tag_item_renamed = pyqtSignal()
|
||||
search_item_renamed = pyqtSignal()
|
||||
|
||||
def __init__(self, *args):
|
||||
QTreeView.__init__(self, *args)
|
||||
def __init__(self, parent=None):
|
||||
QTreeView.__init__(self, parent=None)
|
||||
self.tag_match = None
|
||||
self.setUniformRowHeights(True)
|
||||
self.setCursor(Qt.PointingHandCursor)
|
||||
self.setIconSize(QSize(30, 30))
|
||||
self.tag_match = None
|
||||
self.setTabKeyNavigation(True)
|
||||
self.setAlternatingRowColors(True)
|
||||
self.setAnimated(True)
|
||||
self.setHeaderHidden(True)
|
||||
self.setItemDelegate(TagDelegate(self))
|
||||
|
||||
def set_database(self, db, tag_match, popularity):
|
||||
def set_database(self, db, tag_match, sort_by):
|
||||
self.hidden_categories = config['tag_browser_hidden_categories']
|
||||
self._model = TagsModel(db, parent=self,
|
||||
hidden_categories=self.hidden_categories,
|
||||
search_restriction=None)
|
||||
self.popularity = popularity
|
||||
self.sort_by = sort_by
|
||||
self.tag_match = tag_match
|
||||
self.db = db
|
||||
self.search_restriction = None
|
||||
@ -49,8 +92,9 @@ class TagsView(QTreeView): # {{{
|
||||
self.setContextMenuPolicy(Qt.CustomContextMenu)
|
||||
self.clicked.connect(self.toggle)
|
||||
self.customContextMenuRequested.connect(self.show_context_menu)
|
||||
self.popularity.setChecked(config['sort_by_popularity'])
|
||||
self.popularity.stateChanged.connect(self.sort_changed)
|
||||
pop = config['sort_tags_by']
|
||||
self.sort_by.setCurrentIndex(self.db.CATEGORY_SORTS.index(pop))
|
||||
self.sort_by.currentIndexChanged.connect(self.sort_changed)
|
||||
self.refresh_required.connect(self.recount, type=Qt.QueuedConnection)
|
||||
db.add_listener(self.database_changed)
|
||||
|
||||
@ -61,10 +105,9 @@ class TagsView(QTreeView): # {{{
|
||||
def match_all(self):
|
||||
return self.tag_match and self.tag_match.currentIndex() > 0
|
||||
|
||||
def sort_changed(self, state):
|
||||
config.set('sort_by_popularity', state == Qt.Checked)
|
||||
self.model().refresh()
|
||||
# self.search_restriction_set()
|
||||
def sort_changed(self, pop):
|
||||
config.set('sort_tags_by', self.db.CATEGORY_SORTS[pop])
|
||||
self.recount()
|
||||
|
||||
def set_search_restriction(self, s):
|
||||
if s:
|
||||
@ -105,6 +148,9 @@ class TagsView(QTreeView): # {{{
|
||||
if action == 'manage_searches':
|
||||
self.saved_search_edit.emit(category)
|
||||
return
|
||||
if action == 'edit_author_sort':
|
||||
self.author_sort_edit.emit(self, index)
|
||||
return
|
||||
if action == 'hide':
|
||||
self.hidden_categories.add(category)
|
||||
elif action == 'show':
|
||||
@ -125,6 +171,7 @@ class TagsView(QTreeView): # {{{
|
||||
if item.type == TagTreeItem.TAG:
|
||||
tag_item = item
|
||||
tag_name = item.tag.name
|
||||
tag_id = item.tag.id
|
||||
item = item.parent
|
||||
if item.type == TagTreeItem.CATEGORY:
|
||||
category = unicode(item.name.toString())
|
||||
@ -138,10 +185,15 @@ class TagsView(QTreeView): # {{{
|
||||
# the possibility of renaming that item
|
||||
if tag_name and \
|
||||
(key in ['authors', 'tags', 'series', 'publisher', 'search'] or \
|
||||
self.db.field_metadata[key]['is_custom']):
|
||||
self.context_menu.addAction(_('Rename') + " '" + tag_name + "'",
|
||||
self.db.field_metadata[key]['is_custom'] and \
|
||||
self.db.field_metadata[key]['datatype'] != 'rating'):
|
||||
self.context_menu.addAction(_('Rename \'%s\'')%tag_name,
|
||||
partial(self.context_menu_handler, action='edit_item',
|
||||
category=tag_item, index=index))
|
||||
if key == 'authors':
|
||||
self.context_menu.addAction(_('Edit sort for \'%s\'')%tag_name,
|
||||
partial(self.context_menu_handler,
|
||||
action='edit_author_sort', index=tag_id))
|
||||
self.context_menu.addSeparator()
|
||||
# Hide/Show/Restore categories
|
||||
self.context_menu.addAction(_('Hide category %s') % category,
|
||||
@ -158,9 +210,12 @@ class TagsView(QTreeView): # {{{
|
||||
self.context_menu.addSeparator()
|
||||
if key in ['tags', 'publisher', 'series'] or \
|
||||
self.db.field_metadata[key]['is_custom']:
|
||||
self.context_menu.addAction(_('Manage ') + category,
|
||||
self.context_menu.addAction(_('Manage %s')%category,
|
||||
partial(self.context_menu_handler, action='open_editor',
|
||||
category=tag_name, key=key))
|
||||
elif key == 'authors':
|
||||
self.context_menu.addAction(_('Manage %s')%category,
|
||||
partial(self.context_menu_handler, action='edit_author_sort'))
|
||||
elif key == 'search':
|
||||
self.context_menu.addAction(_('Manage Saved Searches'),
|
||||
partial(self.context_menu_handler, action='manage_searches',
|
||||
@ -184,13 +239,21 @@ class TagsView(QTreeView): # {{{
|
||||
if self.model():
|
||||
self.model().clear_state()
|
||||
|
||||
def is_visible(self, idx):
|
||||
item = idx.internalPointer()
|
||||
if getattr(item, 'type', None) == TagTreeItem.TAG:
|
||||
idx = idx.parent()
|
||||
return self.isExpanded(idx)
|
||||
|
||||
def recount(self, *args):
|
||||
ci = self.currentIndex()
|
||||
if not ci.isValid():
|
||||
ci = self.indexAt(QPoint(10, 10))
|
||||
path = self.model().path_for_index(ci)
|
||||
path = self.model().path_for_index(ci) if self.is_visible(ci) else None
|
||||
try:
|
||||
self.model().refresh()
|
||||
if not self.model().refresh(): # categories changed!
|
||||
self.set_new_model()
|
||||
path = None
|
||||
except: #Database connection could be closed if an integrity check is happening
|
||||
pass
|
||||
if path:
|
||||
@ -203,10 +266,16 @@ class TagsView(QTreeView): # {{{
|
||||
# gone, or if columns have been hidden or restored, we must rebuild the
|
||||
# model. Reason: it is much easier than reconstructing the browser tree.
|
||||
def set_new_model(self):
|
||||
self._model = TagsModel(self.db, parent=self,
|
||||
hidden_categories=self.hidden_categories,
|
||||
search_restriction=self.search_restriction)
|
||||
self.setModel(self._model)
|
||||
try:
|
||||
self._model = TagsModel(self.db, parent=self,
|
||||
hidden_categories=self.hidden_categories,
|
||||
search_restriction=self.search_restriction)
|
||||
self.setModel(self._model)
|
||||
except:
|
||||
# The DB must be gone. Set the model to None and hope that someone
|
||||
# will call set_database later. I don't know if this in fact works
|
||||
self._model = None
|
||||
self.setModel(None)
|
||||
# }}}
|
||||
|
||||
class TagTreeItem(object): # {{{
|
||||
@ -310,25 +379,17 @@ class TagsModel(QAbstractItemModel): # {{{
|
||||
':custom' : QIcon(I('column.svg')),
|
||||
':user' : QIcon(I('drawer.svg')),
|
||||
'search' : QIcon(I('search.svg'))})
|
||||
self.categories_with_ratings = ['authors', 'series', 'publisher', 'tags']
|
||||
|
||||
self.icon_state_map = [None, QIcon(I('plus.svg')), QIcon(I('minus.svg'))]
|
||||
self.db = db
|
||||
self.tags_view = parent
|
||||
self.hidden_categories = hidden_categories
|
||||
self.search_restriction = search_restriction
|
||||
self.row_map = []
|
||||
|
||||
# Reconstruct the user categories, putting them into metadata
|
||||
tb_cats = self.db.field_metadata
|
||||
for k in tb_cats.keys():
|
||||
if tb_cats[k]['kind'] in ['user', 'search']:
|
||||
del tb_cats[k]
|
||||
for user_cat in sorted(prefs['user_categories'].keys()):
|
||||
cat_name = user_cat+':' # add the ':' to avoid name collision
|
||||
tb_cats.add_user_category(label=cat_name, name=user_cat)
|
||||
if len(saved_searches.names()):
|
||||
tb_cats.add_search_category(label='search', name=_('Searches'))
|
||||
|
||||
data = self.get_node_tree(config['sort_by_popularity'])
|
||||
# get_node_tree cannot return None here, because row_map is empty
|
||||
data = self.get_node_tree(config['sort_tags_by'])
|
||||
self.root_item = TagTreeItem()
|
||||
for i, r in enumerate(self.row_map):
|
||||
if self.hidden_categories and self.categories[i] in self.hidden_categories:
|
||||
@ -341,36 +402,58 @@ class TagsModel(QAbstractItemModel): # {{{
|
||||
data=self.categories[i],
|
||||
category_icon=self.category_icon_map[r],
|
||||
tooltip=tt, category_key=r)
|
||||
# This duplicates code in refresh(). Having it here as well
|
||||
# can save seconds during startup, because we avoid a second
|
||||
# call to get_node_tree.
|
||||
for tag in data[r]:
|
||||
if r not in self.categories_with_ratings and \
|
||||
not self.db.field_metadata[r]['is_custom'] and \
|
||||
not self.db.field_metadata[r]['kind'] == 'user':
|
||||
tag.avg_rating = None
|
||||
TagTreeItem(parent=c, data=tag, icon_map=self.icon_state_map)
|
||||
|
||||
def set_search_restriction(self, s):
|
||||
self.search_restriction = s
|
||||
|
||||
def get_node_tree(self, sort):
|
||||
old_row_map = self.row_map[:]
|
||||
self.row_map = []
|
||||
self.categories = []
|
||||
|
||||
# Reconstruct the user categories, putting them into metadata
|
||||
tb_cats = self.db.field_metadata
|
||||
for k in tb_cats.keys():
|
||||
if tb_cats[k]['kind'] in ['user', 'search']:
|
||||
del tb_cats[k]
|
||||
for user_cat in sorted(prefs['user_categories'].keys()):
|
||||
cat_name = user_cat+':' # add the ':' to avoid name collision
|
||||
tb_cats.add_user_category(label=cat_name, name=user_cat)
|
||||
if len(saved_searches.names()):
|
||||
tb_cats.add_search_category(label='search', name=_('Searches'))
|
||||
|
||||
# Now get the categories
|
||||
if self.search_restriction:
|
||||
data = self.db.get_categories(sort_on_count=sort,
|
||||
data = self.db.get_categories(sort=sort,
|
||||
icon_map=self.category_icon_map,
|
||||
ids=self.db.search('', return_matches=True))
|
||||
else:
|
||||
data = self.db.get_categories(sort_on_count=sort, icon_map=self.category_icon_map)
|
||||
data = self.db.get_categories(sort=sort, icon_map=self.category_icon_map)
|
||||
|
||||
tb_categories = self.db.field_metadata
|
||||
self.category_items = {}
|
||||
for category in tb_categories:
|
||||
if category in data: # They should always be there, but ...
|
||||
# make a map of sets of names per category for duplicate
|
||||
# checking when editing
|
||||
self.category_items[category] = set([tag.name for tag in data[category]])
|
||||
if category in data: # The search category can come and go
|
||||
self.row_map.append(category)
|
||||
self.categories.append(tb_categories[category]['name'])
|
||||
if len(old_row_map) != 0 and len(old_row_map) != len(self.row_map):
|
||||
# A category has been added or removed. We must force a rebuild of
|
||||
# the model
|
||||
return None
|
||||
return data
|
||||
|
||||
def refresh(self):
|
||||
data = self.get_node_tree(config['sort_by_popularity']) # get category data
|
||||
data = self.get_node_tree(config['sort_tags_by']) # get category data
|
||||
if data is None:
|
||||
return False
|
||||
row_index = -1
|
||||
for i, r in enumerate(self.row_map):
|
||||
if self.hidden_categories and self.categories[i] in self.hidden_categories:
|
||||
@ -389,9 +472,14 @@ class TagsModel(QAbstractItemModel): # {{{
|
||||
if len(data[r]) > 0:
|
||||
self.beginInsertRows(category_index, 0, len(data[r])-1)
|
||||
for tag in data[r]:
|
||||
if r not in self.categories_with_ratings and \
|
||||
not self.db.field_metadata[r]['is_custom'] and \
|
||||
not self.db.field_metadata[r]['kind'] == 'user':
|
||||
tag.avg_rating = None
|
||||
tag.state = state_map.get(tag.name, 0)
|
||||
t = TagTreeItem(parent=category, data=tag, icon_map=self.icon_state_map)
|
||||
self.endInsertRows()
|
||||
return True
|
||||
|
||||
def columnCount(self, parent):
|
||||
return 1
|
||||
@ -405,6 +493,8 @@ class TagsModel(QAbstractItemModel): # {{{
|
||||
def setData(self, index, value, role=Qt.EditRole):
|
||||
if not index.isValid():
|
||||
return NONE
|
||||
# set up to position at the category label
|
||||
path = self.path_for_index(self.parent(index))
|
||||
val = unicode(value.toString())
|
||||
if not val:
|
||||
error_dialog(self.tags_view, _('Item is blank'),
|
||||
@ -412,15 +502,14 @@ class TagsModel(QAbstractItemModel): # {{{
|
||||
return False
|
||||
item = index.internalPointer()
|
||||
key = item.parent.category_key
|
||||
# make certain we know about the category
|
||||
# make certain we know about the item's category
|
||||
if key not in self.db.field_metadata:
|
||||
return
|
||||
if val in self.category_items[key]:
|
||||
error_dialog(self.tags_view, 'Duplicate item',
|
||||
_('The name %s is already used.')%val).exec_()
|
||||
return False
|
||||
oldval = item.tag.name
|
||||
if key == 'search':
|
||||
if val in saved_searches.names():
|
||||
error_dialog(self.tags_view, _('Duplicate search name'),
|
||||
_('The saved search name %s is already used.')%val).exec_()
|
||||
return False
|
||||
saved_searches.rename(unicode(item.data(role).toString()), val)
|
||||
self.tags_view.search_item_renamed.emit()
|
||||
else:
|
||||
@ -437,10 +526,12 @@ class TagsModel(QAbstractItemModel): # {{{
|
||||
label=self.db.field_metadata[key]['label'])
|
||||
self.tags_view.tag_item_renamed.emit()
|
||||
item.tag.name = val
|
||||
self.dataChanged.emit(index, index)
|
||||
# replace the old value in the duplicate detection map with the new one
|
||||
self.category_items[key].discard(oldval)
|
||||
self.category_items[key].add(val)
|
||||
self.refresh() # Should work, because no categories can have disappeared
|
||||
if path:
|
||||
idx = self.index_for_path(path)
|
||||
if idx.isValid():
|
||||
self.tags_view.setCurrentIndex(idx)
|
||||
self.tags_view.scrollTo(idx, QTreeView.PositionAtCenter)
|
||||
return True
|
||||
|
||||
def headerData(self, *args):
|
||||
@ -564,3 +655,89 @@ class TagsModel(QAbstractItemModel): # {{{
|
||||
|
||||
# }}}
|
||||
|
||||
class TagBrowserMixin(object): # {{{
|
||||
|
||||
def __init__(self, db):
|
||||
self.library_view.model().count_changed_signal.connect(self.tags_view.recount)
|
||||
self.tags_view.set_database(self.library_view.model().db,
|
||||
self.tag_match, self.sort_by)
|
||||
self.tags_view.tags_marked.connect(self.search.search_from_tags)
|
||||
self.tags_view.tags_marked.connect(self.saved_search.clear_to_help)
|
||||
self.tags_view.tag_list_edit.connect(self.do_tags_list_edit)
|
||||
self.tags_view.user_category_edit.connect(self.do_user_categories_edit)
|
||||
self.tags_view.saved_search_edit.connect(self.do_saved_search_edit)
|
||||
self.tags_view.author_sort_edit.connect(self.do_author_sort_edit)
|
||||
self.tags_view.tag_item_renamed.connect(self.do_tag_item_renamed)
|
||||
self.tags_view.search_item_renamed.connect(self.saved_search.clear_to_help)
|
||||
self.edit_categories.clicked.connect(lambda x:
|
||||
self.do_user_categories_edit())
|
||||
|
||||
def do_user_categories_edit(self, on_category=None):
|
||||
d = TagCategories(self, self.library_view.model().db, on_category)
|
||||
d.exec_()
|
||||
if d.result() == d.Accepted:
|
||||
self.tags_view.set_new_model()
|
||||
self.tags_view.recount()
|
||||
|
||||
def do_tags_list_edit(self, tag, category):
|
||||
d = TagListEditor(self, self.library_view.model().db, tag, category)
|
||||
d.exec_()
|
||||
if d.result() == d.Accepted:
|
||||
# Clean up everything, as information could have changed for many books.
|
||||
self.library_view.model().refresh()
|
||||
self.tags_view.set_new_model()
|
||||
self.tags_view.recount()
|
||||
self.saved_search.clear_to_help()
|
||||
self.search.clear_to_help()
|
||||
|
||||
def do_tag_item_renamed(self):
|
||||
# Clean up library view and search
|
||||
self.library_view.model().refresh()
|
||||
self.saved_search.clear_to_help()
|
||||
self.search.clear_to_help()
|
||||
|
||||
def do_author_sort_edit(self, parent, id):
|
||||
db = self.library_view.model().db
|
||||
editor = EditAuthorsDialog(parent, db, id)
|
||||
d = editor.exec_()
|
||||
if d:
|
||||
for (id, old_author, new_author, new_sort) in editor.result:
|
||||
if old_author != new_author:
|
||||
# The id might change if the new author already exists
|
||||
id = db.rename_author(id, new_author)
|
||||
db.set_sort_field_for_author(id, unicode(new_sort))
|
||||
self.library_view.model().refresh()
|
||||
self.tags_view.recount()
|
||||
|
||||
# }}}
|
||||
|
||||
class TagBrowserWidget(QWidget): # {{{
|
||||
|
||||
def __init__(self, parent):
|
||||
QWidget.__init__(self, parent)
|
||||
self._layout = QVBoxLayout()
|
||||
self.setLayout(self._layout)
|
||||
|
||||
parent.tags_view = TagsView(parent)
|
||||
self._layout.addWidget(parent.tags_view)
|
||||
|
||||
parent.sort_by = QComboBox(parent)
|
||||
# Must be in the same order as db2.CATEGORY_SORTS
|
||||
for x in (_('Sort by name'), _('Sort by popularity'),
|
||||
_('Sort by average rating')):
|
||||
parent.sort_by.addItem(x)
|
||||
parent.sort_by.setCurrentIndex(0)
|
||||
self._layout.addWidget(parent.sort_by)
|
||||
|
||||
parent.tag_match = QComboBox(parent)
|
||||
for x in (_('Match any'), _('Match all')):
|
||||
parent.tag_match.addItem(x)
|
||||
parent.tag_match.setCurrentIndex(0)
|
||||
self._layout.addWidget(parent.tag_match)
|
||||
|
||||
parent.edit_categories = QPushButton(_('Manage &user categories'), parent)
|
||||
self._layout.addWidget(parent.edit_categories)
|
||||
|
||||
|
||||
# }}}
|
||||
|
||||
|
@ -3,12 +3,13 @@ __copyright__ = '2008, Kovid Goyal <kovid at kovidgoyal.net>'
|
||||
|
||||
import traceback
|
||||
|
||||
from PyQt4.QtCore import QThread, pyqtSignal
|
||||
from PyQt4.Qt import QThread, pyqtSignal, QDesktopServices, QUrl, Qt
|
||||
import mechanize
|
||||
|
||||
from calibre.constants import __version__, iswindows, isosx
|
||||
from calibre.constants import __appname__, __version__, iswindows, isosx
|
||||
from calibre import browser
|
||||
from calibre.utils.config import prefs
|
||||
from calibre.gui2 import config, dynamic, question_dialog
|
||||
|
||||
URL = 'http://status.calibre-ebook.com/latest'
|
||||
|
||||
@ -36,3 +37,35 @@ class CheckForUpdates(QThread):
|
||||
traceback.print_exc()
|
||||
self.sleep(self.INTERVAL)
|
||||
|
||||
class UpdateMixin(object):
|
||||
|
||||
def __init__(self, opts):
|
||||
if not opts.no_update_check:
|
||||
self.update_checker = CheckForUpdates(self)
|
||||
self.update_checker.update_found.connect(self.update_found,
|
||||
type=Qt.QueuedConnection)
|
||||
self.update_checker.start()
|
||||
|
||||
def update_found(self, version):
|
||||
os = 'windows' if iswindows else 'osx' if isosx else 'linux'
|
||||
url = 'http://calibre-ebook.com/download_%s'%os
|
||||
self.latest_version = '<br>' + _('<span style="color:red; font-weight:bold">'
|
||||
'Latest version: <a href="%s">%s</a></span>')%(url, version)
|
||||
self.vanity.setText(self.vanity_template%\
|
||||
(dict(version=self.latest_version,
|
||||
device=self.device_info)))
|
||||
self.vanity.update()
|
||||
if config.get('new_version_notification') and \
|
||||
dynamic.get('update to version %s'%version, True):
|
||||
if question_dialog(self, _('Update available'),
|
||||
_('%s has been updated to version %s. '
|
||||
'See the <a href="http://calibre-ebook.com/whats-new'
|
||||
'">new features</a>. Visit the download pa'
|
||||
'ge?')%(__appname__, version)):
|
||||
url = 'http://calibre-ebook.com/download_'+\
|
||||
('windows' if iswindows else 'osx' if isosx else 'linux')
|
||||
QDesktopServices.openUrl(QUrl(url))
|
||||
dynamic.set('update to version %s'%version, False)
|
||||
|
||||
|
||||
|
||||
|
@ -229,9 +229,9 @@ class EbookViewer(MainWindow, Ui_EbookViewer):
|
||||
self.connect(self.action_previous_page, SIGNAL('triggered(bool)'),
|
||||
lambda x:self.view.previous_page())
|
||||
self.connect(self.action_find_next, SIGNAL('triggered(bool)'),
|
||||
lambda x:self.find(self.search.smart_text, True, repeat=True))
|
||||
lambda x:self.find(self.search.smart_text, repeat=True))
|
||||
self.connect(self.action_find_previous, SIGNAL('triggered(bool)'),
|
||||
lambda x:self.find(self.search.smart_text, True,
|
||||
lambda x:self.find(self.search.smart_text,
|
||||
repeat=True, backwards=True))
|
||||
|
||||
self.connect(self.action_full_screen, SIGNAL('triggered(bool)'),
|
||||
|
@ -4,16 +4,18 @@ __copyright__ = '2008, Kovid Goyal <kovid at kovidgoyal.net>'
|
||||
Miscellaneous widgets used in the GUI
|
||||
'''
|
||||
import re, os, traceback
|
||||
|
||||
from PyQt4.Qt import QListView, QIcon, QFont, QLabel, QListWidget, \
|
||||
QListWidgetItem, QTextCharFormat, QApplication, \
|
||||
QSyntaxHighlighter, QCursor, QColor, QWidget, \
|
||||
QPixmap, QPalette, QSplitterHandle, \
|
||||
QPixmap, QPalette, QSplitterHandle, QToolButton, \
|
||||
QAbstractListModel, QVariant, Qt, SIGNAL, pyqtSignal, \
|
||||
QRegExp, QSettings, QSize, QModelIndex, QSplitter, \
|
||||
QAbstractButton, QPainter, QLineEdit, QComboBox, \
|
||||
QMenu, QStringListModel, QCompleter, QStringList
|
||||
QMenu, QStringListModel, QCompleter, QStringList, \
|
||||
QTimer
|
||||
|
||||
from calibre.gui2 import NONE, error_dialog, pixmap_to_data, dynamic
|
||||
from calibre.gui2 import NONE, error_dialog, pixmap_to_data, gprefs
|
||||
|
||||
from calibre.gui2.filename_pattern_ui import Ui_Form
|
||||
from calibre import fit_image, human_readable
|
||||
@ -927,6 +929,7 @@ class SplitterHandle(QSplitterHandle):
|
||||
self.double_clicked.connect(splitter.double_clicked,
|
||||
type=Qt.QueuedConnection)
|
||||
self.highlight = False
|
||||
self.setToolTip(_('Drag to resize')+' '+splitter.label)
|
||||
|
||||
def splitter_moved(self, *args):
|
||||
oh = self.highlight
|
||||
@ -944,20 +947,62 @@ class SplitterHandle(QSplitterHandle):
|
||||
def mouseDoubleClickEvent(self, ev):
|
||||
self.double_clicked.emit(self)
|
||||
|
||||
class LayoutButton(QToolButton):
|
||||
|
||||
def __init__(self, icon, text, splitter, parent=None):
|
||||
QToolButton.__init__(self, parent)
|
||||
self.label = text
|
||||
self.setIcon(QIcon(icon))
|
||||
self.setCheckable(True)
|
||||
|
||||
self.splitter = splitter
|
||||
splitter.state_changed.connect(self.update_state)
|
||||
|
||||
def set_state_to_show(self, *args):
|
||||
self.setChecked(False)
|
||||
label =_('Show')
|
||||
self.setText(label + ' ' + self.label)
|
||||
|
||||
def set_state_to_hide(self, *args):
|
||||
self.setChecked(True)
|
||||
label = _('Hide')
|
||||
self.setText(label + ' ' + self.label)
|
||||
|
||||
def update_state(self, *args):
|
||||
if self.splitter.is_side_index_hidden:
|
||||
self.set_state_to_show()
|
||||
else:
|
||||
self.set_state_to_hide()
|
||||
|
||||
class Splitter(QSplitter):
|
||||
|
||||
state_changed = pyqtSignal(object)
|
||||
|
||||
def __init__(self, *args):
|
||||
QSplitter.__init__(self, *args)
|
||||
def __init__(self, name, label, icon, initial_show=True,
|
||||
initial_side_size=120, connect_button=True,
|
||||
orientation=Qt.Horizontal, side_index=0, parent=None):
|
||||
QSplitter.__init__(self, parent)
|
||||
self.resize_timer = QTimer(self)
|
||||
self.resize_timer.setSingleShot(True)
|
||||
self.desired_side_size = initial_side_size
|
||||
self.desired_show = initial_show
|
||||
self.resize_timer.setInterval(5)
|
||||
self.resize_timer.timeout.connect(self.do_resize)
|
||||
self.setOrientation(orientation)
|
||||
self.side_index = side_index
|
||||
self._name = name
|
||||
self.label = label
|
||||
self.initial_side_size = initial_side_size
|
||||
self.initial_show = initial_show
|
||||
self.splitterMoved.connect(self.splitter_moved, type=Qt.QueuedConnection)
|
||||
self.button = LayoutButton(icon, label, self)
|
||||
if connect_button:
|
||||
self.button.clicked.connect(self.double_clicked)
|
||||
|
||||
def createHandle(self):
|
||||
return SplitterHandle(self.orientation(), self)
|
||||
|
||||
def initialize(self, name=None):
|
||||
if name is not None:
|
||||
self._name = name
|
||||
def initialize(self):
|
||||
for i in range(self.count()):
|
||||
h = self.handle(i)
|
||||
if h is not None:
|
||||
@ -965,40 +1010,117 @@ class Splitter(QSplitter):
|
||||
self.state_changed.emit(not self.is_side_index_hidden)
|
||||
|
||||
def splitter_moved(self, *args):
|
||||
self.desired_side_size = self.side_index_size
|
||||
self.state_changed.emit(not self.is_side_index_hidden)
|
||||
|
||||
@property
|
||||
def side_index(self):
|
||||
return 0 if self.orientation() == Qt.Horizontal else 1
|
||||
|
||||
@property
|
||||
def is_side_index_hidden(self):
|
||||
sizes = list(self.sizes())
|
||||
return sizes[self.side_index] == 0
|
||||
|
||||
def toggle_side_index(self):
|
||||
self.double_clicked(None)
|
||||
@property
|
||||
def save_name(self):
|
||||
ori = 'horizontal' if self.orientation() == Qt.Horizontal \
|
||||
else 'vertical'
|
||||
return self._name + '_' + ori
|
||||
|
||||
def double_clicked(self, handle):
|
||||
visible = not self.is_side_index_hidden
|
||||
sizes = list(self.sizes())
|
||||
if 0 in sizes:
|
||||
idx = sizes.index(0)
|
||||
sizes[idx] = 80
|
||||
else:
|
||||
sizes[self.side_index] = 0
|
||||
def print_sizes(self):
|
||||
if self.count() > 1:
|
||||
print self.save_name, 'side:', self.side_index_size, 'other:',
|
||||
print list(self.sizes())[self.other_index]
|
||||
|
||||
if visible:
|
||||
dynamic.set(self._name + '_last_open_state', str(self.saveState()))
|
||||
@dynamic_property
|
||||
def side_index_size(self):
|
||||
def fget(self):
|
||||
if self.count() < 2: return 0
|
||||
return self.sizes()[self.side_index]
|
||||
|
||||
def fset(self, val):
|
||||
if self.count() < 2: return
|
||||
if val == 0 and not self.is_side_index_hidden:
|
||||
self.save_state()
|
||||
sizes = list(self.sizes())
|
||||
for i in range(len(sizes)):
|
||||
sizes[i] = val if i == self.side_index else 10
|
||||
self.setSizes(sizes)
|
||||
total = sum(self.sizes())
|
||||
sizes = list(self.sizes())
|
||||
for i in range(len(sizes)):
|
||||
sizes[i] = val if i == self.side_index else total-val
|
||||
self.setSizes(sizes)
|
||||
self.initialize()
|
||||
|
||||
return property(fget=fget, fset=fset)
|
||||
|
||||
def do_resize(self, *args):
|
||||
orig = self.desired_side_size
|
||||
QSplitter.resizeEvent(self, self._resize_ev)
|
||||
if orig > 20 and self.desired_show:
|
||||
c = 0
|
||||
while abs(self.side_index_size - orig) > 10 and c < 5:
|
||||
self.apply_state(self.get_state(), save_desired=False)
|
||||
c += 1
|
||||
|
||||
def resizeEvent(self, ev):
|
||||
if self.resize_timer.isActive():
|
||||
self.resize_timer.stop()
|
||||
self._resize_ev = ev
|
||||
self.resize_timer.start()
|
||||
|
||||
def get_state(self):
|
||||
if self.count() < 2: return (False, 200)
|
||||
return (self.desired_show, self.desired_side_size)
|
||||
|
||||
def apply_state(self, state, save_desired=True):
|
||||
if state[0]:
|
||||
self.side_index_size = state[1]
|
||||
if save_desired:
|
||||
self.desired_side_size = self.side_index_size
|
||||
else:
|
||||
state = dynamic.get(self._name+ '_last_open_state', None)
|
||||
if state is not None:
|
||||
self.restoreState(state)
|
||||
else:
|
||||
self.setSizes(sizes)
|
||||
self.initialize()
|
||||
self.side_index_size = 0
|
||||
self.desired_show = state[0]
|
||||
|
||||
def default_state(self):
|
||||
return (self.initial_show, self.initial_side_size)
|
||||
|
||||
# Public API {{{
|
||||
|
||||
def save_state(self):
|
||||
if self.count() > 1:
|
||||
gprefs[self.save_name+'_state'] = self.get_state()
|
||||
|
||||
@property
|
||||
def other_index(self):
|
||||
return (self.side_index+1)%2
|
||||
|
||||
def restore_state(self):
|
||||
if self.count() > 1:
|
||||
state = gprefs.get(self.save_name+'_state',
|
||||
self.default_state())
|
||||
self.apply_state(state, save_desired=False)
|
||||
self.desired_side_size = state[1]
|
||||
|
||||
def toggle_side_pane(self, hide=None):
|
||||
if hide is None:
|
||||
action = 'show' if self.is_side_index_hidden else 'hide'
|
||||
else:
|
||||
action = 'hide' if hide else 'show'
|
||||
getattr(self, action+'_side_pane')()
|
||||
|
||||
def show_side_pane(self):
|
||||
if self.count() < 2 or not self.is_side_index_hidden:
|
||||
return
|
||||
if self.desired_side_size == 0:
|
||||
self.desired_side_size = self.initial_side_size
|
||||
self.apply_state((True, self.desired_side_size))
|
||||
|
||||
def hide_side_pane(self):
|
||||
if self.count() < 2 or self.is_side_index_hidden:
|
||||
return
|
||||
self.apply_state((False, self.desired_side_size))
|
||||
|
||||
def double_clicked(self, *args):
|
||||
self.toggle_side_pane()
|
||||
|
||||
# }}}
|
||||
|
||||
|
@ -96,14 +96,14 @@ class Kobo(Device):
|
||||
class Booq(Device):
|
||||
name = 'Booq Reader'
|
||||
manufacturer = 'Booq'
|
||||
output_profile = 'prs505'
|
||||
output_profile = 'sony'
|
||||
output_format = 'EPUB'
|
||||
id = 'booq'
|
||||
|
||||
class TheBook(Device):
|
||||
name = 'The Book'
|
||||
manufacturer = 'Augen'
|
||||
output_profile = 'prs505'
|
||||
output_profile = 'sony'
|
||||
output_format = 'EPUB'
|
||||
id = 'thebook'
|
||||
|
||||
|
@ -10,14 +10,14 @@ import collections, glob, os, re, itertools, functools
|
||||
from itertools import repeat
|
||||
from datetime import timedelta
|
||||
|
||||
from PyQt4.QtCore import QThread, QReadWriteLock
|
||||
from PyQt4.QtGui import QImage
|
||||
from PyQt4.Qt import QThread, QReadWriteLock, QImage, Qt
|
||||
|
||||
from calibre.utils.config import tweaks
|
||||
from calibre.utils.date import parse_date, now, UNDEFINED_DATE
|
||||
from calibre.utils.search_query_parser import SearchQueryParser
|
||||
from calibre.utils.pyparsing import ParseException
|
||||
from calibre.ebooks.metadata import title_sort
|
||||
from calibre import fit_image
|
||||
|
||||
class CoverCache(QThread):
|
||||
|
||||
@ -96,6 +96,11 @@ class CoverCache(QThread):
|
||||
img.loadFromData(data)
|
||||
if img.isNull():
|
||||
continue
|
||||
scaled, nwidth, nheight = fit_image(img.width(),
|
||||
img.height(), 600, 800)
|
||||
if scaled:
|
||||
img = img.scaled(nwidth, nheight, Qt.KeepAspectRatio,
|
||||
Qt.SmoothTransformation)
|
||||
except:
|
||||
continue
|
||||
self.cache_lock.lockForWrite()
|
||||
@ -619,9 +624,12 @@ class ResultCache(SearchQueryParser):
|
||||
if self.first_sort:
|
||||
subsort = True
|
||||
self.first_sort = False
|
||||
fcmp = self.seriescmp if field == 'series' else \
|
||||
functools.partial(self.cmp, self.FIELD_MAP[field], subsort=subsort,
|
||||
asstr=as_string)
|
||||
fcmp = self.seriescmp \
|
||||
if field == 'series' and \
|
||||
tweaks['title_series_sorting'] == 'library_order' \
|
||||
else \
|
||||
functools.partial(self.cmp, self.FIELD_MAP[field],
|
||||
subsort=subsort, asstr=as_string)
|
||||
self._map.sort(cmp=fcmp, reverse=not ascending)
|
||||
self._map_filtered = [id for id in self._map if id in self._map_filtered]
|
||||
|
||||
|
@ -83,7 +83,7 @@ class CSV_XML(CatalogPlugin):
|
||||
|
||||
if not len(data):
|
||||
log.error("\nNo matching database entries for search criteria '%s'" % opts.search_text)
|
||||
raise SystemExit(1)
|
||||
#raise SystemExit(1)
|
||||
|
||||
# Get the requested output fields as a list
|
||||
fields = self.get_output_fields(opts)
|
||||
|
@ -183,15 +183,30 @@ class CustomColumns(object):
|
||||
ans = self.conn.get('SELECT id, value FROM %s'%table)
|
||||
return ans
|
||||
|
||||
def rename_custom_item(self, id, new_name, label=None, num=None):
|
||||
if id:
|
||||
if label is not None:
|
||||
data = self.custom_column_label_map[label]
|
||||
if num is not None:
|
||||
data = self.custom_column_num_map[num]
|
||||
table,lt = self.custom_table_names(data['num'])
|
||||
self.conn.execute('UPDATE %s SET value=? WHERE id=?'%table, (new_name, id))
|
||||
self.conn.commit()
|
||||
def rename_custom_item(self, old_id, new_name, label=None, num=None):
|
||||
if label is not None:
|
||||
data = self.custom_column_label_map[label]
|
||||
if num is not None:
|
||||
data = self.custom_column_num_map[num]
|
||||
table,lt = self.custom_table_names(data['num'])
|
||||
# check if item exists
|
||||
new_id = self.conn.get(
|
||||
'SELECT id FROM %s WHERE value=?'%table, (new_name,), all=False)
|
||||
if new_id is None or old_id == new_id:
|
||||
self.conn.execute('UPDATE %s SET value=? WHERE id=?'%table, (new_name, old_id))
|
||||
else:
|
||||
# New id exists. If the column is_multiple, then process like
|
||||
# tags, otherwise process like publishers (see database2)
|
||||
if data['is_multiple']:
|
||||
books = self.conn.get('''SELECT book from %s
|
||||
WHERE value=?'''%lt, (old_id,))
|
||||
for (book_id,) in books:
|
||||
self.conn.execute('''DELETE FROM %s
|
||||
WHERE book=? and value=?'''%lt, (book_id, new_id))
|
||||
self.conn.execute('''UPDATE %s SET value=?
|
||||
WHERE value=?'''%lt, (new_id, old_id,))
|
||||
self.conn.execute('DELETE FROM %s WHERE id=?'%table, (old_id,))
|
||||
self.conn.commit()
|
||||
|
||||
def delete_custom_item_using_id(self, id, label=None, num=None):
|
||||
if id:
|
||||
@ -446,14 +461,27 @@ class CustomColumns(object):
|
||||
CREATE VIEW tag_browser_{table} AS SELECT
|
||||
id,
|
||||
value,
|
||||
(SELECT COUNT(id) FROM {lt} WHERE value={table}.id) count
|
||||
(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
|
||||
FROM {table};
|
||||
|
||||
CREATE VIEW tag_browser_filtered_{table} AS SELECT
|
||||
id,
|
||||
value,
|
||||
(SELECT COUNT({lt}.id) FROM {lt} WHERE value={table}.id AND
|
||||
books_list_filter(book)) count
|
||||
books_list_filter(book)) 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 AND
|
||||
books_list_filter(bl.book)) avg_rating
|
||||
FROM {table};
|
||||
|
||||
'''.format(lt=lt, table=table),
|
||||
@ -490,7 +518,6 @@ class CustomColumns(object):
|
||||
END;
|
||||
'''.format(table=table),
|
||||
]
|
||||
|
||||
script = ' \n'.join(lines)
|
||||
self.conn.executescript(script)
|
||||
self.conn.commit()
|
||||
|
@ -12,7 +12,7 @@ from math import floor
|
||||
|
||||
from PyQt4.QtGui import QImage
|
||||
|
||||
from calibre.ebooks.metadata import title_sort
|
||||
from calibre.ebooks.metadata import title_sort, author_to_author_sort
|
||||
from calibre.library.database import LibraryDatabase
|
||||
from calibre.library.field_metadata import FieldMetadata, TagsIcons
|
||||
from calibre.library.schema_upgrades import SchemaUpgrade
|
||||
@ -20,7 +20,7 @@ from calibre.library.caches import ResultCache
|
||||
from calibre.library.custom_columns import CustomColumns
|
||||
from calibre.library.sqlite import connect, IntegrityError, DBThread
|
||||
from calibre.ebooks.metadata import string_to_authors, authors_to_string, \
|
||||
MetaInformation, authors_to_sort_string
|
||||
MetaInformation
|
||||
from calibre.ebooks.metadata.meta import get_metadata, metadata_from_formats
|
||||
from calibre.constants import preferred_encoding, iswindows, isosx, filesystem_encoding
|
||||
from calibre.ptempfile import PersistentTemporaryFile
|
||||
@ -28,7 +28,7 @@ from calibre.customize.ui import run_plugins_on_import
|
||||
|
||||
from calibre.utils.filenames import ascii_filename
|
||||
from calibre.utils.date import utcnow, now as nowf, utcfromtimestamp
|
||||
from calibre.utils.config import prefs
|
||||
from calibre.utils.config import prefs, tweaks
|
||||
from calibre.utils.search_query_parser import saved_searches
|
||||
from calibre.ebooks import BOOK_EXTENSIONS, check_ebook_format
|
||||
from calibre.utils.magick_draw import save_cover_data_to
|
||||
@ -56,11 +56,18 @@ copyfile = os.link if hasattr(os, 'link') else shutil.copyfile
|
||||
|
||||
class Tag(object):
|
||||
|
||||
def __init__(self, name, id=None, count=0, state=0, tooltip=None, icon=None):
|
||||
def __init__(self, name, id=None, count=0, state=0, avg=0, sort=None,
|
||||
tooltip=None, icon=None):
|
||||
self.name = name
|
||||
self.id = id
|
||||
self.count = count
|
||||
self.state = state
|
||||
self.avg_rating = avg/2.0 if avg is not None else 0
|
||||
self.sort = sort
|
||||
if self.avg_rating > 0:
|
||||
if tooltip:
|
||||
tooltip = tooltip + ': '
|
||||
tooltip = _('%sAverage rating is %3.1f')%(tooltip, self.avg_rating)
|
||||
self.tooltip = tooltip
|
||||
self.icon = icon
|
||||
|
||||
@ -133,7 +140,9 @@ class LibraryDatabase2(LibraryDatabase, SchemaUpgrade, CustomColumns):
|
||||
CREATE TEMP VIEW IF NOT EXISTS tag_browser_news AS SELECT DISTINCT
|
||||
id,
|
||||
name,
|
||||
(SELECT COUNT(books_tags_link.id) FROM books_tags_link WHERE tag=x.id) count
|
||||
(SELECT COUNT(books_tags_link.id) FROM books_tags_link WHERE tag=x.id) count,
|
||||
(0) as avg_rating,
|
||||
name as sort
|
||||
FROM tags as x WHERE name!="{0}" AND id IN
|
||||
(SELECT DISTINCT tag FROM books_tags_link WHERE book IN
|
||||
(SELECT DISTINCT book FROM books_tags_link WHERE tag IN
|
||||
@ -144,7 +153,9 @@ class LibraryDatabase2(LibraryDatabase, SchemaUpgrade, CustomColumns):
|
||||
CREATE TEMP VIEW IF NOT EXISTS tag_browser_filtered_news AS SELECT DISTINCT
|
||||
id,
|
||||
name,
|
||||
(SELECT COUNT(books_tags_link.id) FROM books_tags_link WHERE tag=x.id and books_list_filter(book)) count
|
||||
(SELECT COUNT(books_tags_link.id) FROM books_tags_link WHERE tag=x.id and books_list_filter(book)) count,
|
||||
(0) as avg_rating,
|
||||
name as sort
|
||||
FROM tags as x WHERE name!="{0}" AND id IN
|
||||
(SELECT DISTINCT tag FROM books_tags_link WHERE book IN
|
||||
(SELECT DISTINCT book FROM books_tags_link WHERE tag IN
|
||||
@ -422,6 +433,11 @@ class LibraryDatabase2(LibraryDatabase, SchemaUpgrade, CustomColumns):
|
||||
if aum: aum = [a.strip().replace('|', ',') for a in aum.split(',')]
|
||||
mi = MetaInformation(self.title(idx, index_is_id=index_is_id), aum)
|
||||
mi.author_sort = self.author_sort(idx, index_is_id=index_is_id)
|
||||
if mi.authors:
|
||||
mi.author_sort_map = {}
|
||||
for name, sort in zip(mi.authors, self.authors_sort_strings(idx,
|
||||
index_is_id)):
|
||||
mi.author_sort_map[name] = sort
|
||||
mi.comments = self.comments(idx, index_is_id=index_is_id)
|
||||
mi.publisher = self.publisher(idx, index_is_id=index_is_id)
|
||||
mi.timestamp = self.timestamp(idx, index_is_id=index_is_id)
|
||||
@ -679,7 +695,9 @@ class LibraryDatabase2(LibraryDatabase, SchemaUpgrade, CustomColumns):
|
||||
tn=field['table'], col=field['link_column']), (id_,))
|
||||
return set(x[0] for x in ans)
|
||||
|
||||
def get_categories(self, sort_on_count=False, ids=None, icon_map=None):
|
||||
CATEGORY_SORTS = ('name', 'popularity', 'rating')
|
||||
|
||||
def get_categories(self, sort='name', ids=None, icon_map=None):
|
||||
self.books_list_filter.change([] if not ids else ids)
|
||||
|
||||
categories = {}
|
||||
@ -698,13 +716,17 @@ class LibraryDatabase2(LibraryDatabase, SchemaUpgrade, CustomColumns):
|
||||
continue
|
||||
cn = cat['column']
|
||||
if ids is None:
|
||||
query = 'SELECT id, {0}, count FROM tag_browser_{1}'.format(cn, tn)
|
||||
query = '''SELECT id, {0}, count, avg_rating, sort
|
||||
FROM tag_browser_{1}'''.format(cn, tn)
|
||||
else:
|
||||
query = 'SELECT id, {0}, count FROM tag_browser_filtered_{1}'.format(cn, tn)
|
||||
if sort_on_count:
|
||||
query += ' ORDER BY count DESC'
|
||||
query = '''SELECT id, {0}, count, avg_rating, sort
|
||||
FROM tag_browser_filtered_{1}'''.format(cn, tn)
|
||||
if sort == 'popularity':
|
||||
query += ' ORDER BY count DESC, sort ASC'
|
||||
elif sort == 'name':
|
||||
query += ' ORDER BY sort ASC'
|
||||
else:
|
||||
query += ' ORDER BY {0} ASC'.format(cn)
|
||||
query += ' ORDER BY avg_rating DESC, sort ASC'
|
||||
data = self.conn.get(query)
|
||||
|
||||
# icon_map is not None if get_categories is to store an icon and
|
||||
@ -722,6 +744,7 @@ class LibraryDatabase2(LibraryDatabase, SchemaUpgrade, CustomColumns):
|
||||
|
||||
datatype = cat['datatype']
|
||||
if datatype == 'rating':
|
||||
# eliminate the zero ratings line as well as count == 0
|
||||
item_not_zero_func = (lambda x: x[1] > 0 and x[2] > 0)
|
||||
formatter = (lambda x:u'\u2605'*int(round(x/2.)))
|
||||
elif category == 'authors':
|
||||
@ -733,11 +756,9 @@ class LibraryDatabase2(LibraryDatabase, SchemaUpgrade, CustomColumns):
|
||||
formatter = (lambda x:unicode(x))
|
||||
|
||||
categories[category] = [Tag(formatter(r[1]), count=r[2], id=r[0],
|
||||
icon=icon, tooltip = tooltip)
|
||||
avg=r[3], sort=r[4],
|
||||
icon=icon, tooltip=tooltip)
|
||||
for r in data if item_not_zero_func(r)]
|
||||
if category == 'series' and not sort_on_count:
|
||||
categories[category].sort(cmp=lambda x,y:cmp(title_sort(x.name).lower(),
|
||||
title_sort(y.name).lower()))
|
||||
|
||||
# We delayed computing the standard formats category because it does not
|
||||
# use a view, but is computed dynamically
|
||||
@ -761,11 +782,10 @@ class LibraryDatabase2(LibraryDatabase, SchemaUpgrade, CustomColumns):
|
||||
if count > 0:
|
||||
categories['formats'].append(Tag(fmt, count=count, icon=icon))
|
||||
|
||||
if sort_on_count:
|
||||
categories['formats'].sort(cmp=lambda x,y:cmp(x.count, y.count),
|
||||
reverse=True)
|
||||
else:
|
||||
categories['formats'].sort(cmp=lambda x,y:cmp(x.name, y.name))
|
||||
if sort == 'popularity':
|
||||
categories['formats'].sort(key=lambda x: x.count, reverse=True)
|
||||
else: # no ratings exist to sort on
|
||||
categories['formats'].sort(key = lambda x:x.name)
|
||||
|
||||
#### Now do the user-defined categories. ####
|
||||
user_categories = prefs['user_categories']
|
||||
@ -790,12 +810,15 @@ class LibraryDatabase2(LibraryDatabase, SchemaUpgrade, CustomColumns):
|
||||
# Not a problem if we accumulate entries in the icon map
|
||||
if icon_map is not None:
|
||||
icon_map[cat_name] = icon_map[':user']
|
||||
if sort_on_count:
|
||||
if sort == 'popularity':
|
||||
categories[cat_name] = \
|
||||
sorted(items, cmp=(lambda x, y: cmp(y.count, x.count)))
|
||||
sorted(items, key=lambda x: x.count, reverse=True)
|
||||
elif sort == 'name':
|
||||
categories[cat_name] = \
|
||||
sorted(items, key=lambda x: x.sort.lower())
|
||||
else:
|
||||
categories[cat_name] = \
|
||||
sorted(items, cmp=(lambda x, y: cmp(x.name.lower(), y.name.lower())))
|
||||
sorted(items, key=lambda x:x.avg_rating, reverse=True)
|
||||
|
||||
#### Finally, the saved searches category ####
|
||||
items = []
|
||||
@ -905,6 +928,38 @@ class LibraryDatabase2(LibraryDatabase, SchemaUpgrade, CustomColumns):
|
||||
self.set_path(id, True)
|
||||
self.notify('metadata', [id])
|
||||
|
||||
# Given a book, return the list of author sort strings for the book's authors
|
||||
def authors_sort_strings(self, id, index_is_id=False):
|
||||
id = id if index_is_id else self.id(id)
|
||||
aut_strings = self.conn.get('''
|
||||
SELECT sort
|
||||
FROM authors, books_authors_link as bl
|
||||
WHERE bl.book=? and authors.id=bl.author
|
||||
ORDER BY bl.id''', (id,))
|
||||
result = []
|
||||
for (sort,) in aut_strings:
|
||||
result.append(sort)
|
||||
return result
|
||||
|
||||
# Given a book, return the author_sort string for authors of the book
|
||||
def author_sort_from_book(self, id, index_is_id=False):
|
||||
auts = self.authors_sort_strings(id, index_is_id)
|
||||
return ' & '.join(auts).replace('|', ',')
|
||||
|
||||
# Given a list of authors, return the author_sort string for the authors,
|
||||
# preferring the author sort associated with the author over the computed
|
||||
# string
|
||||
def author_sort_from_authors(self, authors):
|
||||
result = []
|
||||
for aut in authors:
|
||||
r = self.conn.get('SELECT sort FROM authors WHERE name=?',
|
||||
(aut.replace(',', '|'),), all=False)
|
||||
if r is None:
|
||||
result.append(author_to_author_sort(aut))
|
||||
else:
|
||||
result.append(r)
|
||||
return ' & '.join(result).replace('|', ',')
|
||||
|
||||
def set_authors(self, id, authors, notify=True):
|
||||
'''
|
||||
`authors`: A list of authors.
|
||||
@ -931,7 +986,8 @@ class LibraryDatabase2(LibraryDatabase, SchemaUpgrade, CustomColumns):
|
||||
(id, aid))
|
||||
except IntegrityError: # Sometimes books specify the same author twice in their metadata
|
||||
pass
|
||||
ss = authors_to_sort_string(authors)
|
||||
self.conn.commit()
|
||||
ss = self.author_sort_from_book(id, index_is_id=True)
|
||||
self.conn.execute('UPDATE books SET author_sort=? WHERE id=?',
|
||||
(ss, id))
|
||||
self.conn.commit()
|
||||
@ -950,7 +1006,10 @@ class LibraryDatabase2(LibraryDatabase, SchemaUpgrade, CustomColumns):
|
||||
title = title.decode(preferred_encoding, 'replace')
|
||||
self.conn.execute('UPDATE books SET title=? WHERE id=?', (title, id))
|
||||
self.data.set(id, self.FIELD_MAP['title'], title, row_is_id=True)
|
||||
self.data.set(id, self.FIELD_MAP['sort'], title_sort(title), row_is_id=True)
|
||||
if tweaks['title_series_sorting'] == 'library_order':
|
||||
self.data.set(id, self.FIELD_MAP['sort'], title_sort(title), row_is_id=True)
|
||||
else:
|
||||
self.data.set(id, self.FIELD_MAP['sort'], title, row_is_id=True)
|
||||
self.set_path(id, True)
|
||||
self.conn.commit()
|
||||
if notify:
|
||||
@ -999,16 +1058,39 @@ class LibraryDatabase2(LibraryDatabase, SchemaUpgrade, CustomColumns):
|
||||
return []
|
||||
return result
|
||||
|
||||
def rename_tag(self, id, new_name):
|
||||
if id:
|
||||
self.conn.execute('UPDATE tags SET name=? WHERE id=?', (new_name, id))
|
||||
self.conn.commit()
|
||||
def rename_tag(self, old_id, new_name):
|
||||
new_name = new_name.strip()
|
||||
new_id = self.conn.get(
|
||||
'''SELECT id from tags
|
||||
WHERE name=?''', (new_name,), all=False)
|
||||
if new_id is None or old_id == new_id:
|
||||
# easy cases. Simply rename the tag. Do it even if equal, in case
|
||||
# there is a change of case
|
||||
self.conn.execute('''UPDATE tags SET name=?
|
||||
WHERE id=?''', (new_name, old_id))
|
||||
else:
|
||||
# It is possible that by renaming a tag, the tag will appear
|
||||
# twice on a book. This will throw an integrity error, aborting
|
||||
# all the changes. To get around this, we first delete any links
|
||||
# to the new_id from books referencing the old_id, so that
|
||||
# renaming old_id to new_id will be unique on the book
|
||||
books = self.conn.get('''SELECT book from books_tags_link
|
||||
WHERE tag=?''', (old_id,))
|
||||
for (book_id,) in books:
|
||||
self.conn.execute('''DELETE FROM books_tags_link
|
||||
WHERE book=? and tag=?''', (book_id, new_id))
|
||||
|
||||
# Change the link table to point at the new tag
|
||||
self.conn.execute('''UPDATE books_tags_link SET tag=?
|
||||
WHERE tag=?''',(new_id, old_id,))
|
||||
# Get rid of the no-longer used publisher
|
||||
self.conn.execute('DELETE FROM tags WHERE id=?', (old_id,))
|
||||
self.conn.commit()
|
||||
|
||||
def delete_tag_using_id(self, id):
|
||||
if id:
|
||||
self.conn.execute('DELETE FROM books_tags_link WHERE tag=?', (id,))
|
||||
self.conn.execute('DELETE FROM tags WHERE id=?', (id,))
|
||||
self.conn.commit()
|
||||
self.conn.execute('DELETE FROM books_tags_link WHERE tag=?', (id,))
|
||||
self.conn.execute('DELETE FROM tags WHERE id=?', (id,))
|
||||
self.conn.commit()
|
||||
|
||||
def get_series_with_ids(self):
|
||||
result = self.conn.get('SELECT id,name FROM series')
|
||||
@ -1016,19 +1098,44 @@ class LibraryDatabase2(LibraryDatabase, SchemaUpgrade, CustomColumns):
|
||||
return []
|
||||
return result
|
||||
|
||||
def rename_series(self, id, new_name):
|
||||
if id:
|
||||
self.conn.execute('UPDATE series SET name=? WHERE id=?', (new_name, id))
|
||||
self.conn.commit()
|
||||
def rename_series(self, old_id, new_name):
|
||||
new_name = new_name.strip()
|
||||
new_id = self.conn.get(
|
||||
'''SELECT id from series
|
||||
WHERE name=?''', (new_name,), all=False)
|
||||
if new_id is None or old_id == new_id:
|
||||
self.conn.execute('UPDATE series SET name=? WHERE id=?',
|
||||
(new_name, old_id))
|
||||
else:
|
||||
# New series exists. Must update the link, then assign a
|
||||
# new series index to each of the books.
|
||||
|
||||
# Get the list of books where we must update the series index
|
||||
books = self.conn.get('''SELECT books.id
|
||||
FROM books, books_series_link as lt
|
||||
WHERE books.id = lt.book AND lt.series=?
|
||||
ORDER BY books.series_index''', (old_id,))
|
||||
# Get the next series index
|
||||
index = self.get_next_series_num_for(new_name)
|
||||
# Now update the link table
|
||||
self.conn.execute('''UPDATE books_series_link
|
||||
SET series=?
|
||||
WHERE series=?''',(new_id, old_id,))
|
||||
# Now set the indices
|
||||
for (book_id,) in books:
|
||||
self.conn.execute('''UPDATE books
|
||||
SET series_index=?
|
||||
WHERE id=?''',(index, book_id,))
|
||||
index = index + 1
|
||||
self.conn.commit()
|
||||
|
||||
def delete_series_using_id(self, id):
|
||||
if id:
|
||||
books = self.conn.get('SELECT book from books_series_link WHERE series=?', (id,))
|
||||
self.conn.execute('DELETE FROM books_series_link WHERE series=?', (id,))
|
||||
self.conn.execute('DELETE FROM series WHERE id=?', (id,))
|
||||
self.conn.commit()
|
||||
for (book_id,) in books:
|
||||
self.conn.execute('UPDATE books SET series_index=1.0 WHERE id=?', (book_id,))
|
||||
books = self.conn.get('SELECT book from books_series_link WHERE series=?', (id,))
|
||||
self.conn.execute('DELETE FROM books_series_link WHERE series=?', (id,))
|
||||
self.conn.execute('DELETE FROM series WHERE id=?', (id,))
|
||||
self.conn.commit()
|
||||
for (book_id,) in books:
|
||||
self.conn.execute('UPDATE books SET series_index=1.0 WHERE id=?', (book_id,))
|
||||
|
||||
def get_publishers_with_ids(self):
|
||||
result = self.conn.get('SELECT id,name FROM publishers')
|
||||
@ -1036,43 +1143,119 @@ class LibraryDatabase2(LibraryDatabase, SchemaUpgrade, CustomColumns):
|
||||
return []
|
||||
return result
|
||||
|
||||
def rename_publisher(self, id, new_name):
|
||||
if id:
|
||||
self.conn.execute('UPDATE publishers SET name=? WHERE id=?', (new_name, id))
|
||||
self.conn.commit()
|
||||
def rename_publisher(self, old_id, new_name):
|
||||
new_name = new_name.strip()
|
||||
new_id = self.conn.get(
|
||||
'''SELECT id from publishers
|
||||
WHERE name=?''', (new_name,), all=False)
|
||||
if new_id is None or old_id == new_id:
|
||||
# New name doesn't exist. Simply change the old name
|
||||
self.conn.execute('UPDATE publishers SET name=? WHERE id=?', \
|
||||
(new_name, old_id))
|
||||
else:
|
||||
# Change the link table to point at the new one
|
||||
self.conn.execute('''UPDATE books_publishers_link
|
||||
SET publisher=?
|
||||
WHERE publisher=?''',(new_id, old_id,))
|
||||
# Get rid of the no-longer used publisher
|
||||
self.conn.execute('DELETE FROM publishers WHERE id=?', (old_id,))
|
||||
self.conn.commit()
|
||||
|
||||
def delete_publisher_using_id(self, id):
|
||||
if id:
|
||||
self.conn.execute('DELETE FROM books_publishers_link WHERE publisher=?', (id,))
|
||||
self.conn.execute('DELETE FROM publishers WHERE id=?', (id,))
|
||||
self.conn.commit()
|
||||
def delete_publisher_using_id(self, old_id):
|
||||
self.conn.execute('''DELETE FROM books_publishers_link
|
||||
WHERE publisher=?''', (old_id,))
|
||||
self.conn.execute('DELETE FROM publishers WHERE id=?', (old_id,))
|
||||
self.conn.commit()
|
||||
|
||||
# There is no editor for author, so we do not need get_authors_with_ids or
|
||||
# delete_author_using_id.
|
||||
def rename_author(self, id, new_name):
|
||||
if id:
|
||||
# Make sure that any commas in new_name are changed to '|'!
|
||||
new_name = new_name.replace(',', '|')
|
||||
self.conn.execute('UPDATE authors SET name=? WHERE id=?', (new_name, id))
|
||||
self.conn.commit()
|
||||
# now must fix up the books
|
||||
books = self.conn.get('SELECT book from books_authors_link WHERE author=?', (id,))
|
||||
for (book_id,) in books:
|
||||
# First, must refresh the cache to see the new authors
|
||||
self.data.refresh_ids(self, [book_id])
|
||||
# now fix the filesystem paths
|
||||
self.set_path(book_id, index_is_id=True)
|
||||
# Next fix the author sort. Reset it to the default
|
||||
def get_authors_with_ids(self):
|
||||
result = self.conn.get('SELECT id,name,sort FROM authors')
|
||||
if not result:
|
||||
return []
|
||||
return result
|
||||
|
||||
def set_sort_field_for_author(self, old_id, new_sort):
|
||||
self.conn.execute('UPDATE authors SET sort=? WHERE id=?', \
|
||||
(new_sort.strip(), old_id))
|
||||
self.conn.commit()
|
||||
# Now change all the author_sort fields in books by this author
|
||||
bks = self.conn.get('SELECT book from books_authors_link WHERE author=?', (old_id,))
|
||||
for (book_id,) in bks:
|
||||
ss = self.author_sort_from_book(book_id, index_is_id=True)
|
||||
self.set_author_sort(book_id, ss)
|
||||
|
||||
def rename_author(self, old_id, new_name):
|
||||
# Make sure that any commas in new_name are changed to '|'!
|
||||
new_name = new_name.replace(',', '|').strip()
|
||||
|
||||
# Get the list of books we must fix up, one way or the other
|
||||
# Save the list so we can use it twice
|
||||
bks = self.conn.get('SELECT book from books_authors_link WHERE author=?', (old_id,))
|
||||
books = []
|
||||
for (book_id,) in bks:
|
||||
books.append(book_id)
|
||||
|
||||
# check if the new author already exists
|
||||
new_id = self.conn.get('SELECT id from authors WHERE name=?',
|
||||
(new_name,), all=False)
|
||||
if new_id is None or old_id == new_id:
|
||||
# No name clash. Go ahead and update the author's name
|
||||
self.conn.execute('UPDATE authors SET name=? WHERE id=?',
|
||||
(new_name, old_id))
|
||||
else:
|
||||
# First check for the degenerate case -- changing a value to itself.
|
||||
# Update it in case there is a change of case, but do nothing else
|
||||
if old_id == new_id:
|
||||
self.conn.execute('UPDATE authors SET name=? WHERE id=?',
|
||||
(new_name, old_id))
|
||||
self.conn.commit()
|
||||
return new_id
|
||||
# Author exists. To fix this, we must replace all the authors
|
||||
# instead of replacing the one. Reason: db integrity checks can stop
|
||||
# the rename process, which would leave everything half-done. We
|
||||
# can't do it the same way as tags (delete and add) because author
|
||||
# order is important.
|
||||
|
||||
for book_id in books:
|
||||
# Get the existing list of authors
|
||||
authors = self.conn.get('''
|
||||
SELECT authors.name
|
||||
FROM authors, books_authors_link as bl
|
||||
WHERE bl.book = ? and bl.author = authors.id
|
||||
''' , (book_id,))
|
||||
# unpack the double-list structure
|
||||
SELECT author from books_authors_link
|
||||
WHERE book=?
|
||||
ORDER BY id''',(book_id,))
|
||||
|
||||
# unpack the double-list structure, replacing the old author
|
||||
# with the new one while we are at it
|
||||
for i,aut in enumerate(authors):
|
||||
authors[i] = aut[0]
|
||||
ss = authors_to_sort_string(authors)
|
||||
self.conn.execute('UPDATE books SET author_sort=? WHERE id=?', (ss, id))
|
||||
authors[i] = aut[0] if aut[0] != old_id else new_id
|
||||
# Delete the existing authors list
|
||||
self.conn.execute('''DELETE FROM books_authors_link
|
||||
WHERE book=?''',(book_id,))
|
||||
# Change the authors to the new list
|
||||
for aid in authors:
|
||||
try:
|
||||
self.conn.execute('''
|
||||
INSERT INTO books_authors_link(book, author)
|
||||
VALUES (?,?)''', (book_id, aid))
|
||||
except IntegrityError:
|
||||
# Sometimes books specify the same author twice in their
|
||||
# metadata. Ignore it.
|
||||
pass
|
||||
# Now delete the old author from the DB
|
||||
bks = self.conn.get('SELECT book FROM books_authors_link WHERE author=?', (old_id,))
|
||||
self.conn.execute('DELETE FROM authors WHERE id=?', (old_id,))
|
||||
self.conn.commit()
|
||||
# the authors are now changed, either by changing the author's name
|
||||
# or replacing the author in the list. Now must fix up the books.
|
||||
for book_id in books:
|
||||
# First, must refresh the cache to see the new authors
|
||||
self.data.refresh_ids(self, [book_id])
|
||||
# now fix the filesystem paths
|
||||
self.set_path(book_id, index_is_id=True)
|
||||
# Next fix the author sort. Reset it to the default
|
||||
ss = self.author_sort_from_book(book_id, index_is_id=True)
|
||||
self.set_author_sort(book_id, ss)
|
||||
# the caller will do a general refresh, so we don't need to
|
||||
# do one here
|
||||
return new_id
|
||||
|
||||
# end convenience methods
|
||||
|
||||
@ -1175,12 +1358,6 @@ class LibraryDatabase2(LibraryDatabase, SchemaUpgrade, CustomColumns):
|
||||
aid = self.conn.execute('INSERT INTO series(name) VALUES (?)', (series,)).lastrowid
|
||||
self.conn.execute('INSERT INTO books_series_link(book, series) VALUES (?,?)', (id, aid))
|
||||
self.conn.commit()
|
||||
try:
|
||||
row = self.row(id)
|
||||
if row is not None:
|
||||
self.data.set(row, 9, series)
|
||||
except ValueError:
|
||||
pass
|
||||
self.data.set(id, self.FIELD_MAP['series'], series, row_is_id=True)
|
||||
if notify:
|
||||
self.notify('metadata', [id])
|
||||
@ -1313,7 +1490,7 @@ class LibraryDatabase2(LibraryDatabase, SchemaUpgrade, CustomColumns):
|
||||
if not add_duplicates and self.has_book(mi):
|
||||
return None
|
||||
series_index = 1.0 if mi.series_index is None else mi.series_index
|
||||
aus = mi.author_sort if mi.author_sort else ', '.join(mi.authors)
|
||||
aus = mi.author_sort if mi.author_sort else self.author_sort_from_authors(mi.authors)
|
||||
title = mi.title
|
||||
if isinstance(aus, str):
|
||||
aus = aus.decode(preferred_encoding, 'replace')
|
||||
@ -1353,7 +1530,7 @@ class LibraryDatabase2(LibraryDatabase, SchemaUpgrade, CustomColumns):
|
||||
duplicates.append((path, format, mi))
|
||||
continue
|
||||
series_index = 1.0 if mi.series_index is None else mi.series_index
|
||||
aus = mi.author_sort if mi.author_sort else ', '.join(mi.authors)
|
||||
aus = mi.author_sort if mi.author_sort else self.author_sort_from_authors(mi.authors)
|
||||
title = mi.title
|
||||
if isinstance(aus, str):
|
||||
aus = aus.decode(preferred_encoding, 'replace')
|
||||
@ -1392,7 +1569,7 @@ class LibraryDatabase2(LibraryDatabase, SchemaUpgrade, CustomColumns):
|
||||
mi.title = _('Unknown')
|
||||
if not mi.authors:
|
||||
mi.authors = [_('Unknown')]
|
||||
aus = mi.author_sort if mi.author_sort else authors_to_sort_string(mi.authors)
|
||||
aus = mi.author_sort if mi.author_sort else self.author_sort_from_authors(mi.authors)
|
||||
if isinstance(aus, str):
|
||||
aus = aus.decode(preferred_encoding, 'replace')
|
||||
title = mi.title if isinstance(mi.title, unicode) else \
|
||||
@ -1713,6 +1890,8 @@ books_series_link feeds
|
||||
os.remove(self.dbpath)
|
||||
shutil.copyfile(dest, self.dbpath)
|
||||
self.connect()
|
||||
self.field_metadata.remove_dynamic_categories()
|
||||
self.field_metadata.remove_custom_fields()
|
||||
self.initialize_dynamic()
|
||||
self.refresh()
|
||||
if os.path.exists(dest):
|
||||
|
@ -44,9 +44,12 @@ class FieldMetadata(dict):
|
||||
is_category: is a tag browser category. If true, then:
|
||||
table: name of the db table used to construct item list
|
||||
column: name of the column in the normalized table to join on
|
||||
link_column: name of the column in the connection table to join on
|
||||
link_column: name of the column in the connection table to join on. This
|
||||
key should not be present if there is no link table
|
||||
category_sort: the field in the normalized table to sort on. This
|
||||
key must be present if is_category is True
|
||||
If these are None, then the category constructor must know how
|
||||
to build the item list (e.g., formats).
|
||||
to build the item list (e.g., formats, news).
|
||||
The order below is the order that the categories will
|
||||
appear in the tags pane.
|
||||
|
||||
@ -66,6 +69,7 @@ class FieldMetadata(dict):
|
||||
('authors', {'table':'authors',
|
||||
'column':'name',
|
||||
'link_column':'author',
|
||||
'category_sort':'sort',
|
||||
'datatype':'text',
|
||||
'is_multiple':',',
|
||||
'kind':'field',
|
||||
@ -76,6 +80,7 @@ class FieldMetadata(dict):
|
||||
('series', {'table':'series',
|
||||
'column':'name',
|
||||
'link_column':'series',
|
||||
'category_sort':'(title_sort(name))',
|
||||
'datatype':'text',
|
||||
'is_multiple':None,
|
||||
'kind':'field',
|
||||
@ -95,6 +100,7 @@ class FieldMetadata(dict):
|
||||
('publisher', {'table':'publishers',
|
||||
'column':'name',
|
||||
'link_column':'publisher',
|
||||
'category_sort':'name',
|
||||
'datatype':'text',
|
||||
'is_multiple':None,
|
||||
'kind':'field',
|
||||
@ -105,6 +111,7 @@ class FieldMetadata(dict):
|
||||
('rating', {'table':'ratings',
|
||||
'column':'rating',
|
||||
'link_column':'rating',
|
||||
'category_sort':'rating',
|
||||
'datatype':'rating',
|
||||
'is_multiple':None,
|
||||
'kind':'field',
|
||||
@ -114,6 +121,7 @@ class FieldMetadata(dict):
|
||||
'is_category':True}),
|
||||
('news', {'table':'news',
|
||||
'column':'name',
|
||||
'category_sort':'name',
|
||||
'datatype':None,
|
||||
'is_multiple':None,
|
||||
'kind':'category',
|
||||
@ -124,6 +132,7 @@ class FieldMetadata(dict):
|
||||
('tags', {'table':'tags',
|
||||
'column':'name',
|
||||
'link_column': 'tag',
|
||||
'category_sort':'name',
|
||||
'datatype':'text',
|
||||
'is_multiple':',',
|
||||
'kind':'field',
|
||||
@ -374,11 +383,22 @@ class FieldMetadata(dict):
|
||||
'search_terms':[key], 'label':label,
|
||||
'colnum':colnum, 'display':display,
|
||||
'is_custom':True, 'is_category':is_category,
|
||||
'link_column':'value',
|
||||
'link_column':'value','category_sort':'value',
|
||||
'is_editable': is_editable,}
|
||||
self._add_search_terms_to_map(key, [key])
|
||||
self.custom_label_to_key_map[label] = key
|
||||
|
||||
def remove_custom_fields(self):
|
||||
for key in self.get_custom_fields():
|
||||
del self._tb_cats[key]
|
||||
|
||||
def remove_dynamic_categories(self):
|
||||
for key in list(self._tb_cats.keys()):
|
||||
val = self._tb_cats[key]
|
||||
if val['is_category'] and val['kind'] in ('user', 'search'):
|
||||
del self._tb_cats[key]
|
||||
|
||||
|
||||
def add_user_category(self, label, name):
|
||||
if label in self._tb_cats:
|
||||
raise ValueError('Duplicate user field [%s]'%(label))
|
||||
|
@ -291,4 +291,122 @@ class SchemaUpgrade(object):
|
||||
|
||||
for field in self.field_metadata.itervalues():
|
||||
if field['is_category'] and not field['is_custom'] and 'link_column' in field:
|
||||
create_tag_browser_view(field['table'], field['link_column'], field['column'])
|
||||
table = self.conn.get(
|
||||
'SELECT name FROM sqlite_master WHERE type="table" AND name=?',
|
||||
('books_%s_link'%field['table'],), all=False)
|
||||
if table is not None:
|
||||
create_tag_browser_view(field['table'], field['link_column'], field['column'])
|
||||
|
||||
def upgrade_version_11(self):
|
||||
'Add average rating to tag browser views'
|
||||
def create_std_tag_browser_view(table_name, column_name,
|
||||
view_column_name, sort_column_name):
|
||||
script = ('''
|
||||
DROP VIEW IF EXISTS tag_browser_{tn};
|
||||
CREATE VIEW tag_browser_{tn} AS SELECT
|
||||
id,
|
||||
{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 {tn};
|
||||
DROP VIEW IF EXISTS tag_browser_filtered_{tn};
|
||||
CREATE VIEW tag_browser_filtered_{tn} AS SELECT
|
||||
id,
|
||||
{vcn},
|
||||
(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
|
||||
books_list_filter(bl.book)) avg_rating,
|
||||
{scn} AS sort
|
||||
FROM {tn};
|
||||
|
||||
'''.format(tn=table_name, cn=column_name,
|
||||
vcn=view_column_name, scn= sort_column_name))
|
||||
self.conn.executescript(script)
|
||||
|
||||
def create_cust_tag_browser_view(table_name, link_table_name):
|
||||
script = '''
|
||||
DROP VIEW IF EXISTS tag_browser_{table};
|
||||
CREATE VIEW tag_browser_{table} AS SELECT
|
||||
id,
|
||||
value,
|
||||
(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
|
||||
FROM {table};
|
||||
|
||||
DROP VIEW IF EXISTS tag_browser_filtered_{table};
|
||||
CREATE VIEW tag_browser_filtered_{table} AS SELECT
|
||||
id,
|
||||
value,
|
||||
(SELECT COUNT({lt}.id) FROM {lt} WHERE value={table}.id AND
|
||||
books_list_filter(book)) 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 AND
|
||||
books_list_filter(bl.book)) avg_rating,
|
||||
value AS sort
|
||||
FROM {table};
|
||||
'''.format(lt=link_table_name, table=table_name)
|
||||
self.conn.executescript(script)
|
||||
|
||||
for field in self.field_metadata.itervalues():
|
||||
if field['is_category'] and not field['is_custom'] and 'link_column' in field:
|
||||
table = self.conn.get(
|
||||
'SELECT name FROM sqlite_master WHERE type="table" AND name=?',
|
||||
('books_%s_link'%field['table'],), all=False)
|
||||
if table is not None:
|
||||
create_std_tag_browser_view(field['table'], field['link_column'],
|
||||
field['column'], field['category_sort'])
|
||||
|
||||
db_tables = self.conn.get('''SELECT name FROM sqlite_master
|
||||
WHERE type='table'
|
||||
ORDER BY name''');
|
||||
tables = []
|
||||
for (table,) in db_tables:
|
||||
tables.append(table)
|
||||
for table in tables:
|
||||
link_table = 'books_%s_link'%table
|
||||
if table.startswith('custom_column_') and link_table in tables:
|
||||
create_cust_tag_browser_view(table, link_table)
|
||||
|
||||
from calibre.ebooks.metadata import author_to_author_sort
|
||||
|
||||
aut = self.conn.get('SELECT id, name FROM authors');
|
||||
records = []
|
||||
for (id, author) in aut:
|
||||
records.append((id, author.replace('|', ',')))
|
||||
for id,author in records:
|
||||
self.conn.execute('UPDATE authors SET sort=? WHERE id=?',
|
||||
(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;
|
||||
END;
|
||||
''')
|
||||
|
@ -60,6 +60,7 @@ class ContentServer(object):
|
||||
items.sort(cmp=self.seriescmp, reverse=not order)
|
||||
else:
|
||||
lookup = 'sort' if field == 'title' else field
|
||||
lookup = 'author_sort' if field == 'authors' else field
|
||||
field = self.db.FIELD_MAP[lookup]
|
||||
getter = operator.itemgetter(field)
|
||||
items.sort(cmp=lambda x, y: cmpf(getter(x), getter(y)), reverse=not order)
|
||||
|
@ -99,17 +99,20 @@ def html_to_lxml(raw):
|
||||
raw = etree.tostring(root, encoding=None)
|
||||
return etree.fromstring(raw)
|
||||
|
||||
def CATALOG_ENTRY(item, base_href, version, updated):
|
||||
def CATALOG_ENTRY(item, base_href, version, updated, ignore_count=False):
|
||||
id_ = 'calibre:category:'+item.name
|
||||
iid = 'N' + item.name
|
||||
if item.id is not None:
|
||||
iid = 'I' + str(item.id)
|
||||
link = NAVLINK(href = base_href + '/' + hexlify(iid))
|
||||
count = _('%d books')%item.count
|
||||
if ignore_count:
|
||||
count = ''
|
||||
return E.entry(
|
||||
TITLE(item.name),
|
||||
ID(id_),
|
||||
UPDATED(updated),
|
||||
E.content(_('%d books')%item.count, type='text'),
|
||||
E.content(count, type='text'),
|
||||
link
|
||||
)
|
||||
|
||||
@ -265,8 +268,12 @@ class CategoryFeed(NavFeed):
|
||||
def __init__(self, items, which, id_, updated, version, offsets, page_url, up_url):
|
||||
NavFeed.__init__(self, id_, updated, version, offsets, page_url, up_url)
|
||||
base_href = self.base_href + '/category/' + hexlify(which)
|
||||
ignore_count = False
|
||||
if which == 'search':
|
||||
ignore_count = True
|
||||
for item in items:
|
||||
self.root.append(CATALOG_ENTRY(item, base_href, version, updated))
|
||||
self.root.append(CATALOG_ENTRY(item, base_href, version, updated,
|
||||
ignore_count=ignore_count))
|
||||
|
||||
class CategoryGroupFeed(NavFeed):
|
||||
|
||||
@ -393,7 +400,7 @@ class OPDSServer(object):
|
||||
owhich = hexlify('N'+which)
|
||||
up_url = url_for('opdsnavcatalog', version, which=owhich)
|
||||
items = categories[category]
|
||||
items = [x for x in items if x.name.startswith(which)]
|
||||
items = [x for x in items if getattr(x, 'sort', x.name).startswith(which)]
|
||||
if not items:
|
||||
raise cherrypy.HTTPError(404, 'No items in group %r:%r'%(category,
|
||||
which))
|
||||
@ -458,11 +465,11 @@ class OPDSServer(object):
|
||||
def __init__(self, text, count):
|
||||
self.text, self.count = text, count
|
||||
|
||||
starts = set([x.name[0] for x in items])
|
||||
starts = set([getattr(x, 'sort', x.name)[0] for x in items])
|
||||
category_groups = OrderedDict()
|
||||
for x in sorted(starts, cmp=lambda x,y:cmp(x.lower(), y.lower())):
|
||||
category_groups[x] = len([y for y in items if
|
||||
y.name.startswith(x)])
|
||||
getattr(y, 'sort', y.name).startswith(x)])
|
||||
items = [Group(x, y) for x, y in category_groups.items()]
|
||||
max_items = self.opts.max_opds_items
|
||||
offsets = OPDSOffsets(offset, max_items, len(items))
|
||||
|
@ -14,7 +14,8 @@ from Queue import Queue
|
||||
from threading import RLock
|
||||
from datetime import datetime
|
||||
|
||||
from calibre.ebooks.metadata import title_sort
|
||||
from calibre.ebooks.metadata import title_sort, author_to_author_sort
|
||||
from calibre.utils.config import tweaks
|
||||
from calibre.utils.date import parse_date, isoformat
|
||||
|
||||
global_lock = RLock()
|
||||
@ -115,7 +116,12 @@ class DBThread(Thread):
|
||||
self.conn.create_aggregate('concat', 1, Concatenate)
|
||||
self.conn.create_aggregate('sortconcat', 2, SortedConcatenate)
|
||||
self.conn.create_aggregate('sort_concat', 2, SafeSortedConcatenate)
|
||||
self.conn.create_function('title_sort', 1, title_sort)
|
||||
if tweaks['title_series_sorting'] == 'strictly_alphabetic':
|
||||
self.conn.create_function('title_sort', 1, lambda x:x)
|
||||
else:
|
||||
self.conn.create_function('title_sort', 1, title_sort)
|
||||
self.conn.create_function('author_to_author_sort', 1,
|
||||
lambda x: author_to_author_sort(x.replace('|', ',')))
|
||||
self.conn.create_function('uuid4', 0, lambda : str(uuid.uuid4()))
|
||||
# Dummy functions for dynamically created filters
|
||||
self.conn.create_function('books_list_filter', 1, lambda x: 1)
|
||||
|
@ -411,7 +411,8 @@ def options(option_parser):
|
||||
def opts_and_words(name, op, words):
|
||||
opts = '|'.join(options(op))
|
||||
words = '|'.join([w.replace("'", "\\'") for w in words])
|
||||
return ('_'+name+'()'+\
|
||||
fname = name.replace('-', '_')
|
||||
return ('_'+fname+'()'+\
|
||||
'''
|
||||
{
|
||||
local cur opts
|
||||
@ -435,7 +436,7 @@ def opts_and_words(name, op, words):
|
||||
esac
|
||||
|
||||
}
|
||||
complete -F _'''%(opts, words) + name + ' ' + name +"\n\n").encode('utf-8')
|
||||
complete -F _'''%(opts, words) + fname + ' ' + name +"\n\n").encode('utf-8')
|
||||
|
||||
|
||||
def opts_and_exts(name, op, exts):
|
||||
|
@ -19,12 +19,20 @@ use *plugins* to add funtionality to |app|.
|
||||
Environment variables
|
||||
-----------------------
|
||||
|
||||
* ``CALIBRE_CONFIG_DIRECTORY``
|
||||
* ``CALIBRE_OVERRIDE_DATABASE_PATH``
|
||||
* ``CALIBRE_DEVELOP_FROM``
|
||||
* ``CALIBRE_OVERRIDE_LANG``
|
||||
* ``SYSFS_PATH``
|
||||
* ``http_proxy``
|
||||
* ``CALIBRE_CONFIG_DIRECTORY`` - sets the directory where configuration files are stored/read.
|
||||
* ``CALIBRE_OVERRIDE_DATABASE_PATH`` - allows you to specify the full path to metadata.db. Using this variable you can have metadata.db be in a location other than the library folder. Useful if your library folder is on a networked drive that does not support file locking.
|
||||
* ``CALIBRE_DEVELOP_FROM`` - Used to run from a calibre development environment. See :ref:`develop`.
|
||||
* ``CALIBRE_OVERRIDE_LANG`` - Used to force the language used by the interface (ISO 639 language code)
|
||||
* ``SYSFS_PATH`` - Use if sysfs is mounted somewhere other than /sys
|
||||
* ``http_proxy`` - Used on linux to specify an HTTP proxy
|
||||
|
||||
Tweaks
|
||||
------------
|
||||
|
||||
Tweaks are small changes that you can specify to control various aspects of |app|'s behavior. You specify them by editing the 2tweaks.py file in the config directory.
|
||||
The default tweaks.py file is reproduced below
|
||||
|
||||
.. literalinclude:: ../../../resources/default_tweaks.py
|
||||
|
||||
|
||||
A Hello World plugin
|
||||
|
@ -159,7 +159,8 @@ Alternative for the iPad
|
||||
|
||||
As of |app| version 0.7.0, you can plugin your iPad into the computer using its charging cable, and |app| will detect it and show you a list of books on the iPad. You can then use the Send to device button to send books directly to iBooks on the iPad.
|
||||
|
||||
This method only works on Windows XP and higher and OS X 10.5 and higher. Linux is not supported (iTunes is not available in linux) and OS X 10.4 is not supported.
|
||||
This method only works on Windows XP and higher and OS X 10.5 and higher. Linux is not supported (iTunes is not available in linux) and OS X 10.4 is not supported. For more details, see
|
||||
`this forum post http://www.mobileread.com/forums/showpost.php?p=944079&postcount=1`_.
|
||||
|
||||
How do I use |app| with my Android phone?
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
@ -111,7 +111,7 @@ Pre/post processing of downloaded HTML
|
||||
|
||||
.. automember:: BasicNewsRecipe.remove_javascript
|
||||
|
||||
.. automethod:: BasicNewsRecipe.prepreprocess_html
|
||||
.. automethod:: BasicNewsRecipe.skip_ad_pages
|
||||
|
||||
.. automethod:: BasicNewsRecipe.preprocess_html
|
||||
|
||||
|