void MimeTypeListView::ShowIcons(bool showIcons) { if (showIcons == fShowIcons) return; fShowIcons = showIcons; if (Window() == NULL) return; // update items BFont font; GetFont(&font); for (int32 i = FullListCountItems(); i-- > 0;) { MimeTypeItem* item = dynamic_cast<MimeTypeItem*>(FullListItemAt(i)); if (item == NULL) continue; if (!item->IsSupertypeOnly()) item->ShowIcon(showIcons); item->Update(this, &font); } FrameResized(Bounds().Width(), Bounds().Height()); // update scroller Invalidate(); }
void MimeTypeListView::_AddNewType(const char* type) { MimeTypeItem* item = FindItem(type); BMimeType mimeType(type); bool isApp = mimetype_is_application_signature(mimeType); if (fApplicationMode ^ isApp || !mimeType.IsInstalled()) { if (item != NULL) { // type doesn't belong here RemoveItem(item); delete item; } return; } if (item != NULL) { // for some reason, the type already exists return; } BMimeType superType; MimeTypeItem* superItem = NULL; if (mimeType.GetSupertype(&superType) == B_OK) superItem = FindItem(superType.Type()); item = new MimeTypeItem(mimeType, fShowIcons, fSupertype.Type() != NULL); if (item->IsSupertypeOnly()) item->ShowIcon(false); item->SetApplicationMode(isApp); if (superItem != NULL) { AddUnder(item, superItem); InvalidateItem(IndexOf(superItem)); // the super item is not picked up from the class (ie. bug) } else AddItem(item); UpdateItem(item); if (!fSelectNewType.ICompare(mimeType.Type())) { SelectItem(item); fSelectNewType = ""; } }