void StackLayout::doRelayout() { const List<DisplayItem *> &items = getItems(); DisplayItem *inputField = items.getAt(0); int bottom; if (isItemVisible(inputField)) { setItemSize(inputField, getWidth(), font->getLineHeight()); bottom = getHeight() - inputField->getHeight(); setItemPosition(inputField, 0, bottom); } else { bottom = getHeight(); } int i = 0; upperItemNr = 0; while (bottom > 0 && i + firstLevelVisible < stack->getLength()) { upperItemNr++; DisplayItem *item; if (items.getLength() <= upperItemNr) { item = stack->getAt(i + firstLevelVisible)->getDisplayItem(*font); addItem(item); } else { item = items.getAt(upperItemNr); if (item == NULL) { item = stack->getAt(i + firstLevelVisible)->getDisplayItem(*font); setItemAt(upperItemNr, item); } } if (item) { int nw = getNumberWidth(upperItemNr + firstLevelVisible); setItemSize(item, getWidth() - nw, -1); int h = item->getHeight(); if (h < font->getLineHeight()) h = font->getLineHeight(); bottom -= h; int w = item->getWidth(); if (w < getWidth() - nw) setItemPosition(item, getWidth() - w, bottom); else setItemPosition(item, nw, bottom); } else { bottom -= font->getLineHeight(); } i++; } while (items.getLength() > upperItemNr + 1) { removeItemAt(upperItemNr + 1); } while (bottom > 0) { upperItemNr++; bottom -= font->getLineHeight(); } upperItemScanStart = -bottom; }
void PlayList::insertItemAt(const PlayListItem &item, int row) { if (mMaxRows > 0 && mpModel->rowCount() >= mMaxRows) { // +1 because new row is to be inserted mpModel->removeRows(mMaxRows, mpModel->rowCount() - mMaxRows + 1); } if (!mpModel->insertRow(row)) return; setItemAt(item, row); }