I have a list of the products which I display in a listbox customizing each item. Sometimes I need to dipslay only certain type of products. For example:
Component* ProductsListComponent::refreshComponentForRow(int rowNumber, bool /*isSelected*/, Component* existingComponentToUpdate) { ProductsListItemComponent* comp = static_cast<ProductsListItemComponent*>(existingComponentToUpdate); if(rowNumber < m_products.size()) { if (m_products[rowNumber]->needToShow()) { delete existingComponentToUpdate; comp = new ProductsListItemComponent(this, m_products[rowNumber], *m_productsListBox, rowNumber, m_onlineInstall, productTypeToShow); // 'true' means it is always checked on adding } else { delete existingComponentToUpdate; comp = nullptr; } } else { delete existingComponentToUpdate; comp = nullptr; } return comp; }
In this case I have the spaces where unshown items are. What's the best way to remove these "empty items"?