本文整理汇总了C++中GroupList::AddGroup方法的典型用法代码示例。如果您正苦于以下问题:C++ GroupList::AddGroup方法的具体用法?C++ GroupList::AddGroup怎么用?C++ GroupList::AddGroup使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GroupList
的用法示例。
在下文中一共展示了GroupList::AddGroup方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: AddPerson
void PeepsWindow::AddPerson(const entry_ref &ref, bool highlight)
{
// Check to see if it's actually a Person file
if(!IsPerson(ref))
return;
GroupData *gdata;
// Add person to data list
PersonData *pdata=new PersonData(ref);
gPeopleData.AddItem(pdata);
// add group(s) and an item for each group
if(strlen(pdata->Group())==0)
{
// Ungrouped case
gdata=gGroupData.AddGroup(TRANSLATE("Ungrouped"));
if(!fPeopleList->HasItem(gdata->GetInstance()))
fPeopleList->AddItem(gdata->GetInstance());
gdata->AddPerson(pdata);
fPeopleList->AddUnder(pdata->CreateInstance(TRANSLATE("Ungrouped")),gdata->GetInstance());
return;
}
GroupParser gp(pdata->Group());
for(int32 i=0; i<gp.CountGroups(); i++)
{
gdata=gGroupData.AddGroup(gp.GroupAt(i));
gdata->AddPerson(pdata);
if(!fPeopleList->HasItem(gdata->GetInstance()))
fPeopleList->AddItem(gdata->GetInstance());
fPeopleList->AddUnder(pdata->CreateInstance(gp.GroupAt(i)),gdata->GetInstance());
}
if(highlight)
{
SelectPerson(pdata->Name());
}
}
示例2: DeleteGroup
void PeepsWindow::DeleteGroup(GroupItem *item)
{
// We are going to delete the group. All items will be made ungrouped. Because
// it cannot be undone, we will ask the user if it's ok to delete the group
BString alertmsg=TRANSLATE("Are you sure you want to delete this group?");
alertmsg+="\n\n";
alertmsg+=TRANSLATE("All items will be removed from this group, but the items themselves will not"
" be deleted. Once done, this cannot be undone.");
BAlert *alert=new BAlert("Mr. Peeps!", alertmsg.String(), TRANSLATE("Delete Group"),
TRANSLATE("Cancel"));
if(alert->Go()==1)
return;
if(!item)
return;
if(!item->IsExpanded())
fPeopleList->Expand(item);
// First, ensure that we have a group for all these items to go to
GroupData *oldgdata=item->GetData(),
*ungrouped=gGroupData.FindGroup(TRANSLATE("Ungrouped"));
if(!ungrouped)
{
ungrouped=gGroupData.AddGroup(TRANSLATE("Ungrouped"));
fPeopleList->AddItem(ungrouped->GetInstance());
}
if(!ungrouped->GetInstance()->IsExpanded())
fPeopleList->Expand(ungrouped->GetInstance());
int32 groupindex=fPeopleList->FullListIndexOf(ungrouped->GetInstance())+1;
// Now, we iterate through each person in the group to remove the group name
// from their group list strings
for(int32 i=0; i<oldgdata->CountPeople(); i++)
{
PersonData *pdata=oldgdata->PersonAt(i);
if(pdata->CountGroups()==1)
{
pdata->AddToGroup(ungrouped->GetInstance());
fPeopleList->MoveItem(fPeopleList->FullListIndexOf(pdata->InstanceAt(0)),groupindex);
}
else
{
PersonItem *instance=pdata->InstanceForGroup(item->Name());
fPeopleList->RemoveItem(instance);
pdata->DestroyInstance(instance);
}
pdata->RemoveFromGroup((GroupItem*)item);
}
fPeopleList->RemoveItem((GroupItem*)item);
gGroupData.RemoveGroup(item->Name());
fPeopleList->SortItemsUnder(ungrouped->GetInstance(),true,compare_peeps);
fPeopleList->Select(fPeopleList->IndexOf(ungrouped->GetInstance()));
}