当前位置: 首页>>代码示例>>C++>>正文


C++ BList::RemoveItem方法代码示例

本文整理汇总了C++中BList::RemoveItem方法的典型用法代码示例。如果您正苦于以下问题:C++ BList::RemoveItem方法的具体用法?C++ BList::RemoveItem怎么用?C++ BList::RemoveItem使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在BList的用法示例。


在下文中一共展示了BList::RemoveItem方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: new

void
Model::AddToHistory(const char* text)
{
	BList items;
	_LoadHistory(items);

	BString* string = new (nothrow) BString(text);
	if (string == NULL || !items.AddItem(string)) {
		delete string;
		_FreeHistory(items);
		return;
	}

	int32 count = items.CountItems() - 1;
		// don't check last item, since that's the one we just added
	for (int32 t = 0; t < count; ++t) {
		// If the same text is already in the list,
		// then remove it first. Case-sensitive.
		BString* string = static_cast<BString*>(items.ItemAt(t));
		if (*string == text) {
			delete static_cast<BString*>(items.RemoveItem(t));
			break;
		}
	}

	while (items.CountItems() >= HISTORY_LIMIT)
		delete static_cast<BString*>(items.RemoveItem((int32)0));

	_SaveHistory(items);
	_FreeHistory(items);
}
开发者ID:looncraz,项目名称:haiku,代码行数:31,代码来源:Model.cpp

示例2: output

static void
listener_output(syslog_message &message)
{
	// compose the message to be sent to all listeners; just convert
	// the syslog_message into a BMessage
	BMessage output(SYSLOG_MESSAGE);

	output.AddInt32("from", message.from);
	output.AddInt32("when", message.when);
	output.AddString("ident", message.ident);
	output.AddString("message", message.message);
	output.AddInt32("options", message.options);
	output.AddInt32("priority", message.priority);

	sLocker.Lock();

	for (int32 i = sListeners.CountItems(); i-- > 0;) {
		BMessenger *target = (BMessenger *)sListeners.ItemAt(i);

		status_t status = target->SendMessage(&output);
		if (status < B_OK) {
			// remove targets once they can't be reached anymore
			sListeners.RemoveItem(target);
		}
	}

	sLocker.Unlock();
}
开发者ID:SummerSnail2014,项目名称:haiku,代码行数:28,代码来源:listener_output.cpp

示例3: BMessage

void
TestWindow::AddTest(Test* test)
{
	if (test == NULL || fTests.HasItem(test))
		return;

	if (!fTests.AddItem(test)) {
		delete test;
		return;
	}

	BMessage* message = new BMessage(MSG_SELECT_TEST);
	message->AddInt32("index", fTests.CountItems() - 1);

	BMenuItem* item = new BMenuItem(test->Name(), message);
	if (!fTestSelectionField->Menu()->AddItem(item)) {
		fTests.RemoveItem(fTests.CountItems() - 1);
		delete test;
		delete item;
		return;
	}

	if (fTests.CountItems() == 1)
		SetToTest(0);
}
开发者ID:SummerSnail2014,项目名称:haiku,代码行数:25,代码来源:main.cpp

示例4: Delete

void Accounts::Delete()
{
	for (int32 i = gAccounts.CountItems();i-- > 0;)
	{
		Account *account = (Account *)gAccounts.RemoveItem(i);
		delete account;
	}
}
开发者ID:mmanley,项目名称:Antares,代码行数:8,代码来源:Account.cpp

示例5:

void 
remove_listener(BMessenger *messenger)
{
	if (sLocker.Lock()) {
		sListeners.RemoveItem(messenger);

		sLocker.Unlock();
	}
}
开发者ID:SummerSnail2014,项目名称:haiku,代码行数:9,代码来源:listener_output.cpp

示例6: gui_empty_clipboard

bool gui_empty_clipboard(void)
{
	current_selection.Truncate(0);
	while (current_selection_textruns.ItemAt(0)) {
		text_run *run = (text_run *)current_selection_textruns.RemoveItem(0L);
		delete run;
	}
	return true;
}
开发者ID:pcwalton,项目名称:NetSurf,代码行数:9,代码来源:window.cpp

示例7: DoRemoveAttribute

void RemoveAttribute::DoRemoveAttribute(PDocument *doc, BMessage *node, BMessage *valueContainer,BMessage *undoMessage)
{
	node->PrintToStream();
	valueContainer->PrintToStream();
	undoMessage->PrintToStream();
	status_t	err				= B_OK;
	int32 		i				= 0;
	int32		j				= 0;
	BList		*subGroupList	= new BList();
	BMessage	*subGroup		= NULL;
	BMessage	*tmpSubGroup	= new BMessage();
	BList		*changed		= doc->GetChangedNodes();
	//do 
	char		*name			= NULL;
	char		*tmpName		= NULL;
	char		*subGroupName	= NULL;
	type_code	type			= B_ANY_TYPE;
	void*		oldValue		= NULL;
	int32		index			= 0;
	int32		count			= 0;
	ssize_t 	size			= 0;
	err = valueContainer->FindString("name",(const char**)&name);
	err = err | valueContainer->FindInt32("index",(int32 *)&index);
	subGroup = node;
	subGroupList->AddItem(subGroup);
	while (valueContainer->FindString("subgroup",i,(const char**)&subGroupName) == B_OK)
	{	
		subGroup->FindMessage(subGroupName,tmpSubGroup);
		subGroupList->AddItem(tmpSubGroup);
		subGroup	= tmpSubGroup;
		tmpSubGroup	= new BMessage();
		i++;
	}
	delete tmpSubGroup;
#ifdef B_ZETA_VERSION_1_0_0
	while ((subGroup->GetInfo(B_ANY_TYPE, j, (const char **)&tmpName, &type, &count) == B_OK) && ((count-1) != index))
#else
	while((subGroup->GetInfo(B_ANY_TYPE, j, (char**)&tmpName, &type, &count) == B_OK) && ((count-1) != index))
#endif
		j++;
	subGroup->FindData(name,type,count-1,(const void **)&oldValue,&size);

	undoMessage->AddData("deletedAttribut",type,oldValue,size);
	undoMessage->AddString("deletedName",name);
	undoMessage->AddInt32("deletedType",type);
	subGroup->RemoveData(name,index);
	for (i=subGroupList->CountItems()-1;i>0;i--)
	{
		tmpSubGroup = (BMessage *)subGroupList->ItemAt(i-1);
		valueContainer->FindString("subgroup",i-1,(const char**)&subGroupName);
		if (tmpSubGroup)
			tmpSubGroup->ReplaceMessage(subGroupName,(BMessage *)subGroupList->ItemAt(i));
		delete subGroupList->RemoveItem(i);
	}
	changed->AddItem(node);
	
}
开发者ID:BackupTheBerlios,项目名称:projectconcepto-svn,代码行数:57,代码来源:RemoveAttribute.cpp

示例8: curImage

// Function taken from Haiku ShowImage,
// function originally written by Michael Pfeiffer
bool
SlideShowSaver::FindNextImage(entry_ref *in_current, entry_ref *out_image, bool next, bool rewind)
{
//	ASSERT(next || !rewind);
	BEntry curImage(in_current);
	entry_ref entry, *ref;
	BDirectory parent;
	BList entries;
	bool found = false;
	int32 cur;

	if (curImage.GetParent(&parent) != B_OK)
		return false;

	while (parent.GetNextRef(&entry) == B_OK) {
		if (entry != *in_current) {
			entries.AddItem(new entry_ref(entry));
		} else {
			// insert current ref, so we can find it easily after sorting
			entries.AddItem(in_current);
		}
	}

	entries.SortItems(CompareEntries);

	cur = entries.IndexOf(in_current);
//	ASSERT(cur >= 0);

	// remove it so FreeEntries() does not delete it
	entries.RemoveItem(in_current);

	if (next) {
		// find the next image in the list
		if (rewind) cur = 0; // start with first
		for (; (ref = (entry_ref*)entries.ItemAt(cur)) != NULL; cur ++) {
			if (IsImage(ref)) {
				found = true;
				*out_image = (const entry_ref)*ref;
				break;
			}
		}
	} else {
		// find the previous image in the list
		cur --;
		for (; cur >= 0; cur --) {
			ref = (entry_ref*)entries.ItemAt(cur);
			if (IsImage(ref)) {
				found = true;
				*out_image = (const entry_ref)*ref;
				break;
			}
		}
	}

	FreeEntries(&entries);
	return found;
}
开发者ID:AmirAbrams,项目名称:haiku,代码行数:59,代码来源:SlideShowSaver.cpp

示例9: GetAppList

/*
	void GetAppList(const char *signature, BList *teamIDList) const
	@case 3			teamIDList is not NULL and not empty, signature is not
					NULL and app(s) with this signature is (are) running
	@results		Should append the team IDs of all running apps with the
					supplied signature to teamIDList.
*/
void GetAppListTester::GetAppListTestB3()
{
	const char *signature = "application/x-vnd.obos-app-run-testapp1";
	// create a list with some dummy entries
	BList list;
	list.AddItem((void*)-7);
	list.AddItem((void*)-42);
	// get a list of running applications for reference
	BRoster roster;
	BList list1(list);
	roster.GetAppList(signature, &list1);
	check_list(list1, list);
	// run some apps
	AppRunner runner1(true);
	AppRunner runner2(true);
	AppRunner runner3(true);
	CHK(runner1.Run("AppRunTestApp1") == B_OK);
	CHK(runner2.Run("AppRunTestApp2") == B_OK);
	CHK(runner3.Run("BMessengerTestApp1") == B_OK);
	BList expectedApps;
	expectedApps.AddItem((void*)runner1.Team());
	expectedApps.AddItem((void*)runner2.Team());
	// get a new app list and check it
	BList list2(list);
	roster.GetAppList(signature, &list2);
	check_list(list2, list, expectedApps);
	// quit app 1
	runner1.WaitFor(true);
	expectedApps.RemoveItem((void*)runner1.Team());
	BList list3(list);
	roster.GetAppList(signature, &list3);
	check_list(list3, list, expectedApps);
	// quit app 2
	runner2.WaitFor(true);
	expectedApps.RemoveItem((void*)runner2.Team());
	BList list4(list);
	roster.GetAppList(signature, &list4);
	check_list(list4, list, expectedApps);
	// quit app 3
	runner3.WaitFor(true);
	BList list5(list);
	roster.GetAppList(signature, &list5);
	check_list(list5, list, expectedApps);
}
开发者ID:SummerSnail2014,项目名称:haiku,代码行数:51,代码来源:GetAppListTester.cpp

示例10: QuitRequested

bool TCueSheetWindow::QuitRequested()
{
	bool retVal = true;
	bool quit       = false;

	// Ask user to save document
	if (fCueSheetView->IsDirty()) {
		long userVal = SaveAlert();

		// Check user response
		switch( userVal)
		{
		// User does not want to save
		case 0:
			fCueSheetView->SetDirty(false);
			retVal = true;
			break;

		// User decided not to quit
		case 1:
			retVal = false;
			break;

		// User wants to save
		case 2:
			retVal = false;
			break;

		default:
			retVal = true;

		}
	}

	// Remove ourself from applications Cue Sheet list if window is closing
	if (retVal) {
		BList* theList = static_cast<MuseumApp*>(be_app)->GetCueSheetList();
		if (theList) {
			theList->RemoveItem(this);

			// If this is the last cue sheet open, tell application to quit
			if (theList->CountItems() == 0) {
				quit = true;
				be_app->PostMessage(B_QUIT_REQUESTED);
			}
		}
	}

	// Now tell app to fix Windows menu to reflect new state
	if (quit == false)
		be_app->PostMessage(FIX_WINDOWS_MENU_MSG);

	// Return user response to application
	return retVal;
}
开发者ID:Barrett17,项目名称:UltraDV,代码行数:55,代码来源:TCueSheetWindow.cpp

示例11: generate_music

// mix audio from any running notes into the output buffer,
// and start any new notes as we run across their sample-positions
static void generate_music(uint8_t *outbuffer, int len)
{
	// account for stereo
	len *= 2;
	
	int outpos = 0;
	while(outpos < len)
	{
		// start any notes that are supposed to begin on this sample
		if (--song.samples_left_in_beat <= 0)
		{
			for(int t=0;t<TOTAL_TRACKS;t++)
				start_notes(&song.track[t], song.beat);
			
			song.beat++;
			song.samples_left_in_beat = song.samples_per_beat;
			
			if (song.beat >= song.loop_end)
				song.beat = song.loop_start;
		}
		
		// mix
		int mix_left = 0;
		int mix_right = 0;
		for(int chan=0;;chan++)
		{
			stRunningNote *snd = (stRunningNote *)running_notes.ItemAt(chan);
			if (!snd) break;
			
			mix_left  += snd->samples[snd->curpos++];
			mix_right += snd->samples[snd->curpos++];
			
			if (snd->curpos >= snd->nsamples*2)
			{
				free_running_note(snd);
				running_notes.RemoveItem(chan);
				chan--;
			}
		}
		
		mix_left /= 3;
		mix_right /= 3;
		
		mix_left = (mix_left / 256) + 128;
		mix_right = (mix_right / 256) + 128;
		
		if (mix_left  < 0) mix_left = 0;
		if (mix_right < 0) mix_right = 0;
		if (mix_left  > 255) mix_left = 255;
		if (mix_right > 255) mix_right = 255;
		
		outbuffer[outpos++] = mix_left;
		outbuffer[outpos++] = mix_right;
	}
}
开发者ID:histat,项目名称:dc-nx,代码行数:57,代码来源:pmd.cpp

示例12:

void
BOutlineListView::_CullInvisibleItems(BList& list)
{
	int32 index = 0;
	while (index < list.CountItems()) {
		if (reinterpret_cast<BListItem*>(list.ItemAt(index))->IsItemVisible())
			++index;
		else
			list.RemoveItem(index);
	}
}
开发者ID:,项目名称:,代码行数:11,代码来源:

示例13: DeletePerson

void PeepsWindow::DeletePerson(PersonData *data)
{
	if(!data)
		return;
	
	PeepsListItem *previtem=NULL, *nextitem=NULL;
	
	for(int32 i=0; i<data->CountGroups();i++)
	{
		PersonItem *pitem=data->InstanceAt(i);
		GroupItem *gitem=(GroupItem*)fPeopleList->Superitem(pitem);

		if(pitem->IsSelected())
		{
			int32 index=fPeopleList->IndexOf(pitem);
			if(index>1)
			{
				previtem=(PeepsListItem*)fPeopleList->ItemAt(index-1);
//				nextitem=(PeepsListItem*)fPeopleList->ItemAt(index+1);
			}
			else
			{
				// First person in the entire list. Check to see if this is the only item in
				// the group. If it is, then select the next item in the list, if it exists.
				if(fPeopleList->CountItemsUnder(gitem,true)==1)
					nextitem=(PeepsListItem*)fPeopleList->ItemAt(index+1);
				else
					previtem=(PeepsListItem*)fPeopleList->ItemAt(index-1);
			}
		}
		fPeopleList->RemoveItem(pitem);
		data->DestroyInstance(pitem);
		if(fPeopleList->CountItemsUnder(gitem,true)==0)
		{
			fPeopleList->RemoveItem(gitem);
			gGroupData.RemoveGroup(gitem->Name());
		}
	}
	entry_ref personref=data->FileRef();
	BEntry entry(&personref);
	if(previtem)
		fPeopleList->Select(fPeopleList->IndexOf(previtem));
	else
	if(nextitem)
		fPeopleList->Select(fPeopleList->IndexOf(nextitem));
	else
		fPeopleList->Select(0L);
#ifndef DATA_READ_ONLY
	TrashFile(&entry);
#endif

	gPeopleData.RemoveItem(data);
	delete data;
}
开发者ID:HaikuArchives,项目名称:MrPeeps,代码行数:54,代码来源:PeepsWindow.cpp

示例14: AddAttribute

void RemoveAttribute::AddAttribute(PDocument *doc, BMessage *node, BMessage *valueContainer,BMessage *undoMessage)
{
	node->PrintToStream();
	valueContainer->PrintToStream();
	undoMessage->PrintToStream();
	int32 		i				= 0;
	status_t	err				= B_OK;
	BList		*subGroupList	= new BList();
	BMessage	*subGroup		= NULL;
	BMessage	*tmpSubGroup	= new BMessage();
	BList		*changed		= doc->GetChangedNodes();
	//do 
	char		*name			= NULL;
	char		*subGroupName	= NULL;
	type_code	type			= B_ANY_TYPE;
	ssize_t		size			= 0;
	
	//undo
	char		*compareName	= NULL;
	void*		newValue		= NULL;
	int32		lastIndex		= -1;
	int32		count			= 0;
	int32		index			= 0;
	type_code	typeFound		= B_ANY_TYPE;

	err = undoMessage->FindString("deletedName",(const char**)&name);
	err = err | undoMessage->FindInt32("deletedType",(int32 *)&type);
	err = undoMessage->FindData("deletedAttribut", type,(const void **)&newValue, &size);
	
	subGroup = node;
	subGroupList->AddItem(subGroup);
	while (valueContainer->FindString("subgroup",i,(const char**)&subGroupName) == B_OK)
	{	
		subGroup->FindMessage(subGroupName,tmpSubGroup);
		subGroupList->AddItem(tmpSubGroup);
		subGroup	= tmpSubGroup;
		tmpSubGroup	= new BMessage();
		i++;
	}
	delete tmpSubGroup;
	subGroup->AddData(name,type,newValue,size);
	for (i=subGroupList->CountItems()-1;i>0;i--)
	{
		tmpSubGroup = (BMessage *)subGroupList->ItemAt(i-1);
		valueContainer->FindString("subgroup",i-1,(const char**)&subGroupName);
		if (tmpSubGroup)
			tmpSubGroup->ReplaceMessage(subGroupName,(BMessage *)subGroupList->ItemAt(i));
		delete subGroupList->RemoveItem(i);
	}
	changed->AddItem(node);
}
开发者ID:BackupTheBerlios,项目名称:projectconcepto-svn,代码行数:51,代码来源:RemoveAttribute.cpp

示例15: fortunes

void
AboutView::PickRandomHaiku()
{
	BPath path;
	if (find_directory(B_SYSTEM_DATA_DIRECTORY, &path) != B_OK)
		path = "/system/data";
	path.Append("fortunes");
	path.Append("Haiku");

	BFile fortunes(path.Path(), B_READ_ONLY);
	struct stat st;
	if (fortunes.InitCheck() < B_OK)
		return;
	if (fortunes.GetStat(&st) < B_OK)
		return;

	char* buff = (char*)malloc((size_t)st.st_size + 1);
	if (!buff)
		return;
	buff[(size_t)st.st_size] = '\0';
	BList haikuList;
	if (fortunes.Read(buff, (size_t)st.st_size) == (ssize_t)st.st_size) {
		char* p = buff;
		while (p && *p) {
			char* e = strchr(p, '%');
			BString* s = new BString(p, e ? (e - p) : -1);
			haikuList.AddItem(s);
			p = e;
			if (p && (*p == '%'))
				p++;
			if (p && (*p == '\n'))
				p++;
		}
	}
	free(buff);
	if (haikuList.CountItems() < 1)
		return;

	BString* s = (BString*)haikuList.ItemAt(rand() % haikuList.CountItems());
	BFont font(be_bold_font);
	font.SetSize(be_bold_font->Size());
	font.SetFace(B_BOLD_FACE | B_ITALIC_FACE);
	fCreditsView->SelectAll();
	fCreditsView->Delete();
	fCreditsView->SetFontAndColor(&font, B_FONT_ALL, &kDarkGrey);
	fCreditsView->Insert(s->String());
	fCreditsView->Insert("\n");
	while ((s = (BString*)haikuList.RemoveItem((int32)0))) {
		delete s;
	}
}
开发者ID:,项目名称:,代码行数:51,代码来源:


注:本文中的BList::RemoveItem方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。