MCPcopy Create free account
hub / github.com/baldurk/renderdoc / paintEvent

Method paintEvent

qrenderdoc/Widgets/Extended/RDTableView.cpp:238–324  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

236}
237
238void RDTableView::paintEvent(QPaintEvent *e)
239{
240 const int gridWidth = showGrid() ? 1 : 0;
241 QStyleOptionViewItem opt = viewOptions();
242
243 QPainter painter(viewport());
244
245 if(model()->rowCount() == 0 || model()->columnCount() == 0)
246 return;
247
248 int firstRow = qMax(verticalHeader()->visualIndexAt(0), 0);
249 int lastRow = verticalHeader()->visualIndexAt(viewport()->height());
250 if(lastRow < 0)
251 {
252 // if lastRow is negative, display as many will fit. This is a reasonable upper bound without
253 // displaying all rows which could be massive
254 lastRow = firstRow + (viewport()->height() / qMax(1, rowHeight(firstRow))) + 1;
255 }
256 lastRow = qMin(lastRow, verticalHeader()->count() - 1);
257
258 int firstCol = qMax(horizontalHeader()->visualIndexAt(horizontalHeader()->pinnedWidth() + 1), 0);
259 int lastCol = horizontalHeader()->visualIndexAt(viewport()->width());
260 if(lastCol < 0)
261 lastCol = horizontalHeader()->count() - 1;
262 lastCol = qMin(lastCol, horizontalHeader()->count() - 1);
263
264 firstCol = qMax(m_pinnedColumns, firstCol);
265
266 for(int row = firstRow; row <= lastRow; row++)
267 {
268 for(int col = firstCol; col <= lastCol; col++)
269 {
270 const QModelIndex index = model()->index(row, col);
271 if(index.isValid())
272 paintCell(&painter, index, opt);
273 }
274 for(int col = 0; col < m_pinnedColumns; col++)
275 {
276 const QModelIndex index = model()->index(row, col);
277 if(index.isValid())
278 paintCell(&painter, index, opt);
279 }
280 }
281
282 if(gridWidth)
283 {
284 QPen prevPen = painter.pen();
285 QBrush prevBrush = painter.brush();
286
287 QColor gridCol(QRgb(style()->styleHint(QStyle::SH_Table_GridLineColor, &opt, this)));
288
289 painter.setPen(QPen(gridCol, 0, gridStyle()));
290 painter.setBrush(QBrush(gridCol));
291
292 // draw bottom line of each row
293 for(int row = firstRow; row <= lastRow; row++)
294 {
295 int y = rowViewportPosition(row) + rowHeight(row) - gridWidth;

Callers

nothing calls this directly

Calls 15

visualIndexAtMethod · 0.80
pinnedWidthMethod · 0.80
setBrushMethod · 0.80
groupGapSizeMethod · 0.80
hasGroupGapMethod · 0.80
drawRectMethod · 0.80
bottomMethod · 0.80
modelFunction · 0.50
styleFunction · 0.50
QPenFunction · 0.50
QBrushClass · 0.50
rowCountMethod · 0.45

Tested by

no test coverage detected