| 177 | }; |
| 178 | |
| 179 | void GitEditorPrivate::paintLineNumbers(QPainter &painter, |
| 180 | const ExtraAreaPaintEventData &data, |
| 181 | const QRectF &blockBoundingRect) const |
| 182 | { |
| 183 | const QString &number = q->lineNumber(data.block.blockNumber()); |
| 184 | const bool selected = ((data.selectionStart < data.block.position() + data.block.length() |
| 185 | && data.selectionEnd > data.block.position()) |
| 186 | || (data.selectionStart == data.selectionEnd && data.selectionEnd == data.block.position())); |
| 187 | if (selected) { |
| 188 | painter.save(); |
| 189 | QFont f = painter.font(); |
| 190 | f.setBold(data.currentLineNumberFormat.font().bold()); |
| 191 | f.setItalic(data.currentLineNumberFormat.font().italic()); |
| 192 | painter.setFont(f); |
| 193 | painter.setPen(data.currentLineNumberFormat.foreground().color()); |
| 194 | if (data.currentLineNumberFormat.background() != Qt::NoBrush) { |
| 195 | painter.fillRect(QRectF(0, blockBoundingRect.top(), |
| 196 | data.extraAreaWidth, blockBoundingRect.height()), |
| 197 | data.currentLineNumberFormat.background().color()); |
| 198 | } |
| 199 | } |
| 200 | painter.drawText(QRectF(0, blockBoundingRect.top(), |
| 201 | data.extraAreaWidth - 4, blockBoundingRect.height()), |
| 202 | Qt::AlignRight, |
| 203 | number); |
| 204 | if (selected) |
| 205 | painter.restore(); |
| 206 | } |
| 207 | |
| 208 | GitEditor::GitEditor(QWidget *parent) |
| 209 | : QPlainTextEdit(parent), |
no test coverage detected