本文整理汇总了C++中BList::CountItems方法的典型用法代码示例。如果您正苦于以下问题:C++ BList::CountItems方法的具体用法?C++ BList::CountItems怎么用?C++ BList::CountItems使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BList
的用法示例。
在下文中一共展示了BList::CountItems方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: locker
//.........这里部分代码省略.........
B_TRANSLATE_CONTEXT("Add shape with style",
"Icon-O-Matic-Menu-Shape"),
0);
} else {
Command** commands = new Command*[2];
commands[0] = pathCommand;
commands[1] = shapeCommand;
command = new CompoundCommand(commands, 2,
B_TRANSLATE_CONTEXT("Add shape with path",
"Icon-O-Matic-Menu-Shape"),
0);
}
} else {
command = shapeCommand;
}
fDocument->CommandStack()->Perform(command);
break;
}
// TODO: listen to selection in CanvasView to add a manipulator
case MSG_PATH_SELECTED: {
VectorPath* path;
if (message->FindPointer("path", (void**)&path) < B_OK)
path = NULL;
fPathListView->SetCurrentShape(NULL);
fStyleListView->SetCurrentShape(NULL);
fTransformerListView->SetShape(NULL);
fState->DeleteManipulators();
if (fDocument->Icon()->Paths()->HasPath(path)) {
PathManipulator* pathManipulator = new (nothrow) PathManipulator(path);
fState->AddManipulator(pathManipulator);
}
break;
}
case MSG_STYLE_SELECTED:
case MSG_STYLE_TYPE_CHANGED: {
Style* style;
if (message->FindPointer("style", (void**)&style) < B_OK)
style = NULL;
if (!fDocument->Icon()->Styles()->HasStyle(style))
style = NULL;
fStyleView->SetStyle(style);
fPathListView->SetCurrentShape(NULL);
fStyleListView->SetCurrentShape(NULL);
fTransformerListView->SetShape(NULL);
fState->DeleteManipulators();
Gradient* gradient = style ? style->Gradient() : NULL;
if (gradient != NULL) {
TransformGradientBox* transformBox
= new (nothrow) TransformGradientBox(fCanvasView, gradient, NULL);
fState->AddManipulator(transformBox);
}
break;
}
case MSG_SHAPE_SELECTED: {
Shape* shape;
if (message->FindPointer("shape", (void**)&shape) < B_OK)
shape = NULL;
if (!fIcon || !fIcon->Shapes()->HasShape(shape))
shape = NULL;
fPathListView->SetCurrentShape(shape);
fStyleListView->SetCurrentShape(shape);
fTransformerListView->SetShape(shape);
BList selectedShapes;
ShapeContainer* shapes = fDocument->Icon()->Shapes();
int32 count = shapes->CountShapes();
for (int32 i = 0; i < count; i++) {
shape = shapes->ShapeAtFast(i);
if (shape->IsSelected()) {
selectedShapes.AddItem((void*)shape);
}
}
fState->DeleteManipulators();
if (selectedShapes.CountItems() > 0) {
TransformShapesBox* transformBox = new (nothrow) TransformShapesBox(
fCanvasView,
(const Shape**)selectedShapes.Items(),
selectedShapes.CountItems());
fState->AddManipulator(transformBox);
}
break;
}
case MSG_RENAME_OBJECT:
fPropertyListView->FocusNameProperty();
break;
default:
BWindow::MessageReceived(message);
}
if (requiresWriteLock)
fDocument->WriteUnlock();
}
示例2: ServerIsRunning
bool FeedListener::ServerIsRunning(void) {
BList teams;
be_roster->GetAppList(FeedKit::ServerSignature, &teams);
return teams.CountItems() > 0;
};
示例3: msgr
//.........这里部分代码省略.........
if (termpref.FindInt32(TP_TABWIDTH, &ival) >= B_OK) {
//XXX: handle that ?
}
BFont tFont;
tp.p.font_size = 12;
strcpy(tp.p.font, "Courier10 BT/Roman");
if (FindFont(termpref, TP_FONT, 0, &tFont) == B_OK) {
font_family ff;
font_style fs;
tFont.GetFamilyAndStyle(&ff, &fs);
s = "";
s << ff;
lines.AddString(PREF_HALF_FONT_FAMILY, s.String());
s = "";
s << fs;
lines.AddString(PREF_HALF_FONT_STYLE, s.String());
s = "";
s << tFont.Size();
lines.AddString(PREF_HALF_FONT_SIZE, s.String());
}
if (FindRGBColor(termpref, TP_BG, 0, &color) != B_OK)
color = make_color(255,255,255,255);
s = "";
s << color.red << ", " << color.green << ", " << color.blue;
lines.AddString(PREF_TEXT_BACK_COLOR, s.String());
if (FindRGBColor(termpref, TP_FG, 0, &color) != B_OK)
color = make_color(0,0,0,255);
s = "";
s << color.red << ", " << color.green << ", " << color.blue;
lines.AddString(PREF_TEXT_FORE_COLOR, s.String());
if (FindRGBColor(termpref, TP_CURBG, 0, &color) != B_OK)
color = make_color(255,255,255,255);
s = "";
s << color.red << ", " << color.green << ", " << color.blue;
lines.AddString(PREF_CURSOR_BACK_COLOR, s.String());
if (FindRGBColor(termpref, TP_CURFG, 0, &color) != B_OK)
color = make_color(0,0,0,255);
s = "";
s << color.red << ", " << color.green << ", " << color.blue;
lines.AddString(PREF_CURSOR_FORE_COLOR, s.String());
if (FindRGBColor(termpref, TP_SELBG, 0, &color) != B_OK)
color = make_color(0,0,0,255);
s = "";
s << color.red << ", " << color.green << ", " << color.blue;
lines.AddString(PREF_SELECT_BACK_COLOR, s.String());
if (FindRGBColor(termpref, TP_SELFG, 0, &color) != B_OK)
color = make_color(255,255,255,255);
s = "";
s << color.red << ", " << color.green << ", " << color.blue;
lines.AddString(PREF_SELECT_FORE_COLOR, s.String());
/* XXX: handle PREF_IM_FORE_COLOR PREF_IM_BACK_COLOR PREF_IM_SELECT_COLOR */
if (termpref.FindInt32(TP_ENCODING, &ival) != B_OK)
ival = 0; // UTF-8
s = "";
s << ival;
//XXX: shouldn't really be touched...
//lines.AddString(, s.String());
if (flags & UI_THEME_SETTINGS_SAVE && AddonFlags() & Z_THEME_ADDON_DO_SAVE) {
SaveHaikuTerminalSettings(lines);
}
if (flags & UI_THEME_SETTINGS_APPLY && AddonFlags() & Z_THEME_ADDON_DO_APPLY) {
BList teamList;
app_info ainfo;
int32 count, i;
be_roster->GetAppList(&teamList);
count = teamList.CountItems();
for (i = 0; i < count; i++) {
if (be_roster->GetRunningAppInfo((team_id)(teamList.ItemAt(i)), &ainfo) == B_OK) {
if (!strcmp(ainfo.signature, kHaikuTerminalAppSig)) {
err = B_OK;
//XXX: WRITEME
/* BMessage msg(MSG_R5_SET_PREF);
BMessenger msgr(NULL, ainfo.team);
tp.x = 0;
tp.y = 0;
//msg.AddData("", 'UBYT', &(tp.p), sizeof(struct tpref));
msg.AddData("", 'UBYT', &(tp), sizeof(struct termprefs));
msg.AddSpecifier("Window", 0L);
err = msgr.SendMessage(&msg);
*/
}
}
}
}
return B_OK;
}
示例4: CopyPLItemsCommand
void
PlaylistListView::CopyItems(const BList& indices, int32 toIndex)
{
fCommandStack->Perform(new (nothrow) CopyPLItemsCommand(fPlaylist,
(int32*)indices.Items(), indices.CountItems(), toIndex));
}
示例5: node
//.........这里部分代码省略.........
ReadNodeAttrString(&node,"META:email",&addr[0]);
ReadNodeAttrString(&node,"META:email2",&addr[1]);
ReadNodeAttrString(&node,"META:email3",&addr[2]);
ReadNodeAttrString(&node,"META:email4",&addr[3]);
ReadNodeAttrString(&node,"META:group",&group);
ReadNodeAttrString(&node,"META:nickname",&nick);
for(int32 i = 0;i < 4;i++)
{
if(addr[i].Length() > 0)
{
if(nick.Length() > 0)
{
nick += " <";
nick += addr[i];
nick += ">";
fAddrList.AddItem(strdup(nick.String()));
}
fAddrList.AddItem(strdup(addr[i].String()));
BString title = name;
title << " <" << addr[i] << ">";
AddPersonToList(peopleList,title.String(),group.String());
}
}
}
// Sort people data
peopleList.SortItems(HAddressView::SortPeople);
// Build menus
BTextControl *control[3] = {fTo,fCc,fBcc};
BMenu *menus[3] = {toMenu,ccMenu,bccMenu};
int32 count = peopleList.CountItems();
PersonData *data;
bool needSeparator = false;
bool hasSeparator = false;
for(int32 k = 0;k < 3;k++)
{
for(int32 i = 0;i < count;i++)
{
BMessage *msg = new BMessage(M_ADDR_MSG);
msg->AddPointer("pointer",control[k]);
data = (PersonData*)peopleList.ItemAt(i);
msg->AddString("email",data->email);
if(needSeparator && !hasSeparator && strlen(data->group) == 0)
{
menus[k]->AddSeparatorItem();
hasSeparator = true;
}else
needSeparator = true;
AddPerson(menus[k],data->email,data->group,msg,0,0);
}
hasSeparator = false;
needSeparator = false;
}
// free all data
while(count > 0)
{
data = (PersonData*)peopleList.RemoveItem(--count);
free(data->email);
free(data->group);
delete data;
}
}
BMenuField *field = new BMenuField(menuRect,"ToMenu","",toMenu,
示例6: self
void
TExpandoMenuBar::AttachedToWindow()
{
BMessenger self(this);
BList teamList;
TBarApp::Subscribe(self, &teamList);
float width = fVertical ? Frame().Width() : kMinimumWindowWidth;
float height = -1.0f;
// top or bottom mode, add be menu and sep for menubar tracking consistency
if (!fVertical) {
TBeMenu *beMenu = new TBeMenu(fBarView);
TBarWindow::SetBeMenu(beMenu);
fBeMenuItem = new TBarMenuTitle(kBeMenuWidth, Frame().Height(),
AppResSet()->FindBitmap(B_MESSAGE_TYPE, R_BeLogoIcon), beMenu, true);
AddItem(fBeMenuItem);
fSeparatorItem = new TTeamMenuItem(kSepItemWidth, height, fVertical);
AddItem(fSeparatorItem);
fSeparatorItem->SetEnabled(false);
fFirstApp = 2;
} else {
fBeMenuItem = NULL;
fSeparatorItem = NULL;
}
desk_settings *settings = ((TBarApp *)be_app)->Settings();
if (settings->sortRunningApps)
teamList.SortItems(CompareByName);
int32 count = teamList.CountItems();
for (int32 i = 0; i < count; i++) {
BarTeamInfo *barInfo = (BarTeamInfo *)teamList.ItemAt(i);
if ((barInfo->flags & B_BACKGROUND_APP) == 0
&& strcasecmp(barInfo->sig, kDeskbarSignature) != 0) {
if (settings->trackerAlwaysFirst
&& !strcmp(barInfo->sig, kTrackerSignature)) {
AddItem(new TTeamMenuItem(barInfo->teams, barInfo->icon,
barInfo->name, barInfo->sig, width, height,
fDrawLabel, fVertical), fFirstApp);
} else {
AddItem(new TTeamMenuItem(barInfo->teams, barInfo->icon,
barInfo->name, barInfo->sig, width, height,
fDrawLabel, fVertical));
}
barInfo->teams = NULL;
barInfo->icon = NULL;
barInfo->name = NULL;
barInfo->sig = NULL;
}
delete barInfo;
}
BMenuBar::AttachedToWindow();
if (CountItems() == 0) {
// If we're empty, BMenuBar::AttachedToWindow() resizes us to some
// weird value - we just override it again
ResizeTo(width, 0);
}
if (fVertical) {
sDoMonitor = true;
sMonThread = spawn_thread(monitor_team_windows,
"Expando Window Watcher", B_LOW_PRIORITY, this);
resume_thread(sMonThread);
}
}
示例7:
void
Model::_FreeHistory(const BList& items) const
{
for (int32 t = items.CountItems() - 1; t >= 0; --t)
delete static_cast<BString*>((items.ItemAtFast(t)));
}
示例8: RecordLoop
int32 AmInputQueue::RecordLoop()
{
while (mRecordAvail >= B_OK) {
while (acquire_sem(mRecordAvail) == B_INTERRUPTED) ;
BList items;
if (mRecordLock.Lock()) {
items = mRecordItems;
mRecordItems.MakeEmpty();
mRecordLock.Unlock();
}
AmSongRef songRef = AmGlobals().SongRef(mSong);
if (songRef.IsValid()) {
for (int32 i=0; i<items.CountItems(); i++) {
record_item* ri = (record_item*)items.ItemAt(i);
if (!ri) continue;
{
// READ SONG BLOCK
#ifdef AM_TRACE_LOCKS
printf("AmInputQueue::RecordLoop() read lock\n"); fflush(stdout);
#endif
const AmSong* song = songRef.ReadLock();
if (song) {
ri->events = ArpExecFilters(ri->events, REALTIME_EXEC_TYPE, false);
if (ri->events) ri->events = ri->events->HeadEvent();
songRef.ReadUnlock(song);
}
// END READ SONG BLOCK
}
{
// WRITE SONG BLOCK
AmSong* song = songRef.WriteLock();
if (song) {
#if 1
/* New mechanism -- all events should have been supplied
* a track by the last filter they went through. So,
* record to the requested track. This wouldn't be
* necessary if we had a full architecture -- that is,
* the tracks were just another filter in the pipeline.
*/
AmTrack* track = 0;
AmEvent* e = 0;
AmEvent* head = ri->events;
while ((e = _get_record_t_and_e(head, song, &head, &track)) != 0) {
if (track) track->RecordEvents(e);
else e->DeleteChain();
}
if (head) head->DeleteChain();
ri->events = 0;
#endif
#if 0
AmTrack* track = song->Track(ri->track);
if (track && ri->events) {
track->RecordEvents(ri->events);
ri->events = NULL;
}
#endif
songRef.WriteUnlock(song);
}
// END WRITE SONG BLOCK
}
if (ri->events) ri->events->DeleteChain();
delete ri;
}
}
}
return B_OK;
}
示例9: MessageReceived
//.........这里部分代码省略.........
// Save the image data to a real file and attach the Person attributes
// to it
fPeopleList->SaveImageData();
}
// Offer to move/copy file if not in People directory
BDirectory dir,peopledir("/boot/home/people");
BEntry entry(&ref);
entry.GetParent(&dir);
if(dir!=peopledir)
{
BString refname(ref.name);
BString errstr=TRANSLATE("%s is not currently stored in the People folder. Mr. Peeps! will not"
" see it on startup unless it is stored there. Would you like to move it"
" there?");
char errmsg[errstr.CountChars() - 2 + refname.CountChars() + 1];
sprintf(errmsg,errstr.String(),refname.String());
BAlert *alert=new BAlert("Mr. Peeps!",errmsg,TRANSLATE("Move"),TRANSLATE("Don't Move"));
if(alert->Go()==0)
{
entry.MoveTo(&peopledir);
entry.GetRef(&ref);
}
}
if(!SelectPerson(ref))
AddPerson(ref,true);
}
break;
}
case M_PREV_ITEM:
{
if(fPeopleList->CountItems()==0)
break;
int32 selection=fPeopleList->CurrentSelection();
if(!fPeopleList->IsFocus())
{
fPeopleList->MakeFocus(true);
PeepsListItem *pitem=(PeepsListItem*)fPeopleList->ItemAt(selection);
if(!pitem->IsGroup())
{
fPeopleList->SyncData((PersonItem*)pitem);
// fPeopleList->SaveData();
}
fPeopleList->SaveData();
}
if(selection>=0)
{
if(selection>0)
fPeopleList->Select(selection-1);
}
else
{
fPeopleList->Select(0L);
}
break;
}
case M_NEXT_ITEM:
{
if(fPeopleList->CountItems()==0)
break;
示例10: rect
// MessageReceived
void
DragSortableListView::MessageReceived(BMessage* message)
{
if (AcceptDragMessage(message)) {
DragSortableListView *list = NULL;
if (message->FindPointer("list", (void **)&list) == B_OK
&& list == this) {
int32 count = CountItems();
if (fDropIndex < 0 || fDropIndex > count)
fDropIndex = count;
BList indices;
int32 index;
for (int32 i = 0; message->FindInt32("index", i, &index) == B_OK; i++)
indices.AddItem((void*)(addr_t)index);
if (indices.CountItems() > 0) {
if (modifiers() & B_SHIFT_KEY)
CopyItems(indices, fDropIndex);
else
MoveItems(indices, fDropIndex);
}
fDropIndex = -1;
}
} else {
switch (message->what) {
case MSG_TICK: {
float scrollV = 0.0;
BRect rect(Bounds());
BPoint point;
uint32 buttons;
GetMouse(&point, &buttons, false);
if (rect.Contains(point)) {
// calculate the vertical scrolling offset
float hotDist = rect.Height() * SCROLL_AREA;
if (point.y > rect.bottom - hotDist)
scrollV = hotDist - (rect.bottom - point.y);
else if (point.y < rect.top + hotDist)
scrollV = (point.y - rect.top) - hotDist;
}
// scroll
if (scrollV != 0.0 && fScrollView) {
if (BScrollBar* scrollBar = fScrollView->ScrollBar(B_VERTICAL)) {
float value = scrollBar->Value();
scrollBar->SetValue(scrollBar->Value() + scrollV);
if (scrollBar->Value() != value) {
// update mouse position
uint32 buttons;
BPoint point;
GetMouse(&point, &buttons, false);
uint32 transit = Bounds().Contains(point) ? B_INSIDE_VIEW : B_OUTSIDE_VIEW;
MouseMoved(point, transit, &fDragMessageCopy);
}
}
}
break;
}
case B_MODIFIERS_CHANGED:
ModifiersChanged();
break;
case B_MOUSE_WHEEL_CHANGED: {
BListView::MessageReceived( message );
BPoint point;
uint32 buttons;
GetMouse(&point, &buttons, false);
uint32 transit = Bounds().Contains(point) ? B_INSIDE_VIEW : B_OUTSIDE_VIEW;
MouseMoved(point, transit, &fDragMessageCopy);
break;
}
default:
BListView::MessageReceived( message );
break;
}
}
}
示例11: PerformLoop
/* EEAAAAAAAGHH! My new code uses the current time from the transport
* to add signature information to the params. God I hope this is OK.
*/
int32 AmInputQueue::PerformLoop()
{
while (mPerformAvail >= B_OK) {
while (acquire_sem(mPerformAvail) == B_INTERRUPTED) ;
BList items;
if (mPerformLock.Lock()) {
items = mPerformItems;
mPerformItems.MakeEmpty();
mPerformLock.Unlock();
}
am_filter_params params;
am_filter_params* p = 0;
AmSongRef songRef = AmGlobals().SongRef(mSong);
if (songRef.IsValid()) {
for (int32 i=0; i<items.CountItems(); i++) {
record_item* ri = (record_item*)items.ItemAt(i);
if (!ri) continue;
{
// READ SONG BLOCK
#ifdef AM_TRACE_LOCKS
printf("AmInputQueue::PerformLoop() read lock\n"); fflush(stdout);
#endif
const AmSong* song = songRef.ReadLock();
const AmTrack* track = song ? song->Track(ri->track) : NULL;
if (track) {
p = 0;
AmEvent* signatures = 0;
AmTime currentTime = song->Transport().CurrentTime();
if (currentTime >= 0) {
signatures = song->PlaybackList(currentTime, currentTime, PLAYBACK_NO_PERFORMANCE | PLAYBACK_NO_TEMPO | PLAYBACK_RAW_CONTEXT);
if (signatures) {
// printf("Sigs: \n"); signatures->PrintChain();
params.cur_signature = dynamic_cast<AmSignature*>(signatures);
} else params.cur_signature = 0;
p = ¶ms;
}
// Run events through input filters
ri->events = ArpExecFilters(ri->events, REALTIME_EXEC_TYPE, false, p, 0, 0, 0, signatures);
if (ri->events) ri->events = ri->events->HeadEvent();
// Run result through output filters.
AmFilterHolderI* h = track->Filter(OUTPUT_PIPELINE);
if (h) {
AmEvent* pos = ri->events;
while (pos) {
if (!pos->NextFilter()) pos->SetNextFilter(h);
pos = pos->NextEvent();
}
ri->events = ArpExecFilters(ri->events, REALTIME_EXEC_TYPE, false, p, 0, 0, 0, signatures);
if (ri->events) ri->events = ri->events->HeadEvent();
}
song->Transport().Merge(ri->events);
ri->events = NULL;
}
params.cur_signature = 0;
songRef.ReadUnlock(song);
// END READ SONG BLOCK
}
if (ri->events) ri->events->DeleteChain();
delete ri;
}
}
}
return B_OK;
}
示例12: if
void
update_preferred_app_menu(BMenu* menu, BMimeType* type, uint32 what,
const char* preferredFrom)
{
// clear menu (but leave the first entry, ie. "None")
for (int32 i = menu->CountItems(); i-- > 1;) {
delete menu->RemoveItem(i);
}
// fill it again
menu->ItemAt(0)->SetMarked(true);
BMessage applications;
if (type == NULL || type->GetSupportingApps(&applications) != B_OK)
return;
char preferred[B_MIME_TYPE_LENGTH];
if (type->GetPreferredApp(preferred) != B_OK)
preferred[0] = '\0';
int32 lastFullSupport;
if (applications.FindInt32("be:sub", &lastFullSupport) != B_OK)
lastFullSupport = -1;
BList subList;
BList superList;
const char* signature;
int32 i = 0;
while (applications.FindString("applications", i, &signature) == B_OK) {
BMenuItem* item = create_application_item(signature, what);
if (i < lastFullSupport)
subList.AddItem(item);
else
superList.AddItem(item);
i++;
}
// sort lists
subList.SortItems(compare_menu_items);
superList.SortItems(compare_menu_items);
// add lists to the menu
if (subList.CountItems() != 0 || superList.CountItems() != 0)
menu->AddSeparatorItem();
for (int32 i = 0; i < subList.CountItems(); i++) {
menu->AddItem((BMenuItem*)subList.ItemAt(i));
}
// Add type separator
if (superList.CountItems() != 0 && subList.CountItems() != 0)
menu->AddSeparatorItem();
for (int32 i = 0; i < superList.CountItems(); i++) {
menu->AddItem((BMenuItem*)superList.ItemAt(i));
}
// make items unique and select current choice
bool lastItemSame = false;
const char* lastSignature = NULL;
BMenuItem* last = NULL;
BMenuItem* select = NULL;
for (int32 index = 0; index < menu->CountItems(); index++) {
BMenuItem* item = menu->ItemAt(index);
if (item == NULL)
continue;
if (item->Message() == NULL
|| item->Message()->FindString("signature", &signature) != B_OK)
continue;
if ((preferredFrom == NULL && !strcasecmp(signature, preferred))
|| (preferredFrom != NULL
&& !strcasecmp(signature, preferredFrom))) {
select = item;
}
if (last == NULL || strcmp(last->Label(), item->Label())) {
if (lastItemSame)
add_signature(last, lastSignature);
lastItemSame = false;
last = item;
lastSignature = signature;
continue;
}
lastItemSame = true;
add_signature(last, lastSignature);
last = item;
//.........这里部分代码省略.........
示例13: cached_url_proto
void
Win::UrlTypedHandler( bool show_all )
{
// printf( "Win::UrlTypedHandler()\n" );
// get the stripped list from GlobalHistory
BList* slist = ( ( App* )be_app )->GetGlobalHistory()->GetStrippedList();
// create the matching urls list
BList* list = new BList( 0 );
BString typed_url; // the typed url
BString cached_url; // the cached url
BString cached_url_proto( "" ); // protocol of the cached url
if( show_all == true )
typed_url.SetTo( "" );
else
{
typed_url.SetTo( navview->urlview->Text() );
typed_url.ToLower();
}
// printf( " typed_url: %s length: %ld\n", typed_url.String(), typed_url.Length() );
int32 count = slist->CountItems();
for( int32 i = 0; i < count; i++ )
{
GlobalHistoryItem* item = ( GlobalHistoryItem* )slist->ItemAt( i );
if( item != NULL )
{
cached_url.SetTo( item->Text() );
// printf( " cached_url: %s\n", cached_url.String() );
if( typed_url.Length() != 0 )
{
// if the typed url matches beginning of cached url, add it
if( strncmp( cached_url.String(), typed_url.String(), typed_url.Length() ) == 0 )
{
list->AddItem( new BStringItem( cached_url.String() ) );
}
else
{
// if the urls dont match, take away the protocol of the cached url
if( cached_url.FindFirst( "://" ) > 0 )
{
cached_url.MoveInto( cached_url_proto, 0, cached_url.FindFirst( "://" ) + 3 );
}
// if the urls fit now
if( strncmp( cached_url.String(), typed_url.String(), typed_url.Length() ) == 0 )
{
// add the missing proto again
if( cached_url_proto.Length() != 0 )
cached_url.Prepend( cached_url_proto );
list->AddItem( new BStringItem( cached_url.String() ) );
}
else
{
// if they still don't fit, remove 'www.' from cached url
if( cached_url.FindFirst( "www." ) == 0 )
{
cached_url.Remove( 0, 4 );
}
// check if they finally fit
if( strncmp( cached_url.String(), typed_url.String(), typed_url.Length() ) == 0 )
{
// add missing 'www.' and proto
cached_url.Prepend( "www." );
if( cached_url_proto.Length() != 0 )
cached_url.Prepend( cached_url_proto );
list->AddItem( new BStringItem( cached_url.String() ) );
}
}
cached_url_proto.SetTo( "" );
}
}
else
{
list->AddItem( new BStringItem( cached_url.String() ) );
}
} // if( item != NULL )
}
// delete slist ( not needed anymore )
for( int32 i = 0; i < count; i++ )
{
GlobalHistoryItem* item = ( GlobalHistoryItem* )slist->ItemAt( i );
if( item != NULL )
{
slist->RemoveItem( item );
delete item;
}
}
delete slist;
//.........这里部分代码省略.........
示例14: messenger
//.........这里部分代码省略.........
"source and target volume will be overwritten with the source "
"volume version."),
B_TRANSLATE("Install anyway"), B_TRANSLATE("Cancel"), 0,
B_WIDTH_AS_USUAL, B_STOP_ALERT))->Go() != 0)) {
// TODO: Would be cool to offer the option here to clean additional
// folders at the user's choice (like /boot/common and /boot/develop).
err = B_CANCELED;
goto error;
}
// Begin actual installation
_LaunchInitScript(targetDirectory);
// Create the default indices which should always be present on a proper
// boot volume. We don't care if the source volume does not have them.
// After all, the user might be re-installing to another drive and may
// want problems fixed along the way...
err = _CreateDefaultIndices(targetDirectory);
if (err != B_OK)
goto error;
// Mirror all the indices which are present on the source volume onto
// the target volume.
err = _MirrorIndices(srcDirectory, targetDirectory);
if (err != B_OK)
goto error;
// Let the engine collect information for the progress bar later on
engine.ResetTargets(srcDirectory.Path());
err = engine.CollectTargets(srcDirectory.Path(), fCancelSemaphore);
if (err != B_OK)
goto error;
// Collect selected packages also
if (fPackages) {
BPath pkgRootDir(srcDirectory.Path(), PACKAGES_DIRECTORY);
int32 count = fPackages->CountItems();
for (int32 i = 0; i < count; i++) {
Package *p = static_cast<Package*>(fPackages->ItemAt(i));
BPath packageDir(pkgRootDir.Path(), p->Folder());
err = engine.CollectTargets(packageDir.Path(), fCancelSemaphore);
if (err != B_OK)
goto error;
}
}
// collect information about all zip packages
err = _ProcessZipPackages(srcDirectory.Path(), targetDirectory.Path(),
&reporter, unzipEngines);
if (err != B_OK)
goto error;
reporter.StartTimer();
// copy source volume
err = engine.CopyFolder(srcDirectory.Path(), targetDirectory.Path(),
fCancelSemaphore);
if (err != B_OK)
goto error;
// copy selected packages
if (fPackages) {
BPath pkgRootDir(srcDirectory.Path(), PACKAGES_DIRECTORY);
int32 count = fPackages->CountItems();
for (int32 i = 0; i < count; i++) {
Package *p = static_cast<Package*>(fPackages->ItemAt(i));
BPath packageDir(pkgRootDir.Path(), p->Folder());
err = engine.CopyFolder(packageDir.Path(), targetDirectory.Path(),
fCancelSemaphore);
if (err != B_OK)
goto error;
}
}
// Extract all zip packages. If an error occured, delete the rest of
// the engines, but stop extracting.
for (int32 i = 0; i < unzipEngines.CountItems(); i++) {
UnzipEngine* engine = reinterpret_cast<UnzipEngine*>(
unzipEngines.ItemAtFast(i));
if (err == B_OK)
err = engine->UnzipPackage();
delete engine;
}
if (err != B_OK)
goto error;
_LaunchFinishScript(targetDirectory);
BMessenger(fWindow).SendMessage(MSG_INSTALL_FINISHED);
return;
error:
BMessage statusMessage(MSG_RESET);
if (err == B_CANCELED)
_SetStatusMessage(B_TRANSLATE("Installation canceled."));
else
statusMessage.AddInt32("error", err);
ERR("_PerformInstall failed");
BMessenger(fWindow).SendMessage(&statusMessage);
}
示例15: separatorRect
BView *
DefaultMediaTheme::MakeViewFor(BParameterGroup& group, const BRect* hintRect)
{
CALLED();
if (group.Flags() & B_HIDDEN_PARAMETER)
return NULL;
BRect rect;
if (hintRect != NULL)
rect = *hintRect;
GroupView *view = new GroupView(rect, group.Name());
// Create the parameter views - but don't add them yet
rect.OffsetTo(B_ORIGIN);
rect.InsetBySelf(5, 5);
BList views;
for (int32 i = 0; i < group.CountParameters(); i++) {
BParameter *parameter = group.ParameterAt(i);
if (parameter == NULL)
continue;
BView *parameterView = MakeSelfHostingViewFor(*parameter,
hintRect ? &rect : NULL);
if (parameterView == NULL)
continue;
parameterView->SetViewColor(view->ViewColor());
// ToDo: dunno why this is needed, but the controls
// sometimes (!) have a white background without it
views.AddItem(parameterView);
}
// Identify a title view, and add it at the top if present
TitleView *titleView = dynamic_cast<TitleView *>((BView *)views.ItemAt(0));
if (titleView != NULL) {
view->AddChild(titleView);
rect.OffsetBy(0, titleView->Bounds().Height());
}
// Add the sub-group views
rect.right = rect.left + 20;
rect.bottom = rect.top + 20;
float lastHeight = 0;
for (int32 i = 0; i < group.CountGroups(); i++) {
BParameterGroup *subGroup = group.GroupAt(i);
if (subGroup == NULL)
continue;
BView *groupView = MakeViewFor(*subGroup, &rect);
if (groupView == NULL)
continue;
if (i > 0) {
// add separator view
BRect separatorRect(groupView->Frame());
separatorRect.left -= 3;
separatorRect.right = separatorRect.left + 1;
if (lastHeight > separatorRect.Height())
separatorRect.bottom = separatorRect.top + lastHeight;
view->AddChild(new SeparatorView(separatorRect));
}
view->AddChild(groupView);
rect.OffsetBy(groupView->Bounds().Width() + 5, 0);
lastHeight = groupView->Bounds().Height();
if (lastHeight > rect.Height())
rect.bottom = rect.top + lastHeight - 1;
}
view->ResizeTo(rect.left + 10, rect.bottom + 5);
view->SetContentBounds(view->Bounds());
if (group.CountParameters() == 0)
return view;
// add the parameter views part of the group
if (group.CountGroups() > 0) {
rect.top = rect.bottom + 10;
rect.bottom = rect.top + 20;
}
bool center = false;
for (int32 i = 0; i < views.CountItems(); i++) {
BView *parameterView = static_cast<BView *>(views.ItemAt(i));
if (parameterView->Bounds().Width() + 5 > rect.Width())
rect.right = parameterView->Bounds().Width() + rect.left + 5;
//.........这里部分代码省略.........