| 211 | } |
| 212 | |
| 213 | void GitDiffEditor::paintBlock(const QRect &eventRect) const |
| 214 | { |
| 215 | QPainter painter(viewport()); |
| 216 | auto offset = contentOffset(); |
| 217 | painter.setBrushOrigin(offset); |
| 218 | |
| 219 | QTextBlock block = firstVisibleBlock(); |
| 220 | while (block.isValid()) { |
| 221 | PaintEventBlockData blockData; |
| 222 | blockData.boundingRect = blockBoundingRect(block).translated(offset); |
| 223 | |
| 224 | if (blockData.boundingRect.bottom() >= eventRect.top() |
| 225 | && blockData.boundingRect.top() <= eventRect.bottom()) { |
| 226 | blockData.position = block.position(); |
| 227 | blockData.length = block.length(); |
| 228 | |
| 229 | paintBlock(&painter, block, offset, blockData.selections, eventRect); |
| 230 | } |
| 231 | |
| 232 | offset.ry() += blockData.boundingRect.height(); |
| 233 | if (offset.y() > viewport()->rect().height()) |
| 234 | break; |
| 235 | |
| 236 | block = block.next(); |
| 237 | } |
| 238 | } |
| 239 | |
| 240 | void GitDiffEditor::paintBlock(QPainter *painter, |
| 241 | const QTextBlock &block, |