summaryrefslogtreecommitdiffstats
path: root/src/gui
diff options
context:
space:
mode:
authormae <qt-info@nokia.com>2009-05-08 09:51:34 (GMT)
committermae <qt-info@nokia.com>2009-05-08 09:59:48 (GMT)
commit97d24ee90e59f7f33c28f6442e63d5f27fb7cca2 (patch)
tree91b1da5f4b9f40418d096f968ac5062d597e8dd8 /src/gui
parent04975e4a594af999600e175f65869f615f5e9740 (diff)
downloadQt-97d24ee90e59f7f33c28f6442e63d5f27fb7cca2.zip
Qt-97d24ee90e59f7f33c28f6442e63d5f27fb7cca2.tar.gz
Qt-97d24ee90e59f7f33c28f6442e63d5f27fb7cca2.tar.bz2
Improved scrolling performance with invisible blocks
Reviewed-by: Thorbjørn
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/widgets/qplaintextedit.cpp14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/gui/widgets/qplaintextedit.cpp b/src/gui/widgets/qplaintextedit.cpp
index 14efd23..f317742 100644
--- a/src/gui/widgets/qplaintextedit.cpp
+++ b/src/gui/widgets/qplaintextedit.cpp
@@ -560,7 +560,8 @@ QRectF QPlainTextEditControl::blockBoundingRect(const QTextBlock &block) const {
if (!currentBlock.isValid())
return QRectF();
Q_ASSERT(currentBlock.blockNumber() == currentBlockNumber);
- QPlainTextDocumentLayout *documentLayout = qobject_cast<QPlainTextDocumentLayout*>(document()->documentLayout());
+ QTextDocument *doc = document();
+ QPlainTextDocumentLayout *documentLayout = qobject_cast<QPlainTextDocumentLayout*>(doc->documentLayout());
Q_ASSERT(documentLayout);
QPointF offset;
@@ -571,13 +572,22 @@ QRectF QPlainTextEditControl::blockBoundingRect(const QTextBlock &block) const {
offset.ry() += r.height();
currentBlock = currentBlock.next();
++currentBlockNumber;
+ if (!currentBlock.isVisible()) {
+ currentBlock = doc->findBlockByLineNumber(currentBlock.firstLineNumber());
+ currentBlockNumber = currentBlock.blockNumber();
+ }
r = documentLayout->blockBoundingRect(currentBlock);
}
while (currentBlockNumber > blockNumber && offset.y() >= -textEdit->viewport()->height()) {
currentBlock = currentBlock.previous();
+ --currentBlockNumber;
+ while (!currentBlock.isVisible()) {
+ currentBlock = currentBlock.previous();
+ --currentBlockNumber;
+ }
if (!currentBlock.isValid())
break;
- --currentBlockNumber;
+
r = documentLayout->blockBoundingRect(currentBlock);
offset.ry() -= r.height();
}