mirror of
https://gitee.com/vnotex/vnote.git
synced 2025-07-05 13:59:52 +08:00
bug-fix: VTextEdit::visibleBlockRange() may get wrong range before updating document size after preview
This commit is contained in:
parent
d3a5642d06
commit
4de97522a1
@ -590,4 +590,13 @@ void VPreviewManager::relayoutEditor(const OrderedIntSet &p_blocks)
|
||||
}
|
||||
|
||||
m_editor->relayout(bs);
|
||||
|
||||
// We may get the wrong visible block range before relayout() updating the document size.
|
||||
OrderedIntSet after;
|
||||
int afterFirst = m_editor->firstVisibleBlockNumber();
|
||||
for (int i = afterFirst; i < first; ++i) {
|
||||
after.insert(i, QMapDummyValue());
|
||||
}
|
||||
|
||||
m_editor->relayout(after);
|
||||
}
|
||||
|
@ -277,6 +277,13 @@ void VTextEdit::updateLineNumberArea()
|
||||
}
|
||||
}
|
||||
|
||||
int VTextEdit::firstVisibleBlockNumber() const
|
||||
{
|
||||
VTextDocumentLayout *layout = getLayout();
|
||||
Q_ASSERT(layout);
|
||||
return layout->findBlockByPosition(QPointF(0, -contentOffsetY()));
|
||||
}
|
||||
|
||||
QTextBlock VTextEdit::firstVisibleBlock() const
|
||||
{
|
||||
VTextDocumentLayout *layout = getLayout();
|
||||
@ -317,6 +324,8 @@ void VTextEdit::clearBlockImages()
|
||||
void VTextEdit::relayout(const OrderedIntSet &p_blocks)
|
||||
{
|
||||
getLayout()->relayout(p_blocks);
|
||||
|
||||
updateLineNumberArea();
|
||||
}
|
||||
|
||||
void VTextEdit::relayoutVisibleBlocks()
|
||||
@ -330,6 +339,8 @@ void VTextEdit::relayoutVisibleBlocks()
|
||||
}
|
||||
|
||||
getLayout()->relayout(blocks);
|
||||
|
||||
updateLineNumberArea();
|
||||
}
|
||||
|
||||
bool VTextEdit::containsImage(const QString &p_imageName) const
|
||||
@ -419,6 +430,8 @@ void VTextEdit::setCursorLineBlockBg(const QColor &p_bg)
|
||||
void VTextEdit::relayout()
|
||||
{
|
||||
getLayout()->relayout();
|
||||
|
||||
updateLineNumberArea();
|
||||
}
|
||||
|
||||
void VTextEdit::setDisplayScaleFactor(qreal p_factor)
|
||||
|
@ -33,6 +33,8 @@ public:
|
||||
|
||||
void setLineNumberColor(const QColor &p_foreground, const QColor &p_background);
|
||||
|
||||
int firstVisibleBlockNumber() const;
|
||||
|
||||
QTextBlock firstVisibleBlock() const;
|
||||
|
||||
QTextBlock lastVisibleBlock() const;
|
||||
|
Loading…
x
Reference in New Issue
Block a user