MCPcopy Create free account
hub / github.com/cutechess/cutechess / indexToRowCol

Method indexToRowCol

projects/gui/3rdparty/qcustomplot/qcustomplot.cpp:4557–4586  ·  view source on GitHub ↗

! Converts the linear index to row and column indices and writes the result to \a row and \a column. The way the cells are indexed depends on \ref setFillOrder. If it is \ref foRowsFirst, the indices increase left to right and then top to bottom. If it is \ref foColumnsFirst, the indices increase top to bottom and then left to right. If there are no cells (i.e. column or row count is

Source from the content-addressed store, hash-verified

4555 \see rowColToIndex
4556*/
4557void QCPLayoutGrid::indexToRowCol(int index, int &row, int &column) const
4558{
4559 row = -1;
4560 column = -1;
4561 const int nCols = columnCount();
4562 const int nRows = rowCount();
4563 if (nCols == 0 || nRows == 0)
4564 return;
4565 if (index < 0 || index >= elementCount())
4566 {
4567 qDebug() << Q_FUNC_INFO << "index out of bounds:" << index;
4568 return;
4569 }
4570
4571 switch (mFillOrder)
4572 {
4573 case foRowsFirst:
4574 {
4575 column = index / nRows;
4576 row = index % nRows;
4577 break;
4578 }
4579 case foColumnsFirst:
4580 {
4581 row = index / nCols;
4582 column = index % nCols;
4583 break;
4584 }
4585 }
4586}
4587
4588/* inherits documentation from base class */
4589void QCPLayoutGrid::updateLayout()

Callers

nothing calls this directly

Calls 3

columnCountFunction · 0.85
rowCountFunction · 0.85
elementCountFunction · 0.85

Tested by

no test coverage detected