本文整理汇总了C++中ListItem::Update方法的典型用法代码示例。如果您正苦于以下问题:C++ ListItem::Update方法的具体用法?C++ ListItem::Update怎么用?C++ ListItem::Update使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ListItem
的用法示例。
在下文中一共展示了ListItem::Update方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ListItem
void C4Network2ResDlg::Update()
{
// check through own resources and current res list
ListItem *pItem = static_cast<ListItem *>(pClientWindow->GetFirst()), *pNext;
C4Network2Res *pRes; int iResID=-1;
while ((pRes = ::Network.ResList.getRefNextRes(++iResID)))
{
iResID = pRes->getResID();
// resource checking: deleted resource(s) present?
while (pItem && (pItem->GetResID() < iResID))
{
pNext = static_cast<ListItem *>(pItem->GetNext());
delete pItem; pItem = pNext;
}
// same resource present for update?
if (pItem && pItem->GetResID() == iResID)
{
pItem->Update(pRes);
pItem = static_cast<ListItem *>(pItem->GetNext());
}
else
// not present: insert (or add if pItem=NULL)
InsertElement(new ListItem(this, pRes), pItem);
}
// del trailing items
while (pItem)
{
pNext = static_cast<ListItem *>(pItem->GetNext());
delete pItem; pItem = pNext;
}
}
示例2: ClientListItem
void C4Network2ClientListBox::Update()
{
// sync with client list
ListItem *pItem = static_cast<ListItem *>(pClientWindow->GetFirst()), *pNext;
const C4Client *pClient = nullptr;
while ((pClient = Game.Clients.getClient(pClient)))
{
// skip host in startup board
if (IsStartup() && pClient->isHost()) continue;
// deleted client(s) present? this will also delete unneeded client connections of previous client
while (pItem && (pItem->GetClientID() < pClient->getID()))
{
pNext = static_cast<ListItem *>(pItem->GetNext());
delete pItem; pItem = pNext;
}
// same present for update?
// need not check for connection ID, because a client item will always be placed before the corresponding connection items
if (pItem && pItem->GetClientID() == pClient->getID())
{
pItem->Update();
pItem = static_cast<ListItem *>(pItem->GetNext());
}
else
// not present: insert (or add if pItem=nullptr)
InsertElement(new ClientListItem(this, pClient->getID()), pItem);
// update connections for client
// but no connections in startup board
if (IsStartup()) continue;
// enumerate client connections
C4Network2Client *pNetClient = pClient->getNetClient();
if (!pNetClient) continue; // local client does not have connections
C4Network2IOConnection *pLastConn = nullptr;
for (int i = 0; i<2; ++i)
{
C4Network2IOConnection *pConn = i ? pNetClient->getMsgConn() : pNetClient->getDataConn();
if (!pConn) continue;
if (pConn == pLastConn) continue; // combined connection: Display only one
pLastConn = pConn;
// del leading items
while (pItem && ((pItem->GetClientID() < pClient->getID()) || ((pItem->GetClientID() == pClient->getID()) && (pItem->GetConnectionID() < i))))
{
pNext = static_cast<ListItem *>(pItem->GetNext());
delete pItem; pItem = pNext;
}
// update connection item
if (pItem && pItem->GetClientID() == pClient->getID() && pItem->GetConnectionID() == i)
{
pItem->Update();
pItem = static_cast<ListItem *>(pItem->GetNext());
}
else
{
// new connection: create it
InsertElement(new ConnectionListItem(this, pClient->getID(), i), pItem);
}
}
}
// del trailing items
while (pItem)
{
pNext = static_cast<ListItem *>(pItem->GetNext());
delete pItem; pItem = pNext;
}
}