void PrefListView::BuildView(XmlNode *node, int level, BListItem* parent) { if (!node) { puts("Rebuild mit NULL?!"); return; } int anz = node->Children(); //printf("BuildView: %s %d einträge\n", node->Attribute("text"), anz); if (anz>0) { if (level==0) { for (int i=0;i<anz;i++) { XmlNode* c = (XmlNode*)node->ItemAt(i); const char* t = c->Attribute("text"); BStringItem* item = new BStringItem(t); item->SetText( t ); if (level>0) AddUnder(item, parent); else AddItem(item); //printf("Hinzufügen war %d\n", b); if (c->Children()>0) { BuildView(c, level+1, item); } } DeselectAll(); } else { for (int i=anz-1;i>=0;i--) { XmlNode* c = (XmlNode*)node->ItemAt(i); const char* t = c->Attribute("text"); BStringItem* item = new BStringItem(t); item->SetText( t ); if (level>0) AddUnder(item, parent); else AddItem(item); //printf("Hinzufügen war %d\n", b); if (c->Children()>0) { BuildView(c, level+1, item); } } } } else { //puts("Tja..."); } }
void MimeTypeListView::_CollectSubtypes(const char* supertype, MimeTypeItem* supertypeItem) { BMessage types; if (BMimeType::GetInstalledTypes(supertype, &types) != B_OK) return; const char* type; int32 index = 0; while (types.FindString("types", index++, &type) == B_OK) { BMimeType mimeType(type); bool isApp = mimetype_is_application_signature(mimeType); if (fApplicationMode ^ isApp) continue; MimeTypeItem* typeItem = new MimeTypeItem(mimeType, fShowIcons, supertypeItem == NULL); typeItem->SetApplicationMode(isApp); if (supertypeItem != NULL) AddUnder(typeItem, supertypeItem); else AddItem(typeItem); } }
void RosterView::LinkUser(UserID *added_user, bool sort = true) { if (!added_user) return; Window()->Lock(); if (added_user->UserType() == UserID::CONFERENCE) { AddUnder(new RosterItem(added_user), _conferences); if (sort) SortItemsUnder(_conferences, true, _ListComparison); } else if (added_user->UserType() == UserID::JABBER) { if (added_user->SubscriptionStatus() == "none") { AddUnder(new RosterItem(added_user), _unknown); if (sort) SortItemsUnder(_unknown, true, _ListComparison); } else { if (added_user->OnlineStatus() == UserID::ONLINE) { AddUnder(new RosterItem(added_user), _online); if (sort) SortItemsUnder(_offline, true, _ListComparison); } else if (added_user->OnlineStatus() == UserID::CONF_STATUS) { AddUnder(new RosterItem(added_user), _conferences); if (sort) SortItemsUnder(_offline, true, _ListComparison); } else { AddUnder(new RosterItem(added_user), _offline); if (sort) SortItemsUnder(_offline, true, _ListComparison); } } } Window()->Unlock(); }
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 = ""; } }