| 183 | } |
| 184 | |
| 185 | void TableView::insertCellAtIndex(ssize_t idx) |
| 186 | { |
| 187 | if (idx == AX_INVALID_INDEX) |
| 188 | { |
| 189 | return; |
| 190 | } |
| 191 | |
| 192 | auto countOfItems = _dataSource->numberOfCellsInTableView(this); |
| 193 | if (0 == countOfItems || idx > countOfItems - 1) |
| 194 | { |
| 195 | return; |
| 196 | } |
| 197 | |
| 198 | ssize_t newIdx = 0; |
| 199 | |
| 200 | auto cell = cellAtIndex(idx); |
| 201 | if (cell) |
| 202 | { |
| 203 | newIdx = _cellsUsed.getIndex(cell); |
| 204 | // Move all cells behind the inserted position |
| 205 | for (auto i = newIdx; i < _cellsUsed.size(); i++) |
| 206 | { |
| 207 | cell = _cellsUsed.at(i); |
| 208 | this->_setIndexForCell(cell->getIdx() + 1, cell); |
| 209 | } |
| 210 | } |
| 211 | |
| 212 | // insert a new cell |
| 213 | cell = _dataSource->tableCellAtIndex(this, idx); |
| 214 | this->_setIndexForCell(idx, cell); |
| 215 | this->_addCellIfNecessary(cell); |
| 216 | |
| 217 | this->_updateCellPositions(); |
| 218 | this->_updateContentSize(); |
| 219 | } |
| 220 | |
| 221 | void TableView::removeCellAtIndex(ssize_t idx) |
| 222 | { |
no test coverage detected