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
@ -120,8 +120,9 @@ class RsGxsIdGroup
|
|||||||
time_t mLastUsageTS ;
|
time_t mLastUsageTS ;
|
||||||
|
|
||||||
// Not Serialised - for GUI's benefit.
|
// Not Serialised - for GUI's benefit.
|
||||||
bool mPgpKnown;
|
bool mPgpKnown;
|
||||||
RsPgpId mPgpId;
|
bool mIsAContact; // change that into flags one day
|
||||||
|
RsPgpId mPgpId;
|
||||||
GxsReputation mReputation;
|
GxsReputation mReputation;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1060,33 +1060,33 @@ bool p3IdService::getGroupData(const uint32_t &token, std::vector<RsGxsIdGroup>
|
|||||||
if (item)
|
if (item)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_IDS
|
#ifdef DEBUG_IDS
|
||||||
std::cerr << "p3IdService::getGroupData() Item is:";
|
std::cerr << "p3IdService::getGroupData() Item is:";
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
item->print(std::cerr);
|
item->print(std::cerr);
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
#endif // DEBUG_IDS
|
#endif // DEBUG_IDS
|
||||||
RsGxsIdGroup group ;
|
RsGxsIdGroup group ;
|
||||||
item->toGxsIdGroup(group,false) ;
|
item->toGxsIdGroup(group,false) ;
|
||||||
|
|
||||||
{
|
{
|
||||||
RS_STACK_MUTEX(mIdMtx) ;
|
RS_STACK_MUTEX(mIdMtx) ;
|
||||||
group.mLastUsageTS = locked_getLastUsageTS(RsGxsId(group.mMeta.mGroupId)) ;
|
group.mLastUsageTS = locked_getLastUsageTS(RsGxsId(group.mMeta.mGroupId)) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Decode information from serviceString.
|
// Decode information from serviceString.
|
||||||
SSGxsIdGroup ssdata;
|
SSGxsIdGroup ssdata;
|
||||||
if (ssdata.load(group.mMeta.mServiceString))
|
if (ssdata.load(group.mMeta.mServiceString))
|
||||||
{
|
{
|
||||||
group.mPgpKnown = ssdata.pgp.idKnown;
|
group.mPgpKnown = ssdata.pgp.idKnown;
|
||||||
group.mPgpId = ssdata.pgp.pgpId;
|
group.mPgpId = ssdata.pgp.pgpId;
|
||||||
group.mReputation = ssdata.score.rep;
|
group.mReputation = ssdata.score.rep;
|
||||||
#ifdef DEBUG_IDS
|
#ifdef DEBUG_IDS
|
||||||
std::cerr << "p3IdService::getGroupData() Success decoding ServiceString";
|
std::cerr << "p3IdService::getGroupData() Success decoding ServiceString";
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
std::cerr << "\t mGpgKnown: " << group.mPgpKnown;
|
std::cerr << "\t mGpgKnown: " << group.mPgpKnown;
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
std::cerr << "\t mGpgId: " << group.mPgpId;
|
std::cerr << "\t mGpgId: " << group.mPgpId;
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
#endif // DEBUG_IDS
|
#endif // DEBUG_IDS
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -1094,13 +1094,15 @@ bool p3IdService::getGroupData(const uint32_t &token, std::vector<RsGxsIdGroup>
|
|||||||
group.mPgpKnown = false;
|
group.mPgpKnown = false;
|
||||||
group.mPgpId.clear();
|
group.mPgpId.clear();
|
||||||
|
|
||||||
std::cerr << "p3IdService::getGroupData() Failed to decode ServiceString \""
|
std::cerr << "p3IdService::getGroupData() Failed to decode ServiceString \""
|
||||||
<< group.mMeta.mServiceString << "\"" ;
|
<< group.mMeta.mServiceString << "\"" ;
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
group.mIsAContact = (mContacts.find(RsGxsId(group.mMeta.mGroupId)) != mContacts.end());
|
||||||
|
|
||||||
groups.push_back(group);
|
groups.push_back(group);
|
||||||
delete(item);
|
delete(item);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -442,6 +442,7 @@ void IdDialog::insertIdList(uint32_t token)
|
|||||||
RsGxsIdGroup data;
|
RsGxsIdGroup data;
|
||||||
std::vector<RsGxsIdGroup> datavector;
|
std::vector<RsGxsIdGroup> datavector;
|
||||||
std::vector<RsGxsIdGroup>::iterator vit;
|
std::vector<RsGxsIdGroup>::iterator vit;
|
||||||
|
|
||||||
if (!rsIdentity->getGroupData(token, datavector))
|
if (!rsIdentity->getGroupData(token, datavector))
|
||||||
{
|
{
|
||||||
#ifdef ID_DEBUG
|
#ifdef ID_DEBUG
|
||||||
@ -454,72 +455,69 @@ void IdDialog::insertIdList(uint32_t token)
|
|||||||
|
|
||||||
return;
|
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);
|
mStateHelper->setActive(IDDIALOG_IDLIST, true);
|
||||||
|
|
||||||
RsPgpId ownPgpId = rsPeers->getGPGOwnId();
|
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);
|
QTreeWidgetItemIterator itemIterator(ui->idTreeWidget);
|
||||||
QTreeWidgetItem *item = NULL;
|
QTreeWidgetItem *item = NULL;
|
||||||
while ((item = *itemIterator) != NULL) {
|
|
||||||
|
while ((item = *itemIterator) != NULL)
|
||||||
|
{
|
||||||
++itemIterator;
|
++itemIterator;
|
||||||
|
std::map<RsGxsGroupId,RsGxsIdGroup>::iterator it = ids_set.find(RsGxsGroupId(item->text(RSID_COL_KEYID).toStdString())) ;
|
||||||
|
|
||||||
for (vit = datavector.begin(); vit != datavector.end(); ++vit)
|
if(it == ids_set.end())
|
||||||
{
|
{
|
||||||
if (vit->mMeta.mGroupId == RsGxsGroupId(item->text(RSID_COL_KEYID).toStdString()))
|
if(item != allItem && item != contactsItem)
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (vit == datavector.end())
|
|
||||||
{
|
|
||||||
if(item != allItem && item != contactsItem)
|
|
||||||
{
|
|
||||||
delete(item);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (!fillIdListItem(*vit, item, ownPgpId, accept))
|
|
||||||
{
|
|
||||||
delete(item);
|
delete(item);
|
||||||
}
|
|
||||||
datavector.erase(vit);
|
continue ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
||||||
|
ids_set.erase(it); // erase, so it is not considered to be a new item
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Insert new items */
|
/* 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;
|
item = NULL;
|
||||||
|
|
||||||
ui->idTreeWidget->insertTopLevelItem(0, contactsItem );
|
ui->idTreeWidget->insertTopLevelItem(0, contactsItem );
|
||||||
ui->idTreeWidget->insertTopLevelItem(0, allItem);
|
ui->idTreeWidget->insertTopLevelItem(0, allItem);
|
||||||
|
|
||||||
if (fillIdListItem(*vit, item, ownPgpId, accept))
|
if (fillIdListItem(vit->second, item, ownPgpId, accept))
|
||||||
{
|
if(vit->second.mIsAContact)
|
||||||
RsIdentityDetails details;
|
contactsItem->addChild(item);
|
||||||
std::string keyId = item->text(RSID_COL_KEYID).toStdString();
|
else
|
||||||
rsIdentity->getIdDetails(RsGxsId(keyId), details);
|
allItem->addChild(item);
|
||||||
|
|
||||||
if(details.mFlags & RS_IDENTITY_FLAGS_IS_A_CONTACT)
|
|
||||||
{
|
|
||||||
contactsItem->addChild(item);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
allItem->addChild(item);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
//int itemCount = item->childCount();
|
|
||||||
|
|
||||||
/* count items */
|
|
||||||
//ui->label_count->setText( "(" + QString::number(itemCount) + ")" );
|
|
||||||
|
|
||||||
filterIds();
|
filterIds();
|
||||||
|
|
||||||
updateSelection();
|
updateSelection();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1110,7 +1108,6 @@ void IdDialog::addtoContacts()
|
|||||||
|
|
||||||
rsIdentity->setAsRegularContact(RsGxsId(Id),true);
|
rsIdentity->setAsRegularContact(RsGxsId(Id),true);
|
||||||
|
|
||||||
requestIdDetails();
|
|
||||||
requestIdList();
|
requestIdList();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1126,7 +1123,6 @@ void IdDialog::removefromContacts()
|
|||||||
|
|
||||||
rsIdentity->setAsRegularContact(RsGxsId(Id),false);
|
rsIdentity->setAsRegularContact(RsGxsId(Id),false);
|
||||||
|
|
||||||
requestIdDetails();
|
|
||||||
requestIdList();
|
requestIdList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user