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


C++ ListItem::Update方法代码示例

本文整理汇总了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;
	}
}
开发者ID:TheBlackJokerDevil,项目名称:openclonk,代码行数:31,代码来源:C4Network2ResDlg.cpp

示例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;
	}
}
开发者ID:gitMarky,项目名称:openclonk,代码行数:64,代码来源:C4Network2Dialogs.cpp


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