| 268 | } |
| 269 | |
| 270 | void GitDiffEditor::paintSeparator(const QRect &eventRect) const |
| 271 | { |
| 272 | QPainter painter(viewport()); |
| 273 | const QPointF offset = contentOffset(); |
| 274 | QTextBlock currentBlock = firstVisibleBlock(); |
| 275 | |
| 276 | while (currentBlock.isValid()) { |
| 277 | if (currentBlock.isVisible()) { |
| 278 | qreal top = blockBoundingGeometry(currentBlock).translated(offset).top(); |
| 279 | qreal bottom = top + blockBoundingRect(currentBlock).height(); |
| 280 | |
| 281 | if (top > eventRect.bottom()) |
| 282 | break; |
| 283 | |
| 284 | if (bottom >= eventRect.top()) { |
| 285 | const int blockNumber = currentBlock.blockNumber(); |
| 286 | |
| 287 | auto it = diffData.blockSkippedLines.constFind(blockNumber); |
| 288 | if (it != diffData.blockSkippedLines.constEnd()) { |
| 289 | QString skippedRowsText = '[' + skippedText(it->first) + ']'; |
| 290 | if (!it->second.isEmpty()) |
| 291 | skippedRowsText += ' ' + it->second; |
| 292 | paintSeparator(painter, chunkLineForeground, |
| 293 | skippedRowsText, currentBlock, top); |
| 294 | } |
| 295 | |
| 296 | const DiffFileInfo fileInfo = diffData.diffFileInfo.value(blockNumber); |
| 297 | if (!fileInfo.fileName.isEmpty()) { |
| 298 | const QString fileNameText = fileInfo.typeInfo.isEmpty() |
| 299 | ? fileInfo.fileName |
| 300 | : tr("[%1] %2").arg(fileInfo.typeInfo, fileInfo.fileName); |
| 301 | paintSeparator(painter, fileLineForeground, |
| 302 | fileNameText, currentBlock, top); |
| 303 | } |
| 304 | } |
| 305 | } |
| 306 | currentBlock = currentBlock.next(); |
| 307 | } |
| 308 | } |
| 309 | |
| 310 | void GitDiffEditor::paintSeparator(QPainter &painter, const QColor &color, const QString &text, |
| 311 | const QTextBlock &block, int top) const |
nothing calls this directly
no test coverage detected