本文整理汇总了C++中KviPointerList::insert方法的典型用法代码示例。如果您正苦于以下问题:C++ KviPointerList::insert方法的具体用法?C++ KviPointerList::insert怎么用?C++ KviPointerList::insert使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KviPointerList
的用法示例。
在下文中一共展示了KviPointerList::insert方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: fillTreeWidget
void OptionsDialog::fillTreeWidget(QTreeWidgetItem * p,KviPointerList<OptionsWidgetInstanceEntry> * l,const QString &szGroup,bool bNotContainedOnly)
{
if(!l)return;
OptionsDialogTreeWidgetItem * it;
OptionsWidgetInstanceEntry * e;
KviPointerList<OptionsWidgetInstanceEntry> tmp;
tmp.setAutoDelete(false);
for(e = l->first(); e; e = l->next())
{
// must be in the correct group
// if we want only containers then well.. must be one
e->bDoInsert = KviQString::equalCI(szGroup,e->szGroup) && ((!bNotContainedOnly) || e->bIsContainer || e->bIsNotContained);
OptionsWidgetInstanceEntry * ee = tmp.first();
int idx = 0;
while(ee)
{
if(ee->iPriority >= e->iPriority)break;
idx++;
ee = tmp.next();
}
tmp.insert(idx,e);
}
for(e = tmp.first(); e; e = tmp.next())
{
if(e->bDoInsert)
{
if(p)it = new OptionsDialogTreeWidgetItem(p,e);
else it = new OptionsDialogTreeWidgetItem(m_pTreeWidget,e);
if(!it->m_pOptionsWidget)
{
it->m_pOptionsWidget = g_pOptionsInstanceManager->getInstance(it->m_pInstanceEntry,m_pWidgetStack);
if(it->m_pOptionsWidget)
m_pWidgetStack->addWidget(it->m_pOptionsWidget);
}
} else {
it = (OptionsDialogTreeWidgetItem *)p;
}
if(e->pChildList)
{
if(e->bIsContainer)
{
// it's a container: add only eventual not contained children (containers or explicitly marked as not contained)
fillTreeWidget(it,e->pChildList,szGroup,true);
} else {
// it's not a container, add any children
fillTreeWidget(it,e->pChildList,szGroup,false);
}
}
}
}
示例2: cleanup
void KviAvatarCache::cleanup()
{
// first do a quick run deleting the avatars really too old
KviPointerHashTableIterator<QString,KviAvatarCacheEntry> it(*m_pAvatarDict);
kvi_time_t tNow = kvi_unixTime();
KviPointerList<QString> l;
l.setAutoDelete(false);
KviAvatarCacheEntry * e;
while((e = it.current()))
{
if((tNow - e->tLastAccess) > MAX_UNACCESSED_TIME)
{
l.append(new QString(it.currentKey()));
}
++it;
}
for(QString *s = l.first();s;s = l.next())m_pAvatarDict->remove(*s);
if(m_pAvatarDict->count() < CACHE_GUARD_LEVEL)return;
// not done.. need to kill the last accessed :/
it.toFirst();
KviPointerList<KviAvatarCacheEntry> ll;
ll.setAutoDelete(true);
// here we use the cache entries in another way
// szAvatar is the KEY instead of the avatar name
while((e = it.current()))
{
KviAvatarCacheEntry * current = ll.first();
unsigned int idx = 0;
while(current)
{
// if the current is newer than the inserted one
// then stop searching and insert it just before
if(current->tLastAccess > e->tLastAccess)break;
// otherwise the current is older and the inserted
// one goes after
current = ll.next();
idx++;
}
KviAvatarCacheEntry * xx = new KviAvatarCacheEntry;
xx->szIdString = it.currentKey();
xx->tLastAccess = e->tLastAccess;
if(current)ll.insert(idx,xx);
else ll.append(xx);
++it;
}
// the oldest keys are at the beginning
int uRemove = ll.count() - CACHE_GUARD_LEVEL;
if(uRemove < 1)return; // huh ?
// remember that szAvatar contains the key!
for(e = ll.first();e && (uRemove > 0);e = ll.next())
{
m_pAvatarDict->remove(e->szIdString);
uRemove--;
}
// now we should be ok
}