mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Get rid of more xrange
This commit is contained in:
parent
2d4127f7b9
commit
b4e467ea18
@ -11,12 +11,13 @@ from uuid import uuid4
|
|||||||
|
|
||||||
from calibre.ebooks.oeb.base import OEB_STYLES
|
from calibre.ebooks.oeb.base import OEB_STYLES
|
||||||
from calibre.ebooks.oeb.transforms.subset import find_font_face_rules
|
from calibre.ebooks.oeb.transforms.subset import find_font_face_rules
|
||||||
|
from polyglot.builtins import range
|
||||||
|
|
||||||
|
|
||||||
def obfuscate_font_data(data, key):
|
def obfuscate_font_data(data, key):
|
||||||
prefix = bytearray(data[:32])
|
prefix = bytearray(data[:32])
|
||||||
key = bytearray(reversed(key.bytes))
|
key = bytearray(reversed(key.bytes))
|
||||||
prefix = bytes(bytearray(prefix[i]^key[i % len(key)] for i in xrange(len(prefix))))
|
prefix = bytes(bytearray(prefix[i]^key[i % len(key)] for i in range(len(prefix))))
|
||||||
return prefix + data[32:]
|
return prefix + data[32:]
|
||||||
|
|
||||||
|
|
||||||
|
@ -10,6 +10,7 @@ from collections import namedtuple
|
|||||||
|
|
||||||
from calibre.ebooks.docx.writer.utils import convert_color
|
from calibre.ebooks.docx.writer.utils import convert_color
|
||||||
from calibre.ebooks.docx.writer.styles import read_css_block_borders as rcbb, border_edges
|
from calibre.ebooks.docx.writer.styles import read_css_block_borders as rcbb, border_edges
|
||||||
|
from polyglot.builtins import range
|
||||||
|
|
||||||
|
|
||||||
class Dummy(object):
|
class Dummy(object):
|
||||||
@ -309,7 +310,7 @@ class Table(object):
|
|||||||
for cell in tuple(row.cells):
|
for cell in tuple(row.cells):
|
||||||
idx = row.cells.index(cell)
|
idx = row.cells.index(cell)
|
||||||
if cell.col_span > 1 and (cell is row.cells[-1] or not isinstance(row.cells[idx+1], SpannedCell)):
|
if cell.col_span > 1 and (cell is row.cells[-1] or not isinstance(row.cells[idx+1], SpannedCell)):
|
||||||
row.cells[idx:idx+1] = [cell] + [SpannedCell(cell, horizontal=True) for i in xrange(1, cell.col_span)]
|
row.cells[idx:idx+1] = [cell] + [SpannedCell(cell, horizontal=True) for i in range(1, cell.col_span)]
|
||||||
|
|
||||||
# Expand vertically
|
# Expand vertically
|
||||||
for r, row in enumerate(self.rows):
|
for r, row in enumerate(self.rows):
|
||||||
@ -322,7 +323,7 @@ class Table(object):
|
|||||||
except Exception:
|
except Exception:
|
||||||
tcell = None
|
tcell = None
|
||||||
if tcell is None:
|
if tcell is None:
|
||||||
nrow.cells.extend([SpannedCell(nrow.cells[-1], horizontal=True) for i in xrange(idx - len(nrow.cells))])
|
nrow.cells.extend([SpannedCell(nrow.cells[-1], horizontal=True) for i in range(idx - len(nrow.cells))])
|
||||||
nrow.cells.append(sc)
|
nrow.cells.append(sc)
|
||||||
else:
|
else:
|
||||||
if isinstance(tcell, SpannedCell):
|
if isinstance(tcell, SpannedCell):
|
||||||
|
@ -7,7 +7,7 @@ from calibre.ebooks.lrf.fonts import get_font
|
|||||||
from calibre.ebooks.lrf.pylrs.pylrs import TextBlock, Text, CR, Span, \
|
from calibre.ebooks.lrf.pylrs.pylrs import TextBlock, Text, CR, Span, \
|
||||||
CharButton, Plot, Paragraph, \
|
CharButton, Plot, Paragraph, \
|
||||||
LrsTextTag
|
LrsTextTag
|
||||||
from polyglot.builtins import string_or_bytes
|
from polyglot.builtins import string_or_bytes, range
|
||||||
|
|
||||||
|
|
||||||
def ceil(num):
|
def ceil(num):
|
||||||
@ -315,7 +315,7 @@ class Table(object):
|
|||||||
Return widths of columns + self.colpad
|
Return widths of columns + self.colpad
|
||||||
'''
|
'''
|
||||||
rows, cols = self.number_or_rows(), self.number_of_columns()
|
rows, cols = self.number_or_rows(), self.number_of_columns()
|
||||||
widths = range(cols)
|
widths = list(range(cols))
|
||||||
for c in range(cols):
|
for c in range(cols):
|
||||||
cellwidths = [0 for i in range(rows)]
|
cellwidths = [0 for i in range(rows)]
|
||||||
for r in range(rows):
|
for r in range(rows):
|
||||||
@ -325,8 +325,8 @@ class Table(object):
|
|||||||
continue
|
continue
|
||||||
widths[c] = max(cellwidths)
|
widths[c] = max(cellwidths)
|
||||||
|
|
||||||
min_widths = [self.minimum_width(i)+10 for i in xrange(cols)]
|
min_widths = [self.minimum_width(i)+10 for i in range(cols)]
|
||||||
for i in xrange(len(widths)):
|
for i in range(len(widths)):
|
||||||
wp = self.width_percent(i)
|
wp = self.width_percent(i)
|
||||||
if wp >= 0.:
|
if wp >= 0.:
|
||||||
widths[i] = max(min_widths[i], ceil((wp/100.) * (maxwidth - (cols-1)*self.colpad)))
|
widths[i] = max(min_widths[i], ceil((wp/100.) * (maxwidth - (cols-1)*self.colpad)))
|
||||||
|
@ -5,6 +5,7 @@ __copyright__ = '2009, John Schember <john@nachtimwald.com>'
|
|||||||
__docformat__ = 'restructuredtext en'
|
__docformat__ = 'restructuredtext en'
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
from polyglot.builtins import range
|
||||||
|
|
||||||
|
|
||||||
class EreaderError(Exception):
|
class EreaderError(Exception):
|
||||||
@ -21,10 +22,9 @@ def image_name(name, taken_names=[]):
|
|||||||
name = '%s%s.png' % (names, namee)
|
name = '%s%s.png' % (names, namee)
|
||||||
|
|
||||||
while name in taken_names:
|
while name in taken_names:
|
||||||
for i in xrange(999999999999999999999999999):
|
for i in range(999999999999999999999999999):
|
||||||
name = '%s%s.png' % (name[:-len('%s' % i)], i)
|
name = '%s%s.png' % (name[:-len('%s' % i)], i)
|
||||||
|
|
||||||
name = name.ljust(32, '\x00')[:32]
|
name = name.ljust(32, '\x00')[:32]
|
||||||
|
|
||||||
return name
|
return name
|
||||||
|
|
||||||
|
@ -11,6 +11,7 @@ __docformat__ = 'restructuredtext en'
|
|||||||
|
|
||||||
from calibre.ebooks.pdb.formatreader import FormatReader
|
from calibre.ebooks.pdb.formatreader import FormatReader
|
||||||
from calibre.ptempfile import PersistentTemporaryFile
|
from calibre.ptempfile import PersistentTemporaryFile
|
||||||
|
from polyglot.builtins import range
|
||||||
|
|
||||||
|
|
||||||
class Reader(FormatReader):
|
class Reader(FormatReader):
|
||||||
@ -27,7 +28,7 @@ class Reader(FormatReader):
|
|||||||
pdf = PersistentTemporaryFile('.pdf')
|
pdf = PersistentTemporaryFile('.pdf')
|
||||||
pdf.close()
|
pdf.close()
|
||||||
pdf = open(pdf, 'wb')
|
pdf = open(pdf, 'wb')
|
||||||
for x in xrange(self.header.section_count()):
|
for x in range(self.header.section_count()):
|
||||||
pdf.write(self.header.section_data(x))
|
pdf.write(self.header.section_data(x))
|
||||||
pdf.close()
|
pdf.close()
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@ from calibre.ebooks.pdb.formatreader import FormatReader
|
|||||||
from calibre.ebooks.compression.palmdoc import decompress_doc
|
from calibre.ebooks.compression.palmdoc import decompress_doc
|
||||||
from calibre.utils.imghdr import identify
|
from calibre.utils.imghdr import identify
|
||||||
from calibre.utils.img import save_cover_data_to, Canvas, image_from_data
|
from calibre.utils.img import save_cover_data_to, Canvas, image_from_data
|
||||||
from polyglot.builtins import codepoint_to_chr
|
from polyglot.builtins import codepoint_to_chr, range
|
||||||
|
|
||||||
DATATYPE_PHTML = 0
|
DATATYPE_PHTML = 0
|
||||||
DATATYPE_PHTML_COMPRESSED = 1
|
DATATYPE_PHTML_COMPRESSED = 1
|
||||||
@ -129,7 +129,7 @@ class HeaderRecord(object):
|
|||||||
self.home_html = None
|
self.home_html = None
|
||||||
|
|
||||||
self.reserved = {}
|
self.reserved = {}
|
||||||
for i in xrange(self.records):
|
for i in range(self.records):
|
||||||
adv = 4*i
|
adv = 4*i
|
||||||
name, = struct.unpack('>H', raw[6+adv:8+adv])
|
name, = struct.unpack('>H', raw[6+adv:8+adv])
|
||||||
id, = struct.unpack('>H', raw[8+adv:10+adv])
|
id, = struct.unpack('>H', raw[8+adv:10+adv])
|
||||||
@ -166,7 +166,7 @@ class SectionHeaderText(object):
|
|||||||
# Paragraph attributes.
|
# Paragraph attributes.
|
||||||
self.attributes = []
|
self.attributes = []
|
||||||
|
|
||||||
for i in xrange(section_header.paragraphs):
|
for i in range(section_header.paragraphs):
|
||||||
adv = 4*i
|
adv = 4*i
|
||||||
self.sizes.append(struct.unpack('>H', raw[adv:2+adv])[0])
|
self.sizes.append(struct.unpack('>H', raw[adv:2+adv])[0])
|
||||||
self.attributes.append(struct.unpack('>H', raw[2+adv:4+adv])[0])
|
self.attributes.append(struct.unpack('>H', raw[2+adv:4+adv])[0])
|
||||||
@ -200,7 +200,7 @@ class SectionMetadata(object):
|
|||||||
record_count, = struct.unpack('>H', raw[0:2])
|
record_count, = struct.unpack('>H', raw[0:2])
|
||||||
|
|
||||||
adv = 0
|
adv = 0
|
||||||
for i in xrange(record_count):
|
for i in range(record_count):
|
||||||
try:
|
try:
|
||||||
type, length = struct.unpack_from('>HH', raw, 2 + adv)
|
type, length = struct.unpack_from('>HH', raw, 2 + adv)
|
||||||
except struct.error:
|
except struct.error:
|
||||||
@ -213,7 +213,7 @@ class SectionMetadata(object):
|
|||||||
# ExceptionalCharSets
|
# ExceptionalCharSets
|
||||||
elif type == 2:
|
elif type == 2:
|
||||||
ii_adv = 0
|
ii_adv = 0
|
||||||
for ii in xrange(length / 2):
|
for ii in range(length / 2):
|
||||||
uid, = struct.unpack('>H', raw[6+adv+ii_adv:8+adv+ii_adv])
|
uid, = struct.unpack('>H', raw[6+adv+ii_adv:8+adv+ii_adv])
|
||||||
mib, = struct.unpack('>H', raw[8+adv+ii_adv:10+adv+ii_adv])
|
mib, = struct.unpack('>H', raw[8+adv+ii_adv:10+adv+ii_adv])
|
||||||
self.exceptional_uid_encodings[uid] = MIBNUM_TO_NAME.get(mib, 'latin-1')
|
self.exceptional_uid_encodings[uid] = MIBNUM_TO_NAME.get(mib, 'latin-1')
|
||||||
@ -270,9 +270,9 @@ class SectionCompositeImage(object):
|
|||||||
# to an image record.
|
# to an image record.
|
||||||
self.layout = []
|
self.layout = []
|
||||||
offset = 4
|
offset = 4
|
||||||
for i in xrange(self.rows):
|
for i in range(self.rows):
|
||||||
col = []
|
col = []
|
||||||
for j in xrange(self.columns):
|
for j in range(self.columns):
|
||||||
col.append(struct.unpack('>H', raw[offset:offset+2])[0])
|
col.append(struct.unpack('>H', raw[offset:offset+2])[0])
|
||||||
offset += 2
|
offset += 2
|
||||||
self.layout.append(col)
|
self.layout.append(col)
|
||||||
|
@ -8,7 +8,7 @@ __copyright__ = '2013, Kovid Goyal <kovid at kovidgoyal.net>'
|
|||||||
__docformat__ = 'restructuredtext en'
|
__docformat__ = 'restructuredtext en'
|
||||||
|
|
||||||
import sys, copy
|
import sys, copy
|
||||||
from polyglot.builtins import map
|
from polyglot.builtins import map, range
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
|
||||||
from PyQt5.Qt import QLinearGradient, QPointF
|
from PyQt5.Qt import QLinearGradient, QPointF
|
||||||
@ -111,7 +111,7 @@ class LinearGradientPattern(Dictionary):
|
|||||||
do_reflect = spread == gradient.ReflectSpread
|
do_reflect = spread == gradient.ReflectSpread
|
||||||
totl = abs(stops[-1][0] - stops[0][0])
|
totl = abs(stops[-1][0] - stops[0][0])
|
||||||
intervals = [abs(stops[i+1][0] - stops[i][0])/totl
|
intervals = [abs(stops[i+1][0] - stops[i][0])/totl
|
||||||
for i in xrange(len(stops)-1)]
|
for i in range(len(stops)-1)]
|
||||||
|
|
||||||
while in_page(llimit):
|
while in_page(llimit):
|
||||||
reflect ^= True
|
reflect ^= True
|
||||||
@ -139,14 +139,14 @@ class LinearGradientPattern(Dictionary):
|
|||||||
intervals = [i*rlen for i in intervals]
|
intervals = [i*rlen for i in intervals]
|
||||||
rintervals = list(reversed(intervals))
|
rintervals = list(reversed(intervals))
|
||||||
|
|
||||||
for i in xrange(num):
|
for i in range(num):
|
||||||
reflect ^= True
|
reflect ^= True
|
||||||
pos = i * len(base_stops)
|
pos = i * len(base_stops)
|
||||||
tvals = [t]
|
tvals = [t]
|
||||||
for ival in (rintervals if reflect and do_reflect else
|
for ival in (rintervals if reflect and do_reflect else
|
||||||
intervals):
|
intervals):
|
||||||
tvals.append(tvals[-1] + ival)
|
tvals.append(tvals[-1] + ival)
|
||||||
for j in xrange(len(base_stops)):
|
for j in range(len(base_stops)):
|
||||||
stops[pos+j][0] = tvals[j]
|
stops[pos+j][0] = tvals[j]
|
||||||
t = tvals[-1]
|
t = tvals[-1]
|
||||||
|
|
||||||
|
@ -15,6 +15,7 @@ from PyQt5.Qt import (QBrush, QColor, QPoint, QPixmap, QPainterPath, QRectF,
|
|||||||
QBrush, QColor, QPoint, QPixmap, QPainterPath, QRectF, Qt, QPointF
|
QBrush, QColor, QPoint, QPixmap, QPainterPath, QRectF, Qt, QPointF
|
||||||
|
|
||||||
from calibre.ebooks.pdf.render.engine import PdfDevice
|
from calibre.ebooks.pdf.render.engine import PdfDevice
|
||||||
|
from polyglot.builtins import range
|
||||||
|
|
||||||
|
|
||||||
def full(p, xmax, ymax):
|
def full(p, xmax, ymax):
|
||||||
@ -25,7 +26,7 @@ def full(p, xmax, ymax):
|
|||||||
pp.addRect(0, 0, xmax, ymax)
|
pp.addRect(0, 0, xmax, ymax)
|
||||||
p.drawPath(pp)
|
p.drawPath(pp)
|
||||||
p.save()
|
p.save()
|
||||||
for i in xrange(3):
|
for i in range(3):
|
||||||
col = [0, 0, 0, 200]
|
col = [0, 0, 0, 200]
|
||||||
col[i] = 255
|
col[i] = 255
|
||||||
p.setOpacity(0.3)
|
p.setOpacity(0.3)
|
||||||
|
@ -10,6 +10,7 @@ import os
|
|||||||
|
|
||||||
from lxml.html import tostring
|
from lxml.html import tostring
|
||||||
from lxml.html.builder import (HTML, HEAD, BODY, TABLE, TR, TD, H2, STYLE)
|
from lxml.html.builder import (HTML, HEAD, BODY, TABLE, TR, TD, H2, STYLE)
|
||||||
|
from polyglot.builtins import range
|
||||||
|
|
||||||
|
|
||||||
def calculate_page_number(num, map_expression, evaljs):
|
def calculate_page_number(num, map_expression, evaljs):
|
||||||
@ -49,7 +50,7 @@ def process_children(toc, table, level, pdf, pdf_page_number_map, evaljs):
|
|||||||
def toc_as_html(toc, pdf, opts, evaljs):
|
def toc_as_html(toc, pdf, opts, evaljs):
|
||||||
pdf = pdf.engine.pdf
|
pdf = pdf.engine.pdf
|
||||||
indents = []
|
indents = []
|
||||||
for i in xrange(1, 7):
|
for i in range(1, 7):
|
||||||
indents.extend((i, 1.4*i))
|
indents.extend((i, 1.4*i))
|
||||||
html = HTML(
|
html = HTML(
|
||||||
HEAD(
|
HEAD(
|
||||||
|
@ -21,6 +21,8 @@
|
|||||||
# *
|
# *
|
||||||
# */
|
# */
|
||||||
|
|
||||||
|
from polyglot.builtins import range
|
||||||
|
|
||||||
|
|
||||||
class H2a (object):
|
class H2a (object):
|
||||||
|
|
||||||
@ -79,7 +81,7 @@ class H2a (object):
|
|||||||
u"\u3063\u3058\u3085":"jju", u"\u3063\u3058\u3087":"jjo",
|
u"\u3063\u3058\u3085":"jju", u"\u3063\u3058\u3087":"jjo",
|
||||||
u"\u3063\u3059":"ssu", u"\u3063\u305a":"zzu",
|
u"\u3063\u3059":"ssu", u"\u3063\u305a":"zzu",
|
||||||
u"\u3063\u305b":"sse", u"\u3063\u305e":"zze",
|
u"\u3063\u305b":"sse", u"\u3063\u305e":"zze",
|
||||||
u"\u3063\u305d":"sso", u"\u3063\u305e":"zzo",
|
u"\u3063\u305d":"sso", u"\u3063\u305c":"zzo",
|
||||||
u"\u3063\u305f":"tta", u"\u3063\u3060":"dda",
|
u"\u3063\u305f":"tta", u"\u3063\u3060":"dda",
|
||||||
u"\u3063\u3061":"tchi", u"\u3063\u3061\u3083":"tcha",
|
u"\u3063\u3061":"tchi", u"\u3063\u3061\u3083":"tcha",
|
||||||
u"\u3063\u3061\u3085":"tchu", u"\u3063\u3061\u3087":"tcho",
|
u"\u3063\u3061\u3085":"tchu", u"\u3063\u3061\u3087":"tcho",
|
||||||
@ -173,10 +175,9 @@ class H2a (object):
|
|||||||
Hstr = ""
|
Hstr = ""
|
||||||
max_len = -1
|
max_len = -1
|
||||||
r = min(4, len(text)+1)
|
r = min(4, len(text)+1)
|
||||||
for x in xrange(r):
|
for x in range(r):
|
||||||
if text[:x] in self.H2a_table:
|
if text[:x] in self.H2a_table:
|
||||||
if max_len < x:
|
if max_len < x:
|
||||||
max_len = x
|
max_len = x
|
||||||
Hstr = self.H2a_table[text[:x]]
|
Hstr = self.H2a_table[text[:x]]
|
||||||
return (Hstr, max_len)
|
return (Hstr, max_len)
|
||||||
|
|
||||||
|
@ -22,6 +22,7 @@
|
|||||||
# */
|
# */
|
||||||
|
|
||||||
from calibre.ebooks.unihandecode.pykakasi.jisyo import jisyo
|
from calibre.ebooks.unihandecode.pykakasi.jisyo import jisyo
|
||||||
|
from polyglot.builtins import range
|
||||||
|
|
||||||
|
|
||||||
class K2a (object):
|
class K2a (object):
|
||||||
@ -38,10 +39,9 @@ class K2a (object):
|
|||||||
Hstr = ""
|
Hstr = ""
|
||||||
max_len = -1
|
max_len = -1
|
||||||
r = min(10, len(text)+1)
|
r = min(10, len(text)+1)
|
||||||
for x in xrange(r):
|
for x in range(r):
|
||||||
if text[:x] in self.kanwa.kanadict:
|
if text[:x] in self.kanwa.kanadict:
|
||||||
if max_len < x:
|
if max_len < x:
|
||||||
max_len = x
|
max_len = x
|
||||||
Hstr = self.kanwa.kanadict[text[:x]]
|
Hstr = self.kanwa.kanadict[text[:x]]
|
||||||
return (Hstr, max_len)
|
return (Hstr, max_len)
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@ from calibre.gui2.actions import InterfaceAction
|
|||||||
from calibre.gui2 import question_dialog
|
from calibre.gui2 import question_dialog
|
||||||
from calibre.ebooks.metadata import MetaInformation
|
from calibre.ebooks.metadata import MetaInformation
|
||||||
from calibre.ptempfile import PersistentTemporaryFile
|
from calibre.ptempfile import PersistentTemporaryFile
|
||||||
from polyglot.builtins import string_or_bytes
|
from polyglot.builtins import string_or_bytes, range
|
||||||
|
|
||||||
|
|
||||||
def get_filters():
|
def get_filters():
|
||||||
@ -311,7 +311,7 @@ class AddAction(InterfaceAction):
|
|||||||
book_id = db.id(index.row())
|
book_id = db.id(index.row())
|
||||||
orig_fmts = tuple(db.new_api.format(book_id, fmt, as_path=True) for fmt in db.new_api.formats(book_id))
|
orig_fmts = tuple(db.new_api.format(book_id, fmt, as_path=True) for fmt in db.new_api.formats(book_id))
|
||||||
|
|
||||||
for x in xrange(num):
|
for x in range(num):
|
||||||
if dlg.duplicate_current_book:
|
if dlg.duplicate_current_book:
|
||||||
mi = origmi
|
mi = origmi
|
||||||
else:
|
else:
|
||||||
|
@ -12,6 +12,7 @@ from calibre.gui2 import error_dialog
|
|||||||
from calibre.gui2.actions import InterfaceAction
|
from calibre.gui2.actions import InterfaceAction
|
||||||
from calibre.devices.usbms.device import Device
|
from calibre.devices.usbms.device import Device
|
||||||
from calibre.gui2.dialogs.progress import ProgressDialog
|
from calibre.gui2.dialogs.progress import ProgressDialog
|
||||||
|
from polyglot.builtins import range
|
||||||
|
|
||||||
|
|
||||||
class Updater(QThread): # {{{
|
class Updater(QThread): # {{{
|
||||||
@ -74,7 +75,7 @@ class FetchAnnotationsAction(InterfaceAction):
|
|||||||
def get_ids_from_selected_rows():
|
def get_ids_from_selected_rows():
|
||||||
rows = self.gui.library_view.selectionModel().selectedRows()
|
rows = self.gui.library_view.selectionModel().selectedRows()
|
||||||
if not rows or len(rows) < 2:
|
if not rows or len(rows) < 2:
|
||||||
rows = xrange(self.gui.library_view.model().rowCount(QModelIndex()))
|
rows = range(self.gui.library_view.model().rowCount(QModelIndex()))
|
||||||
ids = map(self.gui.library_view.model().id, rows)
|
ids = map(self.gui.library_view.model().id, rows)
|
||||||
return ids
|
return ids
|
||||||
|
|
||||||
@ -160,5 +161,3 @@ class FetchAnnotationsAction(InterfaceAction):
|
|||||||
_('Could not fetch annotations for some books. Click '
|
_('Could not fetch annotations for some books. Click '
|
||||||
'show details to see which ones.'),
|
'show details to see which ones.'),
|
||||||
det_msg='\n'.join(entries), show=True)
|
det_msg='\n'.join(entries), show=True)
|
||||||
|
|
||||||
|
|
||||||
|
@ -8,6 +8,7 @@ from polyglot.builtins import map
|
|||||||
|
|
||||||
from calibre.gui2 import gprefs
|
from calibre.gui2 import gprefs
|
||||||
from calibre.gui2.actions import InterfaceAction
|
from calibre.gui2.actions import InterfaceAction
|
||||||
|
from polyglot.builtins import range
|
||||||
|
|
||||||
|
|
||||||
class AuthorMapAction(InterfaceAction):
|
class AuthorMapAction(InterfaceAction):
|
||||||
@ -24,7 +25,7 @@ class AuthorMapAction(InterfaceAction):
|
|||||||
selected = True
|
selected = True
|
||||||
if not rows or len(rows) < 2:
|
if not rows or len(rows) < 2:
|
||||||
selected = False
|
selected = False
|
||||||
rows = xrange(self.gui.library_view.model().rowCount(None))
|
rows = range(self.gui.library_view.model().rowCount(None))
|
||||||
ids = set(map(self.gui.library_view.model().id, rows))
|
ids = set(map(self.gui.library_view.model().id, rows))
|
||||||
self.do_map(ids, selected)
|
self.do_map(ids, selected)
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@ from calibre.utils.icu import sort_key
|
|||||||
from calibre.gui2 import (gprefs, warning_dialog, Dispatcher, error_dialog,
|
from calibre.gui2 import (gprefs, warning_dialog, Dispatcher, error_dialog,
|
||||||
question_dialog, info_dialog, open_local_file, choose_dir)
|
question_dialog, info_dialog, open_local_file, choose_dir)
|
||||||
from calibre.gui2.actions import InterfaceAction
|
from calibre.gui2.actions import InterfaceAction
|
||||||
from polyglot.builtins import unicode_type
|
from polyglot.builtins import unicode_type, range
|
||||||
|
|
||||||
|
|
||||||
def db_class():
|
def db_class():
|
||||||
@ -593,7 +593,7 @@ class ChooseLibraryAction(InterfaceAction):
|
|||||||
import gc
|
import gc
|
||||||
from calibre.utils.mem import memory
|
from calibre.utils.mem import memory
|
||||||
ref = self.dbref
|
ref = self.dbref
|
||||||
for i in xrange(3):
|
for i in range(3):
|
||||||
gc.collect()
|
gc.collect()
|
||||||
if ref() is not None:
|
if ref() is not None:
|
||||||
print('DB object alive:', ref())
|
print('DB object alive:', ref())
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
from __future__ import (unicode_literals, division, absolute_import,
|
from __future__ import (unicode_literals, division, absolute_import,
|
||||||
print_function)
|
print_function)
|
||||||
from polyglot.builtins import map
|
from polyglot.builtins import map, range
|
||||||
|
|
||||||
from calibre.gui2 import gprefs
|
from calibre.gui2 import gprefs
|
||||||
from calibre.gui2.actions import InterfaceAction
|
from calibre.gui2.actions import InterfaceAction
|
||||||
@ -24,7 +24,7 @@ class TagMapAction(InterfaceAction):
|
|||||||
selected = True
|
selected = True
|
||||||
if not rows or len(rows) < 2:
|
if not rows or len(rows) < 2:
|
||||||
selected = False
|
selected = False
|
||||||
rows = xrange(self.gui.library_view.model().rowCount(None))
|
rows = range(self.gui.library_view.model().rowCount(None))
|
||||||
ids = set(map(self.gui.library_view.model().id, rows))
|
ids = set(map(self.gui.library_view.model().id, rows))
|
||||||
self.do_map(ids, selected)
|
self.do_map(ids, selected)
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@ from calibre.gui2 import gprefs, config, rating_font, empty_index
|
|||||||
from calibre.gui2.gestures import GestureManager
|
from calibre.gui2.gestures import GestureManager
|
||||||
from calibre.gui2.library.caches import CoverCache, ThumbnailCache
|
from calibre.gui2.library.caches import CoverCache, ThumbnailCache
|
||||||
from calibre.utils.config import prefs, tweaks
|
from calibre.utils.config import prefs, tweaks
|
||||||
from polyglot.builtins import unicode_type
|
from polyglot.builtins import unicode_type, range
|
||||||
|
|
||||||
CM_TO_INCH = 0.393701
|
CM_TO_INCH = 0.393701
|
||||||
CACHE_FORMAT = 'PPM'
|
CACHE_FORMAT = 'PPM'
|
||||||
@ -740,8 +740,8 @@ class GridView(QListView):
|
|||||||
@property
|
@property
|
||||||
def first_visible_row(self):
|
def first_visible_row(self):
|
||||||
geom = self.viewport().geometry()
|
geom = self.viewport().geometry()
|
||||||
for y in xrange(geom.top(), (self.spacing()*2) + geom.top(), 5):
|
for y in range(geom.top(), (self.spacing()*2) + geom.top(), 5):
|
||||||
for x in xrange(geom.left(), (self.spacing()*2) + geom.left(), 5):
|
for x in range(geom.left(), (self.spacing()*2) + geom.left(), 5):
|
||||||
ans = self.indexAt(QPoint(x, y)).row()
|
ans = self.indexAt(QPoint(x, y)).row()
|
||||||
if ans > -1:
|
if ans > -1:
|
||||||
return ans
|
return ans
|
||||||
@ -749,8 +749,8 @@ class GridView(QListView):
|
|||||||
@property
|
@property
|
||||||
def last_visible_row(self):
|
def last_visible_row(self):
|
||||||
geom = self.viewport().geometry()
|
geom = self.viewport().geometry()
|
||||||
for y in xrange(geom.bottom(), geom.bottom() - 2 * self.spacing(), -5):
|
for y in range(geom.bottom(), geom.bottom() - 2 * self.spacing(), -5):
|
||||||
for x in xrange(geom.left(), (self.spacing()*2) + geom.left(), 5):
|
for x in range(geom.left(), (self.spacing()*2) + geom.left(), 5):
|
||||||
ans = self.indexAt(QPoint(x, y)).row()
|
ans = self.indexAt(QPoint(x, y)).row()
|
||||||
if ans > -1:
|
if ans > -1:
|
||||||
item_width = self.delegate.item_size.width() + 2*self.spacing()
|
item_width = self.delegate.item_size.width() + 2*self.spacing()
|
||||||
@ -760,7 +760,7 @@ class GridView(QListView):
|
|||||||
self.ignore_render_requests.clear()
|
self.ignore_render_requests.clear()
|
||||||
self.update_timer.stop()
|
self.update_timer.stop()
|
||||||
m = self.model()
|
m = self.model()
|
||||||
for r in xrange(self.first_visible_row or 0, self.last_visible_row or (m.count() - 1)):
|
for r in range(self.first_visible_row or 0, self.last_visible_row or (m.count() - 1)):
|
||||||
self.update(m.index(r, 0))
|
self.update(m.index(r, 0))
|
||||||
|
|
||||||
def start_view_animation(self, index):
|
def start_view_animation(self, index):
|
||||||
|
@ -30,7 +30,7 @@ from calibre.constants import filesystem_encoding, DEBUG, config_dir
|
|||||||
from calibre.gui2.library import DEFAULT_SORT
|
from calibre.gui2.library import DEFAULT_SORT
|
||||||
from calibre.utils.localization import calibre_langcode_to_name
|
from calibre.utils.localization import calibre_langcode_to_name
|
||||||
from calibre.library.coloring import color_row_key
|
from calibre.library.coloring import color_row_key
|
||||||
from polyglot.builtins import unicode_type, string_or_bytes
|
from polyglot.builtins import unicode_type, string_or_bytes, range
|
||||||
|
|
||||||
Counts = namedtuple('Counts', 'library_total total current')
|
Counts = namedtuple('Counts', 'library_total total current')
|
||||||
|
|
||||||
@ -263,7 +263,7 @@ class BooksModel(QAbstractTableModel): # {{{
|
|||||||
if alignment != 'left':
|
if alignment != 'left':
|
||||||
self.alignment_map[colname] = alignment
|
self.alignment_map[colname] = alignment
|
||||||
col = self.column_map.index(colname)
|
col = self.column_map.index(colname)
|
||||||
for row in xrange(self.rowCount(QModelIndex())):
|
for row in range(self.rowCount(QModelIndex())):
|
||||||
self.dataChanged.emit(self.index(row, col), self.index(row,
|
self.dataChanged.emit(self.index(row, col), self.index(row,
|
||||||
col))
|
col))
|
||||||
|
|
||||||
@ -278,7 +278,7 @@ class BooksModel(QAbstractTableModel): # {{{
|
|||||||
old[colname] = font_type
|
old[colname] = font_type
|
||||||
self.db.new_api.set_pref('styled_columns', old)
|
self.db.new_api.set_pref('styled_columns', old)
|
||||||
col = self.column_map.index(colname)
|
col = self.column_map.index(colname)
|
||||||
for row in xrange(self.rowCount(QModelIndex())):
|
for row in range(self.rowCount(QModelIndex())):
|
||||||
self.dataChanged.emit(self.index(row, col), self.index(row,
|
self.dataChanged.emit(self.index(row, col), self.index(row,
|
||||||
col))
|
col))
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@ __docformat__ = 'restructuredtext en'
|
|||||||
|
|
||||||
import itertools, operator
|
import itertools, operator
|
||||||
from functools import partial
|
from functools import partial
|
||||||
from polyglot.builtins import map, unicode_type
|
from polyglot.builtins import map, unicode_type, range
|
||||||
from collections import OrderedDict
|
from collections import OrderedDict
|
||||||
|
|
||||||
from PyQt5.Qt import (
|
from PyQt5.Qt import (
|
||||||
@ -688,7 +688,7 @@ class BooksView(QTableView): # {{{
|
|||||||
# Because of a bug in Qt 5 we have to ensure that the header is actually
|
# Because of a bug in Qt 5 we have to ensure that the header is actually
|
||||||
# relaid out by changing this value, without this sometimes ghost
|
# relaid out by changing this value, without this sometimes ghost
|
||||||
# columns remain visible when changing libraries
|
# columns remain visible when changing libraries
|
||||||
for i in xrange(h.count()):
|
for i in range(h.count()):
|
||||||
val = h.isSectionHidden(i)
|
val = h.isSectionHidden(i)
|
||||||
h.setSectionHidden(i, not val)
|
h.setSectionHidden(i, not val)
|
||||||
h.setSectionHidden(i, val)
|
h.setSectionHidden(i, val)
|
||||||
@ -967,7 +967,7 @@ class BooksView(QTableView): # {{{
|
|||||||
@property
|
@property
|
||||||
def visible_columns(self):
|
def visible_columns(self):
|
||||||
h = self.horizontalHeader()
|
h = self.horizontalHeader()
|
||||||
logical_indices = (x for x in xrange(h.count()) if not h.isSectionHidden(x))
|
logical_indices = (x for x in range(h.count()) if not h.isSectionHidden(x))
|
||||||
rmap = {i:x for i, x in enumerate(self.column_map)}
|
rmap = {i:x for i, x in enumerate(self.column_map)}
|
||||||
return (rmap[h.visualIndex(x)] for x in logical_indices if h.visualIndex(x) > -1)
|
return (rmap[h.visualIndex(x)] for x in logical_indices if h.visualIndex(x) > -1)
|
||||||
|
|
||||||
@ -1108,7 +1108,7 @@ class BooksView(QTableView): # {{{
|
|||||||
row_map = OrderedDict()
|
row_map = OrderedDict()
|
||||||
ids = frozenset(ids)
|
ids = frozenset(ids)
|
||||||
m = self.model()
|
m = self.model()
|
||||||
for row in xrange(m.rowCount(QModelIndex())):
|
for row in range(m.rowCount(QModelIndex())):
|
||||||
if len(row_map) >= len(ids):
|
if len(row_map) >= len(ids):
|
||||||
break
|
break
|
||||||
c = m.id(row)
|
c = m.id(row)
|
||||||
@ -1128,7 +1128,7 @@ class BooksView(QTableView): # {{{
|
|||||||
rows = set([])
|
rows = set([])
|
||||||
identifiers = set(identifiers)
|
identifiers = set(identifiers)
|
||||||
m = self.model()
|
m = self.model()
|
||||||
for row in xrange(m.rowCount(QModelIndex())):
|
for row in range(m.rowCount(QModelIndex())):
|
||||||
if m.id(row) in identifiers:
|
if m.id(row) in identifiers:
|
||||||
rows.add(row)
|
rows.add(row)
|
||||||
rows = list(sorted(rows))
|
rows = list(sorted(rows))
|
||||||
@ -1174,7 +1174,7 @@ class BooksView(QTableView): # {{{
|
|||||||
if val is None:
|
if val is None:
|
||||||
return
|
return
|
||||||
m = self.model()
|
m = self.model()
|
||||||
for row in xrange(m.rowCount(QModelIndex())):
|
for row in range(m.rowCount(QModelIndex())):
|
||||||
if m.id(row) == val:
|
if m.id(row) == val:
|
||||||
self.set_current_row(row, select=False)
|
self.set_current_row(row, select=False)
|
||||||
break
|
break
|
||||||
@ -1193,7 +1193,7 @@ class BooksView(QTableView): # {{{
|
|||||||
i.isValid()])
|
i.isValid()])
|
||||||
column = ci.column()
|
column = ci.column()
|
||||||
|
|
||||||
for i in xrange(ci.row()+1, self.row_count()):
|
for i in range(ci.row()+1, self.row_count()):
|
||||||
if i in selected_rows:
|
if i in selected_rows:
|
||||||
continue
|
continue
|
||||||
try:
|
try:
|
||||||
@ -1202,7 +1202,7 @@ class BooksView(QTableView): # {{{
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
# No unselected rows after the current row, look before
|
# No unselected rows after the current row, look before
|
||||||
for i in xrange(ci.row()-1, -1, -1):
|
for i in range(ci.row()-1, -1, -1):
|
||||||
if i in selected_rows:
|
if i in selected_rows:
|
||||||
continue
|
continue
|
||||||
try:
|
try:
|
||||||
|
@ -12,6 +12,7 @@ from PyQt5.Qt import (QLabel, QVBoxLayout, QListWidget, QListWidgetItem, Qt,
|
|||||||
|
|
||||||
from calibre.customize.ui import enable_plugin
|
from calibre.customize.ui import enable_plugin
|
||||||
from calibre.gui2.preferences import ConfigWidgetBase, test_widget
|
from calibre.gui2.preferences import ConfigWidgetBase, test_widget
|
||||||
|
from polyglot.builtins import range
|
||||||
|
|
||||||
|
|
||||||
class ConfigWidget(ConfigWidgetBase):
|
class ConfigWidget(ConfigWidgetBase):
|
||||||
@ -78,7 +79,7 @@ class ConfigWidget(ConfigWidgetBase):
|
|||||||
|
|
||||||
def commit(self):
|
def commit(self):
|
||||||
devs = {}
|
devs = {}
|
||||||
for i in xrange(0, self.devices.count()):
|
for i in range(0, self.devices.count()):
|
||||||
e = self.devices.item(i)
|
e = self.devices.item(i)
|
||||||
dev, uid = e.data(Qt.UserRole)
|
dev, uid = e.data(Qt.UserRole)
|
||||||
if dev not in devs:
|
if dev not in devs:
|
||||||
@ -89,7 +90,7 @@ class ConfigWidget(ConfigWidgetBase):
|
|||||||
for dev, bl in devs.iteritems():
|
for dev, bl in devs.iteritems():
|
||||||
dev.set_user_blacklisted_devices(bl)
|
dev.set_user_blacklisted_devices(bl)
|
||||||
|
|
||||||
for i in xrange(self.device_plugins.count()):
|
for i in range(self.device_plugins.count()):
|
||||||
e = self.device_plugins.item(i)
|
e = self.device_plugins.item(i)
|
||||||
dev = e.data(Qt.UserRole)
|
dev = e.data(Qt.UserRole)
|
||||||
if e.checkState() == Qt.Unchecked:
|
if e.checkState() == Qt.Unchecked:
|
||||||
@ -97,8 +98,8 @@ class ConfigWidget(ConfigWidgetBase):
|
|||||||
|
|
||||||
return True # Restart required
|
return True # Restart required
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
from PyQt5.Qt import QApplication
|
from PyQt5.Qt import QApplication
|
||||||
app = QApplication([])
|
app = QApplication([])
|
||||||
test_widget('Sharing', 'Ignored Devices')
|
test_widget('Sharing', 'Ignored Devices')
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@ from PyQt5.Qt import (
|
|||||||
from calibre.constants import config_dir
|
from calibre.constants import config_dir
|
||||||
from calibre.gui2 import choose_files, error_dialog
|
from calibre.gui2 import choose_files, error_dialog
|
||||||
from calibre.utils.icu import sort_key
|
from calibre.utils.icu import sort_key
|
||||||
from polyglot.builtins import unicode_type
|
from polyglot.builtins import unicode_type, range
|
||||||
|
|
||||||
|
|
||||||
def texture_dir():
|
def texture_dir():
|
||||||
@ -85,7 +85,7 @@ class TextureChooser(QDialog):
|
|||||||
self.update_remove_state()
|
self.update_remove_state()
|
||||||
|
|
||||||
if initial:
|
if initial:
|
||||||
existing = {unicode_type(i.data(Qt.UserRole) or ''):i for i in (self.images.item(c) for c in xrange(self.images.count()))}
|
existing = {unicode_type(i.data(Qt.UserRole) or ''):i for i in (self.images.item(c) for c in range(self.images.count()))}
|
||||||
item = existing.get(initial, None)
|
item = existing.get(initial, None)
|
||||||
if item is not None:
|
if item is not None:
|
||||||
item.setSelected(True)
|
item.setSelected(True)
|
||||||
@ -116,7 +116,7 @@ class TextureChooser(QDialog):
|
|||||||
path = path[0]
|
path = path[0]
|
||||||
fname = os.path.basename(path)
|
fname = os.path.basename(path)
|
||||||
name = fname.rpartition('.')[0]
|
name = fname.rpartition('.')[0]
|
||||||
existing = {unicode_type(i.data(Qt.UserRole) or ''):i for i in (self.images.item(c) for c in xrange(self.images.count()))}
|
existing = {unicode_type(i.data(Qt.UserRole) or ''):i for i in (self.images.item(c) for c in range(self.images.count()))}
|
||||||
dest = os.path.join(self.tdir, fname)
|
dest = os.path.join(self.tdir, fname)
|
||||||
with open(path, 'rb') as s, open(dest, 'wb') as f:
|
with open(path, 'rb') as s, open(dest, 'wb') as f:
|
||||||
shutil.copyfileobj(s, f)
|
shutil.copyfileobj(s, f)
|
||||||
|
@ -19,7 +19,7 @@ from calibre import isbytestring
|
|||||||
from calibre.utils.icu import lower
|
from calibre.utils.icu import lower
|
||||||
from calibre.utils.search_query_parser import (ParseException,
|
from calibre.utils.search_query_parser import (ParseException,
|
||||||
SearchQueryParser)
|
SearchQueryParser)
|
||||||
from polyglot.builtins import unicode_type
|
from polyglot.builtins import unicode_type, range
|
||||||
|
|
||||||
from PyQt5.Qt import (
|
from PyQt5.Qt import (
|
||||||
QAbstractListModel, Qt, QStyledItemDelegate, QStyle, QStyleOptionViewItem,
|
QAbstractListModel, Qt, QStyledItemDelegate, QStyle, QStyleOptionViewItem,
|
||||||
@ -282,7 +282,7 @@ class Tweaks(QAbstractListModel, AdaptSQP): # {{{
|
|||||||
self.plugin_tweaks = d
|
self.plugin_tweaks = d
|
||||||
|
|
||||||
def universal_set(self):
|
def universal_set(self):
|
||||||
return set(xrange(self.rowCount()))
|
return set(range(self.rowCount()))
|
||||||
|
|
||||||
def get_matches(self, location, query, candidates=None):
|
def get_matches(self, location, query, candidates=None):
|
||||||
if candidates is None:
|
if candidates is None:
|
||||||
|
@ -23,6 +23,7 @@ from calibre.utils.icu import sort_key, lower, strcmp, collation_order, primary_
|
|||||||
from calibre.library.field_metadata import category_icon_map
|
from calibre.library.field_metadata import category_icon_map
|
||||||
from calibre.gui2.dialogs.confirm_delete import confirm
|
from calibre.gui2.dialogs.confirm_delete import confirm
|
||||||
from calibre.utils.formatter import EvalFormatter
|
from calibre.utils.formatter import EvalFormatter
|
||||||
|
from polyglot.builtins import range
|
||||||
|
|
||||||
TAG_SEARCH_STATES = {'clear': 0, 'mark_plus': 1, 'mark_plusplus': 2,
|
TAG_SEARCH_STATES = {'clear': 0, 'mark_plus': 1, 'mark_plusplus': 2,
|
||||||
'mark_minus': 3, 'mark_minusminus': 4}
|
'mark_minus': 3, 'mark_minusminus': 4}
|
||||||
@ -1492,7 +1493,7 @@ class TagsModel(QAbstractItemModel): # {{{
|
|||||||
if path[depth] > start_path[depth]:
|
if path[depth] > start_path[depth]:
|
||||||
start_path = path
|
start_path = path
|
||||||
my_key = self.get_node(category_index).category_key
|
my_key = self.get_node(category_index).category_key
|
||||||
for j in xrange(self.rowCount(category_index)):
|
for j in range(self.rowCount(category_index)):
|
||||||
tag_index = self.index(j, 0, category_index)
|
tag_index = self.index(j, 0, category_index)
|
||||||
tag_item = self.get_node(tag_index)
|
tag_item = self.get_node(tag_index)
|
||||||
if tag_item.type == TagTreeItem.CATEGORY:
|
if tag_item.type == TagTreeItem.CATEGORY:
|
||||||
@ -1503,7 +1504,7 @@ class TagsModel(QAbstractItemModel): # {{{
|
|||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
for i in xrange(self.rowCount(QModelIndex())):
|
for i in range(self.rowCount(QModelIndex())):
|
||||||
if process_level(0, self.index(i, 0, QModelIndex()), start_path):
|
if process_level(0, self.index(i, 0, QModelIndex()), start_path):
|
||||||
break
|
break
|
||||||
return self.path_found
|
return self.path_found
|
||||||
@ -1517,7 +1518,7 @@ class TagsModel(QAbstractItemModel): # {{{
|
|||||||
if not key:
|
if not key:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
for i in xrange(self.rowCount(parent)):
|
for i in range(self.rowCount(parent)):
|
||||||
idx = self.index(i, 0, parent)
|
idx = self.index(i, 0, parent)
|
||||||
node = self.get_node(idx)
|
node = self.get_node(idx)
|
||||||
if node.type == TagTreeItem.CATEGORY:
|
if node.type == TagTreeItem.CATEGORY:
|
||||||
@ -1547,7 +1548,7 @@ class TagsModel(QAbstractItemModel): # {{{
|
|||||||
process_tag(self.index(i, 0, tag_index), c)
|
process_tag(self.index(i, 0, tag_index), c)
|
||||||
|
|
||||||
def process_level(category_index):
|
def process_level(category_index):
|
||||||
for j in xrange(self.rowCount(category_index)):
|
for j in range(self.rowCount(category_index)):
|
||||||
tag_index = self.index(j, 0, category_index)
|
tag_index = self.index(j, 0, category_index)
|
||||||
tag_item = self.get_node(tag_index)
|
tag_item = self.get_node(tag_index)
|
||||||
if tag_item.boxed:
|
if tag_item.boxed:
|
||||||
@ -1558,7 +1559,7 @@ class TagsModel(QAbstractItemModel): # {{{
|
|||||||
else:
|
else:
|
||||||
process_tag(tag_index, tag_item)
|
process_tag(tag_index, tag_item)
|
||||||
|
|
||||||
for i in xrange(self.rowCount(QModelIndex())):
|
for i in range(self.rowCount(QModelIndex())):
|
||||||
process_level(self.index(i, 0, QModelIndex()))
|
process_level(self.index(i, 0, QModelIndex()))
|
||||||
|
|
||||||
# }}}
|
# }}}
|
||||||
|
@ -24,7 +24,7 @@ from calibre.gui2.tag_browser.model import (TagTreeItem, TAG_SEARCH_STATES,
|
|||||||
TagsModel, DRAG_IMAGE_ROLE, COUNT_ROLE)
|
TagsModel, DRAG_IMAGE_ROLE, COUNT_ROLE)
|
||||||
from calibre.gui2 import config, gprefs, choose_files, pixmap_to_data, rating_font, empty_index
|
from calibre.gui2 import config, gprefs, choose_files, pixmap_to_data, rating_font, empty_index
|
||||||
from calibre.utils.icu import sort_key
|
from calibre.utils.icu import sort_key
|
||||||
from polyglot.builtins import unicode_type
|
from polyglot.builtins import unicode_type, range
|
||||||
|
|
||||||
|
|
||||||
class TagDelegate(QStyledItemDelegate): # {{{
|
class TagDelegate(QStyledItemDelegate): # {{{
|
||||||
@ -723,7 +723,7 @@ class TagsView(QTreeView): # {{{
|
|||||||
if not index.isValid():
|
if not index.isValid():
|
||||||
return
|
return
|
||||||
self.expand(index)
|
self.expand(index)
|
||||||
for r in xrange(self.model().rowCount(index)):
|
for r in range(self.model().rowCount(index)):
|
||||||
self.expand_node_and_descendants(index.child(r, 0))
|
self.expand_node_and_descendants(index.child(r, 0))
|
||||||
|
|
||||||
def collapse_menu_hovered(self, action):
|
def collapse_menu_hovered(self, action):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user