本文整理汇总了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);
}
示例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();
}
示例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);
}
示例4: Delete
void Accounts::Delete()
{
for (int32 i = gAccounts.CountItems();i-- > 0;)
{
Account *account = (Account *)gAccounts.RemoveItem(i);
delete account;
}
}
示例5:
void
remove_listener(BMessenger *messenger)
{
if (sLocker.Lock()) {
sListeners.RemoveItem(messenger);
sLocker.Unlock();
}
}
示例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;
}
示例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);
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}
}
示例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);
}
}
示例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;
}
示例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);
}
示例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;
}
}