BOOL CXmlItem::DeleteItem(CXmlItem* pXI) { if (RemoveItem(pXI)) { delete pXI; return TRUE; } return FALSE; }
void JobListView::RemoveJob(Job* job) { JobItem* item = FindJob(job); if (item) { RemoveItem(item); delete item; Invalidate(); } }
void PopupHistoryList::AddItem(PopupHistoryData item) { if (count >= size) { RemoveItem(0); //remove first element - the oldest count--; //it will be inc'ed later } historyData[count++] = item; //item has it's relevant strings dupped() RefreshPopupHistory(hHistoryWindow, GetRenderer()); }
void TExpandoMenuBar::RemoveTeam(team_id team, bool partial) { TWindowMenuItem* windowItem = NULL; for (int32 i = CountItems() - 1; i >= 0; i--) { TTeamMenuItem* item = dynamic_cast<TTeamMenuItem*>(ItemAt(i)); if (item != NULL && item->Teams()->HasItem((void*)(addr_t)team)) { item->Teams()->RemoveItem(team); if (partial) return; BAutolock locker(sMonLocker); // make the update thread wait RemoveItem(i); if (item == fPreviousDragTargetItem) fPreviousDragTargetItem = NULL; if (item == fLastMousedOverItem) fLastMousedOverItem = NULL; if (item == fLastClickedItem) fLastClickedItem = NULL; delete item; while ((windowItem = dynamic_cast<TWindowMenuItem*>( ItemAt(i))) != NULL) { // Also remove window items (if there are any) RemoveItem(i); if (windowItem == fLastMousedOverItem) fLastMousedOverItem = NULL; if (windowItem == fLastClickedItem) fLastClickedItem = NULL; delete windowItem; } SizeWindow(-1); Window()->UpdateIfNeeded(); return; } } }
//************************************************************************ // removes a contact from the list //************************************************************************ void CContactList::RemoveContact(MCONTACT hContact) { CListContainer<CContactListEntry*,CContactListGroup*> *pGroup = NULL; ///tstring strGroup = GetContactGroupPath(hContact); CListEntry<CContactListEntry*,CContactListGroup*> *pContactEntry = FindContact(hContact); if(!pContactEntry) { return; } if( !CConfig::GetBoolSetting(CLIST_USEGROUPS)){ if(pContactEntry->GetType() == ITEM) RemoveItem(((CListItem<CContactListEntry*,CContactListGroup*>*)pContactEntry)->GetItemData()); else RemoveGroup(((CListContainer<CContactListEntry*,CContactListGroup*>*)pContactEntry)->GetGroupData()); } else { pGroup = (CListContainer<CContactListEntry*,CContactListGroup*>*)pContactEntry->GetParent(); ASSERT(pGroup != NULL); CContactListEntry *pEntry = GetContactData(pContactEntry); if(!pEntry) { return; } // Update the contacts group if it has one if(pGroup->GetType() != ROOT) { if(!db_mc_isSub(hContact) && pEntry->iStatus != ID_STATUS_OFFLINE) ChangeGroupObjectCounters(pGroup->GetGroupData()->strPath,0,-1); if(!db_mc_isSub(hContact) && pEntry->iMessages > 0) ChangeGroupObjectCounters(pGroup->GetGroupData()->strPath,0,0,-pEntry->iMessages); } if(pContactEntry->GetType() == ITEM) pGroup->RemoveItem(((CListItem<CContactListEntry*,CContactListGroup*>*)pContactEntry)->GetItemData()); else { pGroup->RemoveGroup(((CListContainer<CContactListEntry*,CContactListGroup*>*)pContactEntry)->GetGroupData()); // Reenumerate all subcontacts (maybe MetaContacts was disabled int numContacts = db_mc_getSubCount(hContact); for(int i=0;i<numContacts;i++) { MCONTACT hSubContact = db_mc_getSub(hContact, i); if(!FindContact(hSubContact)) AddContact(hSubContact); } } CListContainer<CContactListEntry*,CContactListGroup*> *pParent = (CListContainer<CContactListEntry*,CContactListGroup*>*)pGroup->GetParent(); while(pParent != NULL && pGroup->IsEmpty() && !pGroup->GetGroupData()->hMetaContact) { pParent->RemoveGroup(pGroup->GetGroupData()); pGroup = pParent; pParent = (CListContainer<CContactListEntry*,CContactListGroup*>*)pGroup->GetParent(); } } }
void NickDataViewCtrl::RemoveUser(const User& user) { if (!RemoveRealUser(user)) { return; } //Only remove added users if (ContainsItem(user)) { RemoveItem(user); } }
void DormantNodeView::_freeList() { D_HOOK(("DormantNodeView::_freeList()\n")); // remove and delete all items in the list while (CountItems() > 0) { BListItem *item = ItemAt(0); if (RemoveItem(item)) { delete item; } } }
void CLDisplayClassTable::SetElement( DMElement* inElement) { // Validate pointers. ValidateThis_(); if (inElement != nil) ValidateObject_(inElement); // See if the element has changed. If not, ignore request. if (inElement == mElement) return; // Make sure screen doesn't flash while changing elements. #if PP_Target_Carbon StClipRgnState noFlash(nil); #else StVisRgn noFlash(GetMacPort()); #endif ValidateObject_(mSuperView); mSuperView->Refresh(); // Override to allow changing elements. If we are assigned // to an element already, empty the table. if (mElement != nil) { ValidateObject_(mElement.GetObject()); while (mRows > 0) { LOutlineItem* item = FindItemForRow(1); ValidateObject_(item); RemoveItem(item, false, false); } AdjustImageSize(false); mSuperView->Refresh(); // GHD: Refresh SuperView so that scroll bars get redrawn mElement->RemoveListener(this); mElement = nil; mContainer = nil; } // Now call the inherited method for set element only // if the new element is non-nil. if (inElement != nil) OVTable::SetElement(inElement); }
void Sound::ProcessSamplerRemove() { std::vector<size_t> & sremove = samplers_update.getLast().sremove; for (size_t i = 0; i < sremove.size(); ++i) { size_t id = sremove[i]; assert(id < samplers.size()); RemoveItem(id, samplers, samplers_num); } sremove.clear(); }
void CMyTreeView::RemoveItem(const TCHAR *szFullFileName) { HTREEITEM hItem; hItem = LocateDeletedItem(szFullFileName); if(hItem != NULL) { RemoveItem(hItem); } }
/***************************************************************************** * DragSortableListView::RemoveItemList *****************************************************************************/ void DragSortableListView::RemoveItemList( BList& items ) { int32 count = items.CountItems(); for ( int32 i = 0; i < count; i++ ) { BListItem* item = (BListItem*)items.ItemAt( i ); if ( RemoveItem( item ) ) delete item; } }
void NotifyList::UpdateList(BObjectList<NotifyListItem> *newList) { while (CountItems() > 0) delete RemoveItem ((int32)0); BList updateList; // make private copy of list items otherwise things go bad for (int32 i = 0; i < newList->CountItems(); i++) updateList.AddItem (new NotifyListItem (*newList->ItemAt(i))); AddList(&updateList); }
IWindowContainer* SplitterContainer::RemoveItem(IWindow *lpWnd, bool bUpdateComponents) { AFX_MANAGE_STATE(AfxGetStaticModuleState()); for(int i=0; i<MAXITEMSCOL; i++) { if(m_bHorizontalMode) { TWindows &tw = m_controls[0][i]; if(tw.itf == lpWnd) RemoveItem(i, NULL, bUpdateComponents); } else { TWindows &tw = m_controls[i][0]; if(tw.itf == lpWnd) RemoveItem(i, NULL, bUpdateComponents); } } return this; }
void vmsBrowserActivityMonitor::RemoveTimedoutItems(void) { DWORD dwNow = GetTickCount (); vmsAUTOLOCKSECTION (m_csList); for (size_t i = 0; i < m_vList.size (); i++) { if (dwNow - m_vList [i].dwTimeLastActivity >= 10*1000) RemoveItem (i--); } }
void LogisticsPilotListBox::removePilot(LogisticsPilot* pPilot) { for(size_t i = 0; i < itemCount; i++) { LogisticsPilotListBoxItem* pItem = dynamic_cast<LogisticsPilotListBoxItem*>(items[i]); if(pItem && pItem->getPilot() == pPilot) { RemoveItem(pItem, true); return; } } }
/** Use the selected item on the inventory * @param item : the inventory * @param data : the object on what is item is used (generally a character) */ void Inventory::UseSelectedItem(void* data) { if(selected_item != NULL) { int count = selected_item->Use(data); if(count == 0) { RemoveItem(selected_item); selected_item = NULL; } } }
void PrinterListView::EntryRemoved(node_ref* node) { PrinterItem* item = _FindItem(node); if (item) { if (item == fActivePrinter) fActivePrinter = NULL; RemoveItem(item); delete item; } }
int main(void) { List list; Item item; //初始化单链表 printf("Initialize List\n"); Initialize(&list); if (IsEmpty(&list)) { printf("List is empty!\n"); while (1 == scanf("%d", &item)) { AddItemHead(item, &list); } ClearBuffer(); } printf("List items:\n"); Traverse(&list, (void (*) (Item item)) (&DisplayItem)); printf("\nList has %d items.\n", ItemCount(&list)); if (IsFull(&list)) { printf("List is full!\n"); } printf("Clear List!\n"); ClearList(&list); if (IsEmpty(&list)) { printf("List is empty!\n"); while (1 == scanf("%d", &item)) { AddItemTail(item, &list); } ClearBuffer(); } DeleteFirstItem(&list); DeleteLastItem(&list); printf("List items:\n"); Traverse(&list, (void (*) (Item item)) (&DisplayItem)); printf("\nList has %d items.\n", ItemCount(&list)); item = 3; RemoveItem(item, &list); printf("List items:\n"); Traverse(&list, (void (*) (Item item)) (&DisplayItem)); printf("\nList has %d items.\n", ItemCount(&list)); DestroyList(&list); return 0; }
void DocPrintMarkList::RemoveMark(UINT32 handle) { DocPrintMark* pMark = FindMark(handle); if (pMark) { RemoveItem(pMark); delete pMark; } else { TRACEUSER( "Mike", _T("Unable to find mark during DocPrintMarkList::RemoveMark()")); } }
void RosterView::RemoveSelected() { if (CurrentItemSelection()) { int32 selected = CurrentSelection(); RosterItem *item = CurrentItemSelection(); if (item == NULL) return; RemoveItem(CurrentSelection()); if (ItemAt(selected)) Select(selected); else if (ItemAt(selected - 1)) Select(selected - 1); } }
void LogisticsPilotListBox::update() { aListBox::update(); for(size_t i = 0; i < itemCount; i++) { if(((LogisticsPilotListBoxItem*)items[i])->getPilot() && ((LogisticsPilotListBoxItem*)items[i])->getPilot()->isUsed()) { RemoveItem(items[i], true); i--; } } }
void Necklace::UseItem(PlayerInfo& playerInfo, Raknet& raknet) { { RakNet::BitStream bsOut; bsOut.Write((RakNet::MessageID)ID_EQIUP_ITEM); bsOut.Write(mItemNumber); bsOut.Write(mImageNumber); bsOut.Write(necklace); raknet.mPeer->Send(&bsOut,HIGH_PRIORITY,RELIABLE_ORDERED,0,raknet.mServerAddress,false); } RemoveItem(raknet); }
void CUIDMStatisticWnd::Update () { inherited::Update(); //----------------------------------- if (!Game().local_player) return; PLAYERS_STATS_it pPlayerI; if (!Game().m_WeaponUsageStatistic->GetPlayer(Game().local_player->getName(), pPlayerI)) { while (GetItemCount()) { RemoveItem(0); } return; }; Player_Statistic* pPS = &(*pPlayerI); //----------------------------------------- while (pPS->aWeaponStats.size() < GetItemCount()) { RemoveItem(0); }; //--------------------------------------- while (pPS->aWeaponStats.size() > GetItemCount()) { AddItem(); }; //--------------------------------------- for (u32 i=0; i<GetItemCount(); i++) { CUIStatsListItem *pItem = GetItem(i); if (!pItem) continue; if (SetItemData(&(pPS->aWeaponStats[i]), pItem)) continue; pItem->FieldsVector[0]->SetText(NULL); pItem->FieldsVector[1]->SetText(NULL); pItem->FieldsVector[2]->SetText(NULL); }; };
/*********************************************************** * Rebuild ***********************************************************/ void AddOnMenu::Rebuild() { // Delete all items BMenuItem *item; for(;;){ item = RemoveItem(0L); if(!item) break; delete item; } // Build items again Build(); }
bool MyListView::AddItem (BListItem *item) { bool ok = MListView::AddItem(item); int32 total = CountItems(); BListItem *rem; if (ok && (listLimit > 0)) { // remove some old list items while (total > listLimit) { rem = RemoveItem((int32)0); total--; delete rem; } } return ok; }
void JobListView::SetSpoolFolder(SpoolFolder* folder) { // clear list while (!IsEmpty()) delete RemoveItem(0L); if (folder == NULL) return; // Find directory containing printer definition nodes for (int32 i = 0; i < folder->CountJobs(); i++) AddJob(folder->JobAt(i)); }
BOOL Hotlist::ChangeItem(OpTreeModel* model, INT32 model_pos) { if( !model ) { return FALSE; } OpTreeModelItem* model_item = model->GetItemByPosition(model_pos); if( !model_item ) { return FALSE; } INT32 pos = FindItem(model_item->GetID()); if (pos == -1) { return AddItem(model, model_pos); } // if pos is not -1, that is, if the item is in panels, remoe if neccessary HotlistManager::ItemData item_data; g_hotlist_manager->GetItemValue( model_item, item_data ); if( item_data.panel_position == -1 ) { return RemoveItem(model, model_pos); } // This Panel is already in panels (m_widgets) and should be there m_selector->GetWidget(pos)->SetText(item_data.name.CStr()); // Move the panel to the position given in bookmarks model m_selector->MoveWidget(pos, item_data.panel_position); for (INT32 i = 0; i < GetPanelCount(); i++) { HotlistPanel* panel = GetPanel(i); if (panel->GetType() == PANEL_TYPE_WEB && model_item->GetID() == panel->GetID()) { panel->UpdateSettings(); return TRUE; } } return TRUE; }
void SkillInventory::OnRightPress(ItemSlot& itemSlot) { // Don't do anything unless the local player is selected. if(!GetClient()->IsLocalPlayerSelected() || GetClient()->GetArenaState() == PLAYING_STATE) return; // Sell skill. RemoveItem(itemSlot.item); Player* player = GetClient()->GetLocalPlayer(); player->SetGold(player->GetGold() + itemSlot.item->GetCost() - 1); // [NOTE][TODO] Hard coded!!!! // Send message to server. SendGoldChange(player->GetId(), player->GetGold()); }
bool RecentItemsMenu::StartBuildingItemList() { // remove any preexisting items int32 itemCount = CountItems(); while (itemCount--) delete RemoveItem((int32)0); fCount = 0; fSanityCount = 0; fIterator->Rewind(); return true; }
/** if resref is "", then destroy ALL items this function can look for stolen, equipped, identified, destructible etc, items. You just have to specify the flags in the bitmask specifying 1 in a bit signifies a requirement */ unsigned int Inventory::DestroyItem(const char *resref, ieDword flags, ieDword count) { unsigned int destructed = 0; size_t slot = Slots.size(); while(slot--) { //ignore the fist slot if (slot == (unsigned int)SLOT_FIST) { continue; } CREItem *item = Slots[slot]; if (!item) { continue; } // here you can simply destroy all items of a specific type if ( (flags&item->Flags)!=flags) { continue; } if (resref[0] && strnicmp(item->ItemResRef, resref, 8) ) { continue; } //we need to acknowledge that the item was destroyed //use unequip stuff, decrease encumbrance etc, //until that, we simply erase it ieDword removed; if (item->Flags&IE_INV_ITEM_STACKED) { removed=item->Usages[0]; if (count && (removed + destructed > count) ) { removed = count - destructed; item = RemoveItem( (unsigned int) slot, removed ); } else { KillSlot( (unsigned int) slot); } } else { removed=1; KillSlot( (unsigned int) slot); } delete item; Changed = true; destructed+=removed; if (count && (destructed>=count) ) break; } if (Changed && Owner && Owner->InParty) displaymsg->DisplayConstantString(STR_LOSTITEM, 0xbcefbc); return destructed; }