mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
fixed display of contactlist when changing status, and improved computaitonal efficiency
This commit is contained in:
parent
5d9272055f
commit
52da8cd0e6
@ -121,6 +121,7 @@ class RsGxsIdGroup
|
||||
|
||||
// Not Serialised - for GUI's benefit.
|
||||
bool mPgpKnown;
|
||||
bool mIsAContact; // change that into flags one day
|
||||
RsPgpId mPgpId;
|
||||
GxsReputation mReputation;
|
||||
};
|
||||
|
@ -1099,6 +1099,8 @@ bool p3IdService::getGroupData(const uint32_t &token, std::vector<RsGxsIdGroup>
|
||||
std::cerr << std::endl;
|
||||
}
|
||||
|
||||
group.mIsAContact = (mContacts.find(RsGxsId(group.mMeta.mGroupId)) != mContacts.end());
|
||||
|
||||
groups.push_back(group);
|
||||
delete(item);
|
||||
}
|
||||
|
@ -442,6 +442,7 @@ void IdDialog::insertIdList(uint32_t token)
|
||||
RsGxsIdGroup data;
|
||||
std::vector<RsGxsIdGroup> datavector;
|
||||
std::vector<RsGxsIdGroup>::iterator vit;
|
||||
|
||||
if (!rsIdentity->getGroupData(token, datavector))
|
||||
{
|
||||
#ifdef ID_DEBUG
|
||||
@ -455,71 +456,68 @@ void IdDialog::insertIdList(uint32_t token)
|
||||
return;
|
||||
}
|
||||
|
||||
// turn that vector into a std::set, to avoid a linear search
|
||||
|
||||
std::map<RsGxsGroupId,RsGxsIdGroup> ids_set ;
|
||||
|
||||
for(uint32_t i=0;i<datavector.size();++i)
|
||||
ids_set[datavector[i].mMeta.mGroupId] = datavector[i] ;
|
||||
|
||||
mStateHelper->setActive(IDDIALOG_IDLIST, true);
|
||||
|
||||
RsPgpId ownPgpId = rsPeers->getGPGOwnId();
|
||||
|
||||
/* Update existing and remove not existing items */
|
||||
// Update existing and remove not existing items
|
||||
// Also remove items that do not have the correct parent
|
||||
|
||||
QTreeWidgetItemIterator itemIterator(ui->idTreeWidget);
|
||||
QTreeWidgetItem *item = NULL;
|
||||
while ((item = *itemIterator) != NULL) {
|
||||
++itemIterator;
|
||||
|
||||
for (vit = datavector.begin(); vit != datavector.end(); ++vit)
|
||||
while ((item = *itemIterator) != NULL)
|
||||
{
|
||||
if (vit->mMeta.mGroupId == RsGxsGroupId(item->text(RSID_COL_KEYID).toStdString()))
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (vit == datavector.end())
|
||||
++itemIterator;
|
||||
std::map<RsGxsGroupId,RsGxsIdGroup>::iterator it = ids_set.find(RsGxsGroupId(item->text(RSID_COL_KEYID).toStdString())) ;
|
||||
|
||||
if(it == ids_set.end())
|
||||
{
|
||||
if(item != allItem && item != contactsItem)
|
||||
{
|
||||
delete(item);
|
||||
|
||||
continue ;
|
||||
}
|
||||
} else {
|
||||
if (!fillIdListItem(*vit, item, ownPgpId, accept))
|
||||
|
||||
QTreeWidgetItem *parent_item = item->parent() ;
|
||||
|
||||
if( (parent_item == allItem && it->second.mIsAContact) || (parent_item == contactsItem && !it->second.mIsAContact))
|
||||
{
|
||||
delete item ; // do not remove from the list, so that it is added again in the correct place.
|
||||
continue ;
|
||||
}
|
||||
|
||||
if (!fillIdListItem(it->second, item, ownPgpId, accept))
|
||||
delete(item);
|
||||
}
|
||||
datavector.erase(vit);
|
||||
}
|
||||
|
||||
ids_set.erase(it); // erase, so it is not considered to be a new item
|
||||
}
|
||||
|
||||
/* Insert new items */
|
||||
for (vit = datavector.begin(); vit != datavector.end(); ++vit)
|
||||
for (std::map<RsGxsGroupId,RsGxsIdGroup>::const_iterator vit = ids_set.begin(); vit != ids_set.end(); ++vit)
|
||||
{
|
||||
data = (*vit);
|
||||
data = vit->second ;
|
||||
|
||||
item = NULL;
|
||||
|
||||
ui->idTreeWidget->insertTopLevelItem(0, contactsItem );
|
||||
ui->idTreeWidget->insertTopLevelItem(0, allItem);
|
||||
|
||||
if (fillIdListItem(*vit, item, ownPgpId, accept))
|
||||
{
|
||||
RsIdentityDetails details;
|
||||
std::string keyId = item->text(RSID_COL_KEYID).toStdString();
|
||||
rsIdentity->getIdDetails(RsGxsId(keyId), details);
|
||||
|
||||
if(details.mFlags & RS_IDENTITY_FLAGS_IS_A_CONTACT)
|
||||
{
|
||||
if (fillIdListItem(vit->second, item, ownPgpId, accept))
|
||||
if(vit->second.mIsAContact)
|
||||
contactsItem->addChild(item);
|
||||
}
|
||||
else
|
||||
{
|
||||
allItem->addChild(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
//int itemCount = item->childCount();
|
||||
|
||||
/* count items */
|
||||
//ui->label_count->setText( "(" + QString::number(itemCount) + ")" );
|
||||
|
||||
filterIds();
|
||||
|
||||
updateSelection();
|
||||
}
|
||||
|
||||
@ -1110,7 +1108,6 @@ void IdDialog::addtoContacts()
|
||||
|
||||
rsIdentity->setAsRegularContact(RsGxsId(Id),true);
|
||||
|
||||
requestIdDetails();
|
||||
requestIdList();
|
||||
}
|
||||
|
||||
@ -1126,7 +1123,6 @@ void IdDialog::removefromContacts()
|
||||
|
||||
rsIdentity->setAsRegularContact(RsGxsId(Id),false);
|
||||
|
||||
requestIdDetails();
|
||||
requestIdList();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user