Listbox and empty items

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"?

Call ListBox::updateContent() and have your model only return a count of and items form the filtereed set.

 

(apolgies for typos, this new site is breaking safari, and I can';t actually read anything I'm typing here)

It works if there are only filtered items in the collection or if these items come first. I wouldn't like to have other collection for filtered items only.

I might not be understanding you, or I might not have explained myself properly.

 

When you need to filter your list, have your controller notify the model of the current filter criteria, then call updateContent().  The ListBox will then ask the model for an item count, and the model can return the number of items in the reduced set.  You're trying to remove rows directly from the ListBox which is not going to work.   

 

(Jules, can someone please take a look at why this editor utterly falls apart in Safari)

valley, re: Safari - thanks for the heads-up, my web-devs are working on a fix right now. Apparently a workaround is to type your message on the fourth paragraph down and then delete the empty paragraphs.  Also if you d a ‘select all’ in the editor then everything should appear temporarily.

 

 

 

 

Cheers Jules!