mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Replace QTextLayouts::*additionalFormats methods
This commit is contained in:
parent
83cd7bfa12
commit
8846f7fd44
@ -138,7 +138,7 @@ class Block:
|
||||
for text in text.split('<br>') if text else ():
|
||||
text, formats = parse_text_formatting(sanitize(text))
|
||||
l = QTextLayout(unescape_formatting(text), font, img)
|
||||
l.setAdditionalFormats(formats)
|
||||
l.setFormats(formats)
|
||||
to = QTextOption(align)
|
||||
to.setWrapMode(QTextOption.WrapMode.WrapAtWordBoundaryOrAnywhere)
|
||||
l.setTextOption(to)
|
||||
|
@ -40,7 +40,7 @@ class QtHighlighter(QTextDocument):
|
||||
dest_block = cursor.block()
|
||||
c = QTextCursor(dest_block)
|
||||
try:
|
||||
afs = block.layout().additionalFormats()
|
||||
afs = block.layout().formats()
|
||||
except AttributeError:
|
||||
afs = ()
|
||||
for af in afs:
|
||||
|
@ -160,9 +160,9 @@ class TextBrowser(PlainTextEdit): # {{{
|
||||
setattr(self, '%s_format' % x, f)
|
||||
|
||||
def calculate_metrics(self):
|
||||
w = self.fontMetrics()
|
||||
self.number_width = max(map(lambda x:w.width(str(x)), range(10)))
|
||||
self.space_width = w.width(' ')
|
||||
fm = self.fontMetrics()
|
||||
self.number_width = max(map(lambda x:fm.horizontalAdvance(str(x)), range(10)))
|
||||
self.space_width = fm.horizontalAdvance(' ')
|
||||
|
||||
def show_context_menu(self, pos):
|
||||
m = QMenu(self)
|
||||
@ -879,7 +879,7 @@ class DiffSplit(QSplitter): # {{{
|
||||
for word in words[lo:hi]:
|
||||
if word == '\n':
|
||||
if fmts:
|
||||
block.layout().setAdditionalFormats(fmts)
|
||||
block.layout().setFormats(fmts)
|
||||
pos, block, fmts = 0, block.next(), []
|
||||
continue
|
||||
|
||||
@ -897,7 +897,7 @@ class DiffSplit(QSplitter): # {{{
|
||||
rsb, rpos, rfmts = do_tag(rsb, rl, rlo, rhi, rpos, rfmts)
|
||||
for block, fmts in ((lsb, lfmts), (rsb, rfmts)):
|
||||
if fmts:
|
||||
block.layout().setAdditionalFormats(fmts)
|
||||
block.layout().setFormats(fmts)
|
||||
# }}}
|
||||
|
||||
# }}}
|
||||
|
@ -95,7 +95,7 @@ class SyntaxHighlighter:
|
||||
c.beginEditBlock()
|
||||
blk = old_doc.begin()
|
||||
while blk.isValid():
|
||||
blk.layout().clearAdditionalFormats()
|
||||
blk.layout().clearFormats()
|
||||
blk = blk.next()
|
||||
c.endEditBlock()
|
||||
self.doc = self.doc_name = None
|
||||
@ -237,4 +237,4 @@ class SyntaxHighlighter:
|
||||
r.start += preedit_length
|
||||
elif r.start + r.length >= preedit_start:
|
||||
r.length += preedit_length
|
||||
layout.setAdditionalFormats(formats)
|
||||
layout.setFormats(formats)
|
||||
|
@ -566,7 +566,7 @@ class TextEdit(PlainTextEdit):
|
||||
c.movePosition(QTextCursor.MoveOperation.Start)
|
||||
block = c.block()
|
||||
while block.isValid():
|
||||
for r in block.layout().additionalFormats():
|
||||
for r in block.layout().formats():
|
||||
if r.format.property(SPELL_PROPERTY):
|
||||
if not from_cursor or block.position() + r.start + r.length > c.position():
|
||||
c.setPosition(block.position() + r.start)
|
||||
@ -730,7 +730,7 @@ class TextEdit(PlainTextEdit):
|
||||
c.movePosition(QTextCursor.MoveOperation.Start)
|
||||
block = c.block()
|
||||
while block.isValid():
|
||||
for r in block.layout().additionalFormats():
|
||||
for r in block.layout().formats():
|
||||
if r.format.property(SPELL_PROPERTY) and self.text_for_range(block, r) == word:
|
||||
self.highlighter.reformat_block(block)
|
||||
break
|
||||
@ -741,7 +741,7 @@ class TextEdit(PlainTextEdit):
|
||||
if cursor.isNull():
|
||||
return
|
||||
pos = cursor.positionInBlock()
|
||||
for r in cursor.block().layout().additionalFormats():
|
||||
for r in cursor.block().layout().formats():
|
||||
if r.start <= pos <= r.start + r.length and r.format.property(SYNTAX_PROPERTY):
|
||||
return r
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user